Catatan reflashing ESP 01 (ESP8266)

Sebagaimana komponen yang lain, di rumah ada beberapa modul/papan ESP 01 yang sudah tidak tersentuh selama beberapa tahun. Sebagai bagian dari pekerjaan yang lebih besar, bulan ini saya lakukan tinkering untuk melakukan pembaruan firmware di papan-papan tersebut. Selain beberapa hal yang terlupa, ternyata (seperti yang bisa diduga) ada juga sejumlah pembaruan mengenai firmware ESP 01. Berikut ini saya buat catatan agar lebih mudah untuk diulangi dan sebagai bagian dari pustaka bebas di Internet yang bisa diakses banyak orang yang ‘mau dan perlu’.

Gambar 1.

Sebelum reflashing

Sebagaimana layaknya, dengan waktu dan sumber daya yang memungkinkan, perlu dilakukan dokumentasi ‘ before & after ‘. Kali ini software yang dipergunakan adalah CuteCom.

Gambar 2.
Gambar 3.
Gambar 4.

Pinout

Gambar 5.
Gambar 6.
Gambar 7.

Firmware

Gambar 8.

Firmware yang dipergunakan di artikel ini adalah Software Development Kit 3.0.5 (SDK 3.0.5).

Note: Espressif has not released a separate version for the 1 MB ESP8285/8266 series of chips, but you can refer to How to Download the Latest Temporary Version of AT Firmware from GitHub and choose to download the 1 MB firmware on the CI (Continuous Integration) of GitHub (Please switch to release/v2.2.0.0_esp8266 branch and download esp8285-1MB-at under the Artifacts page).<span class="su-quote-cite"><a href="https://docs.espressif.com/projects/esp-at/en/release-v2.2.0.0_esp8266/AT_Binary_Lists/ESP8266_AT_binaries.html" target="_blank">About Espressif 1 MB firmware.</a></span>
Gambar 9.

Pada saat artikel ini ditulis salah satu versi yang bisa diunduh (V1.7.5), bisa dilihat di sini. Bisa juga menggunakan “ESP8266 nonOS SDK”  versi v3.0.5. Tampilan di Gambar 8 menunjukkan bahwa yang dipergunakan untuk tinkering ini adalah versi 3.0.5 dan bisa langsung diunduh tautan ini.

Esptool

Saya menggunakan sistem GNU/Linux, berikut sekadar dokumentasi versi GNU/Linux yang sedang dipergunakan saat tinkering ini dilakukan.

[intense_code type=”block”]sunu@sunuMachine:~$ uname -a
Linux sunuMachine 5.4.0-122-generic #138-Ubuntu SMP Wed Jun 22 15:00:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
[/intense_code] [intense_code type=”block”]sunu@sunuMachine:~$ lsb_release -a
No LSB modules are available.
Distributor ID: Linuxmint
Description: Linux Mint 20.3
Release: 20.3
Codename: una
[/intense_code]

Di sistem Linux, cara yang lebih efektif & efisien untuk melakukan flashing ESP* adalah dengan menggunakan esptool. Berikut perintah untuk melakukan instalasi esptool.

[intense_code type=”block”]sudo apt install esptool [/intense_code]

Untuk mengetahui opsi perintah di esptool, dapat langsung menggunakan perintah esptool di terminal seperti di Gambar 10 berikut ini. Untuk format html, mengenai perintah ESP8266 di esptool bisa dilihat di sini

Gambar 10.

Berikut adalah beberapa contoh untuk memeriksa kondisi ESP 01 sebelum melakukan flashing.

[sourcecode] esptool.py –chip esp8266 –port /dev/ttyUSB0 chip_id
esptool.py –chip esp8266 –port /dev/ttyUSB0 flash_id
[/sourcecode]

Berikut beberapa acuan yang bisa dipergunakan untuk melakukan pengaturan flashing dengan esptool.

Gambar 11. ESP8266 Non-OS SDK IoT_Demo Guide
Gambar 12. ESP8266 AT Instruction Set – Espressif Systems
Gambar 13. ESP8266 Non-OS AT Instruction Set – Espressif Systems

Ada beberapa contoh pengaturan yang bisa dicoba, silakan mengacu kembali ke Gambar 11, Gambar 12, dan Gambar 13.

[intense_code type=”block”] esptool.py –chip esp8266 –port /dev/ttyUSB0 write_flash –flash_size 1MB \
0x00000 boot_v1.7.bin \
0x01000 at/512+512/user1.1024.new.2.bin \
0xfb000 blank.bin \
0xfc000 esp_init_data_default_v08.bin \
0xfe000 blank.bin \
0x7e000 blank.bin
[/intense_code] [intense_code type=”block”] esptool.py –chip esp8266 –port /dev/ttyUSB0 write_flash –flash_size 1MB \
0x00000 boot_v1.7.bin \
0x01000 at/512+512/user1.1024.new.2.bin \
0xfb000 blank.bin \
0xfc000 esp_init_data_default_v08.bin \
0xfe000 blank.bin
[/intense_code] [intense_code type=”block”] esptool.py –chip esp8266 –port /dev/ttyUSB0 write_flash –flash_size 1MB \
0x00000 boot_v1.7.bin \
0x01000 at/512+512/user1.1024.new.2.bin \
0xfc000 esp_init_data_default_v08.bin \
0xfe000 blank.bin \
0x7e000 blank.bin
[/intense_code]

