SKRIPSI
Disusun Oleh :
Febri Chahya Setyawichaksana
NIM. 1541160042
i
ii
HALAMAN PENGESAHAN
RANCANG BANGUN SISTEM BAGLOG KARDUS PADA JAMUR
TIRAM BERBASIS INTERNET OF THINGS
Oleh :
Nama : Febri Chahya Setyawichaksana
Nim : 1541160042
Tugas akhir ini telah dipertahankan di depan dewan penguji pada tanggal 13
Agustus 2019 dan disahkan oleh :
Pembimbing I :
Ir. Waluyo, MT
NIP. 1960022021988111001 …………………………………….
Pembimbing II :
Penguji I :
Penguji II:
KATA PENGANTAR
Puji syukur kehadirat Allah SWT yang telah memberikan rahmat dan
hidayah-Nya kepada penulis, sehingga penulis dapat menyelesaikan skripsi yang
berjudul “Rancang Bangun Sistem Baglog Kardus Pada Jamur Tiram Berbasis
Internet Of Things”.
Penulis
vi
ABSTRAK
Febri Chahya Setyawichaksana, 2019. “SISTEM MONITORING KEADAAN
AIR PADA TEMPAT WISATA AIR TERJUN COBAN PUTRI BERBASIS
FIREBASE DAN ANDROID”, Skripsi, Program Studi Jaringan Telekomunikasi
Digital, Jurusan Teknik Elektro, Politeknik Negeri Malang. Pembimbing I: Ir.
Waluyo, MT, Pembimbing II: Ir.Moh. Abdulla Anshori, M,MT.
Di Indonesia terdapat banyak tempat wisata alam air terjun seperti air
terjun Grojokan Sewu.Tidak sedikit masyarakat atau wisatawan yang
mengunjungi wisata air terjun hanya untuk berfoto dan berenang di air terjun
Grojokan Sewu. Namun keadaan air di Grojokan Sewu sering mengalami
perubahan seperti keadaan arus air, suhu air, dan kadar pH air. Para pengunjung
tentunya memiliki kondisi kusus dimana seperti tidak tahan akan suhu dingin,
alergi akan air yang kotor, dan tidak bias berenang di perairan dalam. Dengan ini
saya mengambil judul ini untuk memudah kan para engunjung untuk memantau
keadaan air pada air terjun Grojokan Sewu.
Pada penelitian ini, sistem dimana pada node monitoring akan dipasangi 1
arduino nano yang sudah disambungkan dengan NRF214 sebagai pengirim
informasi. Informasi yang dikirim merupakan hasil pembacaan dari sensor pH,
sensor turbidity (kekeruhan), sensor flow, dan sensor suhu. Sementara fungsi
arduino sendiri adalah untuk memberi fungsi kerja pada sensor pH, Conductifity,
Suhu, dan Flow reader pada setiap sensor. Nanti data yang terbaca pada arduino
nano akan dikirim ke server yaitu nodeMCU. Dari nodeMCU baru diupload ke
firebase sebagai database. Fungsi dari firebase sebagai database adalah
menyimpan hasil pembacaan secara real time yang akan dimonitoring lewat
aplikasi di smartphone berbasis android.
Sistem yang dirancang untuk penelitian ini berhasil dibuat dengan baik
dimana dalam melakukan beberapa pengujian berhasil mendapatkan data yang
diinginkan. Sensor sensor yang digunakan bisa dikalibrasi dengan baik dengan
perbedaan nilai antara sensor dan alat ukur kurang dari 5 persen. Penggunaan
firebase sebagai database realtime berjalan dengan baik dimana pengiriman data
dari sensor via internet tidak mengalami kegagalan disetiap uji coba. Tampilan
informasi yang dibuat dalam aplikasi bekerja dengan baik dengan tingkat
keberhasilan update lebih dari 90 persen dari beberapa kali percobaan.
ABSTRACT
Febri Chahya Setyawichaksana, 2019. “SISTEM MONITORING KEADAAN
AIR PADA TEMPAT WISATA AIR TERJUN COBAN PUTRI BERBASIS
FIREBASE DAN ANDROID”, Skripsi, Program Studi Jaringan Telekomunikasi
Digital, Jurusan Teknik Elektro, Politeknik Negeri Malang. Pembimbing I:
Waluyo, MT, Pembimbing II: Ir.Moh. Abdulla Anshori, M,MT.
n Indonesia, there are many natural waterfalls such as the Grojokan Sewu
waterfall. Not a few people or tourists visit waterfall tours just to take pictures and
swim in the Grojokan Sewu waterfall. However, the condition of the water in
Grojokan Sewu often changes such as the state of the water flow, water
temperature, and water pH levels. The visitors of course have special conditions
where they cannot stand cold temperatures, are allergic to dirty water, and cannot
swim in deep waters. I hereby take this title to make it easier for visitors to
monitor the state of the water at the Grojokan Sewu waterfall.
In this study, a system where the monitoring node will be installed with 1
arduino nano which has been connected to NRF214 as the sender of information.
The information sent is the result of readings from the pH sensor, turbidity sensor
(turbidity), flow sensor, and temperature sensor. While the function of Arduino
itself is to provide work functions on the pH, Conductivity, Temperature, and
Flow reader sensors on each sensor. Later the data read on the Arduino nano will
be sent to the server, namely nodeMCU. From new nodeMCU uploaded to
firebase as database. The function of firebase as a database is to store readings in
real time which will be monitored via an application on an Android-based
smartphone.
The system designed for this research has been successfully built, which in
doing some testing succeeded in getting the desired data. The sensors used can be
calibrated properly with the difference in value between the sensor and measuring
instrument less than 5 percent. The use of firebase as a realtime database went
well where data transmission from sensors via the internet did not fail in every
test. The information display created in the application works well with an update
success rate of more than 90 percent from several trials.
DAFTAR ISI
DAFTAR GAMBAR
DAFTAR TABEL
Tabel 2.1 Spesifikasi pada Arduino Nano............................................................... 6
Tabel 2.2 Desain pin NRF24L01 .......................................................................... 13
Tabel 2.3 Konsumsi Arus Modul wireless NRF24L01......................................... 15
Tabel 3.1 Alat dan Bahan Penelitian......................................................................31
Tabel 3.2 Software Pendukung ............................................................................. 31
Tabel 3.3 Sambungan Pin antar Komponen pada Arduino Nano ......................... 32
Tabel 3.4 Sambungan PIN Server Node MCU dengan NRF24L01 ..................... 33
Tabel 3.5 Kalibrasi Sensor Kekeruhan.................................................................. 35
Tabel 3.6 Data Kalibrasi Sensor pH ...................................................................... 36
Tabel 3.7 Data Kalibrasi Sensor Suhu .................................................................. 37
Tabel 3.8 Data Perhitungan Error ......................................................................... 38
Tabel 3.9 Pengujian Sensor Flow ......................................................................... 40
Tabel 4.1 Pengujian Hari Pertama Pukul 07.00 WIB ............................................43
Tabel 4.2 Pengujian Hari Pertama Pukul 10.00 WIB ........................................... 43
Tabel 4.3 Pengujian Hari Kedua Pukul 07.00 WIB .............................................. 44
Tabel 4.4 Pengujian Hari Kedua Pukul 10.00 WIB .............................................. 44
Tabel 4.5 Perbandingan Nilai Keruh Air .............................................................. 44
Tabel 4.6 Perbandingan Arus Air ......................................................................... 46
Tabel 4.7 Perbandingan Nilai pH .......................................................................... 47
Tabel 4.8 Perbandingan Nilai Arus ....................................................................... 48
BAB I
PENDAHULUAN
1
2
.
BAB II
TINJAUAN PUSTAKA
4
5
Arduino tersebut memiliki flash memory sebesar 32KB (2KB digunkan untuk
bootloader). ATMega168 memiliki 1 KB memory pada SRAM dan 512 byte
padaEEPROM (yang dapat dibaca dan ditulis dengan perpustakaan EEPROM);
Sedangkan ATMega328 memiliki 2 KB memory pada SRAM dan 1 KB pada
EEPROM.
dari mulai GND (ground) hingga 5 Volt, yang juga dapat mengubah titik
jangkauan tertinggi atau terendah dengan menggunakan fungsi analogReference().
Namun, pin analog 6 dan 7 tidak dapat digunakan sebagai pin digital. Beberapa
pin yang dikhususkan, yaitu:
a. I2C: Pin A4 (SDA) dan pin A5 (SCL).Pin ini pendukung komunikasi I2C
(TWI) menggunakan perpustakaan Wire.
b. AREF: Referensi tegangan untuk input analog.Pin ini digunakan dengan
fungsi analogReference().
c. RESET: Jalur LOW. Pada pin ini digunakan untuk me-reset
(menghidupkan ulang) mikrokontroler. Biasanya digunakan untuk
menambahkan tombol reset pada shield yang menghalangi papan utama
Arduino.
pH meter adalah jenis alat ukur untuk mengukur derajat keasaman atau
kebasaan suatu cairan, pada Ph meter digital terdapat elektroda khusus yang
berfungsi untuk mengukur pH bahan-bahan semi padat, elektroda
(probe pengukur) terhubung sebuah alat elektronik yang mengukur dan
menampilkan nilai pH.
11
Sensor Flow mengukur kecepatan aura melalui seberapa cepat putaran kipas
dalam flow meter yang di hasilkan oleh arus air yang di hasilkan dari arus air
yang mengalir.
wirelessterdiri atas 2 unit utama yaitu unit pemancar (transmitter) dan unit
penerima (receiver).Pemancar menggunakan frekuensi gelombang radio pada
prinsipnya mengirim sinyal modulasi yang ditransmisikan melalui media
udara.Sinyal modulasi yang dipancarkan dibagian transmitter ke udara diterima
oleh bagian receiver. Kemudian sinyal modulasi yang sudah diterima bagian
penerima disalurkan ke input modulator untuk melalui proses selanjutnya sampai
sinyal termodulasi tersebut menjadi sinyal informasi (Genubhy,2008).
Modul wireless NRF24L01 merupakan modul komunikasi serial nirkabel
yang didesain untuk aplikasi ultra low power wireless. Modul wirelessmemiliki
register map tersedia melalui antarmuka SPI. Register map sendiri berisikan
semua konfigurasi register pada NRF24L01 dan dapat diakses pada semua mode
operasi dari chip (Nordic Semiconductor, 2007). Bentuk dari modul wireless
NRF24L01 ditunjukkan dalam Gambar 2.6.
Adapun desain pin pada NRF24L01 akan ditunjukkan pada Tabel 2.2
sebagai berikut:
Tabel 2.2 Desain pin NRF24L01
Nomor
Pin Fungsi Pin Keterangan
Pin
1 VCC Power Power Supply (1,9 - 3,6V)
2 GND Power Ground
3 CE Digital input Chip mode TX atau RX
4 CSN Digital input Chip SPI
5 SCK Digital input Clock SPI
6 IRQ Digital Maskable interrupt
output
14
Nomor
Pin Fungsi Pin Keterangan
Pin
7 MOSI Digital input SPI slave data input
8 MISO Digital SPI slave data ouput
output
Sumber : Datasheetmodul wireless NRF24L01
Tabel 2.2 menampilkan desain pin yang digunakan dalam modul wireless
NRF24L01. Dan pin-pin tersebut yang digunakan untuk melakukan pengiriman
data. Catu daya dan arus yang digunakan pada modul NRF24L01 harusnya sesuai
dikarenakan catu daya dan arus tidak sesuai maka modul wirelessNRF24L01
susah melakukan pengiriman data. Adapun konsumsi arus pada modul wireless
NRF24L01 ditunjukkan dalam Tabel 2.2.
Enhancedshockburst ™ menggunakan shockburst ™ untuk penanganan
dan pengaturan paket secara otomatis. Selama transmisi, shockburst ™ merakit
paket dan memasukkan bit-bit dalam paket data ke pemancar untuk
transmisi.Selama menerima, shockburst ™ secara konstan mencari alamat yang
valid dalam sinyal yang didemodulasi. Ketika shockburst ™ menemukan alamat
yang valid, ia memproses sisa paket dan memvalidasinya dengan CRC. Jika paket
valid, payload dipindahkan ke RX FIFO. Penanganan bit berkecepatan tinggi dan
pengaturan waktu dikendalikan oleh shockburst ™. Enhancedshockburst ™
menghadirkan penanganan transaksi paket otomatis yang memungkinkan
penerapan link data bi-directional yang andal. Transaksi paket shockburst ™ yang
disempurnakan adalah pertukaran paket antara transceiver, di mana satu
transceiver adalah Primary Receiver (PRX) dan yang lainnya adalah (PTX).
Transaksi paket shockburst ™ yang ditingkatkan selalu diprakarsai oleh transmisi
paket dari PTX, transaksi selesai ketika PTX telah menerima paket pengakuan
(paket ACK) dari PRX. Penanganan transaksi paket otomatis bekerja sebagai
berikut:
3.1 Pengguna memulai transaksi dengan mengirimkan paket data dari PTX ke
PRX. Enhancedshockburst ™ secara otomatis mengatur PTX dalam mode
terima untuk menunggu paket ACK.
15
3.2 Jika paket diterima oleh PRX, enhanced shockburst ™ secara otomatis
merakit dan mengirim paket pengakuan (paket ACK) ke PTX sebelum
kembali ke mode penerimaan.
3.3 Jika PTX tidak menerima paket ACK dalam waktu yang ditetapkan,
enhanced shockburst ™ akan secara otomatis mengirim ulang paket data
asli dan mengatur PTX dalam mode penerimaan untuk menunggu paket
ACK.
PRX dapat melampirkan data pengguna ke paket ACK yang
memungkinkan tautan data dua arah.Enhancedshockburst ™ sangat dapat
dikonfigurasi; dimungkinkan untuk mengkonfigurasi parameter seperti jumlah
retransmits maksimum dan penundaan dari satu transmisi ke transmisi ulang
berikutnya. Semua penanganan otomatis dilakukan tanpa keterlibatan
MCU.Adapun format pengiriman data modul wireless NRF24L01 ditunjukkan
dalam Gambar 2.8.
Tabel 2.3 Konsumsi Arus Modul wireless NRF24L01
BAB III
METODE PENELITIAN
17
18
Start
End
3. Arduino nano menyala disuplai catu daya, memulai program yang telah
dirancang atau dalam bahasa pemrogramannya “Serial Begin”.
4. Setelah program berjalan pada mikrokontroller, sensor suhu, sensor flow,
sensor kekeruhan, dan sensor pH mulai bekerja.
5. Pada pembacaan sensor suhu, setiap pembacaan suhu ada perubahan maka
akan ada pengiriman data baru ke server. Jika tidak ada perubahan data sensor
akan mengulang pembacaan lagi.
6. Pada pembacaan sensor pH, jika ada perubahan nilai pH pada pembacaan data
maka akan ada pengiriman data baru ke server. Jika tidak ada perubahan data
sensor akan mengulang pembacaan lagi.
21
7. Pada pembacaan sensor flow, jika ada perubahan nilai arus air yang masuk
maka ada pengiriman data baru ke server. Jika tidak ada perubahan data sensor
akan mengulang pembacaan lagi.
8. Pada pembacaan sensor kekeruhan, jika ada perubahan nilai turbidity pada
sensor, maka akan ada pengiriman data baru ke server. Jika tidak ada
perubahan data sensor akan mengulang pembacaan lagi.
Pengiriman data baru dilakukan ketika ada perubahan ditujukan untuk
membuat mikrokontroller tidak bekerja secara maksimal terus menerus yang
dalam kata lain tidak melakukan pengiriman terus menerus. Berikutnya Gambar
3.4 adalah proses dari server ke APK. Jadi prosesnya adalah ketika ada data baru
atau perubahan data yang diterima server maka server akan melakukan update
mengirimkan data ke database firebase, dan jika firebase update maka tampilan
pada serial monitoring APK smartphone juga berubah. Bila tidak ada perubahan
data pada firebase maka tampilan data atau informasi pada APK juga tidak
berubah.
3 Node perintah
program
untuk
nrf24l01
yang akan
digunakan
pada node.
Disini pin
VCC pada
nrf24l01
dimasukkan
ke pin 3v3
arduino
26
11 Server Terakhir
merupakan
program
untuk update
ke database
pada firebase
untuk
memberikan
data realtime.
Berdasarkan data diatas didapatkan hasil nilai output pada sensor berupa data
ADC. Data ADC sensor yang diperoleh dari penggunaan sensor kekeruhan
kemudian dikonversi dengan cara substitusi dan eliminasi sehingga diperoleh
rumus persamaan. Dari persamaan tersebut didapatkan nilai yang digunakan pada
pemrograman arduino untuk mengkonversi nilai desimal dari mikrokontroller
sesuai data standart dari alat ukur.
Tabel diatas menunjukkan akurasi atau nilai error dari sensor
turbiditydengan Turbidity Meter sebagai pembanding. Pada tabel diatas
36
digunakan rumus substitusi untuk menentukan nilai yang akan terbaca oleh
sensor. Berdasarkan data tersebut, dapat diketahui jika dari 3 sampel uji diperoleh
nilai kekeruhan tertinggi sebesar 60,34 NTU dengan nilai pembanding Turbidity
Meter sebesar 60 persen. Sedangkan nilai kekeruhan terendah sebesar 0,93 NTU
dengan nilai pembanding Turbidity Meter sebesar 0.1 persen.
4 3.5 4.1
6.86 6.1 6.4
Sensor Sensor
Termometer Suhu Termometer Suhu
Pengujian Pengujian
(0C) 0
DS18B20 ( C) DS18B20
(0C) (0C)
3 26 26,00 18 61 61,21
4 25 25,88 19 60 60,31
5 25 25,44 20 60 60,2
6 25 25,12 21 60 60,00
7 24 24,62 22 59 59,88
8 24 24,32 23 59 59,53
9 24 24,2 24 59 59,06
10 23 23,94 25 58 58,46
11 23 23,46 26 58 58,12
12 23 23,1 27 58 58,00
13 22 22,88 28 57 56,75
14 22 22,57 29 57 56,37
Pembacaan Pembacaan
Error
Sensor Thermo
23.98 23.94 17%
23.52 23.46 26%
23.12 23.1 9%
22.94 22.88 26%
22.63 22.57 27%
Pembacaan error dari setiap percobaan juga menunjukkan hasil error yang
bervariasi. Eror pada sensor dapat disebabkan karena kondisi air panas yang
mengalami penurunan suhu secara terus menerus sehingga nilai yang didapatkan
berbeda beda pada setiap pengulangan.
41
42
notifikasi untuk menentukan kondisi air saat itu baik atau tidak untuk dikunjung.
Pada Gambar 4.2 kondisi untuk status ada 3 macam, yaitu kondisi
“AMAN”, kondisi “PERINGATAN”, dan kondisi “BAHAYA”. Parameter untuk
3 kondisi ini adalah nilai kadar pH air, nilai arus aliran air, dan nilai kekeruhan
air. Untuk nilai pH adalah dibawah 6 karena nilai air sudah mulai asam, nilai arus
lebih dari 170 karena air deras, dan kekeruhan diatas 40 persen. Jika 3 status
melewati batas akan diambang “BAHAYA”, jika 2 status melewati batas status
“PERINGATAN”, dan jika 1 status melewati ambang batas masih dalam status
“AMAN”.
4.2 Pembahasan Data Monitoring
Sistem secara keseluruhan diuji berdasarkan parameter yang telah
ditentukan. Pengujian implementasi sistem pada aliran air terjun dilakukan selama
2 hari dengan 2 kondisi berbeda yaitu pada pukul 07.00 WIB dan pukul 10.00
WIB.Hal ini dilakukan karena perbedaan waktu dan hari memberikan pengaruh
pada kondisi air dari air terjun. Pengujian di setiap waktu tersebut dilakukan per
10 detik untuk mengamati perubahannya Hasil pengujian sistem secara
keseluruhan dapat dilihat pada Tabel 4.1 berikut.
Tabel 4.1 Pengujian Hari Pertama Pukul 07.00 WIB
Kekeruhan Flow Suhu Waktu
No. pH Status
(%) (ml/s) (OC) (Second)
1 0.5 % 154.09 7.13 15.63 10 Aman
2 0.7 % 145.80 7.16 15.38 20 Aman
3 0.7 % 143.70 7.38 15.56 30 Aman
4 0.6 % 156.40 7.08 15.44 40 Aman
5 1.2 % 139.43 6.98 15.5 50 Aman
6 1.1 % 142.63 7.12 15.68 60 Aman
Kekeruhan
Waktu
1 2 3 4
30 0.70% 4.90% 0.40% 5.90%
40 0.60% 5.60% 0.60% 5.80%
50 1.20% 5.40% 0.80% 5.80%
60 1.10% 5.50% 0.90% 5.90%
6.00%
5.00%
Persen Kekeruhan
1.00%
0.00%
10 20 30 40 50 60
hari pertama), percobaan ke 3 (7 pagi hari kedua), dan percobaan 4 (10 pagi hari
kedua).
Tabel 4.6 Perbandingan Arus Air
Besar Nilai Arus
Waktu
1 2 3 4
10 154.09 100.13 153.09 100.23
20 145.8 95.6 152.64 100.4
30 143.7 100.32 151.32 100.52
40 156.4 96.14 152.41 100.32
50 139.43 99.3 154.4 100.21
60 142.63 92.23 151.3 100.23
100
10 Pagi Hari Pertama
80
07 Pagi Hari Kedua
60 10 Pagi Hari Kedua
40
20
0
10 20 30 40 50 60
Dari tabel diatas bisa dilihat bahwa kondisi air lebih tenang pada jam 10
pagi baik hari pertama dan kedua dimana nilai terendahnya 92.23 ml/s hari
pertama dan 100.21 ml/s hari kedua. Paling deras 100.32 ml/s untuk jam 10 pagi
hari pertama dan 100.52 mls/s untuk hari kedua. Sementara untuk jam 7 hari
pertama memiliki nilai keruh terkecil 139.43 ml/s dan terbesar 156.4 ml/s. Untuk
jam 7 hari kedua memiliki nilai keruh terkecil 151.32 ml/s dan terbesar 154.4
ml/s.
47
Grafik Perbandingan pH
7.5
7.4
7.3
6.8
6.7
10 20 30 40 50 60
Nilai pH untuk semua pengukuran cenderung baik dimana tidak ada yang
kurang dari 6 dikarenakan masih air bersih dari alam dan tidak ada campuran zat
dari alam yang mengalir saat itu.Kondisi air cenderung basah dimana nilai
tertinggi sebesar 7.38 dan nilai terendah sebesar 6.98. Nilai tertinggi terjadi pada
jam 7 pagi dan nilai terendah terjadi pada jam 10 pagi.
48
Penjelasan yang terakhir adalah perbandingan data sensor suhu yang akan
ditampilkan pada tabel 4.7. Sama dengan tabel sebelumnya, Angka 1, 2, 3, dan 4
adalah tanda untuk percobaan ke 1 (7 pagi hari pertama), percobaan ke 2 (10 pagi
hari pertama), percobaan ke 3 (7 pagi hari kedua), dan percobaan 4 (10 pagi hari
kedua).
Tabel 4.8 Perbandingan Nilai Arus
Nilai Suhu
Waktu
1 2 3 4
10 15.63 18.32 15.33 18.21
20 15.38 18.24 15.31 18.23
30 15.56 18.07 15.36 18.17
40 15.44 18.31 15.34 18.15
50 15.5 18.23 15.35 18.22
60 15.68 18.54 15.33 18.24
Nilai suhu pada jam 7 pagi lebih rendah daripada nilai suhu pada jam 10
pagi dikarenakan alam masih segar dan mendapatkan suhu dari embun yang
belum sepenuhnya hilang. Suhu terendah adalah 15.31 Celcius untuk jam 7 pagi
hari kedua dan nilai suhu tertinggi 18.54 untuk jam 10 pagi hari pertama.
BAB V
KESIMPULAN DAN SARAN
5.1 Kesimpulan
Berdasarkan dari pembuatan dan pengujian sistem yang dilakukan pada
bab sebelumnya, bisa ditarik kesimpulan untuk peniltian ini bahwa :
1. Sistem yang dirancang untuk penelitian ini berhasil dibuat dengan baik
dimana dalam melakukan beberapa pengujian berhasil mendapatkan data
yang diinginkan.
2. Sensor sensor yang digunakan bisa dikalibrasi dengan baik dengan
perbedaan nilai antara sensor dan alat ukur kurang dari 5 persen.
3. Penggunaan firebase sebagai database realtime berjalan dengan baik
dimana pengiriman data dari sensor via internet tidak mengalami
kegagalan disetiap uji coba.
4. Tampilan informasi yang dibuat dalam aplikasi bekerja dengan baik
dengan tingkat keberhasilan update lebih dari 90 persen dari beberapa kali
percobaan.
5.2 Saran
Berdasarkan hasil dan pembahasan maka didapat kesimpulan sebagai
berikut :
1. Sistem yang dibangun bisa dikembangkan dalam ruang lingkup Internet Of
Things.
2. Penambahan sensor pada sistem untuk meningkatkan informasi di tempat
wisata.
49
DAFTAR PUSTAKA
[1] Nicolic, G. (2014). Wireless Sensor Node With Low-Power Sensing. 435-453.
[2] Faisal, K.S; Bachani, M; Qureshi, U.M. (2016). Performance Analysis of
Proximity and Light Sensors for Smart Parking.
[3] Aguirre, E; Lopez-Itturi,P; Astrain,J.J; dkk . (2016). Implementation and
Analysis of a Wireless Sensor -Based Pet Location Monitoring System
forDomestic Scenarios.
[4] Aska, F,Z; Satria,D; Kasoep W. (2014). Implementasi Radio Frequency
Identification (Rfid) Sebagai Otomasi Pada Smart Home .
[5] Pratama, I. P., & Suakanto, S. (2015). Wireless Sensor Network. Bandung:
Informatika.
[6] Y. A. Adnantha and W. A. Kusuma, “Implementasi Wireless Sensor Network
Untuk Otomatisasi Suhu Ruang Dan Kelembaban Tanah Pada Greenhouse
Berbasis Web Server,” J. Online Inform., vol. 3, no. 1, p. 14, 2018, doi:
10.15575/join.v3i1.169.
[7] A. Heryanto, J. Budiarto, and S. Hadi, “Sistem Nutrisi Tanaman Hidroponik
Berbasis Internet Of Things Menggunakan NodeMCU ESP8266 Jurnal BITe :
Jurnal Bumigora Information Technology Jurnal BITe : Jurnal Bumigora
Information Technology,” vol. 2, no. 1, pp. 31–39, 2020, doi:
10.30812/bite.v2i1.805.
[8] Y. Wahyudin, S. Suryono, and J. E. Suseno, “Sistem monitoring dan otomasi
pengontrolan kelembaban media tanam (soil moisture) pada tanaman
hidroponik berbasis web,” Youngster Phys. J., vol. 6, no. 3, pp. 213–220,
2017.
[9] M. Makruf, A. Sholehah, and M. Walid, “Implementasi Wireless Sensor
Network (Wsn) Untuk Monitoring Smart Farming Pada Tanaman Hidroponik
Menggunakan Mikrokontroller Wemos D1 Mini,” JIKO (Jurnal Inform. dan
Komputer), vol. 2, no. 2, pp. 95–102, 2019, doi: 10.33387/jiko.v2i2.1360.
[10] B.F. Mahardika and N. Rohmah.2019, “Monitoring Tanaman Mint Dengan
Sistem Vertical Hidroponik Menggunakan ESP32 Berbasis Iot” Tugas Akhir.
50
Teknik Elektro, Jaringan Telekomunikasi Digital, Politeknik Negeri Malang,
Malang
[11] H. Helmy, A. Rahmawati, S. Ramadhan, T. A. Setyawan, and A. Nursyahid,
“Pemantauan dan Pengendalian Kepekatan Larutan Nutrisi Hidroponik
Berbasis Jaringan Sensor Nirkabel,” J. Nas. Tek. Elektro dan Teknol. Inf., vol.
7, no. 4, 2018, doi: 10.22146/jnteti.v7i4.456.
[12] [7] A. M. G. Qilla Aulia Suri, “Fakultas Teknik – Universitas Muria Kudus,”
Pros. SNATIF ke-6 Tahun 2019, no. 2007, pp. 96–101, 2019
[13] Datasheet Arduino Nano Retrieved fromhttp://www.arduino.com
[14] Datasheet NRF24l01 Retrivied from
https://www.sparkfun.com/datasheets/Components/SMD/nRF24L01Pluss_Pr
eliminary_Product_Specification_v1_0.pdf
[15] Pratama, R. P., Akbar, S. R., & Bhawiyuga, A. (2017). Rancang Bangun Low
Power Sensor Node Menggunakan MSP430 Berbasis NRF24L01.Jurnal
Pengembangan Teknologi Informasi dan Ilmu Komputer, Vol. 1, No. 3, 157-
165.
[16] Datasheet LDR Retrieved from https://components101.com/ldr-datasheet
[17] Datasheet Raspi Pi 3 Retrieved from
https://static.raspberrypi.org/files/product-briefs/Raspberry-Pi-Model-Bplus-
Product-Brief.pdf
51
LAMPIRAN DATASHEET
KOMPONEN
52
PRELIMINARY PRODUCT SPECIFICATION
GENERAL DESCRIPTION
nRF24L01 is a single chip radio transceiver for the world wide 2.4 - 2.5 GHz ISM
band. The transceiver consists of a fully integrated frequency synthesizer, a power
amplifier, a crystal oscillator, a demodulator, modulator and Enhanced ShockBurst™
protocol engine. Output power, frequency channels, and protocol setup are easily
programmable through a SPI interface. Current consumption is very low, only 9.0mA
at an output power of -6dBm and 12.3mA in RX mode. Built-in Power Down and
Standby modes makes power saving easily realizable.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 1 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
BLOCK DIAGRAM
VSS=0V
VSS=0V
VSS=0V
DVDD
VDD
VDD
VDD
XC1
VSS=0V
Enhanced
ShockBurstTM XC2
DEMOD
IF BPF
VDD_PA=1.8V
CE LNA
Clock
Recovery,
DataSlicer
ADDR
IRQ Decode
CRC Frequency
Code/Decode Synthesiser
FIFO
CSN In/Out
ANT1
SCK
GFSK
PA 100+j175 Ω
Filter
MISO ANT2
MOSI IREF
22kΩ
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 2 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
PIN FUNCTIONS
PIN ASSIGNMENT
20 19 18 17 16
CE 1 15 VDD
nRF24L01
CSN 2 14 VSS
QFN20 4x4
SCK 3 13 ANT2
MOSI 4 12 ANT1
MISO 5 11 VDD_PA
6 7 8 9 10
IRQ VDD VSS XC2 XC1
Figure 2 nRF24L01 pin assignment (top view) for a QFN20 4x4 package.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 3 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
ELECTRICAL SPECIFICATIONS
Conditions: VDD = +3V, VSS = 0V, TA = - 40ºC to + 85ºC
Symbol Parameter (condition) Notes Min. Typ. Max. Units
Operating conditions
VDD Supply voltage 1.9 3.0 3.6 V
TEMP Operating Temperature -40 +27 +85 ºC
General RF conditions
2
fOP Operating frequency 2400 2525 MHz
fXTAL Crystal frequency 16 MHz
∆f1M Frequency deviation @ 1000kbps ±160 kHz
∆f2M Frequency deviation @ 2000kbps ±320 kHz
RGFSK Data rate ShockBurst™ >0 2000 kbps
FCHANNEL Channel spacing @ 1000kbps 1 MHz
FCHANNEL Channel spacing @ 2000kbps 2 MHz
Transmitter operation
3
PRF Maximum Output Power 0 +4 dBm
PRFC RF Power Control Range 16 18 20 dB
PRFCR RF Power Accuracy ±4 dB
PBW 20dB Bandwidth for Modulated Carrier 1800 2000 kHz
(2000kbps)
PRF1 1st Adjacent Channel Transmit Power 2MHz -20 dBm
PRF2 2nd Adjacent Channel Transmit Power 4MHz -50 dBm
4
IVDD Supply current @ 0dBm output power 11.3 mA
IVDD Supply current @ -18dBm output power 7.0 mA
5
IVDD Average Supply current @ -6dBm output 0.05 mA
power, Enhanced ShockBurst™
6
IVDD Supply current in Standby-I mode 32 µA
IVDD Supply current in power down 900 nA
1
All digital inputs handle up to 5.25V signal inputs. Keep in mind that the VDD of the nRF24L01 must match the
VIH of the driving device for output pins.
2
Usable band is determined by local regulations
3
Antenna load impedance = 15Ω+j88Ω
4
Antenna load impedance = 15Ω+j88Ω. Effective data rate 1000kbps or 2000 kbps
5
Antenna load impedance = 15Ω+j88Ω. Effective data rate 10kbps and full packets
6
Given for a 12pF crystal. Current when using external clock is dependent on signal swing.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 4 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Receiver operation
IVDD Supply current one channel 2000kbps 12.3 mA
IVDD Supply current one channel 1000kbps 11.8 mA
RXSENS Sensitivity at 0.1%BER (@2000kbps) -82 dBm
RXSENS Sensitivity at 0.1%BER (@1000kbps) -85 dBm
7
C/ICO C/I Co-channel (@2000kbps) 78/119 dB
C/I1ST 1st Adjacent Channel Selectivity C/I 2MHz 1/4 dB
C/I2ND 2nd Adjacent Channel Selectivity C/I 4MHz -21/-20 dB
C/I3RD 3rd Adjacent Channel Selectivity C/I 6MHz -27/-27 dB
10
C/ICO C/I Co-channel (@1000kbps) 911/1212 dB
C/I1ST 1st Adjacent Channel Selectivity C/I 1MHz 8/8 dB
C/I2ND 2nd Adjacent Channel Selectivity C/I 2MHz -22/-21 dB
C/I3RD 3rd Adjacent Channel Selectivity C/I 3MHz -30/-30 dB
Table 4 nRF24L01 RF specifications
7
Data rate is 2000kbps for the following C/I measurements
8
According to ETSI EN 300 440-1 V1.3.1 (2001-09) page 27
9
nRF24L01 equal modulation on interfering signal
10
Data rate is 1000kbps for the following C/I measurements
11
According to ETSI EN 300 440-1 V1.3.1 (2001-09) page 27
12
nRF24L01 equal modulation on interfering signal
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 5 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
PACKAGE OUTLINE
nRF24L01 uses the QFN20 4x4 package, with matt tin plating.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 6 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
13
BSC: Basic Spacing between Centers, ref. JEDEC standard 95, page 4.17-11/A
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 7 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Package marking:
n R F B X
2 4 L 0 1
Y Y W W L L
Abbreviations:
B – Build Code, i.e. unique code for production sites,
package type and test platform
X – "X" grade, i.e. Engineering Samples (optional)
YY – 2 digit Year number
WW – 2 digit Week number
LL – 2 letter wafer lot number code
Temperatures
Operating Temperature…. - 40°C to + 85°C
Storage Temperature….… - 40°C to + 125°C
Note: Stress exceeding one or more of the limiting values may cause permanent
damage to the device.
ATTENTION!
Electrostatic Sensitive Device
Observe Precaution for handling.
Glossary of Terms
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 8 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Term Description
ACK Acknowledgement
ART Auto Re-Transmit
CE Chip Enable
CLK Clock
CRC Cyclic Redundancy Check
CSN Chip Select NOT
ESB Enhanced ShockBurst™
GFSK Gaussian Frequency Shift Keying
IRQ Interrupt Request
ISM Industrial-Scientific-Medical
LNA Low Noise Amplifier
LSB Least Significant Bit
LSByte Least Significant Byte
Mbps Megabit per second
MCU Micro Controller Unit
MISO Master In Slave Out
MOSI Master Out Slave In
MSB Most Significant Bit
MSByte Most Significant Byte
PCB Printed Circuit Board
PER Packet Error Rate
PID Packet Identity Bits
PLD Payload
PRX Primary RX
PTX Primary TX
PWR_DWN Power Down
PWR_UP Power Up
RoHS Restriction of use of Certain Hazardous Substances
RX Receive
RX_DR Receive Data Ready
SPI Serial Peripheral Interface
TX Transmit
TX_DS Transmit Data Sent
Table 5 Glossary
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 9 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
FUNCTIONAL DESCRIPTION
Modes of operation
The nRF24L01 can be set in the following main modes depending on the level of the
following primary I/Os and configuration registers:
PWR_UP PRIM_RX
CE FIFO state
register register
Mode
RX mode 1 1 1 -
TX mode 1 0 1 Data in TX FIFO
TX mode 1 0 1Î0 Stays in TX mode until packet
transmission is finished
Standby-II 1 0 1 TX FIFO empty
Standby-I 1 - 0 No ongoing packet transmission
Power Down 0 - - -
Standby Modes
Standby-I mode is used to minimize average current consumption while maintaining
short start up times. In this mode, part of the crystal oscillator is active. In Standby-II
mode some extra clock buffers are active compared to Standby-I mode. Standby-II
occurs when CE is held high on a PTX device with empty TX FIFO. The
configuration word content is maintained during Standby modes. SPI interface may be
activated. For start up time see Table 13.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 10 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
ShockBurst™
ShockBurst™ makes it possible to use the high data rate offered by nRF24L01
without the need of a costly, high-speed microcontroller (MCU) for data
processing/clock recovery. By placing all high speed signal processing related to RF
protocol on-chip, nRF24L01 offers the application microcontroller a simple SPI
compatible interface, the data rate is decided by the interface-speed the micro
controller itself sets up. By allowing the digital part of the application to run at low
speed, while maximizing the data rate on the RF link, ShockBurst™ reduces the
average current consumption in applications.
In ShockBurst™ RX, IRQ notifies the MCU when a valid address and payload is
received respectively. The MCU can then clock out the received payload from an
nRF24L01 RX FIFO.
In ShockBurst™ TX, nRF24L01 automatically generates preamble and CRC, see
Table 12. IRQ notifies the MCU that the transmission is completed. All together, this
means reduced memory demand in the MCU resulting in a low cost MCU, as well as
reduced software development time. nRF24L01 has a three level deep RX FIFO
(shared between 6 pipes) and a three level deep TX FIFO. The MCU can access the
FIFOs at any time, in power down mode, in standby modes, and during RF packet
transmission. This allows the slowest possible SPI interface compared to the average
data-rate, and may enable usage of an MCU without hardware SPI.
Enhanced ShockBurst™
Enhanced ShockBurst™ is a packet handling method with functionality that makes bi-
directional link protocol implementation easier and more efficient. In a typical bi-
directional link, one will let the terminating part acknowledge received packets from
the originating part in order to make it possible to detect data loss. Data loss can then
be recovered by retransmission. The idea with Enhanced ShockBurst™ is to let
nRF24L01 handle both acknowledgement of received packets and retransmissions of
lost packets, without involvement from the microcontroller.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 11 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
TX3 TX4
TX2
TX5
ipe 4
Data
P
Da
5
Data
ipe 3
t
pe
a
TX1
Pi
Pi
pe
TX6
ta
Da
2
Da
ta P 0
ipe ipe
1
Da ta P
RX
Frequency Channel N
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 12 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
An nRF24L01 configured as PTX with Enhanced ShockBurst™ enabled, will use the
ShockBurst™ feature to send a packet whenever the microcontroller wants to. After
the packet has been transmitted, nRF24L01 will switch on its receiver and expect an
acknowledgement to arrive from the terminating part. If this acknowledgement fails to
arrive, nRF24L01 will retransmit the same packet until it receives an
acknowledgement or the number of retries exceeds the number of allowed retries
given in the SETUP_RETR_ARC register. If the number of retries exceeds the
number of allowed retries, this will be showed by the STATUS register bit MAX_RT
which gives an interrupt.
Whenever an acknowledgement is received by an nRF24L01 it will consider the last
transmitted packet as delivered. It will then be cleared from the TX FIFO, and the
TX_DS IRQ source will be set high.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 13 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 14 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
If auto acknowledgement is enabled and a valid packet (correct data pipe address and
CRC) is received, the device will enter TX mode and send an acknowledgement
packet. After the device has sent the acknowledgement packet, normal operation
resumes, and the mode is determined by the PRIM_RX register and CE pin.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 15 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
(i.e. the maximum number of sending is reached). The only way to reset this is to set
the PWR_UP bit low or let the auto retransmission finish. A packet loss counter will
be incremented each time a packet does not succeed to reach the destination before
time out. (Time out is indicated by the MAX_RT interrupt.) The packet loss counter is
reset when writing to the RF channel register.
1: PRX device:
The PRX device compares the received PID with the last PID. If the PID fields are
different, the packet is considered to be new. If the PID is equal to last received PID,
the received packet might be the same as last time. The receiver must check if the
CRC is equal to the previous CRC. If the CRC is equal to the previous one, the packet
is probably the same, and will be discarded.
2: PTX device:
The transmitter increments the PID field each time it sends a new packet.
TX side functionality RX side functionality
Start Start
No
End
End
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 16 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
The length of the CRC is configurable through the SPI interface. It is important to
notice that the CRC is calculated over the whole packet including address, PID and
payload. No packet is accepted as correct if the CRC fails. This is an extra
requirement for packet acceptance that is not illustrated in the figure above.
Data Pipes
nRF24L01 configured as PRX can receive data addressed to 6 different data pipes in
one physical frequency channel. Each data pipe has its own unique address and can be
configured to have individual behavior.
The data pipes are enabled with the bits in the EN_RXADDR register. By default
only data pipe 0 and 1 are enabled.
The address for each data pipe is configured in the RX_ADDR_Px registers. Always
ensure that none of the data pipes have the exact same address.
Data pipe 0 has a unique 40 bit configurable address. Data pipes 1-5 share the 32 most
significant address bits and have only the LSByte unique for each data pipe. Figure 7
shows an example of how data pipes 0-5 are addressed. All pipes can have up to 40
bit address, but for pipe 1-5 only the LSByte is different, and the LSByte must be
unique for all pipes.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 17 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Some configuration settings are common to all data pipes and some are individual.
The following settings are common to all data pipes:
• CRC enabled/disabled (CRC always enabled when ESB is enabled)
• CRC encoding scheme
• RX address width
• Frequency channel
• RF data rate
• LNA gain
• RF output power
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 18 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
DEVICE CONFIGURATION
All configuration of nRF24L01 is defined by values in some configuration registers.
All these registers are writable via the SPI interface.
SPI Interface
The SPI interface is a standard SPI interface with a maximum data rate of 10Mbps.
Most registers are readable.
In parallel to the SPI instruction word applied on the MOSI pin, the STATUS register
is shifted serially out on the MISO pin.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 19 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
writing can be terminated before all bytes in a multi-byte register has been written. In
this case the unwritten MSByte(s) will remain unchanged. E.g. the LSByte of
RX_ADDR_P0 can be modified by writing only one byte to the RX_ADDR_P0
register. The content of the status register will always be read to MISO after a high to
low transition on CSN.
Interrupt
The nRF24L01 has an active low interrupt pin (IRQ). The interrupt pin is activated
when TX_DS, RX_DR or MAX_RT is set high in status register. When MCU writes
'1' to the interrupt source, the IRQ pin will go inactive. The interrupt mask part of the
CONFIG register is used to mask out the interrupt sources that are allowed to set the
IRQ pin low. By setting one of the MASK bits high, the corresponding interrupt
source will be disabled. By default all interrupt sources are enabled.
SPI Timing
The interface supports SPI. SPI operation and timing is given in Figure 8 to Figure 10
and in Table 9 and Table 10. The device must be in one of the standby modes or
power down mode before writing to the configuration registers. In Figure 8 to Figure
10 the following notations are used:
Cn – SPI Instruction Bit
Sn – Status Register Bit
Dn – Data Bit (note: LSByte to MSByte, MSBit in each byte first)
CSN
SCK
MOSI C7 C6 C5 C4 C3 C2 C1 C0
MISO S7 S6 S5 S4 S3 S2 S1 S0 D7 D6 D5 D4 D3 D2 D1 D0 D1 5 D1 4 D1 3 D1 2 D1 1 D1 0 D9 D8
CSN
SCK
MOSI C7 C6 C5 C4 C3 C2 C1 C0 D7 D6 D5 D4 D3 D2 D1 D0 D1 5 D1 4 D1 3 D1 2 D1 1 D1 0 D9 D8
MISO S7 S6 S5 S4 S3 S2 S1 S0
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 20 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Tcwh
CSN
Tdh
Tdc
MOSI C7 C6 C0
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 21 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
MEMORY MAP
All undefined bits in the table below are redundant. They will be read out as '0'.
Address Mnemonic Bit Reset Type Description
(Hex) Value
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 22 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
05 RF_CH RF Channel
Reserved 7 0 R/W Only '0' allowed
RF_CH 6:0 0000010 R/W Sets the frequency channel nRF24L01
operates on
14
Accurate formula for delay from start of transmission, to start of re-transmission:
TRD (us) = 250us * (ARD+1) + 4us *(AW + PW + CRCW) +138,5us.
TRD= total retransmit delay, AW=Address Width (#bytes), PW=Payload Width(#bytes)
, CRCW= CRC Width (#bytes)
15
The Data Ready interrupt is set by a new packet arrival event. The procedure for handling this
interrupt should be: 1) read payload via SPI, 2) clear RX_DR interrupt, 3) read FIFO_STATUS to
check if there are more payloads available in RX FIFO, 4) if there are more data in RX FIFO, repeat
from 1).
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 23 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
09 CD
Reserved 7:1 000000 R
CD 0 0 R Carrier Detect. See page 17.
10 TX_ADDR 39:0 0xE7E7E7E7E7 R/W Transmit address. Used for a PTX device
only. (LSByte is written first)
Set RX_ADDR_P0 equal to this address
to handle automatic acknowledge if this is
a PTX device with Enhanced
ShockBurst™ enabled. See page 14.
11 RX_PW_P0
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P0 5:0 0 R/W Number of bytes in RX payload in data
pipe 0 (1 to 32 bytes).
0 Pipe not used
1 = 1 byte
…
32 = 32 bytes
12 RX_PW_P1
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P1 5:0 0 R/W Number of bytes in RX payload in data
pipe 1 (1 to 32 bytes).
0 Pipe not used
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 24 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
13 RX_PW_P2
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P2 5:0 0 R/W Number of bytes in RX payload in data
pipe 2 (1 to 32 bytes).
0 Pipe not used
1 = 1 byte
…
32 = 32 bytes
14 RX_PW_P3
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P3 5:0 0 R/W Number of bytes in RX payload in data
pipe 3 (1 to 32 bytes).
0 Pipe not used
1 = 1 byte
…
32 = 32 bytes
15 RX_PW_P4
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P4 5:0 0 R/W Number of bytes in RX payload in data
pipe 4 (1 to 32 bytes).
0 Pipe not used
1 = 1 byte
…
32 = 32 bytes
16 RX_PW_P5
Reserved 7:6 00 R/W Only '00' allowed
RX_PW_P5 5:0 0 R/W Number of bytes in RX payload in data
pipe 5 (1 to 32 bytes).
0 Pipe not used
1 = 1 byte
…
32 = 32 bytes
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 25 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 26 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
PACKET DESCRIPTION
An Enhanced ShockBurst™ packet with payload (1-32 bytes).
CRC 0/1/2
Preamble Address 3-5 byte 9 bit Payload 1 - 32 byte
byte
flag bits.
CRC 0/1/2
Preamble Address 3-5 byte Payload 1 - 32 byte
byte
Preamble • Preamble is used to detect 0 and 1 levels. It is stripped off (RX) and added (TX)
by nRF24L01.
Address • The address field contains the receiver address.
• The address can be 3, 4 or 5 bytes wide
• The address fields can be individually configured for all RX channels and the
TX channel
• Address is automatically removed from received packets.16
Flags • PID: Packet Identification. 2 bits that is incremented for each new payload
• 7 bits reserved for packet compatibility with future products
• Not used when compatible to nRF2401/nRF24E1
Payload • 1 - 32 bytes wide.
CRC • The CRC is optional.
• 0-2 bytes wide CRC
• The polynomial for 8 bits CRC check is X8 + X2 + X + 1
• The polynomial for 16 bits CRC check is X16+ X12 + X5 + 1.
Table 12 Data packet description
16
Suggested use of addresses. In general more bits in the address gives less false detection, which in
the end may give lower data Packet-Error-Rate (PER).
A. The address made by (5, 4, or 3) equal bytes are not recommended because it in general will
make the packet-error-rate increase.
B. Addresses where the level shift only one time (i.e. 000FFFFFFF) could often be detected in
noise that may give a false detection, which again may give raised packet-error-rate.
C. Addresses as a continuation of the preamble (hi-low toggling) will raise the Packet-Error-Rate
(PER).
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 27 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
When the nRF24L01 is in power down it must always settle in Standby for 1.5ms
before it can enter one of the TX or RX modes. Note that the configuration word will
be lost if VDD is turned off and that the device then must be configured before going
to one of the TX or RX mode.
1 2
1 byte payload with ACK (339 us )
ESB cycle
CE high minimum 10 us
PTX: CE
2 us
PTX: Mode STBY I TX RX TX
PRX: CE
128 us
PRX: Mode STBY I RX TX RX
Packet:
A ddress : 5 by tes
CRC: 1 by te
Payload: 1 by te
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 28 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
In Figure 11 the sending of one packet and the acknowledgement of this packet is
shown. The loading of payload to the PTX device is not shown in the figure. The PRX
device is turned into RX mode (CE=1), and the PTX device is set into TX mode
(CE=1 for minimum 10 µs). After 130 µs the transmission starts and is finished after
another 37 µs (1 byte payload). The transmission ends, and the PTX device is
automatically turned around to RX mode to wait for the acknowledgement from the
PRX device. After the PTX device has received the acknowledgement it gives an
interrupt to the MCU (IRQ (TX_DS) =>TX-data sent). After the PRX device has
received the packet it gives an interrupt to the MCU (IRQ (RX_DR) =>RX-data
ready).
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 29 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
PERIPHERAL RF INFORMATION
Antenna output
The ANT1 & ANT2 output pins provide a balanced RF output to the antenna. The
pins must have a DC path to VDD, either via a RF choke or via the center point in a
dipole antenna. A load of 15Ω+j88Ω (simulated values) is recommended for
maximum output power (0dBm). Lower load impedance (for instance 50 Ω) can be
obtained by fitting a simple matching network between the load and ANT1 and
ANT2.
Crystal Specification
Frequency accuracy includes initial accuracy (tolerance) and stability over
temperature and aging.
To achieve a crystal oscillator solution with low power consumption and fast start-up
time, it is recommended to specify the crystal with a low value of crystal load
capacitance. Specifying a lower value of crystal parallel equivalent capacitance, C0
will also work, but this can increase the price of the crystal itself. Typically C0=1.5pF
at a crystal specified for C0max=7.0pF.
C1 '⋅C 2 '
CL = C1 ' + C 2 '
, where C1’ = C1 + CPCB1 +CI1 and C2’ = C2 + CPCB2 + CI2
C1 and C2 are SMD capacitors as shown in the application schematics. CPCB1 and
CPCB2 are the layout parasitic on the circuit board. CI1 and CI2 are the capacitance seen
into the XC1 and XC2 pin respectively; the value is typical 1pF.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 30 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Crystal parameters:
When the micro controller drives the nRF24L01 clock input, the requirement of load
capacitance CL is set by the micro controller only. The frequency accuracy of ±60
ppm is still required to get a functional radio link. The nRF24L01 will load the crystal
by 0.5pF at XC1 in addition to the PBC routing.
XO_OUT
Buffer:
Sine to
full swing
Amplitude
controlled
current source
Current starved
inverter:
XOSC core
Vdd Vdd
Vss Vss
ESD ESD
XC1 XC2
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 31 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
A PCB with a minimum of two layers including a ground plane is recommended for
optimum performance. The nRF24L01 DC supply voltage should be de-coupled as
close as possible to the VDD pins with high performance RF capacitors, see Table 16.
It is preferable to mount a large surface mount capacitor (e.g. 4.7µF tantalum) in
parallel with the smaller value capacitors. The nRF24L01 supply voltage should be
filtered and routed separately from the supply voltages of any digital circuitry.
Long power supply lines on the PCB should be avoided. All device grounds, VDD
connections and VDD bypass capacitors must be connected as close as possible to the
nRF24L01 IC. For a PCB with a topside RF ground plane, the VSS pins should be
connected directly to the ground plane. For a PCB with a bottom ground plane, the
best technique is to have via holes as close as possible to the VSS pads. At least one
via hole should be used for each VSS pin.
Full swing digital data or control signals should not be routed close to the crystal or
the power supply lines.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 32 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
APPLICATION EXAMPLE
nRF24L01 with single ended matching network crystal, bias resistor, and decoupling
capacitors.
C7 R2
33nF 22K
VDD 0402 0402
20
19
18
17
16
C9 C8
10nF 1nF U1
0402 0402
VSS
VSS
IREF
DVDD
VDD
CE 1 15
CE VDD
CSN 2 nRF24L01 14 C5
CSN VSS L3
SCK 3 13
SCK ANT2 50ohm, RF I/O
MOSI 4 12 3.9nH
MOSI ANT1
MISO 5 11 L1 0402 1.5pF
MISO VDD_PA
8.2nH 0402
0402
C6
VDD
XC2
XC1
VSS
IRQ
L2 1.0pF
0402
2.7nH
NRF24L01 0402
6
7
8
9
10
IRQ
X1 C3 C4
2.2nF 4.7pF
0402 0402
16 MHz
R1
1M
C1 C2
22pF 22pF
0402 0402
Figure 13 nRF24L01 schematic for RF layouts with single ended 50Ω RF output.
Part Designator Footprint Description
17
22pF C1 0402 NPO, +/- 2%, 50V
17
22pF C2 0402 NPO, +/- 2%, 50V
2.2nF C3 0402 X7R, +/- 10%, 50V
4.7pF C4 0402 NPO, +/- 0.25 pF, 50V
1.5pF C5 0402 NPO, +/- 0.1 pF, 50V
1,0pF C6 0402 NPO, +/- 0.1 pF, 50V
33nF C7 0402 X7R, +/- 10%, 50V
1nF C8 0402 X7R, +/- 10%, 50V
10nF C9 0402 X7R, +/- 10%, 50V
8,2nH L1 0402 chip inductor +/- 5%
2.7nH L2 0402 chip inductor +/- 5%
3,9nH L3 0402 chip inductor +/- 5%
1M R1 0402 +/-10%
22K R2 0402 +/- 1 %
nRF24L01 U1 QFN20 4x4
17
16MHz X1 +/-60ppm, CL=12pF
17
C1 and C2 must have values that match the crystals load capacitance, CL.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 33 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Top overlay
Top layer
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 34 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Bottom layer
Figure 14 nRF24L01 RF layout with single ended connection to PCB antenna and
0603 size passive components
The nest figure (Figure 15) is for the SMA output to have a board for direct
measurements at a 50Ω SMA connector.
Top Overlay
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 35 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Top Layer
Bottom Layer
Figure 15 Module with OFM crystal and SMA connector
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 36 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
DEFINITIONS
Data sheet status
Objective product specification This data sheet contains target specifications for product development.
Preliminary product This data sheet contains preliminary data; supplementary data may be
specification published from Nordic Semiconductor ASA later.
Product specification This data sheet contains final product specifications. Nordic Semiconductor
ASA reserves the right to make changes at any time without notice in order to
improve design and supply the best possible product.
Limiting values
Stress above one or more of the limiting values may cause permanent damage to the device. These are stress
ratings only and operation of the device at these or at any other conditions above those given in the
Specifications sections of the specification is not implied. Exposure to limiting values for extended periods may
affect device reliability.
Application information
Where application information is given, it is advisory and does not form part of the specification.
Nordic Semiconductor ASA reserves the right to make changes without further notice
to the product to improve reliability, function or design. Nordic Semiconductor ASA
does not assume any liability arising out of the application or use of any product or
circuits described herein.
All rights reserved ®. Reproduction in whole or in part is prohibited without the prior
written permission of the copyright holder.
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 37 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
YOUR NOTES
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 38 of 39 March 2006
PRELIMINARY PRODUCT SPECIFICATION
Main Office:
Vestre Rosten 81, N-7075 Tiller, Norway
Phone: +47 72 89 89 00, Fax: +47 72 89 89 89
Nordic Semiconductor ASA - Vestre Rosten 81, N-7075 Tiller, Norway - Phone +4772898900 - Fax +4772898989
Revision: 1.2 Page 39 of 39 March 2006
PH meter(SKU: SEN0161)
Contents
1 Introduction
2 Specification
3 Precautions
4 pH Electrode Characteristics
5 Usage
5.1 Connecting Diagram
5.2 Method 1. Software Calibration
5.3 Method 2. Hardware Calibration through potentiometer
6 FAQ
Introduction
Need to measure water quality and other parameters but haven't got any low cost pH meter? Find it
difficult to use with Arduino? Here comes an analog pH meter, specially designed for Arduino
controllers and has built-in simple, convenient and practical connection and features. It has an LED
which works as the Power Indicator, a BNC connector and PH2.0 sensor interface. You can just
connect the pH sensor with BNC connector, and plug the PH2.0 interface into any analog input on
Arduino controller to read pH value easily.
Specification
SEN0161 dimension
Precautions
Before and after use of the pH electrode every time, you need to use (pure)water to clean it.
The electrode plug should be kept clean and dry in case of short circuit.
Measurement should be avoided staggered pollution between solutions, so as not to affect the
accuracy of measurement.
Electrode blub or sand core is defiled which will make PTS decline, slow response. So, it should be
based on the characteristics of the pollutant, adapted to the cleaning solution, the electrode
performance recovery.
Electrode when in use, the ceramic sand core and liquid outlet rubber ring should be removed, in
order to make salt bridge solution to maintain a certain velocity.
Their usages/ specifications are almost the same. The differences locates at
Long-firing Operation: SEN0169 supports, while SEN0161 NOT, i.e. you can not
immerse SEN0161 in water for Continuous Testing.
Life Span: In 25 , pure water, do Continuous Testing with them both, SEN0169 can
work two years, while SEN0161 can only last for 6 months. And just for reference, if put
them in turbid, strongly acid and alkali solution, 25 , the life span would drop to one year
(SEN0169), 1 month(or shorter, SEN0161).
Tempreture, pH, turbidity of the water effect the probe life span a lot.
Waterproof: You can immerse the whole probe SEN0169 into the water, while you can
only immerse the front part of the probe SEN0161, the electrode glass bulb, into water,
the rear part, from the white shell to the cable, MUST NOT be under water.
Strongly Acid and Alkali: SEN0169 are preferred for strongly acid and alkali test. And if
your testing range is usually within pH6~8, then SEN0161 is capable for that.
pH Electrode Characteristics
The output of pH electrode is Millivolts, and the pH value of the relationship is shown as follows
(25 ):
NOTE: It is normal that if your reading is much different with the table since you are not
reading from the electrode directly but from the voltage adapter, it has converted the
original voltage (-5V ~ +5V) to Arduino compatible voltage, i.e. 0 ~ 5V. See the discussion
on Forum.
Usage
Connecting Diagram
NOTE:
Before you insert the pH probe into one solution from another, or after you finish using the
sensor, you must wash the pH electrode with pure water everytime (distilled water is the
best)!
The closer power supply to +5.00V, the more accurate pH readings you could get.
You have to immerse the pH probe into stationary solution instead of the running one to
get relative stable pH readings.
How long should it be under the solution? It depends on the pH value, the closer to
neutral solution (pH = 7.00), the longer it will take. As we tested in water pH = 6.0, the
blue one costs 6 minutes, and in standard Acid/ Alkali (4.00/ 10.00) solutions, it only
needs 10 seconds.
The software calibration is easier than the next part - Hardware Calibration
through the Potentiometer. Because it writes the calibration values into
Arduino's EEPROM, so you can calibrate once for all if you won't replace your
Arduino. It uses mathematical method that to draw a line using two points, i.e.
using the Acid standard solution, pH = 4.00 and alkaline pH = 10.00 or 9.18 to
draw the linear relation between the voltage and the pH value.
NOTE:
During the calibration (from step 4 to step 7), power outage should be avoided, or you
will have to start over from step 4.
Software Calibration has nothing to do with the potentiometer on the adapter. Especially
after you finished the calibration, you should never adjust the potentiometer, or you
should start over. Moreover, considering the mechanical vibration might interfere the
potentiometer value, you could seal it by Hot Melt Adhesive.
If you want to try Hardware Calibration, you'd better reset the EEPROM setting by
uploading the Arduino IDE sample sketch "EEPROM Clear" as shown as the right hand
picture.
Steps
1. Wiring the pH probe, pH meter adapter (the little PCB board) and
Arduino UNO as the Diagram section above.
2. Upload the sample code "Software Calibration" below to UNO.
3. Open Serial Monitor, choose command format as “Both NL & CR”and
115200.
4. Send “Calibration” to enter Calibration Mode, and you will see “Enter
Calibration Mode” directly.
5. Acid Calibration
1. Wash your pH probe with pure water (distilled water is best) and dryer it
in case of diluting the standard pH solution. Insert it into standard acid
solution of pH = 4.0. Wait several seconds till the readings get relative
stable.
2. Enter “acid:4.00”(no bland space, lower case), and you will get “Acid
Calibration Successful” notice. Then go on with Alkali Calibration.
6. Alkali Calibration
1. Take out the pH probe out of the acid solution, CLEAN it again as you
did in last step. After this, insert it into the standard alkali solution with
pH = 10 or 9.18. Waiting for the stable readings
2. Enter “alkali:10.00”, and you will see “Alkali Calibration Successful”.
/***************************************************
This example uses software solution to calibration the ph meter,
not the potentiometer. So it is more easy to use and calibrate.
This is for SEN0161 and SEN0169.
Created 2016-8-11
By youyou from DFrobot <youyou.yu@dfrobot.com>
#include <EEPROM.h>
#define EEPROM_write(address, p) {int i = 0; byte *pp = (byte*)&(p
);for(; i < sizeof(p); i++) EEPROM.write(address+i, pp[i]);}
#define EEPROM_read(address, p) {int i = 0; byte *pp = (byte*)&(p
);for(; i < sizeof(p); i++) pp[i]=EEPROM.read(address+i);}
#define ReceivedBufferLength 20
char receivedBuffer[ReceivedBufferLength+1]; // store the serial
command
byte receivedBufferIndex = 0;
#define SCOUNT 30 // sum of sample point
int analogBuffer[SCOUNT]; //store the sample voltage
int analogBufferIndex = 0;
#define SensorPin A0
#define VREF 5000 //for arduino uno, the ADC reference is the pow
er(AVCC), that is 5000mV
void setup()
{
Serial.begin(115200);
readCharacteristicValues(); //read the slope and intercept of th
e ph probe
}
void loop()
{
if(serialDataAvailable() > 0)
{
byte modeIndex = uartParse();
phCalibration(modeIndex); // If the correct calibration c
ommand is received, the calibration function should be called.
EEPROM_read(SlopeValueAddress, slopeValue); // After cal
ibration, the new slope and intercept should be read ,to update cu
rrent value.
EEPROM_read(InterceptValueAddress, interceptValue);
}
static unsigned long sampleTimepoint = millis();
if(millis()-sampleTimepoint>40U)
{
sampleTimepoint = millis();
analogBuffer[analogBufferIndex] = analogRead(SensorPin)/1024.
0*VREF; //read the voltage and store into the buffer,every 40ms
analogBufferIndex++;
if(analogBufferIndex == SCOUNT)
analogBufferIndex = 0;
averageVoltage = getMedianNum(analogBuffer,SCOUNT); // read
the stable value by the median filtering algorithm
}
boolean serialDataAvailable(void)
{
char receivedChar;
static unsigned long receivedTimeOut = millis();
while (Serial.available()>0)
{
if (millis() - receivedTimeOut > 1000U)
{
receivedBufferIndex = 0;
memset(receivedBuffer,0,(ReceivedBufferLength+1));
}
receivedTimeOut = millis();
receivedChar = Serial.read();
if (receivedChar == '\n' || receivedBufferIndex==ReceivedBuffe
rLength){
receivedBufferIndex = 0;
strupr(receivedBuffer);
return true;
}
else{
receivedBuffer[receivedBufferIndex] = receivedChar;
receivedBufferIndex++;
}
}
return false;
}
byte uartParse()
{
byte modeIndex = 0;
if(strstr(receivedBuffer, "CALIBRATION") != NULL)
modeIndex = 1;
else if(strstr(receivedBuffer, "EXIT") != NULL)
modeIndex = 4;
else if(strstr(receivedBuffer, "ACID:") != NULL)
modeIndex = 2;
else if(strstr(receivedBuffer, "ALKALI:") != NULL)
modeIndex = 3;
return modeIndex;
}
case 1:
receivedBufferPtr=strstr(receivedBuffer, "CALIBRATION");
enterCalibrationFlag = 1;
acidCalibrationFinish = 0;
alkaliCalibrationFinish = 0;
Serial.println(F("Enter Calibration Mode"));
break;
case 2:
if(enterCalibrationFlag)
{
receivedBufferPtr=strstr(receivedBuffer, "ACID:");
receivedBufferPtr+=strlen("ACID:");
acidValueTemp = strtod(receivedBufferPtr,NULL);
if((acidValueTemp>3)&&(acidValueTemp<5)) //typica
l ph value of acid standand buffer solution should be 4.00
{
acidValue = acidValueTemp;
acidVoltage = averageVoltage/1000.0; // mV ->
V
acidCalibrationFinish = 1;
Serial.println(F("Acid Calibration Successful"));
}else {
acidCalibrationFinish = 0;
Serial.println(F("Acid Value Error"));
}
}
break;
case 3:
if(enterCalibrationFlag)
{
receivedBufferPtr=strstr(receivedBuffer, "ALKALI:");
receivedBufferPtr+=strlen("ALKALI:");
alkaliValueTemp = strtod(receivedBufferPtr,NULL);
if((alkaliValueTemp>8)&&(alkaliValueTemp<11)) //
typical ph value of alkali standand buffer solution should be 9.18
or 10.01
{
alkaliValue = alkaliValueTemp;
alkaliVoltage = averageVoltage/1000.0;
alkaliCalibrationFinish = 1;
Serial.println(F("Alkali Calibration Successful")
);
}else{
alkaliCalibrationFinish = 0;
Serial.println(F("Alkali Value Error"));
}
}
break;
case 4:
if(enterCalibrationFlag)
{
if(acidCalibrationFinish && alkaliCalibrationFinish)
{
newSlopeValue = (acidValue-alkaliValue)/(acidVoltage
- alkaliVoltage);
EEPROM_write(SlopeValueAddress, newSlopeValue);
newInterceptValue = acidValue - (slopeValue*acidVolt
age);
EEPROM_write(InterceptValueAddress, newInterceptValu
e);
Serial.print(F("Calibration Successful"));
}
else Serial.print(F("Calibration Failed"));
Serial.println(F(",Exit Calibration Mode"));
acidCalibrationFinish = 0;
alkaliCalibrationFinish = 0;
enterCalibrationFlag = 0;
}
break;
}
}
void readCharacteristicValues()
{
EEPROM_read(SlopeValueAddress, slopeValue);
EEPROM_read(InterceptValueAddress, interceptValue);
if(EEPROM.read(SlopeValueAddress)==0xFF && EEPROM.read(SlopeVa
lueAddress+1)==0xFF && EEPROM.read(SlopeValueAddress+2)==0xFF && E
EPROM.read(SlopeValueAddress+3)==0xFF)
{
slopeValue = 3.5; // If the EEPROM is new, the recommendat
ory slope is 3.5.
EEPROM_write(SlopeValueAddress, slopeValue);
}
if(EEPROM.read(InterceptValueAddress)==0xFF && EEPROM.read(Int
erceptValueAddress+1)==0xFF && EEPROM.read(InterceptValueAddress+2
)==0xFF && EEPROM.read(InterceptValueAddress+3)==0xFF)
{
interceptValue = 0; // If the EEPROM is new, the recommenda
tory intercept is 0.
EEPROM_write(InterceptValueAddress, interceptValue);
}
}
/*
# This sample code is used to test the pH meter V1.0.
# Editor : YouYou
# Ver : 1.0
# Product: analog pH meter
# SKU : SEN0161
*/
#define SensorPin A0 //pH meter Analog output to Arduin
o Analog Input 0
#define Offset 0.00 //deviation compensate
#define LED 13
#define samplingInterval 20
#define printInterval 800
#define ArrayLenth 40 //times of collection
int pHArray[ArrayLenth]; //Store the average value of the sensor
feedback
int pHArrayIndex=0;
void setup(void)
{
pinMode(LED,OUTPUT);
Serial.begin(9600);
Serial.println("pH meter experiment!"); //Test the serial mon
itor
}
void loop(void)
{
static unsigned long samplingTime = millis();
static unsigned long printTime = millis();
static float pHValue,voltage;
if(millis()-samplingTime > samplingInterval)
{
pHArray[pHArrayIndex++]=analogRead(SensorPin);
if(pHArrayIndex==ArrayLenth)pHArrayIndex=0;
voltage = avergearray(pHArray, ArrayLenth)*5.0/1024;
pHValue = 3.5*voltage+Offset;
samplingTime=millis();
}
if(millis() - printTime > printInterval) //Every 800 milliseco
nds, print a numerical, convert the state of the LED indicator
{
Serial.print("Voltage:");
Serial.print(voltage,2);
Serial.print(" pH value: ");
Serial.println(pHValue,2);
digitalWrite(LED,digitalRead(LED)^1);
printTime=millis();
}
}
double avergearray(int* arr, int number){
int i;
int max,min;
double avg;
long amount=0;
if(number<=0){
Serial.println("Error number for the array to avraging!/n");
return 0;
}
if(number<5){ //less than 5, calculated directly statistics
for(i=0;i<number;i++){
amount+=arr[i];
}
avg = amount/number;
return avg;
}else{
if(arr[0]<arr[1]){
min = arr[0];max=arr[1];
}
else{
min=arr[1];max=arr[0];
}
for(i=2;i<number;i++){
if(arr[i]<min){
amount+=min; //arr<min
min=arr[i];
}else {
if(arr[i]>max){
amount+=max; //arr>max
max=arr[i];
}else{
amount+=arr[i]; //min<=arr<=max
}
}//if
}//for
avg = (double)amount/(number-2);
}//if
return avg;
}
FAQ
Q1. My PH sensor readings are not correct, what did I miss?
A. 1. Check if the pH sensor circuit board is good? Read on the Forum. or on wiki for the
steps. During the transport, there might be crash causing the probe head cracked, please
check if the probe is good or not.
2. If you don't use Arduino as the controller, then please check your ADC module that
whether it converts the 5V analog input to 1024, if it is 4096(or other byte), please re-
determine the equation in the code.
Q2. Big fluctuations in ph meter readings. When I make measurements in a glass, I have correct,
stable reading. But when I put it inside the aquarium with the pumping system working, the
easurement varies even more than a degree, and it's not stable, if I swicth off the pump the given
value doesn´t oscilate anymore.
A. There should be NO working electrical device in the container. Any tiny leakage of
electricity will cause the probe working error. Especially, many people bought the EC meter
and put it into the same tank for the test, but then the pH meter cannot work well anymore.
Please seperate them into different containers, or turning off the EC meter when using the
pH meter.
Q3. May I know the Maximum range different if we do not calibrate the pH meter.
A. The maximum range differs from probe, you have to calibrate it before use if the pH probe
was kept long.
Q4. I would just like to ask if your pH sensor can be connect to any micro controller aside from
arduino. Would it be compatible with a raspberry pi? Thank You!
A. Yes, it can be used on any device as long as it could give 5V power supply and accept 5V
analog signal, but as the Rasp pi is only compatible with 3.3V sensor, so an expansion shield
is suggested to use with (please make sure which kind of Pi you use)
For any questions and more cool ideas to share, please visit DFRobot Forum
SIZE:G1/2",58*38*38(L*W*H )mm
L*W*H)mm
",58*38*38(L*W*H
When water flows through the rotor components, magnetic rotor rotating, and
speed along with the flow of a linear change. Hall element output
corresponding pulse signal feedback to the controller, the size of the flow of
water by controller judgment, adjust proportional valve control of electric
current.
Water flow sensor fundamentally solve the differential water-gas valve flap
type high pressure and start water valve easy misoperation appear dry and
shortcomings.
It has reflected sensitive, long service life, action quick, safe and reliable,
joins convenient traffic advantages such as the start low, deeply the general
user affection.
The main components of turbine rotor flow switch shell, magnetic rotor, brake
ring composition. Use water flow switch mode, its performance than the
mechanical differential pressure plate structure, and decrease the size. As
the water through the turbine switch shell, promote magnetic rotor, different
pole near the hall element hall element when conduction, and leave the hall
componets disconnect. Thus, can measure the rotor speed. According to the
measured data of the rotor speed and water flow, the output signal (voltage)
curve, can be sure water dispenser, coffee machine and household
appliances start water pressure, hydraulic pressure and startup
corresponding start the flow of water and rotor The start of the speed.
Electrical characteristic
1 Appearance Clean and beautiful, smooth without burr, without off color
Water pressure
1.75 MPa pressure has no slack phenomenon, and parts no crack,
2 resistance
relaxation, inflation, and deformation anomaly
performance
Operating voltage
3 DC3-18V
range
Maximum
4 15mA
operating current
The output pulse In 5 V rated voltage, the output of the high level requirements in 4.5
5
high level V above
The output pulse In 5 V rated voltage, the output of the low level requirements in 0.5 V
6
low level the following
The output pulse In the rated voltage, the output pulse occupies emptiescompared to
7
duty ratio 50%-10%
Flow pulse
8 [4.1Q]±10%
characteristics
Insulating
9 Dielectric resistance>100MΩ
property
2 、 In order to avoid particles, sundry into the flow switch, in the inlet must
install screen pack.
3、In the use of the water flow switch before please read the parameters that
if there are still questions please to our factory technical personnel
consultation.
4、In the process of installation and use must cooperate relays (power in 3 W
below), lest because of switch power small and dry reed pipe burn out.
5、The water flow switch installation use environment to avoid strong vibration
and shaking place, in order to avoid water flow switch produce false action.
GE
Measurement & Control
TSD-10
Turbidity Sensor
The TSD-10 module measures the turbidity (amount
of suspended particles) of the wash water in washing
machines and dishwashers. An optical sensor for
washing machines is a measuring product for a turbid
water density or an extraneous matter concentration
using the refraction of wavelength between photo
transistor and diode. By using an optical transistor
and optical diodes, an optical washing machine
sensor measures the amount of light coming from
the source of the light to the light receiver, in order to
calculate water turbidity.
Theory of Operation
The sensor operates on the principle that when light is
passed through a sample of water, the amount of light
transmitted through the sample is dependent on the
amount of soil in the water. As the soil level increases,
the amount of transmitted light decreases. The turbidity
sensor measures the amount of transmitted light to
determine the turbidity of the wash water. These turbidity
measurements are supplied to the washer controller,
which makes decisions on how long to wash in all the
cycles. These decisions are made based on a comparison
between clean water measurements (taken at the
beginning of the wash cycle) and the wash water turbidity
measurement taken at the end of each wash cycle. By
measuring the turbidity of the wash water, the washing
machine can conserve energy on lightly soiled loads
by only washing as long as necessary. This will result in
energy savings for the consumer.
Specifications
Part Number
TSD-10
Rated Voltage
DC 5V (between No #1 & Ground)
Voltage Differential
3.0V ± 10%
Test Method
After testing voltage in water (0 NTU),
voltage test in water (4000 NTU)
(Turbidity level Calibration -> Master NTU standard liquid )
(Voltage between No #2 pin & Ground)
Rated Current
Max. 30 mA
Insulation Resistance
Min 100 MΩ by 500V DC Application Section
Detecting the turbidity degree of water
www.ge-mcs.com
920-616A
© 2013 General Electric Company. All Rights Reserved. Specifications are subject to change without notice. GE is a registered trademark of General Electric Company. Other company or product
names mentioned in this document may be trademarks or registered trademarks of their respective companies, which are not affiliated with GE.
Arduino Nano (V2.3)
User Manual
http://creativecommons.org/licenses/by-sa/2.5/
More information:
!
D1/TX (1) (30) VIN
D0/RX (2) (29) GND
RESET (3) (28) RESET
GND (4) (27) +5V
D2 (5) (26) A0
D3 (6) (25) A1
D4 (7) (24) A2
D5 (8) (23) A3
D6 (9) (22) A4
D7 (10) (21) A5
D8 (11) (20) A6
D9 (12) (19) A7
D10 (13) (18) AREF
D11 (14) (17) 3V3
D12 (15) (16) D13
!
!
!
!
!
!
Arduino Nano Mechanical Drawing
!
Arduino Nano Bill of Material
Item!Number! Qty.! Ref.!Dest.! Description! Mfg.!P/N! MFG! Vendor!P/N! Vendor!
Capacitor,!0.1uF!50V!10%!
1! 5! C1,C3,C4,C7,C9! Ceramic!X7R!0805! C0805C104K5RACTU! Kemet! 80"C0805C104K5R! Mouser!
Capacitor,!4.7uF!10V!10%!
2! 3! C2,C8,C10! Tantalum!Case!A! T491A475K010AT! Kemet! 80"T491A475K010! Mouser!
Capacitor,!18pF!50V!5%!
3! 2! C5,C6! Ceramic!NOP/COG!0805! C0805C180J5GACTU! Kemet! 80"C0805C180J5G! Mouser!
4! 1! D1! Diode,!Schottky!0.5A!20V! MBR0520LT1G! ONSemi! 863"MBR0520LT1G! Mouser!
5! 1! J1,J2! Headers,!36PS!1!Row! 68000"136HLF! FCI! 649"68000"136HLF! Mouser!
Connector,!Mini"B!Recept!
6! 1! J4! Rt.!Angle! 67503"1020! Molex! 538"67503"1020! Mouser!
7! 1! J5! Headers,!72PS!2!Rows! 67996"272HLF! FCI! 649"67996"272HLF! Mouser!
LED,!Super!Bright!RED!
100mcd!640nm!120degree!
8! 1! LD1! 0805! APT2012SRCPRV! Kingbright! 604"APT2012SRCPRV! Mouser!
LED,!Super!Bright!GREEN!
50mcd!570nm!110degree!
9! 1! LD2! 0805! APHCM2012CGCK"F01! Kingbright! 604"APHCM2012CGCK! Mouser!
LED,!Super!Bright!ORANGE!
160mcd!601nm!110degree!
10! 1! LD3! 0805! APHCM2012SECK"F01! Kingbright! 04"APHCM2012SECK! Mouser!
LED,!Super!Bright!BLUE!
80mcd!470nm!110degree!
11! 1! LD4! 0805! LTST"C170TBKT! Lite"On!Inc! 160"1579"1"ND! Digikey!
Resistor!Pack,!1K!+/"5%!
12! 1! R1! 62.5mW!4RES!SMD! YC164"JR"071KL! Yageo! YC164J"1.0KCT"ND! Digikey!
Resistor!Pack,!680!+/"5%!
13! 1! R2! 62.5mW!4RES!SMD! YC164"JR"07680RL! Yageo! YC164J"680CT"ND! Digikey!
Switch,!Momentary!Tact!
14! 1! SW1! SPST!150gf!3.0x2.5mm! B3U"1000P! Omron! SW1020CT"ND! Digikey!
IC,!Microcontroller!RISC!
16kB!Flash,!0.5kB!EEPROM,!
15! 1! U1! 23!I/O!Pins! ATmega168"20AU! Atmel! 556"ATMEGA168"20AU! Mouser!
IC,!USB!to!SERIAL!UART!28!
16! 1! U2! Pins!SSOP! FT232RL! FTDI! 895"FT232RL! Mouser!
IC,!Voltage!regulator!5V,!
17! 1! U3! 500mA!SOT"223! UA78M05CDCYRG3! TI! 595"UA78M05CDCYRG3! Mouser!
Cystal,!16MHz!+/"20ppm!
18! 1! Y1! HC"49/US!Low!Profile! ABL"16.000MHZ"B2! Abracon! 815"ABL"16"B2! Mouser!
Click here for production status of specific part numbers.
DQ 4 5 GND
SO (150 mils)
(DS18B20Z)
DQ 1 + 8 VDD
GND DQ VDD N.C. 2 7 N.C.
DS18B20
N.C. 3 6 N.C.
1 2 3 GND 4 5 N.C.
1 µSOP
BOTTOM VIEW (DS18B20U)
Ordering Information appears at end of data sheet.
TO-92
(DS18B20)
1-Wire is a registered trademark of Maxim Integrated Products, Inc.
DC Electrical Characteristics
(-55°C to +125°C; VDD = 3.0V to 5.5V)
AC Electrical Characteristics
(-55°C to +125°C; VDD = 3.0V to 5.5V)
tSLOT
tREC START OF NEXT CYCLE
tLOW0
tSLOT
START OF NEXT CYCLE
tREC
tRDV
tRSTL tRSTH
PRESENCE DETECT
1-WIRE PRESENCE DETECT tPDIH
tPDLOW
Pin Description
PIN
NAME FUNCTION
SO µSOP TO-92
1, 2, 6, 2, 3, 5,
— N.C. No Connection
7, 8 6, 7
3 8 3 VDD Optional VDD. VDD must be grounded for operation in parasite power mode.
Data Input/Output. Open-drain 1-Wire interface pin. Also provides power to the
4 1 2 DQ
device when used in parasite power mode (see the Powering the DS18B20 section.)
5 4 1 GND Ground
Overview DQ pin when the bus is high. The high bus signal also
Figure 3 shows a block diagram of the DS18B20, and charges an internal capacitor (CPP), which then supplies
pin descriptions are given in the Pin Description table. power to the device when the bus is low. This method of
The 64-bit ROM stores the device’s unique serial code. deriving power from the 1-Wire bus is referred to as “para-
The scratchpad memory contains the 2-byte temperature site power.” As an alternative, the DS18B20 may also be
register that stores the digital output from the temperature powered by an external supply on VDD.
sensor. In addition, the scratchpad provides access to the
1-byte upper and lower alarm trigger registers (TH and
Operation—Measuring Temperature
TL) and the 1-byte configuration register. The configura- The core functionality of the DS18B20 is its direct-to-
tion register allows the user to set the resolution of the digital temperature sensor. The resolution of the tempera-
temperature-to-digital conversion to 9, 10, 11, or 12 bits. ture sensor is user-configurable to 9, 10, 11, or 12 bits,
The TH, TL, and configuration registers are nonvolatile corresponding to increments of 0.5°C, 0.25°C, 0.125°C,
(EEPROM), so they will retain data when the device is and 0.0625°C, respectively. The default resolution at
powered down. power-up is 12-bit. The DS18B20 powers up in a low-
power idle state. To initiate a temperature measurement
The DS18B20 uses Maxim’s exclusive 1-Wire bus proto-
and A-to-D conversion, the master must issue a Convert
col that implements bus communication using one control
T [44h] command. Following the conversion, the resulting
signal. The control line requires a weak pullup resistor
thermal data is stored in the 2-byte temperature register
since all devices are linked to the bus via a 3-state or
in the scratchpad memory and the DS18B20 returns to its
open-drain port (the DQ pin in the case of the DS18B20).
idle state. If the DS18B20 is powered by an external sup-
In this bus system, the microprocessor (the master
ply, the master can issue “read time slots” (see the 1-Wire
device) identifies and addresses devices on the bus
Bus System section) after the Convert T command and
using each device’s unique 64-bit code. Because each
the DS18B20 will respond by transmitting 0 while the tem-
device has a unique code, the number of devices that
perature conversion is in progress and 1 when the con-
can be addressed on one bus is virtually unlimited. The
version is done. If the DS18B20 is powered with parasite
1-Wire bus protocol, including detailed explanations of the
power, this notification technique cannot be used since
commands and “time slots,” is covered in the 1-Wire Bus
the bus must be pulled high by a strong pullup during the
System section.
entire temperature conversion. The bus requirements for
Another feature of the DS18B20 is the ability to oper- parasite power are explained in detail in the Powering the
ate without an external power supply. Power is instead DS18B20 section.
supplied through the 1-Wire pullup resistor through the
VPU
MEMORY
4.7kΩ PARASITE POWER CIRCUIT CONTROL LOGIC DS18B20
DQ
TEMPERATURE
SENSOR
8-BIT CRC
GENERATOR
S = SIGN
or equal to TL or higher than or equal to TH, an alarm con- by CPP. To assure that the DS18B20 has sufficient supply
dition exists and an alarm flag is set inside the DS18B20. current, it is necessary to provide a strong pullup on the
This flag is updated after every temperature measure- 1-Wire bus whenever temperature conversions are tak-
ment; therefore, if the alarm condition goes away, the flag ing place or data is being copied from the scratchpad to
will be turned off after the next temperature conversion. EEPROM. This can be accomplished by using a MOSFET
The master device can check the alarm flag status of to pull the bus directly to the rail as shown in Figure 6. The
all DS18B20s on the bus by issuing an Alarm Search 1-Wire bus must be switched to the strong pullup within
[ECh] command. Any DS18B20s with a set alarm flag will 10µs (max) after a Convert T [44h] or Copy Scratchpad
respond to the command, so the master can determine [48h] command is issued, and the bus must be held high
exactly which DS18B20s have experienced an alarm by the pullup for the duration of the conversion (tCONV)
condition. If an alarm condition exists and the TH or TL or data transfer (tWR = 10ms). No other activity can take
settings have changed, another temperature conversion place on the 1-Wire bus while the pullup is enabled.
should be done to validate the alarm condition. The DS18B20 can also be powered by the conventional
method of connecting an external power supply to the
Powering the DS18B20 VDD pin, as shown in Figure 7. The advantage of this
The DS18B20 can be powered by an external supply on method is that the MOSFET pullup is not required, and
the VDD pin, or it can operate in “parasite power” mode, the 1-Wire bus is free to carry other traffic during the tem-
which allows the DS18B20 to function without a local perature conversion time.
external supply. Parasite power is very useful for applica- The use of parasite power is not recommended for tem-
tions that require remote temperature sensing or that are peratures above +100°C since the DS18B20 may not be
very space constrained. Figure 3 shows the DS18B20’s able to sustain communications due to the higher leak-
parasite-power control circuitry, which “steals” power from age currents that can exist at these temperatures. For
the 1-Wire bus via the DQ pin when the bus is high. The applications in which such temperatures are likely, it is
stolen charge powers the DS18B20 while the bus is high, strongly recommended that the DS18B20 be powered by
and some of the charge is stored on the parasite power an external power supply.
capacitor (CPP) to provide power when the bus is low.
In some situations the bus master may not know whether
When the DS18B20 is used in parasite power mode, the
the DS18B20s on the bus are parasite powered or pow-
VDD pin must be connected to ground.
ered by external supplies. The master needs this informa-
In parasite power mode, the 1-Wire bus and CPP can pro- tion to determine if the strong bus pullup should be used
vide sufficient current to the DS18B20 for most operations during temperature conversions. To get this information,
as long as the specified timing and voltage requirements the master can issue a Skip ROM [CCh] command fol-
are met (see the DC Electrical Characteristics and AC lowed by a Read Power Supply [B4h] command followed
Electrical Characteristics). However, when the DS18B20 by a “read time slot”. During the read time slot, parasite
is performing temperature conversions or copying data powered DS18B20s will pull the bus low, and externally
from the scratchpad memory to EEPROM, the operating powered DS18B20s will let the bus remain high. If the
current can be as high as 1.5mA. This current can cause bus is pulled low, the master knows that it must supply
an unacceptable voltage drop across the weak 1-Wire the strong pullup on the 1-Wire bus during temperature
pullup resistor and is more current than can be supplied conversions.
VPU
DS18B20 DS18B20
VPU VPU VDD (EXTERNAL
GND DQ VDD GND DQ VDD SUPPLY)
µP µP
4.7kΩ 4.7kΩ
Figure 6. Supplying the Parasite-Powered DS18B20 During Figure 7. Powering the DS18B20 with an External Supply
Temperature Conversions
64-BIT Lasered ROM code ter data, which is explained in detail in the Configuration
Each DS18B20 contains a unique 64–bit code (see Figure Register section. Bytes 5, 6, and 7 are reserved for inter-
8) stored in ROM. The least significant 8 bits of the ROM nal use by the device and cannot be overwritten.
code contain the DS18B20’s 1-Wire family code: 28h. The Byte 8 of the scratchpad is read-only and contains the
next 48 bits contain a unique serial number. The most CRC code for bytes 0 through 7 of the scratchpad.
significant 8 bits contain a cyclic redundancy check (CRC) The DS18B20 generates this CRC using the method
byte that is calculated from the first 56 bits of the ROM described in the CRC Generation section.
code. A detailed explanation of the CRC bits is provided Data is written to bytes 2, 3, and 4 of the scratchpad using
in the CRC Generation section. The 64-bit ROM code and the Write Scratchpad [4Eh] command; the data must be
associated ROM function control logic allow the DS18B20 transmitted to the DS18B20 starting with the least signifi-
to operate as a 1-Wire device using the protocol detailed cant bit of byte 2. To verify data integrity, the scratchpad
in the 1-Wire Bus System section. can be read (using the Read Scratchpad [BEh] command)
after the data is written. When reading the scratchpad,
Memory data is transferred over the 1-Wire bus starting with the
The DS18B20’s memory is organized as shown in Figure least significant bit of byte 0. To transfer the TH, TL and
9. The memory consists of an SRAM scratchpad with configuration data from the scratchpad to EEPROM, the
nonvolatile EEPROM storage for the high and low alarm master must issue the Copy Scratchpad [48h] command.
trigger registers (TH and TL) and configuration register.
Data in the EEPROM registers is retained when the
Note that if the DS18B20 alarm function is not used,
device is powered down; at power-up the EEPROM data
the TH and TL registers can serve as general-purpose
is reloaded into the corresponding scratchpad locations.
memory. All memory commands are described in detail in
Data can also be reloaded from EEPROM to the scratch-
the DS18B20 Function Commands section.
pad at any time using the Recall E2 [B8h] command. The
Byte 0 and byte 1 of the scratchpad contain the LSB and master can issue read time slots following the Recall E2
the MSB of the temperature register, respectively. These command and the DS18B20 will indicate the status of the
bytes are read-only. Bytes 2 and 3 provide access to TH recall by transmitting 0 while the recall is in progress and
and TL registers. Byte 4 contains the configuration regis- 1 when the recall is done.
SCRATCHPAD
(POWER-UP STATE)
Configuration Register received error free. The comparison of CRC values and
Byte 4 of the scratchpad memory contains the configura- the decision to continue with an operation are determined
tion register, which is organized as illustrated in Figure 10. entirely by the bus master. There is no circuitry inside the
The user can set the conversion resolution of the DS18B20 DS18B20 that prevents a command sequence from pro-
using the R0 and R1 bits in this register as shown in Table ceeding if the DS18B20 CRC (ROM or scratchpad) does
2. The power-up default of these bits is R0 = 1 and R1 = not match the value generated by the bus master.
1 (12-bit resolution). Note that there is a direct tradeoff The equivalent polynomial function of the CRC (ROM or
between resolution and conversion time. Bit 7 and bits 0 to scratchpad) is:
4 in the configuration register are reserved for internal use CRC = X8 + X5 + X4 + 1
by the device and cannot be overwritten.
The bus master can re-calculate the CRC and compare it
CRC Generation to the CRC values from the DS18B20 using the polyno-
mial generator shown in Figure 11. This circuit consists
CRC bytes are provided as part of the DS18B20’s 64-bit
of a shift register and XOR gates, and the shift register
ROM code and in the 9th byte of the scratchpad memory.
bits are initialized to 0. Starting with the least significant
The ROM code CRC is calculated from the first 56 bits
bit of the ROM code or the least significant bit of byte 0
of the ROM code and is contained in the most significant
in the scratchpad, one bit at a time should shifted into the
byte of the ROM. The scratchpad CRC is calculated from
shift register. After shifting in the 56th bit from the ROM or
the data stored in the scratchpad, and therefore it chang-
the most significant bit of byte 7 from the scratchpad, the
es when the data in the scratchpad changes. The CRCs
polynomial generator will contain the recalculated CRC.
provide the bus master with a method of data validation
Next, the 8-bit ROM code or scratchpad CRC from the
when data is read from the DS18B20. To verify that data
DS18B20 must be shifted into the circuit. At this point, if
has been read correctly, the bus master must re-calculate
the re-calculated CRC was correct, the shift register will
the CRC from the received data and then compare this
contain all 0s. Additional information about the Maxim
value to either the ROM code CRC (for ROM reads) or
1-Wire cyclic redundancy check is available in Application
to the scratchpad CRC (for scratchpad reads). If the cal-
Note 27: Understanding and Using Cyclic Redundancy
culated CRC matches the read CRC, the data has been
Checks with Maxim iButton Products.
INPUT
MSB LSB
If there is only one slave on the bus, the simpler Read master must return to Step 1 (Initialization) in the transac-
ROM [33h] command can be used in place of the Search tion sequence. See the Operation—Alarm Signaling sec-
ROM process. For a detailed explanation of the Search tion for an explanation of alarm flag operation.
ROM procedure, refer to Application Note 937: Book of
iButton® Standards. After every Search ROM cycle, the DS18B20 Function Commands
bus master must return to Step 1 (Initialization) in the After the bus master has used a ROM command to
transaction sequence. address the DS18B20 with which it wishes to communi-
cate, the master can issue one of the DS18B20 function
Read Rom [33h]
commands. These commands allow the master to write
This command can only be used when there is one slave to and read from the DS18B20’s scratchpad memory,
on the bus. It allows the bus master to read the slave’s initiate temperature conversions and determine the power
64-bit ROM code without using the Search ROM proce- supply mode. The DS18B20 function commands, which
dure. If this command is used when there is more than are described below, are summarized in Table 3 and illus-
one slave present on the bus, a data collision will occur trated by the flowchart in Figure 14.
when all the slaves attempt to respond at the same time.
Convert T [44h]
Match Rom [55H]
This command initiates a single temperature conversion.
The match ROM command followed by a 64-bit ROM Following the conversion, the resulting thermal data is
code sequence allows the bus master to address a stored in the 2-byte temperature register in the scratch-
specific slave device on a multidrop or single-drop bus. pad memory and the DS18B20 returns to its low-power
Only the slave that exactly matches the 64-bit ROM code idle state. If the device is being used in parasite power
sequence will respond to the function command issued mode, within 10µs (max) after this command is issued
by the master; all other slaves on the bus will wait for a the master must enable a strong pullup on the 1-Wire bus
reset pulse. for the duration of the conversion (tCONV) as described
Skip Rom [CCh] in the Powering the DS18B20 section. If the DS18B20 is
powered by an external supply, the master can issue read
The master can use this command to address all devices
time slots after the Convert T command and the DS18B20
on the bus simultaneously without sending out any ROM
will respond by transmitting a 0 while the temperature
code information. For example, the master can make all
conversion is in progress and a 1 when the conversion is
DS18B20s on the bus perform simultaneous temperature
done. In parasite power mode this notification technique
conversions by issuing a Skip ROM command followed by
cannot be used since the bus is pulled high by the strong
a Convert T [44h] command.
pullup during the conversion.
Note that the Read Scratchpad [BEh] command can
follow the Skip ROM command only if there is a single Write Scratchpad [4Eh]
slave device on the bus. In this case, time is saved by This command allows the master to write 3 bytes of data
allowing the master to read from the slave without send- to the DS18B20’s scratchpad. The first data byte is written
ing the device’s 64-bit ROM code. A Skip ROM command into the TH register (byte 2 of the scratchpad), the second
followed by a Read Scratchpad command will cause byte is written into the TL register (byte 3), and the third
a data collision on the bus if there is more than one byte is written into the configuration register (byte 4). Data
slave since multiple devices will attempt to transmit data must be transmitted least significant bit first. All three
simultaneously. bytes MUST be written before the master issues a reset,
or the data may be corrupted.
Alarm Search [ECh]
The operation of this command is identical to the operation Read Scratchpad [BEh]
of the Search ROM command except that only slaves with This command allows the master to read the contents of
a set alarm flag will respond. This command allows the the scratchpad. The data transfer starts with the least sig-
master device to determine if any DS18B20s experienced nificant bit of byte 0 and continues through the scratchpad
an alarm condition during the most recent temperature until the 9th byte (byte 8 – CRC) is read. The master may
conversion. After every Alarm Search cycle (i.e., Alarm issue a reset to terminate reading at any time if only part
Search command followed by data exchange), the bus of the scratchpad data is needed.
iButton is a registered trademark of Maxim Integrated Products, Inc.
Copy Scratchpad [48h] following the Recall E2 command and the DS18B20 will
This command copies the contents of the scratchpad indicate the status of the recall by transmitting 0 while the
TH, TL and configuration registers (bytes 2, 3 and 4) to recall is in progress and 1 when the recall is done. The
EEPROM. If the device is being used in parasite power recall operation happens automatically at power-up, so
mode, within 10µs (max) after this command is issued the valid data is available in the scratchpad as soon as power
master must enable a strong pullup on the 1-Wire bus for is applied to the device.
at least 10ms as described in the Powering the DS18B20 Read Power Supply [B4h]
section.
The master device issues this command followed by a
Recall E2 [B8h] read time slot to determine if any DS18B20s on the bus
This command recalls the alarm trigger values (TH and are using parasite power. During the read time slot, para-
TL) and configuration data from EEPROM and places the site powered DS18B20s will pull the bus low, and exter-
data in bytes 2, 3, and 4, respectively, in the scratchpad nally powered DS18B20s will let the bus remain high. See
memory. The master device can issue read time slots the Powering the DS18B20 section for usage information
for this command.
Y Y Y Y Y
N N N DEVICE(S) N
BIT 0 BIT 0
WITH ALARM
MATCH ? MATCH ?
FLAG SET ?
DS18B20 TX Y Y Y
FAMILY CODE 1
BYTE
DS18B20 Tx BIT 1
MASTER Tx
DS18B20 Tx BIT 1 DS18B20 Tx BIT 1
SERIAL NUMBER
MASTER Tx BIT 1
6 BYTES
DS18B20 Tx
BIT 1 N N BIT 1
CRC BYTE
MATCH? MATCH?
Y Y
DS18B20 Tx BIT 63
MASTER Tx
BIT 63 DS18B20 Tx BIT 63
MASTER Tx BIT 63
BIT 63 N N BIT 63
MATCH? MATCH?
Y Y
MASTER Tx FUNCTION
COMMAND (FIGURE 14)
Y Y
N PARASITE Y N PARASITE Y
POWER ? POWER ?
DS18B20 BEGINS
CONVERSION
MASTER ENABLES STRONG MASTER ENABLES STRONG
PULL-UP ON DQ PULL-UP ON DQ
DEVICE
N DS18B20 CONVERTS COPY IN N DATA COPIED FROM
CONVERTING
TEMPERATURE ?
TEMPERATURE PROGRESS ? SCRATCHPAD TO EEPROM
Y Y Y Y
MASTER BEGINS
N PARASITE Y DATA RECALL FROM MASTER Rx DATA
POWER ? E2 PROM BYTE FROM MASTER Tx TH BYTE TO
SCRATCHPAD SCRATCHPAD
MASTER MASTER
MASTER Tx TL BYTE TO
Rx “1s” Rx “0s” DEVICE BUSY N MASTER Tx Y
SCRATCHPAD
RECALLING RESET ?
DATA ?
MASTER Rx
SCRATCHPAD CRC
BYTE
RETURN TO INITIALIZATION
SEQUENCE (FIGURE 13)
FOR NEXT TRANSACTION
1-Wire BUS
GND
START START
OF SLOT OF SLOT
MASTER WRITE “0” SLOT
1µs < TREC < ∞ MASTER WRITE “1” SLOT
60µs < Tx “0” < 120µs
1µs
VPU
1-Wire BUS
GND
DS18B20 SAMPLES DS18B20 SAMPLES
MIN TYP MAX MIN TYP MAX
1-Wire BUS
GND
MASTER SAMPLES > 1µs
MASTER SAMPLES
> 1µs
15µs 45µs 15µs
Read Time Slots read time slot, the DS18B20 will begin transmitting a 1
The DS18B20 can only transmit data to the master when or 0 on bus. The DS18B20 transmits a 1 by leaving the
the master issues read time slots. Therefore, the master bus high and transmits a 0 by pulling the bus low. When
must generate read time slots immediately after issuing transmitting a 0, the DS18B20 will release the bus by the
a Read Scratchpad [BEh] or Read Power Supply [B4h] end of the time slot, and the bus will be pulled back to
command, so that the DS18B20 can provide the request- its high idle state by the pullup resister. Output data from
ed data. In addition, the master can generate read time the DS18B20 is valid for 15µs after the falling edge that
slots after issuing Convert T [44h] or Recall E2 [B8h] com- initiated the read time slot. Therefore, the master must
mands to find out the status of the operation as explained release the bus and then sample the bus state within
in the DS18B20 Function Commands section. 15µs from the start of the slot.
All read time slots must be a minimum of 60µs in duration Figure 17 illustrates that the sum of TINIT, TRC, and
with a minimum of a 1µs recovery time between slots. A TSAMPLE must be less than 15µs for a read time slot.
read time slot is initiated by the master device pulling the Figure 18 shows that system timing margin is maximized
1-Wire bus low for a minimum of 1µs and then releasing by keeping TINIT and TRC as short as possible and by
the bus (see Figure 16). After the master initiates the locating the master sample time during read time slots
towards the end of the 15µs period.
VPU
VIH OF MASTER
1-Wire BUS
GND
TINT > 1µs TRC MASTER SAMPLES
15µs
VPU
VIH OF MASTER
1-Wire BUS
GND
TINT = TRC =
SMALL SMALL MASTER SAMPLES
15µs
Ordering Information
PART TEMP RANGE PIN-PACKAGE TOP MARK
DS18B20 -55°C to +125°C 3 TO-92 18B20
DS18B20+ -55°C to +125°C 3 TO-92 18B20
DS18B20/T&R -55°C to +125°C 3 TO-92 (2000 Piece) 18B20
DS18B20+T&R -55°C to +125°C 3 TO-92 (2000 Piece) 18B20
DS18B20-SL/T&R -55°C to +125°C 3 TO-92 (2000 Piece)* 18B20
DS18B20-SL+T&R -55°C to +125°C 3 TO-92 (2000 Piece)* 18B20
DS18B20U -55°C to +125°C 8 FSOP 18B20
DS18B20U+ -55°C to +125°C 8 FSOP 18B20
DS18B20U/T&R -55°C to +125°C 8 FSOP (3000 Piece) 18B20
DS18B20U+T&R -55°C to +125°C 8 FSOP (3000 Piece) 18B20
DS18B20Z -55°C to +125°C 8 SO DS18B20
DS18B20Z+ -55°C to +125°C 8 SO DS18B20
DS18B20Z/T&R -55°C to +125°C 8 SO (2500 Piece) DS18B20
DS18B20Z+T&R -55°C to +125°C 8 SO (2500 Piece) DS18B20
+Denotes a lead-free package. A “+” will appear on the top mark of lead-free packages.
T&R = Tape and reel.
*TO-92 packages in tape and reel can be ordered with straight or formed leads. Choose “SL” for straight leads. Bulk TO-92 orders
are straight leads only.
Revision History
REVISION PAGES
DESCRIPTION
DATE CHANGED
In the Absolute Maximum Ratings section, removed the reflow oven temperature value of +220°C.
030107 19
Reference to JEDEC specification for reflow remains.
In the Operation—Alarm Signaling section, added “or equal to” in the description for a TH alarm
5
condition
101207
In the Memory section, removed incorrect text describing memory. 7
In the Configuration Register section, removed incorrect text describing configuration register. 8
In the Ordering Information table, added TO-92 straight-lead packages and included a note that the
042208 2
TO-92 package in tape and reel can be ordered with either formed or straight leads.
1/15 Updated Benefits and Features section 1
09/18 Updated DC Electrical Characteristics table 2
For pricing, delivery, and ordering information, please visit Maxim Integrated’s online storefront at https://www.maximintegrated.com/en/storefront/storefront.html.
Maxim Integrated cannot assume responsibility for use of any circuitry other than circuitry entirely embodied in a Maxim Integrated product. No circuit patent licenses
are implied. Maxim Integrated reserves the right to change the circuitry and specifications without notice at any time. The parametric values (min and max limits)
shown in the Electrical Characteristics table are guaranteed. Other parametric values quoted in this data sheet are provided for guidance.
Maxim Integrated and the Maxim Integrated logo are trademarks of Maxim Integrated Products, Inc. © 2018 Maxim Integrated Products, Inc. │ 20
Handson Technology
User Manual V1.2
The ESP8266 is the name of a micro controller designed by Espressif Systems. The
ESP8266 itself is a self-contained WiFi networking solution offering as a bridge from
existing micro controller to WiFi and is also capable of running self-contained applications.
This module comes with a built in USB connector and a rich assortment of pin-outs. With a
micro USB cable, you can connect NodeMCU devkit to your laptop and flash it without any
trouble, just like Arduino. It is also immediately breadboard friendly.
1 www.handsontec.com
Table of Contents
1. Specification:....................................................................................................................................................... 3
2. Pin Definition: ..................................................................................................................................................... 3
3. Using Arduino IDE ............................................................................................................................................... 3
3.1 Install the Arduino IDE 1.6.4 or greater ........................................................................................................ 4
3.2 Install the ESP8266 Board Package............................................................................................................... 4
3.3 Setup ESP8266 Support ............................................................................................................................... 5
3.4 Blink Test ..................................................................................................................................................... 7
3.5 Connecting via WiFi ..................................................................................................................................... 9
4. Flashing NodeMCU Firmware on the ESP8266 using Windows........................................................................... 12
4.1 Parts Required:................................................................................................................................................ 12
4.2 Pin Assignment:............................................................................................................................................... 12
4.3 Wiring: ............................................................................................................................................................ 13
4.4 Downloading NodeMCU Flasher for Windows ................................................................................................. 13
4.5 Flashing your ESP8266 using Windows ............................................................................................................ 13
5. Getting Started with the ESPlorer IDE ................................................................................................................ 15
5.1 Installing ESPlorer............................................................................................................................................ 15
5.2 Schematics ...................................................................................................................................................... 18
5.3 Writing Your Lua Script .................................................................................................................................... 18
6. NodeMCU GPIO for Lua ......................................................................................................................................... 22
7. Web Resources: .................................................................................................................................................... 22
2 www.handsontec.com
1. Specification:
• Voltage:3.3V.
• Wi-Fi Direct (P2P), soft-AP.
• Current consumption: 10uA~170mA.
• Flash memory attachable: 16MB max (512K normal).
• Integrated TCP/IP protocol stack.
• Processor: Tensilica L106 32-bit.
• Processor speed: 80~160MHz.
• RAM: 32K + 80K.
• GPIOs: 17 (multiplexed with other functions).
• Analog to Digital: 1 input with 1024 step resolution.
• +19.5dBm output power in 802.11b mode
• 802.11 support: b/g/n.
• Maximum concurrent TCP connections: 5.
2. Pin Definition:
3 www.handsontec.com
The most basic way to use the ESP8266 module is to use serial commands, as the chip is basically a WiFi/Serial
transceiver. However, this is not convenient. What we recommend is using the very cool Arduino ESP8266 project,
which is a modified version of the Arduino IDE that you need to install on your computer. This makes it very
convenient to use the ESP8266 chip as we will be using the well-known Arduino IDE. Following the below step to
install ESP8266 library to work in Arduino IDE environment.
You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving you
problems.
4 www.handsontec.com
Click ‘Tools’ -> ‘Board:’ -> ‘Board Manager…’ to access this panel.
Scroll down to ‘ esp8266 by ESP8266 Community ’ and click “Install” button to install the ESP8266 library package.
Once installation completed, close and re-open Arduino IDE for ESP8266 library to take effect.
Select 80 MHz as the CPU frequency (you can try 160 MHz overclock later)
5 www.handsontec.com
Select ‘115200’ baud upload speed is a good place to start - later on you can try higher speeds but 115200 is a good
safe place to start.
Go to your Windows ‘Device Manager’ to find out which Com Port ‘USB-Serial CH340’ is assigned to. Select the
matching COM/serial port for your CH340 USB-Serial interface.
6 www.handsontec.com
Find out which Com Port is assign for CH340 Select the correct Com Port as indicated on ‘Device Manager”
Note: if this is your first time using CH340 “ USB-to-Serial ” interface, please install the driver first before proceed
the above Com Port setting. The CH340 driver can be download from the below site:
https://github.com/nodemcu/nodemcu-devkit/tree/master/Drivers
Enter this into the sketch window (and save since you'll have to). Connect a LED as shown in Figure3-1.
void setup() {
pinMode(5, OUTPUT); // GPIO05, Digital Pin D1
}
void loop() {
digitalWrite(5, HIGH);
delay(900);
digitalWrite(5, LOW);
delay(500);
}
Now you'll need to put the board into bootload mode. You'll have to do this before each upload. There is no timeout
for bootload mode, so you don't have to rush!
7 www.handsontec.com
• When you release the ‘RST’ button, the blue indication will blink once, this means its ready to bootload.
Once the ESP board is in bootload mode, upload the sketch via the IDE, Figure 3-2.
8 www.handsontec.com
Figure 3.2: Uploading the sketch to ESP8266 NodeMCU module.
The sketch will start immediately - you'll see the LED blinking. Hooray!
OK once you've got the LED blinking, let’s go straight to the fun part, connecting to a webserver. Create a new sketch
with this code:
to your WiFi access point and password, then upload the same way: get into bootload mode, then upload code via
IDE.
/*
* Simple HTTP get webclient test
*/
#include <ESP8266WiFi.h>
const char* ssid = "handson"; // key in your own SSID
const char* password = "abc1234"; // key in your own WiFi access point
password
9 www.handsontec.com
const char* host = "www.handsontec.com";
void setup() {
Serial.begin(115200);
delay(100);
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
}
int value = 0;
void loop() {
delay(5000);
++value;
Serial.print("connecting to ");
Serial.println(host);
// Read all the lines of the reply from server and print them to Serial
while(client.available()){
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
}
10 www.handsontec.com
Open up the IDE serial console at 115200 baud to see the connection and webpage printout!
That's it, pretty easy right ! This section is just to get you started and test out your module.
11 www.handsontec.com
4. Flashing NodeMCU Firmware on the ESP8266 using Windows
NodeMCU is a firmware that allows you to program the ESP8266 modules with LUA script. And you’ll find it very
similar to the way you program your Arduino. With just a few lines of code you can establish a WiFi connection,
control the ESP8266 GPIOs, turning your ESP8266 into a web server and a lot more.
In this tutorial we are going to use another ESP8266 module with pin header adapter board which is breadboard
friendly.
12 www.handsontec.com
4.3 Wiring:
After wiring your circuit, you have to download the NodeMCU flasher. This is a .exe file that you can download using
one of the following links:
You can find all the information about NodeMCU flasher here.
Open the flasher that you just downloaded and a window should appear (as shown in the following figure).
13 www.handsontec.com
Press the button “Flash” and it should start the flashing process immediately, showing the Module MAC address if
successful connected.
After finishing this flashing process, it should appear a green circle with a check icon at lower left corner.
14 www.handsontec.com
5. Getting Started with the ESPlorer IDE
ESPlorer is an IDE (Integrated Development Environment) for ESP8266 devices. It’s a multi platform IDE, can be
used in any OS environment, this simply means that it runs on Windows, Mac OS X or Linux.
Supported platforms:
• Windows(x86, x86-64)
• Linux(x86, x86-64, ARM soft & hard float)
• Solaris(x86, x86-64)
• Mac OS X(x86, x86-64, PPC, PPC64)
This software allows you to establish a serial communications with your ESP8266 module, send commands, and
upload code and much more.
Requirements:
• You need to have JAVA installed in your computer. If you don’t have, go to this
website: http://java.com/download, download and install the latest version. It requires JAVA (SE version 7
and above) installed.
• In order to complete the sample project presented in this Guide you need to flash your ESP8266 with
NodeMCU firmware. Refer to chapter-4 in this guide on how to flash the NodeMCU firmware.
Main Resources:
Now let’s download the ESPlorer IDE, visit the following URL: http://esp8266.ru/esplorer/#download
Grab the folder that you just downloaded. It should be named “ESPlorer.zip” and unzip it. Inside that folder you
should see the following files:
Execute the “ESPlorer.jar” file and the ESPlorer IDE should open after a few seconds (the “ESPlorer.jar” file is what
you need to open every time you want to work with the ESPlorer IDE).
15 www.handsontec.com
Note: If you’re on Mac OS X or Linux you simply use this command line in your terminal to run the ESPlorer: sudo
java –jar ESPlorer.jar.
When the ESPlorer first opens, that’s what you should see:
The ESPlorer IDE has a couple of main sections, let’s break it down each one.
In the top left corner you can see all the regular options that you find in any software. Create a New file, Open a new
file, Save file, Save file as, Undo, Redo, etc.
16 www.handsontec.com
In the top right corner you have all the options you need to establish a serial communication (you’re going to learn
how to use them later in this Guide).
This next screenshot shows your Code Window, that’s where you write your scripts (your scripts are highlighted with
your code syntax).
Below the Code Window, you have 12 buttons that offer you all the functions you could possible need to interact with
your ESP8266. Here’s the ones you’ll use most: “Save to ESP” and “Send to ESP”.
This screenshot shows the Output Window which tells you exactly what’s going on in your ESP8266. You can see
errors and use prints in your code to debug your projects.
17 www.handsontec.com
5.2 Schematics
To upload code to your ESP8266, you should connect your ESP8266 to your PL2303HX USB-UART Programming Cable
like the figure below:
Right now you don’t need to worry how this code works, but how you can upload it to your ESP8266.
18 www.handsontec.com
Having your ESP8266+PL2303HX Programmer connected to your computer, go to the ESPlorer IDE:
Look at the top right corner of your ESPlorer IDE and follow these instructions:
Then in the top left corner of your ESPlorer IDE, follow these instructions:
1. Select NodeMCU
2. Select Scripts
3. Create a new filled called “init.lua”
19 www.handsontec.com
Copy your Lua script to the code window (as you can see in the Figure below):
20 www.handsontec.com
Note: If you want to delete your “init.lua” file, you can do that easily. Simply type file.remove(“init.lua”) and press
the button “Send” (see Figure above). Or you can type the command file.format() to remove all the files saved in your
ESP8266. You can type any commands and send them to your ESP8266 through that window.
After uploading your code to your ESP8266, unplug your ESP8266 from your computer and power up the ESP8288
module.
Congratulations, you’ve made it! The blue LED at the upper right corner should be blinking every 2 seconds!
21 www.handsontec.com
6. NodeMCU GPIO for Lua
The GPIO(General Purpose Input/Output) allows us to access to pins of ESP8266 , all the pins of ESP8266 accessed
using the command GPIO, all the access is based on the I/O index number on the NoddMCU dev kits, not the internal
GPIO pin, for example, the pin ‘D7’ on the NodeMCU dev kit is mapped to the internal GPIO pin 13, if you want to
turn ‘High’ or ‘Low’ that particular pin you need to called the pin number ‘7’, not the internal GPIO of the pin. When
you are programming with generic ESP8266 this confusion will arise which pin needs to be called during
programming, if you are using NodeMCU devkit, it has come prepared for working with Lua interpreter which can
easily program by looking the pin names associated on the Lua board. If you are using generic ESP8266 device or any
other vendor boards please refer to the table below to know which IO index is associated to the internal GPIO of
ESP8266.
D0 or GPIO16 can be used only as a read and write pin, no other options like PWM/I2C are supported by
this pin.
In our example in chapter 5 on blinking the blue LED, the blue LED in connected to GPIO2, it is defined as
Pin4 (D4) in Lua script.
7. Web Resources:
22 www.handsontec.com