Contoh proses dan hasil eksekusi:
[intense_code type=”block”]

sunu@sunuMachine:/media/sunu/Espressif/ESP 01/ESP8266_NONOS_SDK-3.0.5/bin$ esptool.py –chip esp8266 –port /dev/ttyUSB0 write_flash –flash_size 1MB \
> 0x00000 boot_v1.7.bin \
> 0x01000 at/512+512/user1.1024.new.2.bin \
> 0xfb000 blank.bin \
> 0xfc000 esp_init_data_default_v08.bin \
> 0xfe000 blank.bin \
> 0x7e000 blank.bin
esptool.py v3.1
Serial port /dev/ttyUSB0
Connecting….
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 80:7d:3a:69:73:cc
Uploading stub…
Running stub…
Stub running…
Configuring flash size…
Flash will be erased from 0x00000000 to 0x00000fff…
Flash will be erased from 0x00001000 to 0x00065fff…
Flash will be erased from 0x000fb000 to 0x000fbfff…
Flash will be erased from 0x000fc000 to 0x000fcfff…
Flash will be erased from 0x000fe000 to 0x000fefff…
Flash will be erased from 0x0007e000 to 0x0007efff…
Flash params set to 0x0020
Compressed 4080 bytes to 2936…
Wrote 4080 bytes (2936 compressed) at 0x00000000 in 0.5 seconds (effective 64.4 kbit/s)…
Hash of data verified.
Compressed 413556 bytes to 296998…
Wrote 413556 bytes (296998 compressed) at 0x00001000 in 34.0 seconds (effective 97.2 kbit/s)…
Hash of data verified.
Compressed 4096 bytes to 26…
Wrote 4096 bytes (26 compressed) at 0x000fb000 in 0.3 seconds (effective 130.2 kbit/s)…
Hash of data verified.
Compressed 128 bytes to 75…
Wrote 128 bytes (75 compressed) at 0x000fc000 in 0.0 seconds (effective 33.1 kbit/s)…
Hash of data verified.
Compressed 4096 bytes to 26…
Wrote 4096 bytes (26 compressed) at 0x000fe000 in 0.3 seconds (effective 130.4 kbit/s)…
Hash of data verified.
Compressed 4096 bytes to 26…
Wrote 4096 bytes (26 compressed) at 0x0007e000 in 0.3 seconds (effective 130.4 kbit/s)…
Hash of data verified.

Leaving…
Hard resetting via RTS pin…
[/intense_code]

 

Afterburn

Setelah pembaruan firmware ada beberapa cara untuk memeriksa hasil proses yang sudah dilakukan. Pertama, dengan menggunakan esptool.

[intense_code type=”block”]

sunu@sunuMachine:~$ esptool chip_id
esptool.py v2.8
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting….
Detecting chip type… ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 80:7d:3a:69:73:cc
Enabling default SPI flash mode…
Chip ID: 0x006973cc
Hard resetting via RTS pin…

sunu@sunuMachine:~$ esptool flash_id
esptool.py v2.8
Found 1 serial ports
Serial port /dev/ttyUSB0
Connecting…
Detecting chip type… ESP8266
Chip is ESP8266EX
Features: WiFi
Crystal is 26MHz
MAC: 80:7d:3a:69:73:cc
Enabling default SPI flash mode…
Manufacturer: 85
Device: 6014
Detected flash size: 1MB
Hard resetting via RTS pin…

[/intense_code]

Berikutnya, dalam mode operasional uji coba firmware baru bisa dilakukan dengan menggunakan Moserial. 

Gambar 14. Moserial.
Gambar 15.

Uji coba sebagaimana ditampilkan di Gambar 15 mempergunakan dua perintah terpisah, AT dan AT+GMR. Perintah yang sama juga bisa dicoba dengan menggunakan ESPlorer sebagaimana di Gambar 16.

Gambar 16. ESPlorer.

Reference Docs:

Aplikasi P3X OneNote Linux

Menjelang semester baru, ada beberapa sistem perangkat yang dapat dipakai untuk membantu proses belajar mahasiswa/siswa. Salah satunya adalah Microsoft OneNote.

Software ini bekerja secara offline dan online. Misalnya di Microsoft Windows 10 sudah tersedia, baik secara default maupun dalam bundle Microsoft Office. OneNote dapat juga dibuka langsung dengan menggunakan browser di https://www.onenote.com/ . Untuk sinkronisasi online, OneNote menggunakan OneDrive (https://onedrive.live.com/about/en-us/signin/).

Menurut saya, OneNote masih merupakan aplikasi note-taking terbaik. Aplikasi ini masih bisa dipakai secara gratis dengan kemampuan yang masih baik. Kita bisa memasukkan data/keterangan dengan menggunakan keyboard. Melakukan copy-paste gambar dari luar aplikasi ke dalam catatan di aplikasi. Bahkan ada fasilitas untuk tulis tangan dengan stylus.

Karena saya sekarang kembali menggunakan GNU/Linux sebagai OS utama di laptop, saya perlu mencari beberapa alternatif yang memiliki kemudahan penggunaan yang sama. Tetapi kalau bersedia mengakses secara online, OneNote masih bisa dipergunakan. Bahkan ada desktop-app yang dapat mengakses versi online dari OneNote. Tentu saja aplikasi ini tidak secepat bila dibandingkan dengan aplikasi asli OneNote dari Microsoft. App OneNote untuk GNU/Linux itu bernama P3X OneNote Linux (https://www.corifeus.com/onenote).

P3X dapat bekerja di GNU/Linux karena mempergunakan Electron (https://www.electronjs.org/apps/p3x-onenote). Repository P3X ada di sini: https://github.com/patrikx3/onenote. Versi .deb atau .AppImage terbaru dari P3X dapat diperoleh di sini: https://github.com/patrikx3/onenote/releases/.

 

PCF8591: 8-bit A/D and D/A converter { ADC }

[ [ images & links ] ]

Gambar 1.

PCF8591Gambar 2. [einhugur.com]

Features

  • Module supports external voltage input of the 4-way acquisition (voltage input range of 0-5v)
  • integrated photoresistor
  • integrated thermistor
  • integrated potentiometer
  • Modules power indicator
  • Modules with DA output indicator, when the module DA output interface voltage reaches a certain value, will be lit panel the DA output indicator, the higher the voltage, the more obvious indicator brightness
  • Remove shunts to bypass on board integrated devices

 The left connector

  • AOUT chip DA output interface
  • AINO chip analog input interface 0
  • AIN1 chip analog input interface 1
  • AIN2 chip analog input interface 2
  • AIN3 chip analog input interface 3

  The right connector

  • SCL
  • SDA
  • GND
  • VCC – connected to  3.3v-5v

Gambar 3. [arduinolearning.com]

 

Gambar 4. [arduinolearning.com]

 

Gambar 5.[forum.arduino.cc]

 

Product Description [electrodragon.com]

Gambar 6.

Gambar 7.

 

Micro SD adapter

[ [ images & links ] ]

Pada mashup sebelumnya, telah diungkapkan mengenai data logging shield. Di papan logger yang ditujukan untuk ukuran papan Arduino Uno itu sudah terdapat RTC. Namun ukuran sistem itu relatif besar dan karenanya pin papan itu tidak mudah diterapkan di sistem lain seperti papan Arduino Nano atau papan Arduino Micro. Alternatif lain adalah MicroSD Card Adapter seperti yang akan ditampilkan di halaman ini.

Gambar 1. [elabpeers.com]

Arduino SD Card and Data Logging to Excel Tutorial :

Gambar 3.

 

Arduino Data Logging

Now let’s make another more interesting example of data logging a temperature sensor. For that purpose we will use the DS3231 Real Time Clock module which has a built-in temperature sensor as well. You can find more details about how to connect and use this module in my previous tutorial.

So after connecting the two modules to the Arduino let’s take a look at the code for this example.

Arduino LC Studio SD Card Tutorial :

 

Gambar 4. [henrysbench.capnfatz.com]

Arduino Nano SD Card Connection :

Arduino Nano SD Card ConnectionGambar 5.

 

What is a Data-logger [datalogger.pbworks.com ]

Gambar 6.

[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video01″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video02″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video03″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video04″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video05″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video06″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]

Data logging shield

[ [ images & links ] ]

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Gambar 1. learn.adafruit.com

 

adafruit_products_labeled.jpgGambar 2.

 

Place the SD library folder your sketchbook libraries folder. You may need to create the libraries subfolder if its your first library.

 

 

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_Logger_bb.jpgGambar 3.

Adafruit library examples.

Deek-Robot: Data logging shield V1.0

D10 – Chip Select
D11 – SPI MOSI
D12 – SPI MISO
D13 – SPI SCK

[code lang=”C”] RTC_DS1307 RTC; // define the Real Time Clock object

// for the data logging shield, we use digital pin 10 for the SD cs line
const int chipSelect = 10;

// the logging file
File logfile;

void error(char *str)
{
Serial.print("error: ");
Serial.println(str);

// red LED indicates error
digitalWrite(redLEDpin, HIGH);

while(1);
}
[/code]

“Next is the error() function, which is just a shortcut for us, we use it when something Really Bad happened, like we couldn’t write to the SD card or open it. It prints out the error to the Serial Monitor, turns on the red error LED, and then sits in a while(1); loop forever, also known as a halt

[code lang=”C”] // initialize the SD card
Serial.print("Initializing SD card…");
// make sure that the default chip select pin is set to
// output, even if you don’t use it:
pinMode(10, OUTPUT);

// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don’t do anything more:
return;
}
Serial.println("card initialized.");

// create a new file
char filename[] = "LOGGER00.CSV";
for (uint8_t i = 0; i < 100; i++) {
filename[6] = i/10 + ‘0’;
filename[7] = i%10 + ‘0’;
if (! SD.exists(filename)) {
// only open a new file if it doesn’t exist
logfile = SD.open(filename, FILE_WRITE);
break; // leave the loop!
}
}

if (! logfile) {
error("couldnt create file");
}

Serial.print("Logging to: ");
Serial.println(filename);
[/code]

“Now the code starts to talk to the SD card, it tries to initialize the card and find a FAT16/FAT32 partition. Next it will try to make a logfile. We do a little tricky thing here, we basically want the files to be called something like LOGGERnn.csv where nn is a number. By starting out trying to create LOGGER00.CSV and incrementing every time when the file already exists, until we get to LOGGER99.csv, we basically make a new file every time the Arduino starts up To create a file, we use some Unix style command flags which you can see in the logfile.open() procedure. FILE_WRITE means to create the file and write data to it. Assuming we managed to create a file successfully, we print out the name to the Serial port.”

[code lang=”C”] Wire.begin();
if (!RTC.begin()) {
logfile.println("RTC failed");
#if ECHO_TO_SERIAL
Serial.println("RTC failed");
#endif //ECHO_TO_SERIAL
}

logfile.println("millis,time,light,temp");
#if ECHO_TO_SERIAL
Serial.println("millis,time,light,temp");
#if ECHO_TO_SERIAL// attempt to write out the header to the file
if (logfile.writeError || !logfile.sync()) {
error("write header");
}

pinMode(redLEDpin, OUTPUT);
pinMode(greenLEDpin, OUTPUT);

// If you want to set the aref to something other than 5v
//analogReference(EXTERNAL);
}
[/code]

“OK we’re wrapping up here. Now we kick off the RTC by initializing the Wire library and poking the RTC to see if its alive. Then we print the header. The header is the first line of the file and helps your spreadsheet or math program identify whats coming up next. The data is in CSV (comma separated value) format so the header is too: “millis,time,light,temp” the first item millis is milliseconds since the Arduino started, time is the time and date from the RTC, light is the data from the CdS cell and temp is the temperature read. You’ll notice that right after each call to logfile.print() we have #if ECHO_TO_SERIAL and a matching Serial.print() call followed by a #if ECHO_TO_SERIAL this is that debugging output we mentioned earlier. The logfile.print() call is what writes data to our file on the SD card, it works pretty much the same as the Serial version. If you set ECHO_TO_SERIAL to be 0 up top, you won’t see the written data printed to the Serial terminal. Finally, we set the two LED pins to be outputs so we can use them to communicate with the user. There is a commented-out line where we set the analog reference voltage. This code assumes that you will be using the ‘default’ reference which is the VCC voltage for the chip – on a classic Arduino this is 5.0V. You can get better precision sometimes by lowering the reference. However we’re going to keep this simple for now! Later on, you may want to experiment with it.”

Main loop

Now we’re onto the loop, the loop basically does the following over and over:

  • Wait until its time for the next reading (say once a second – depends on what we defined)
  • Ask for the current time and date froom the RTC
  • Log the time and date to the SD card
  • Read the photocell and temperature sensor
  • Log those readings to the SD card
  • Sync data to the card if its time
[code lang=”C”] void loop(void)
{
DateTime now;

// delay for the amount of time we want between readings
delay((LOG_INTERVAL -1) – (millis() % LOG_INTERVAL));

digitalWrite(greenLEDpin, HIGH);

// log milliseconds since starting
uint32_t m = millis();
logfile.print(m); // milliseconds since start
logfile.print(", ");
#if ECHO_TO_SERIAL
Serial.print(m); // milliseconds since start
Serial.print(", ");
#endif

// fetch the time
now = RTC.now();
// log time
logfile.print(now.get()); // seconds since 2000
logfile.print(", ");
logfile.print(now.year(), DEC);
logfile.print("/");
logfile.print(now.month(), DEC);
logfile.print("/");
logfile.print(now.day(), DEC);
logfile.print(" ");
logfile.print(now.hour(), DEC);
logfile.print(":");
logfile.print(now.minute(), DEC);
logfile.print(":");
logfile.print(now.second(), DEC);
#if ECHO_TO_SERIAL
Serial.print(now.get()); // seconds since 2000
Serial.print(", ");
Serial.print(now.year(), DEC);
Serial.print("/");
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.day(), DEC);
Serial.print(" ");
Serial.print(now.hour(), DEC);
Serial.print(":");
Serial.print(now.minute(), DEC);
Serial.print(":");
Serial.print(now.second(), DEC);
#endif //ECHO_TO_SERIAL
[/code]

  “The first important thing is the delay() call, this is what makes the Arduino wait around until its time to take another reading. If you recall we #defined the delay between readings to be 1000 millseconds (1 second). By having more delay between readings we can use less power and not fill the card as fast. Its basically a tradeoff how often you want to read data but for basic long term logging, taking data every second or so will result in plenty of data! Then we turn the green LED on, this is useful to tell us that yes we’re reading/writing data now. Next we call millis() to get the ‘time since arduino turned on’ and log that to the card. It can be handy to have – especially if you end up not using the RTC. Then the familiar RTC.now() call to get a snapshot of the time. Once we have that, we write a timestamp (seconods since 2000) as well as the date in YY/MM/DD HH:MM:SS time format which can easily be recognized by a spreadsheet. We have both because the nice thing about a timestamp is that its going to montonically increase and the nice thing about printed out date is its human readable.”

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Plotting with a spreadsheet

 

adafruit_products_dataselect.gifGambar 4.

 

Gambar 5.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

Using Gnuplot

set xlabel "Time"              # set the lower X-axis label to 'time'

set xtics rotate by -270       # have the time-marks on their side


set ylabel "Light level (qualitative)"    # set the left Y-axis label

set ytics nomirror             # tics only on left side

set y2label "Temperature in Fahrenheit"   # set the right Y-axis label
set y2tics border              # put tics no right side

set key box top left           # legend box
set key box linestyle 0 

set xdata time                 # the x-axis is time
set format x "%H:%M:%S"        # display as time
set timefmt "%s"               # but read in as 'unix timestamp'

plot "LOGTEST.CSV" using 2:4 with lines title "Light levels" 
replot "LOGTEST.CSV" using 2:5 axes x1y2 with lines title "Temperature (F)"

adafruit_products_gnuplotcmd.gifGambar 6.

adafruit_products_gnuplotted.gifGambar 7.

https://learn.adafruit.com/adafruit-data-logger-shield?view=all :

adafruit_products_adafruitlogshieldsch.pngGambar 8.

Gambar 9.

Gambar 10.

Gambar 11.

Gambar 12.

 

Save

Save

Save

Save

LCD Nokia 5110 + sistem Arduino

[ [ images, codes & links ] ]

The Nokia 5110 display has long been an Arduino Hobbyist favorite and a search of the internet will show that there are tons of different ways to drive this device.

There are a few varieties of this module are out there.   Mine are labeled as you see below.   Others should work just fine with this tutorial if you map your pins correctly.

Remember,  VCC is 3.3 Volts.   The LIGHT Control can use pulse width modulation through a 330 ohm resistor.

https://sunupradana.info/tkr/wp-content/uploads/2017/07/Nokia-5110-Pinouts.png

Gambar 1.

 

~Arduino Nokia 5110 with U8GLIB Tutorial

 

LCD Specifications

  • Controller: PCD8544
  • Supply: 2.7V to 3.3V
  • Interface levels: 2.7V to 5V
  • Backlight Colour: Blue
  • Backlight supply: 3.3V Max
  • Module size: W 43.6mm x H 43.1mm
  • Working current: < 200uA (Backlight off)

Notice that the module only needs 3.3v from the Arduino. More information can be found on the Datasheet located here.

nokiaGambar 2. [sumber]

lcdGambar 3. [sumber]

~hackshed.co.uk

Koneksi pada Gambar 3 hanya contoh, pin pada Arduino dapat diatur sesuai keperluan dan dukungan pustaka.

Gambar 4.

 

Untuk penggunaan LCD Nokia 5110, salah satu pustaka yang bisa dipergunakan adalah u8glib (atau versi yang lebih baru u8g2). Sebagai contoh untuk uji coba, dapat diikuti kode program dari: henrysbench.capnfatz.com berikut:

// Henry's Bench
// Arduino Nokia 5110 U8Glib Tutorial


#include "U8glib.h"

 

#define backlight 11
 
//Delcare the display and assign the pins
 
//U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6
 
 
U8GLIB_PCD8544 u8g(8, 4, 7, 5, 6);  // CLK=8, DIN=4, CE=7, DC=5, RST=6

 
void draw() {
 
  u8g.setFont(u8g_font_profont11);  // select font
  u8g.drawStr(0, 15, "Nokia 5110..");  // put string of display at position X, Y
  u8g.drawStr(29, 35, "HELLO!!!!");
  
  
}
 
void setup() 
{
  // Set Backlight Intensity
  // 0 is Fully bright
  // 255 is off
  analogWrite(backlight, 20);
  //
  // Enter the U8Glib Picture Loop
  //
  
}
 
void loop() 
{ 
 u8g.firstPage(); 
  do 
  {
    draw();
  } while( u8g.nextPage() ); 
  
}

Salah satu pustaka/library yang umum dipergunakan untuk LCD Nokia 5110 adalah pustaka  yang dikeluarkan oleh Adafruit. Terdapat dua bagian pustaka untuk lcd ini, satu adalah untuk driver hardware dan satu untuk pustaka grafik.

Urutan pin LCD 5110 pada produk Adafruit bisa jadi tidak sama dengan urutan pin LCD 5110 yang bisa dibeli di pasaran lokal (impor dari China). Meskipun begitu, pustaka dapat dipergunakan dan berfungsi secara normal.

 

Testing

You can find our Nokia Display Arduino library on github. To install it, click this button to download the compressed ZIP file then install it. This guide will help you with the install process if you have never installed an Arduino library.

Then you’ll have to do the same for the Adafruit GFX Graphics core library, available from github. Click the button to download it. Then install Adafruit_GFX just like the library you’ve done except this time name it Adafruit_GFX, etc.

Restart the Arduino software. You should see a new example folder called Adafruit_PCD8544 and inside, an example called pcdtest. Open up that sketch and upload it to your Arduino. You should see the example test sequence.

Graphics Library

We have a ready to go basic graphics library that has primitives for bitmaps, shapes and text. You can probably do everything you want using it. Because of the way the display works we need to buffer the entire display in ram which is 84×48 bits (504 bytes). However, screen updates are very fast.

For more details about the Adafruit GFX library, please visit http://learn.adafruit.com/adafruit-gfx-graphics-library – it supports lines, rectangles, roundrects, circles, text of different sizes etc.

Note that since this display is MONOCHROMATIC it only supports two colors: BLACK or WHITE. BLACK is a displayed dot and WHITE is for erasing pixels

Dont forget, after drawing anything to the screen, call display() to write it out to the LCD!

Downloads

Our PCD8544 (Nokia 5110) LCD display Arduino library is on github which comes with example code. This library uses 1/2 Kbytes of RAM since it needs to buffer the entire display but its very fast! The code is simple to adapt to any other microcontroller.

You’ll also need to get the Adafruit GFX Graphics core library which can print text, bitmaps, pixels, rectangles, circles and lines, also available on github.

The PCD8544 datasheet tells you all about what the display can do.

~learn.adafruit.com

 

https://raw.githubusercontent.com/wiki/olikraus/u8g2/img/uc1701_dogs102_uno_board_320.jpgGambar 5. [u8g2/wiki]

Library: LCD5110_Basic

Library: LCD5110_Graph

 

 

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Belajar penggunaan LCD “Nokia 5110” di sistem Arduino [video]

[ [ videos ] ]
[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video01″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video02″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video03″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video04″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video05″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video06″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]
[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video07″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video08″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video09″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video10″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video11″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video12″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]
[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video13″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video14″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video15″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]

 

Logic level converter

[ [ images & links ] ]

Papan logic level converter sering diperlukan jika bekerja dengan dua atau lebih sistem yang mempergunakan tingkat tegangan yang berbeda. Sistem yang bekerja di tingkat tegangan 3.3 V dan tidak memiliki toleransi tegangan sampai 5 V akan sangat mungkin mengalami kerusakan. Untuk mencegahnya diperlukan sistem yang mengalihkan level logika digital dari sistem 5 V dari dan ke level 3.3 V.

Penggunaan sistemnya cukup sederhana, yang penting untuk diingat adalah bahwa sumber tegangan di kedua sisi perlu dihubungkan. Jika misalnya sisi 3.3 V tidak memiliki catau daya sendiri maka pergunakan sumber lain dengan tegangan yang sama sebesar 3.3 V. Contohnya dari papan Arduino, hubungkan 5 V dan 3.3 V ke pin masing-masing yang sesuai. Adapun pin Gnd sudah terhubung antar sisi, sehingga level yang dikonversi diukur berdasarkan acuan yang sama. Jadi, Gnd untuk sistem (termasuk untuk ground sisi 3.3 V) bisa didapatkan hanya dari satu hubungan ke GND pada papan Arduino.

 

Do you have a 3.3V I2C or SPI sensor that might go up in smoke if connected to a 5V Arduino? Or a 5V device that needs a workaround to be compatible with your 3.3V Raspberry Pi, Arduino Due or pcDuino?

To get over this obstacle you need a device that can shift 3.3V up to 5V or 5V down to 3.3V. This is called logic level shifting. Level shifting is a dilemma so common we designed a simple PCB assembly to make interfacing devices a little easier: the Bi-Directional Logic Level Converter.

MOSFET logic level shifting circuitGambar 1.

Annotated BD-LLCGambar 2.

 

~learn.sparkfun.com

 

I2c-Bi-Directional-021Gambar 3. [14core.com]

 

As digital devices get smaller and faster, once ubiquitous 5 V logic has given way to ever lower-voltage standards like 3.3 V, 2.5 V, and even 1.8 V, leading to an ecosystem of components that need a little help talking to each other. For example, a 5 V part might fail to read a 3.3 V signal as high, and a 3.3 V part might be damaged by a 5 V signal. This level shifter solves these problems by offering bidirectional voltage translation of up to four independent signals, converting between logic levels as low as 1.5 V on the lower-voltage side and as high as 18 V on the higher-voltage side, and its compact size and breadboard-compatible pin spacing make it easy to integrate into projects.

Gambar 4.

This logic level converter requires two supply voltages: the lower-voltage logic supply (1.5 V to 7 V) connects to the LV pin and the higher-voltage supply (LV to 18 V) connects to the HV pin. The HV supply must be higher than the LV supply for proper operation. Logic low voltages will pass directly from Hx to the corresponding Lx (and vice versa), while logic high voltages will be converted between the HV level to the LV level as the signal passes from Hx to Lx or Lx to Hx.

~www.pololu.com/product/2595

Gambar 5.

Sebagai awalan pengujian sebaiknya dilakukan hanya dengan tegangan DC yang relatif stabil (rata) di input terlebih dahulu. Ukur level tegangan input dan level tegangan output. Apakah nilai tegangan 5 V sudah benar turun (dikonversi) menjadi 3.3 V? Apakah, sebaliknya juga, level tegangan bisa naik dari 3.3 V ke 5 V? Berikutnya baru lakukan percobaan dengan penyakelaran gelombang kotak, karena bentuk gelombang ini adalah bentuk gelombang digital yang paling umum dipergunakaan. Mulailah dari frekuensi rendah dengan pulsa high yang cukup lebar, lalu persempit lebar pulsa high. Teruskan dengan menaikkan frekuensi dan ulangi prosedur mempersempit pulsa high seperti langkah sebelumnya. Demikian seterusnya sampai anda lihat batas lebar pulsa dan/atau batas frekuensi di mana logic converter tidak lagi berfungsi dengan baik.

Gambar 6.

Di Gambar 6, saya mencoba mengggunakan pembangkit gelombang kotak PWM yang sudah sangat banyak dijual bebas di pasaran. Frekuensi yang dipakai diatur sebesar 200 Hz (terukur 201 Hz) dan seperti terlihat di Gambar 6, duty cycle diatur sebesar 20%. Tegangan keluaran modul ini sekitar sebesar 5 V peak.


Gambar 7.

Di Gambar 7 terlihat percobaan pengukuran di sisi tegangan logic level yang lebih rendah. Frekuensi penyakelaran tetap 200 Hz, tetapi lebar pulsa hanya sebesar 40 μS. Tegangan Vpp yang terukur masih sekitar 3.97 V, level tegangan yang jelas masih lebih tinggi dari 3.3 V. 


Gambar 8.

Gambar 8 adalah contoh percobaan konversi dari level tegangan sistem digital 3.3 V ke sistem digital 5 V. Sistem sumber yang dipakai adalah yang menggunakan keluarga ARM STM32. Frekuensi diatur mendekati 500 Hz (496 Hz) dengan lebar pulsa high sebesar 14 μS. Hasil konversi akan terlihat seperti di Gambar 9, level tegangan output adalah Vmax 5.31 V atau Vpp 5.63 V menurut alat ukur yang dipakai.

Gambar 9.

[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video01″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video02″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video03″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video04″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video05″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]

 

 

RTC DS1302

[ [ images & links ] ]

Gambar 1. [sumber]

Sebelumnya, kutipan informasi dari dua RTC telah pernah diungkap di situs ini. Pertama DS1307, dan yang kedua adalah DS3231. Di halaman ini akan saya kutip keterangan mengenai RTC DS1302, yang bersama dua RTC terdahulu saya beli di situs online lokal.

 

The DS1302 trickle-charge timekeeping chip contains a real-time clock/calendar and 31 bytes of static RAM. It communicates with a microprocessor via a simple serial interface. The real-time clock/calendar provides seconds, minutes, hours, day, date, month, and year information. The end of the month date is automatically adjusted for months with fewer than 31 days, including corrections for leap year. The clock operates in either the 24-hour or 12-hour format with an AM/PM indicator.

Interfacing the DS1302 with a microprocessor is simplified by using synchronous serial communication. Only three wires are required to communicate with the clock/RAM: CE, I/O (data line), and SCLK (serial clock). Data can be transferred to and from the clock/RAM 1 byte at a time or in a burst of up to 31 bytes. The DS1302 is designed to operate on very low power and retain data and clock information on less than 1µW.

The DS1302 is the successor to the DS1202. In addition to the basic timekeeping functions of the DS1202, the DS1302 has the additional features of dual power pins for primary and backup power supplies, programmable trickle charger for VCC1, and seven additional bytes of scratchpad memory.

~maximintegrated.com

 

Gambar 2. domoticx.com/arduino-rtc-tijdklok-ds1302/

#include <DS1302.h>

// Init the DS1302
// DS1302 rtc([CE/RST], [I/O], [CLOCK]);
DS1302 rtc(8, 7, 6);

void setup() {
  // Set the clock to run-mode, and disable the write protection
  rtc.halt(false);
  rtc.writeProtect(false);
  
  // Setup Serial connection
  Serial.begin(9600);

  // The following lines can be commented out to use the values already stored in the DS1302
  rtc.setDOW(FRIDAY);        // Set Day-of-Week to FRIDAY
  rtc.setTime(12, 0, 0);     // Set the time to 12:00:00 (24hr format)
  rtc.setDate(6, 8, 2010);   // Set the date to August 6th, 2010
}

void loop() {
  // Send Day-of-Week
  Serial.print(rtc.getDOWStr());
  Serial.print(" ");
  
  // Send date
  Serial.print(rtc.getDateStr());
  Serial.print(" -- ");

  // Send time
  Serial.println(rtc.getTimeStr());
  
  // Wait one second before repeating :)
  delay (1000);
}

Pustaka yang diperlukan untuk mengeksekusi kode bisa diakses di link ini.

Berdasarkan pengalaman saya menguji coba sistem ini dan pengalaman cukup banyak orang lain yang saya pantau di berbagai halaman di Internet, tampaknya sistem RTC DS1302 yang banyak beredar memiliki permasalahan dalam hal operasi. Banyak pengguna yang melaporkan kesalahan pembacaan jika mempergunakan IC ini. Ada beberapa kemungkinan, termasuk kemungkinan IC yang banyak diperjual-belikan yang memang memiliki grade yang lebih rendah.

Secara praktis, sampai ditemukan solusi yang baik untuk IC ini (versi yang banyak dijual), akan lebih baik mempergunakan RTC DS1307 atau DS3231.

RTC DS1307

[ [ images, codes & links ] ]

Gambar 1.

A real-time clock (RTC) is a computer clock (most often in the form of an integrated circuit) that keeps track of the current time.

Although the term often refers to the devices in personal computers, servers and embedded systems, RTCs are present in almost any electronic device which needs to keep accurate time.

<span class="su-quote-cite"><a href="https://en.wikipedia.org/wiki/Real-time_clock" target="_blank">Real-time clock</a></span>

What is an RTC?

A real time clock is basically just like a watch – it runs on a battery and keeps time for you even when there is a power outage! Using an RTC, you can keep track of long timelines, even if you reprogram your microcontroller or disconnect it from USB or a power plug.

Most microcontrollers, including the Arduino, have a built-in timekeeper called millis() and there are also timers built into the chip that can keep track of longer time periods like minutes or days. So why would you want to have a separate RTC chip? Well, the biggest reason is that millis() only keeps track of time since the Arduino was last powered – . That means that when the power is turned on, the millisecond timer is set back to 0. The Arduino doesn’t know that it’s ‘Tuesday’ or ‘March 8th’, all it can tell is ‘It’s been 14,000 milliseconds since I was last turned on’.

OK so what if you wanted to set the time on the Arduino? You’d have to program in the date and time and you could have it count from that point on. But if it lost power, you’d have to reset the time. Much like very cheap alarm clocks: every time they lose power they blink 12:00

While this sort of basic timekeeping is OK for some projects, some projects such as data-loggers, clocks, etc will need to have consistent timekeeping that doesn’t reset when the Arduino battery dies or is reprogrammed. Thus, we include a separate RTC! The RTC chip is a specialized chip that just keeps track of time. It can count leap-years and knows how many days are in a month, but it doesn’t take care of Daylight Savings Time (because it changes from place to place).

~DS1307 Real Time Clock Breakout Board Kit

 

What are Real Time Clocks?

Real time clocks (RTC), as the name recommends are clock modules. The DS1307 real time clock (RTC) IC is an 8 pin device using an I2C interface. The DS1307 is a low-power clock/calendar with 56 bytes of battery backup SRAM. The clock/calendar provides seconds, minutes, hours, day, date, month and year qualified data. The end date of each month is automatically adjusted, especially for months with less than 31 days.

They are available as integrated circuits (ICs) and supervise timing like a clock and also operate date like a calendar. The main advantage of RTC is that they have an arrangement of battery backup which keeps the clock/calendar running even if there is power failure. An exceptionally little current is required for keeping the RTC animated. We can find these RTCs in many applications like embedded systems and computer mother boards, etc.

~www.elprocus.com/rtc-ds1307/

 

 

Arduino Tiny RTC D1307 Tutorial

 

Gambar 2. [henrysbench.capnfatz.com]

Gambar 3. [henrysbench.capnfatz.com]

Gambar 4. [tronixstuff.com]

Connecting your module to an Arduino

Both modules use the I2C bus, which makes connection very easy. If you’re not sure about the I2C bus and Arduino, check out the I2C tutorials (chapters 20 and 21), or review chapter seventeen of my book “Arduino Workshop“.

Moving on – first you will need to identify which pins on your Arduino or compatible boards are used for the I2C bus – these will be knows as SDA (or data) and SCL (or clock).

~ tronixstuff.com

 

 

Tiny RTC

Gambar 5.

Features

  • 5V DC supply
  • Programmable Square-Wave output signal
  • Automatic Power-Fail detect and switch circuitry
  • Consumes less than 500nA in Battery-Backup Mode with Oscillator Running
  • 56-Byte, Battery-Backed, Nonvolatile (NV)RAM for data storage

Gambar 6.

TinyRTC hardware1.jpgGambar 7.

~www.elecrow.com

 

 

RTC DS-1307 with Arduino

DS 1307 RTC Pinout

Gambar 8.

Block Diagram of DS1307

Gambar 9. [Datasheet]

Gambar 10.

~www.theorycircuit.com

 

Terdapat beberapa pustaka/library untuk tiap RTC. Dua yang disampaikan dalam “mashup ini adalah pustaka dari Adafruit dan pustaka dari Makuna.

Contoh-contoh kode program sistem Arduino untuk RTC DS1307.

adafruit: ds1307.ino

[code lang=”C”]// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include "RTClib.h"

RTC_DS1307 rtc;

char daysOfTheWeek[7][12] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

void setup ()
{
while (!Serial); // for Leonardo/Micro/Zero

// Serial.begin(57600);
Serial.begin(9600);

if (! rtc.begin())
{
Serial.println("Couldn’t find RTC");
while (1);
}

if (! rtc.isrunning())
{
Serial.println("RTC is NOT running!");
// following line sets the RTC to the date &amp; time this sketch was compiled
// rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
// This line sets the RTC with an explicit date &amp; time, for example to set
// January 21, 2014 at 3am you would call:
// rtc.adjust(DateTime(2014, 1, 21, 3, 0, 0));
}
}

void loop ()
{
DateTime now = rtc.now();

Serial.print(now.year(), DEC);
Serial.print(‘/’);
Serial.print(now.month(), DEC);
Serial.print(‘/’);
Serial.print(now.day(), DEC);
Serial.print(" (");
Serial.print(daysOfTheWeek[now.dayOfTheWeek()]);
Serial.print(") ");
Serial.print(now.hour(), DEC);
Serial.print(‘:’);
Serial.print(now.minute(), DEC);
Serial.print(‘:’);
Serial.print(now.second(), DEC);
Serial.println();

Serial.print(" since midnight 1/1/1970 = ");
Serial.print(now.unixtime());
Serial.print("s = ");
Serial.print(now.unixtime() / 86400L);
Serial.println("d");

// calculate a date which is 7 days and 30 seconds into the future
DateTime future (now + TimeSpan(7,12,30,6));

Serial.print(" now + 7d + 30s: ");
Serial.print(future.year(), DEC);
Serial.print(‘/’);
Serial.print(future.month(), DEC);
Serial.print(‘/’);
Serial.print(future.day(), DEC);
Serial.print(‘ ‘);
Serial.print(future.hour(), DEC);
Serial.print(‘:’);
Serial.print(future.minute(), DEC);
Serial.print(‘:’);
Serial.print(future.second(), DEC);
Serial.println();

Serial.println();
delay(3000);
}[/code]

[intense_tabs direction=”right” active_tab_background_color=”#000000″ active_tab_font_color=”#ffff00″ trigger=”click”] [intense_tab title=”Video01″ border=”3px solid #e8e8e8″ link_target=”_self” content_background_color=”#000000″ content_font_color=”#ffffff” icon_size=”1″ icon_position=”left”]

[/intense_tab] [intense_tab title=”Video02″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video03″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [intense_tab title=”Video04″ border=”3px solid #e8e8e8″ link_target=”_self” icon_size=”1″ content_background_color=”#000000″ content_font_color=”#ffffff” icon_position=”left”]

[/intense_tab] [/intense_tabs]