Anda di halaman 1dari 174

SISTEM MONITORING KEADAAN AIR PADA

TEMPAT WISATA AIR TERJUN COBAN PUTRI


BERBASIS FIREBASE DAN ANDROID

SKRIPSI

Diajukan untuk memenuhi sebagian persyaratan memperoleh gelar


Sarjana Sains Terapan

Disusun Oleh :
Febri Chahya Setyawichaksana
NIM. 1541160042

PROGRAM STUDI JARINGAN TELEKOMUNIKASI


DIGITAL
JURUSAN TEKNIK ELEKTRO
POLITEKNIK NEGERI MALANG
2022

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 :

Ir.Moh. Abdulla Anshori, M,MT


NIP. 1996302261988031001 …………………………………….

Penguji I :

Hendro Darmono, B.Eng., MT


NIP. 196207101991031003 …………………………………….

Penguji II:

Farida Arinie Soelistianto, ST., MT.


NIP. 196704141993032002 …………………………………….

Hadiwiyatno, ST., MT.


Malang, 23 Maret 2022
NIP. 196310241988031002 …………………………………….
Ketua Program Studi Jaringan
Ketua Jurusan Teknik Elektro Telekomunikasi Digital

(Mochammad Junus, ST., MT.) (M. Nanak Zakaria, ST., MT.)


NIP. 197206191999031002 NIP. 197106111999031004
iii

PERNYATAAN ORISINALITAS SKRIPSI

Saya menyatakan dengan sebenar-benarnya bahwa sepanjang pengetahuan


saya, di dalam naskah skripsi ini tidak terdapat karya tulis ilmiah yang pernah
diajukan oleh orang lain untuk memperoleh gelar akademik di suatu perguruan
tinggi, dan tidak terdapat kerya atau pendapat yang pernah ditulis atau diterbitkan
oleh orang lain, kecuali yang secara tertulis dikutip dalam naskah ini dan
disebutkan dalam sumber kutipan dan daftar pustaka.

Apabila ternyata di dalam naskah skripsi ini dapat dibuktikan terdapat


unsur-unsur PLAGIASI, saya bersedia skripsi ini di gugurkan dan gelar
akademik yang telah saya peroleh (Sarjanah Sains Terapan) dibatalkan, serta
diproses sesuai dengan peraturan perundang-undangan yang berlaku, (UU No. 20
Tahun 2003, Pasal 25 Ayat 2 dan Pasal 70 ).

Malang, 23 Maret 2022


Mahasiswa,

Nama : Febri Chahya Setyawichaksana


NIM : 1541160042
PS :Jaringan Telekomunikasi Digital
iv

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 menyadari tidak akan mampu merealisasikan laporan ini tanpa


bantuan, dorongan dan bimbingan dari para Ibu Bapak dosen, Orang tua dan
teman-teman. Oleh karena itu, atas segala bantuan yang telah diberikan, saya
mengucapkan terima kasih kepada :

1. Allah SWT yang telah memberikan kesehatan, kekuatan dan kelancaran


dalam proses pengerjaan skripsi ini.
2. Nabi Muhammad SAW, sebagai junjungan yang telah memberikan suri
tauladan yang baik kepada umatnya.
3. Kedua Orang tua yang senantiasa memberikan doa restu, kasih sayang,
dorongan semangat, serta bantuan moril maupun materil.
4. Bapak Drs. Awan Setiawan MM. selaku Direktur Politeknik Negeri Malang.
5. Bapak M. Junus, ST., MT. selaku Ketua Jurusan Teknik Elektro.
6. Bapak Nanak Zakaria, ST., MT. selaku Ketua Program Studi Jaringan
Telekomunikasi Digital.
7. Bapak Hudiono, ST., MT. selaku Ketua Panitia Skripsi 2020 Program Studi
Jaringan Telekomunikasi Digital yang telah memberikan bimbingan,
dorongan dan semangat untuk mahasiswanya dalam proses pengerjaan
skripsi hingga selesai.
8. Bapak Ir. Waluyo, MT. selaku Dosen Pembimbing I yang telah memberikan
pengarahan, bimbingan, dan motivasi yang sangat bermanfaat dalam
menyusun skripsi ini.
9. Bapak Ir.Moh. Abdulla Anshori, M,MT. selaku Dosen Pembimbing II yang
telah memberikan pengarahan, bimbingan, dan motivasi yang sangat
bermanfaat dalam menyusun skripsi ini.
10. Bapak dan Ibu Dosen Pengajar Program Studi Jaringan Telekomunikasi
Digital Jurusan Teknik Elektro Politeknik Negeri Malang yang telah
memberikan masukan dan motivasi dalam proses pengerjaan skripsi ini.
v

11. Teman-teman JTD Angkatan 2015 yang telah memberikan bantuan,


dukungan dan semangat.
12. Semua pihak yang tidak dapat penulis sebutkan satu persatu yang telah
memberikan dukungan dan dorongan semangat, sehingga skripsi ini dapat
diselesaikan dengan baik.
Penulis menyadari bahwa dalam penyusunan skripsi ini masih jauh dari
kesempurnaan. Tetapi penulis berharap bahwa skripsi ini akan memberikan
pengetahuan baru dan manfaat bagi penulis dan pembaca. Oleh karena itu, kritik
dan saran diterima dengan baik guna membangun kekurangan-kekurangan
tersebut.

Malang, 23 Maret 2022

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.

Kata Kunci: Firebase, Android, Wireless, Monitoring


vii

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.

Key Word : Firebase, Android, Wireless, Monitoring


viii

DAFTAR ISI

HALAMAN PENGESAHAN ................................................................................. ii


PERNYATAAN ORISINALITAS SKRIPSI ........................................................ iii
KATA PENGANTAR ........................................................................................... iv
ABSTRAK ............................................................................................................. vi
ABSTRACT .......................................................................................................... vii
DAFTAR ISI ........................................................................................................ viii
DAFTAR GAMBAR .............................................................................................. x
DAFTAR TABEL .................................................................................................. xi
BAB I ...................................................................................................................... 1
1.1 Latar Belakang ............................................................................................ 1
1.2 Rumusan Masalah ....................................................................................... 2
1.3 Batasan Masalah .......................................................................................... 2
1.4 Tujuan Penelitian......................................................................................... 2
1.5 Manfaat Penelitianu..................................................................................... 3
1.6 Luaran Penelitian......................................................................................... 3
BAB II ..................................................................................................................... 4
2.1 Penelitian terdahulu ..................................................................................... 4
2.2 Teori Dasar .................................................................................................. 5
2.2.1 Monitoring ................................................................................................... 5
2.2.2 Media Penyimpanan Firebase ..................................................................... 5
2.2.3 Arduino Nano .............................................................................................. 6
2.2.4 Sensor pH air ............................................................................................. 10
2.2.5 Sensor konduktifitas .................................................................................. 11
2.2.6 Sensor Flow ............................................................................................... 11
2.2.7 Sensor Suhu ............................................................................................... 12
1) 2.2.8 Modul Wireless NRF 24L01 ............................................................ 12
BAB III ................................................................................................................. 17
3.1 Jenis Penelitian .......................................................................................... 17
3.2 Rancangan Penelitian ................................................................................ 17
3.3 Blok Diagram ............................................................................................ 19
3.4 Prosedur dan Parameter ............................................................................. 19
ix

3.5 Perancangan Alat ....................................................................................... 22


3.4 Alat dan Bahan .......................................................................................... 30
3.6 Implementasi Hardware ............................................................................ 31
3.6.1 Pemasangan Sensor pada Node Monitoring.............................................. 31
3.6.2 Rangkaian Server NodeMCU + NRF24l01 .............................................. 33
3.7 Uji Coba dan Kalibrasi .............................................................................. 34
3.7.1 Pengujian Kalibrasi Sensor Kekeruhan/Turbidity ..................................... 34
3.7.2 Pengujian Kalibrasi Sensor pH ................................................................. 36
3.7.3 Pengujian Kalibrasi Sensor Suhu .............................................................. 37
3.7.4 Pengujian sensor flow ............................................................................... 39
BAB IV ................................................................................................................. 41
4.1 Hasil pembuatan APK berdasarkan firebase ............................................. 41
4.2 Pembahasan Data Monitoring ................................................................... 43
BAB V KESIMPULAN DAN SARAN ................................................................ 49
5.1 Kesimpulan................................................................................................ 49
5.2 Saran .......................................................................................................... 49
DAFTAR PUSTAKA ........................................................................................... 50
LAMPIRAN DATASHEET KOMPONEN .......................................................... 52
x

DAFTAR GAMBAR

Gambar 2.1 Sistem Monitoring ............................................................................... 5


Gambar 2.2 Tampak Belakang Arduino Nano ........................................................ 7
Gambar 2.3 Tampak Depan Arduino Nano ............................................................ 7
Gambar 2.4 Alat sensor pH air .............................................................................. 10
Gambar 2.5 Alat sensor konduktifitas air ............................................................. 11
Gambar 2.6 Alat sensor Flow ............................................................................... 11
Gambar 2.7 Alat Sensor Suhu ............................................................................... 12
Gambar 2.8 Modul wireless NRF24L01 ............................................................... 13
Gambar 2.9 Format data enhanced shockburst ™ ................................................ 16
Gambar 3.1 Flowchart Kegiatan Penelitian ........................................................18
Gambar 3.2 Diagram Blok Sistem Penelitian ....................................................... 19
Gambar 3.3 Flowchart Sistem dari Node ke Server .............................................. 20
Gambar 3.4 Flowchart Sistem dari Server ke APK .............................................. 21
Gambar 3.5 Rangkaian Sensor pada Arduino ....................................................... 32
Gambar 3.6 Server untuk Monitoring ................................................................... 33
Gambar 3.7 Kalibrasi Sensor Kekeruhan .............................................................. 35
Gambar 3.8 Pengujian Sensor pH ......................................................................... 36
Gambar 3.9 Pengujian Sensor Suhu ...................................................................... 37
Gambar 3.10 Pengujian Sensor Flow .................................................................... 39
Gambar 4.1 Tampilan Database untuk Firebase........ ............................................41
Gambar 4.2 Hasil Pembuatan Sistem Output pada Aplikasi................................. 42
Gambar 4.3 Grafik Perbandingan Suhu ................................................................ 45
Gambar 4.4 Grafik Perbandingan Flow ................................................................ 46
Gambar 4.5 Grafik Perbandingan pH.................................................................... 47
Gambar 4.6 Grafik Perbandingan Suhu ................................................................ 48
xi

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.1 Latar Belakang


Perkembangan teknlogi sekarang ini sangat lah pesat, dan sekarang sudah
banyak kalangan yang sidah tidak asing dengan teknologi. Bahkan, seseorang
akan mengalami kesulitan saat mereka meninggalkan atau tidak sedang
menggunakan smartphone mereka. Internet merupakan hal yang penting sekarang
ini, deengan internet orang akan lebih mudah mengakses informasi,
berkomunikasi dengan mudah. Contoh teknologi sekarang ini ialah smart home,
Internet Of Think (IoT), Wireless Sensor Network (WSN) dan lain-lain. WSN
sendiri adalah jaringan sensor nirkabel atau dalam banyak literatur disebut
Wireless Sensor Network (WSN) adalah sebuah jaringan yang menghubungkan
perangkat-perangkat seperti sensor node, router dan sink node.
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.
Jaringan Sensor Nirkabel atau dalam banyak literatur disebut Wireless
Sensor Network (WSN) adalah sebuah jaringan yang menghubungkan perangkat-
perangkat seperti sensor node, router dan sink node. Perangkat ini terhubung
secara ad-hoc dan mendukung komunikasi multi-hop. Istilah ad-hoc merujuk pada
kemampuan perangkat untuk berkomunikasi satu sama lain secara langsung tanpa
memerlukan infrastruktur jaringan seperti router atau akses poin. Sedangkan
multi-hop yaitu istilah yang merujuk pada komunikasi beberapa perangkat yang
melibatkan perangkat antara (intermediate), multi-hop melibatkan perangkat
antara seperti router untuk meneruskan sebuah paket dari satu node ke node lain
dalam jaringan.

1
2

Penelitian terdahulu telah meneliti monitoring air atau memonitoring


bagaimana kondisi atau kualitas air. Berdasarkan penelitian terdahulu saya ingin
mengembangkan penelitian ini dengan judul SISTEM MONITORING
KELAYAKAN AIR DI GROJOKAN SEWU UNTUK WISATAWAN
BERBASIS FIREBASE. Dan contoh air yang layak untuk wisatawan yang ingin
berenang dan keadaan air tidak pada saat membahayakan wisatawan yang
berenang disana. Air yang aman untuk wisatawan yang berenang ialah air yang
dalam keadaan tenang yang tidak dalam keadaan arus yang deras dan suhu yang
tidak terlalu dingin sehingga tidak membahayakan keselamatan wisatawan.
1.2 Rumusan Masalah
Rumusan masalah sensor-sensoruntuk sistem monitoring keadaan air adalah
sebagai berikut:
1. Bagaimana merancang sistem monitoring keadaan air dengan berbasis
firebase?
2. Bagaimanacara merancang sensor-sensor air untuk memonitoring keadaan
air?
3. Bagaimana merancang sistem monitoring yang terintegrasi dalam satu
server dengan firebase?
4. Bagaimana tampilan outputyang dihasilkan dari sistem monitoring keadaan
air menggunkan sensor-sensor air dan firebase?
1.3 Batasan Masalah
Batasan masalah sensor-sensoruntuk sistem monitoring keadaan air adalah
sebagai berikut:
1. Hanya melakukan monitoring di wilayah wisata alam yang di survey.
2. Tidak membahas secara detail tentang alat sensor air.
3. Tidak membandingkan system sensor dengan system sensor yang lain.

1.4 Tujuan Penelitian


Tujuanuntuk sistem monitoring keadaan airloker adalah sebagai berikut:
1. Menciptakan sistem yang terintegrasi antara mikrokontroller 1 dengan
mikrokontroller lainnya
2. Membantu memonitoring keadaan air pada wilayah wisata alam air terjun.
3. Menambah penelitian pada WSN.
3

1.5 Manfaat Penelitianu


Maanfaat penelitian adalah sebagai berikut:
1. Membantu wisatawan untuk mengetahui keadaan air.
2. Menambah wawasan tentang WSN untuk system perairan.

1.6 Luaran Penelitian


Luaran untuk sistem monitoring keadaan airadalah sebagai berikut:
1. Menghasilkan aplikasi sistem monitoring keadaan air di grojokan sewu
untuk wisatawan berbasis firebase.
2. Menghasilkan Laporan Hasil Penelitian yang nantinya dapat dikembangkan
atau digunakan sebagai referensi untuk penelitian selanjutnya.
3. Menghasilkan Jurnal Penelitian yang diterbitkan oleh Program Studi
Jaringan Telekomunikasi Digital.

.
BAB II
TINJAUAN PUSTAKA

2.1 Penelitian terdahulu


Penelitian terdahulu telah meneliti monitoring air atau memonitoring
bagaimana kondisi atau kualitas air.Berdasarkan penelitian terdahulu saya ingin
mengembangkan penelitian ini dengan judul SISTEM MONITORING
KELAYAKAN AIR DI GROJOKAN SEWU UNTUK WISATAWAN
BERBASIS FIREBASE.Dan contoh keadaan air yang tidak membahayakan bagi
wisatawan yang ingin berenang. Air yang aman untuk berenang ialah dimana
keadaan arus air di air terjun tidak deras dan suhu air yang tidak extrim sehingga
wisatawan aman saat berenang di peraiaran terseut. Berikut beberapa judul jurnal
terdahulu:
1. Jurnal : Sistem Monitoring Kualitas Air Pada Kolam Ikan Berbasis Wireless
Sensor Network Menggunakan Komunikasi Zigbee.
Di jurnal ini menjelaskan sistem untuk memonitoring kualitas air pada
kolam ikan yang menggunakan komunikasi ZIGBEE.
2. Jurnal : Sistem Pemantauan Kadar pH, Suhu dan Warna pada Air Sungai
Melalui Web Berbasis Wireless Sensor Network
Di jurnal ini menjelaskan system pemantauan kadar pH, suhu dan warna
air sungai dengan nmelalui Web yang berbasis wireless.
3. Jurnal : Wireless Sensor Networks: A Survey On Monitoring Water Quality
Di jurnal ini menjelaskan bagaimana survey atau memonitoring kualitas
air yang berbasis WSN.
4. Jurnal : Rancang Bangun Sistem Monitoring Dan Kendali Kualitas Air Sungai
Secara Online Dengan Wireless Sensor Network (WSN) Untuk Industri
Pengolahan Air Minum Di PDAM.
Di jurnal ini menjelaskan rancangan bangun system monitoring dan
kendali kualitas air sungai secara online dengan Wireless Sensor Network (WSN)
yang di tujukan untuk indurtri pengolahan air minum di PDAM. Dari jurnal ini
ingin mengambil sistem komunikasi wireless yang dibentuk oleh perangkat pada
jurnal sehingga mampu mengirimkan data ke server yang diinginkan.

4
5

2.2 Teori Dasar


2.2.1 Monitoring
Monitoring merupakan sebuah proses pengumpulan informasi dari
penerapan suatuprogram termasuk mengecek apakah suatu program telah berjalan
sesuai dengan rencana yang diinginkan sehingga setiap masalah yang ditemukan
dapat diatasi (Foe, 2013). Sistem melakukan monitoring terhadap debit air hasil
pengolahan data jumlah putaran kincir yang dikirim oleh sensor ke
microcontroller. Adapun gambaran mengenai bentuk system Monitoring
ditunjukkan dalam Gambar 2.1.

Gambar 2. 1 Sistem Monitoring


Sumber : (saptaji.com)

2.2.2 Media Penyimpanan Firebase


Media Penyimpanan Firebase atau bias di sebut Cloud Storage for Firebase
adalah layanan penyimpanan objek yang andal, sederhana, dan hemat biaya yang
dibuat untuk skala Google. Firebase SDK untuk Cloud Storage menambahkan
keamanan Google pada upload dan download file untuk aplikasi Firebase Anda,
bagaimanapun kualitas jaringannya. Anda dapat menggunakan SDK kami untuk
menyimpan gambar, audio, video, atau konten buatan pengguna lainnya. Di
server, Anda dapat menggunakan Google Cloud Storageuntuk mengakses file
yang sama.
Di sini sayamenggunakan Firebase untuk media penyimpanan. Data hasil
dari monitoring yang di mana data yang telah didapat dari sensor2 yang di kirim
6

melalui arduino akan di di simpan di firebase. Saya menggunakan media


penyimpanan firebase karena murah dan lebih effisien.

2.2.3 Arduino Nano


Arduino Nano merupakan salah satu jenis mikrokontroller yang memiliki
ukuran yang kecil seperti gambar 2.5 dan gambar 2.6. Arduino Nano memiliki
chip USB to TTL converter yang menggunakan FTDI FT232RL,
sehinggaArduino Nano ini dapat langsung dihubungkan dengan PC (Personal
Computer) atau peralatan berbasis USB serial lainnya melalui konektor USB mini
yang terpasang pada Arduino Nano. Dibawah ini merupakan spesifikasi yang
dimiliki oleh Arduino Nano, diantaranya:
Tabel 2.1 Spesifikasi pada Arduino Nano
Mikrokontroller Atmel ATMega 168 atau ATMega 328
Tegangan Operasi 5 Volt

Tegangan Masukan 7-12 Volt (disarankan)

Tegangan Masukan 6-20 Volt (limit)


14 (pin digunakan sebagai output PMW
Pin Digital I/O
(Pulse Width Modulation)

Pin Input Analog 8


Arus DC per pin 40 Ma
I/O
16KB (ATMega 168) atau 32KB (ATMega
Flash Memory
328)
2KB digunakan sebagai bootloader
SRAM (Static
Random Access 1KB (ATMega 168) atau 2KB (ATMega328)
Memory)
EEPROM
(Electrically 512byte (ATMega 168) atau 1KB(ATMega
Erasable
328)
Programmable
Read Only Memory)
Clock Speed 16MHz
Ukuran 1.85 X 4.3 cm
Sumber : Datasheet Arduino nano
7

Gambar 2. 2 Tampak Belakang Arduino Nano


Sumber: http://www.arduino.cc

Gambar 2.3 Tampak Depan Arduino Nano


Sumber: http://www.arduino.cc

2.2.3.1 Sumber Daya Arduino Nano


Untuk mengaktifkan Arduino Nano dapat dilakukan dengan cara
menghubungkannya melalui USB mini atau melalui catu daya eksternal dengan
tegangan yang belum teregulasi dengan range 6- 20 volt yang dapat dihubungkan
melalui pin 30 (pin Vin), atau dapat juga dilakukan dengan cara menghubungkan
melalui catu daya eksternal dengan tegangan teregulasi 5 volt melalui pin 27 (pin
5 volt). Sumber daya tersebut akan secara otomatis dipilih dari sumber tegangan
yang lebih tinggi. Pada Arduino Nano, chip FTDI FT232L akan segera aktif
apabila memperoleh daya melalui USB. Namun apabila Arduino Nano diberikan
daya eksternal (non-USB), maka chip FTDI tidak aktif dan pin 3.3 volt juga tidak
tersedia (tidak memberikan tegangan), sedangkan LED Tx dan Rx pun akan
berkedip apabila pin digital 0 dan 1 dalam kondisi aktif (high).

2.2.3.2 Memory Arduino Nano


Apabila mikrokontroller pada Arduino Nano merupakan ATMega 168,
maka Arduino Nano tersebut akan memiliki 16KB flash memory yang berfungsi
untuk menyimpan kode (2KB digunakan untuk bootloader). Namun, apabila
mikrokontroller pada Arduino Nano tersebut merupakan ATMega328, maka
8

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.

2.2.3.3 Input dan Output Arduino Nano


Pada Arduino Nano, masing-masing 14 pin digital dapat digunakan
sebagai masukan ataupun keluaran, yaitu dengan menggunakan fungsi fungsi
pinMode(), digitalWrite(), dan digitalRead(). Kesemua pin tersebut dapat
beroperasi pada tegangan 5 volt. Setiap pin dapat memberikan atau menerima arus
maksimum 40 mA dan memiliki resistor pull-up internal (yang terputus secara
default) sebesar 20-50 KOhm. Pada Arduino Nano, terdapat beberapa pin yang
mempunyai pin khusus, diantaranya:
a. Serial: 0 (Rx) dan 1 (Tx)
Digunakan untuk menerima (RX) dan mengirimkan (TX) TTL data serial.
Pin ini terhubung ke pin yang sesuai dari chip FTDI USB-to-TTL Serial.
b. External Interrupt(Interupsi Eksternal): Pin 2 dan pin 3
Pin ini dapat dikonfigurasi untuk memicu sebuah interupsi pada nilai yang
rendah, meningkat atau menurun, atau perubahan nilai.
c. PWM: Pin 3, 5, 6, 9, 10, dan 11.
Pada pin ini menyediakan output PWM 8-bit dengan fungsi analogWrite().
diberi tanda titik atau strip.
d. SPI: Pin 10 (SS), 11 (MOSI), 12 (MISO), 13 (SCK).
Pin ini mendukung komunikasi SPI. Sebenarnya komunikasi SPI ini
tersedia pada hardware, tapi untuk saat belum didukung dalam bahasa Arduino.
e. LED : Pin 13.
Pin ini tersedia secara built-in pada papan Arduino Nano. LED terhubung
ke pin digital 13. Ketika pin diset bernilai HIGH, maka LED menyala, dan ketika
pin diset bernilai LOW, maka LED padam.
Pada Arduino Nano, label A0 sampai A7 berfungsi sebagai input analog,
yang masing-masing memiliki resolusi 10 bit. Secara default, pin ini data diatur
9

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.

2.2.3.4 Komunikasi Pada Arduino Nano


Pada Arduino Nano memiliki sejumlah fasilitas yang digunkan untuk
berkomunikasi dengan komputer, atau dengan mikrokontroller yang lainnya. Pada
Arduino Nano ini terdapat komunikasi serial UART (Universal
AsynchronousReceiver Transmiter) sebesar 5 Volt yang tersedia pada pin digital 0
(Rx) dan pindigital 1 (Tx). Chip FTDI FT232RL berfungsi sebagai media
komunikasi serial melalui USB driver FTDI (tersedia pada software Arduino IDE)
yang akan menyediakan COM Port Virtual (pada Device komputer) untuk
berkomunikasi dengan perangkat lunak pada komputer. Perangkat lunak pada
Arduino terdapat serial monitor yang memungkinkan data tekstual sederhana
dikirim data dari dan ke Arduino. LED Rx dan Tx akan berkedip ketika data
sedang dikirim atau diterima melalui chip FTDI dan koneksi US yang terhubung
melalui USB komputer (Tidak untuk komunikasi serial pada pin 0 dan pin 1).
Mikrokontroller ATMega168 atau ATMega328 yang terdapat pada Arduino Nano
juga mendukung komunikasi I2C (TWI) dan SPI. Perangkat lunak Arduino
termasuk perpustakaan Wire digunakan untuk menyederhanakan penggunaan bus
I2C. Perangkat lunak Arduino termasuk perpustakaan Wire digunakan untuk
menyederhanakan penggunaan bus I2C.
10

2.2.3.5 Reset Otomatis pada Arduino Nano


Arduino Nano didesain yang memungkinkan pengguna untuk melakukan
reset ulang melalui perangkat lunak yang berjalan pada komputer yang terhubung.
Salah satu jalur kontrol hardware (DTR) mengalir dari FT232RL dan terhubung
ke jalur reset dari ATMega168 atau ATMega328 melalui kapasitor 100Nanofarad.
Implikasi lain dari adanya pengaturan ini yaitu saat Arduino Nano terhubung
dengan komputer yang menggunakan sistem operasi Mac OS X atau Linux, papan
Arduino akan di-reset setiap kali dihubungkan dengan perangkat lunak pada
komputer (melalui USB). Saat setengah detik kemudian atau lebih, bootloader
berjalan pada papan Arduino Nano. Proses reset melalui program inidigunakan
untuk mengabaikan data yang cacat (yaitu apapun selain meng-upload kode baru),
ia akan memotong dan membuang beberapa byte pertama dari data yang dikirim
ke papan setelah sambungan terbuka.

2.2.4 Sensor pH air


Sensor untuk memonitoring kadar asam air.

Gambar 2.4 Alat Sensor pH Air

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

2.2.5 Sensor konduktifitas


Sensor untuk mengetes kualitas dan kekeruhan air yang bisa di lihat pada
Gambar 2.5.

Gambar 2.5 Alat Sensor Konduktifitas Air

Conductivity meter adalah alat untuk mengukur nilai konduktivitas listrik


atau kondisi kekeruhan air. Sensor conductifity akan mengukur tingkat kekeruhan
(specific/electric conductivity) suatu larutan atau cairan.

2.2.6 Sensor Flow


Water Flow sensor adalah sensor yang mempunyai fungsi sebagai
penghitung debit air yang mengalir yang dimana terjadi pergerakan motor yang
akan dikonversi kedalam nilai satuan Liter. Sensor ini terdiri dari beberapa bagian
yaitu katup plastik, rotor air, dan sensor hall efek.

Gambar 2.6 Alat Sensor Flow


12

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.

2.2.7 Sensor Suhu


Sensor suhu adalah alat yang digunakan untuk mengubah besaran panas
menjadi besaran listrik yang dapat dengan mudah dianalisis besarnya. Ada
beberapa metode yang digunakan untuk membuatsensor ini, salah satunya dengan
cara menggunakan material yang berubah hambatannya terhadap arus listrik
sesuai dengan suhunya sesuai pada Gambar 2.7.

Gambar 2.7 Alat Sensor Suhu

1) 2.2.8 Modul Wireless NRF 24L01


Sonovane (2009) menjelaskan bahwa transceiver NRF24L01+ adalah
sebuah modul komunikasi jarak jauh yang memanfaatkan pita gelombang radio
frekuensi 2,4 GHz ISM (Industrial, Scientific and Medical). Modul ini
menggunakan antarmuka Serial Pheripheral Interface (SPI) untuk berkomunikasi.
NRF24L01 merupakan transceiver yang terdiri dari frequency synthesizer yang
terintegrasi, power amplifier, osilator kristal, modulator, demodulator, dan
Enhancedshockburst protocol engine. Transmisi sinyal tanpa kabel menggunakan
pemancar sebagai media untuk penyebaran sinyal informasi yang termodulasi
dengan gelombang elektromagetik.Pemanfaatan gelombang elektromagnet dalam
menyebarkan sinyal informasi memiliki keuntungan karena penjalaran gelombang
elektromagnetik tidak membutuhkan medium transmisi.Sistem telemetri
13

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.

Gambar 2. 8 Modul Wireless NRF24L01


Sumber : Datasheet modul wireless NRF24L01

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

Sumber :Datasheetmodul wireless NRF24L01


16

Gambar 2. 9 Format Data Enhanced Shockburst ™


Sumber :Datasheet modul wireless NRF24l01
17

BAB III
METODE PENELITIAN

3.1 Jenis Penelitian


Penelitian yang dilakukan merupakan penelitian dan pengembangan atau
Research and Development (R&D), karena sesuai dengan tujuan yang hendak
dicapai. Menurut Borg dan Gall (1983: 772), “educational research and
development (R & D) is a process used to develop and validate educational
production". Dengan pengertian tersebut maka langkah-langkah penelitian dan
pengembangan dilakukan secara bertahap dan pada setiap langkah yang akan
dilakukan selalu mengacu pada hasil langkah sebelumnya hingga pada akhirnya
diperoleh suatu sistem perangkat yang baru.
Jenis penelitian yang dilakukan merupakan Jenis Penelitian dan
Pengembangan atau dikenal dengan istilah Research and Development (R&D),
hal tersebut karena penelitian yang akan dilakukan saat ini merupakan
pengembangan dari dua penelitian sebelumnya. Dalam buku yang berjudul
“Metode Penelitian Kuantitatif, Kualitatif, dan R &D” yang ditulis oleh Sugiyono,
dijelaskan bahwa Research and Development adalah metode penelitian yang
digunakan untuk menghasilkan produk tertentu, dan menguji keefektifan produk
tersebut. Sedangkan Borg and Gall (1983:772) mendefinisikan penelitian
pengembangan sebagai proses yang digunakan untuk mengembangkan dan
menvalidasi produk pendidikan. Langkah-langkah dari proses ini biasa disebut
sebegai siklus R & D, yang terdiri dari mempelajari temuan penelitian yang
berkaitan dengan produk yang akan dikembangkan, mengembangkan produk
berdasarkan temuan ini, bidang pengujian dalam pengaturan dimana produk akan
digunakan akhirnya, dan merevisinya untuk memperbaiki kekurangan yang
ditemukan dalam mengajukan pengujian. Jenis penelitian dan pengembangan
banyak digunakan pada bidang teknik baik pada produk perangkat keras maupun
perangkat lunak. Jenis penelitian dan pengembangan banyak digunakan pada
bidang teknik baik pada produk perangkat keras maupun perangkat lunak.
3.2 Rancangan Penelitian
Penelitian yangdilakukan ditujukan dalam diagram alir pada Gambar 3.1.

17
18

Gambar 3.1 Flowchart Kegiatan Penelitian


Jadi langkah pertama adalah mencari kajian pustaka yang terkait. Dimana
hal ini terdiri dari buku dasar teori, buku skripsi penelitian yang terkait, jurnal dan
data sheet tentang hal yang dapat mendukung sistem. Kemudian dilakukan
pembelajaran berdasar kajian yang bersangkutandengan cara merangkum dan
membuat list istilah penting yang dianggap penting untuk kedepannya. Setelah itu
melakukan perancangan sistem monitoring sesuai dengan penelitian yang akan
dibuat dan mendukung sistem wsn secara umum. Kemudian mencari perangkat
pendukung yang sesuai dengan alat yang dirancang di toko online/offline.Setelah
perangkat yang diinginkan telah didapatkan dilanjutkan melakukan merangkai alat
serta memasukkan program sesuai skema yang dirancang. Setelah semua
dimasukkan dengan baik akan diadakan pengujian alat dan rangkaian apakah
sudah sesuai atau belum. Jika alat dianggap sudah sesuai dengan apa yang
diinginkan maka hasil penelitian akan dianalisa. Namun apabila pengujian alat
tidak sesuai dengan yang diharapkan maka perlu dilakukan pengecekan pada
19

proses pembuatan alat. Setelah melakukan analisa, selanjutnya pembuatan laporan


sesuai dengan pandauan yang sudah ada.
3.3 Blok Diagram
Gambar 3.2. adalah blok diagram 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.

Gambar 3.2 Diagram Blok Sistem Penelitian


3.4 Prosedur dan Parameter
Untuk mempermudah cara kerja sistem akan dijelaskan dalam flow chart
yang terlihat pada Gambar 3.3 untuk monitoring air terjun yang
dibangun.Penjelasan Gambar 3.3 sebagai berikut :
1. Arduino nano menyala disuplai catu daya, memulai program yang telah
dirancang atau dalam bahasa pemrogramannya “Serial Begin”.
20

2. Setelah program berjalan pada mikrokontroller, sensor suhu, sensor flow,


sensor kekeruhan, dan sensor pH mulai bekerja.

Start

Serial Begin Node

Pembacaan Pembacaan Pembacaan Pembacaan


suhu pH Kekeruhan Arus

Ada Ada Perubahan Ada Perubahan Ada Perubahan


Perubahan

Update data dan kirim ke server

End

Gambar 3.3 Flowchart Sistem dari Node ke Server

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.

Gambar 3.4 Flowchart Sistem dari Server ke APK


22

3.5 Perancangan Alat


Perancangan alat yang akan dilakukan terdiri dari 2 tahap mulai dari
perancangan untuk monitoring kemudian dilanjutkan pada perancangan server dan
database firebase.

3.5.1 Perancangan Node Sensor Pada air


Pada node sensor monitoring terdiri dari beberapa komponen yaitu
Arduino Nano, Sensor Flow, suhu, Conductifity, pH dan NRF24l01. Node
tersebut akan diletakkan pada airsungai air terjun grojokan sewu bagian bawah air
terjun.Dalam prosesnya setiap komponen memiliki fungsi yang mendukung
kinerja node pada setiap sensor air.
Terdapat Sensor flow yang berfungsi sebagai alat pendeteksi deras
tidaknya arus sungai yang dimana sensor flow akan mengukur deras arus air
melalui berapa putaran kipas yang ada di dalam sensor flow per detiknya. Sensor
flow tersebut akan mengambil data terkait deras tidak nya arus sungai. Bila arus
sungai semakin deras, kipas yang ada dalam sensor flow akan semakin deras.
Sebaliknya jika kipas yang ada di dalam sensor flow semakin melambat,
menandakan arus sugai semakin tenang atau (arus air sungai tidak deras).
Sensor pH disini berfungsi sebagai alat pendekteksi kadar asam dan basa
di dalam air. Dimana sensor pH akan mendeteksi zat-zat yang ada pada air sungai
apa bila kadar asam tinggi kemungkinan besar banyak wisatawan yang sedang
mandi atau berenang di bawah air terjun. Sebalik nya apabila kadar zat asam
rendah kemungkinan besar pengunjung yang mandi atau berenang dalam keadaan
sepia tau sedikit orang yang sedang mandi dan berenang.
Sensor konduktivitas berfungsi sebagai alat pendeteksi kekeruhan air yang
ada di sungai.sensor ini akan mendeteksi keadaan air yang dimana sensor
konduktivitas akan mendeteksi keadaan air dalam keadaan keruh dan keadaan
jernih atau bersih.
Sensor Suhu berfungsi sebagai mengukur keadaan suhu air sungai air
terjun. Sensor suhu akan mengukur keadaan suhu air dimana bili keadaan suhu air
sedang dingi dan panas sensor suhu akan mendeteksi berapa nilai suhuair saat itu
juga.
23

3.5.2 Perancangan Server dan Database


Dalam proses pengiriman data dari node ke server menggunakan Modul
Wireless NRF24l01. Server yang digunakan adalah nodeMCU yang dipasang
dengan Modul Wireless NRF24l01 ini memanfaatkan gelombang radio 2,4GHz.
Maka modul Wireless NRF24l01 dapat melakukan komunikasi data antar node
dengan baik.Pemilihan nodeMCU sebagai server dikarenakan kemampuannya
yang mampu terhubung dengan internet sehingga pengiriman dapat dilakukan
secara realtime berbasis internet.
Pengiriman data secara realtime yang dimaksudkan disini adalah
pengiriman ke database firebase menggunakan internet secara terus menerus.
Setelah diterima oleh firebase maka akan diteruskan ke aplikasi monitoring yang
telah dibuat untuk memudahkan yang membutuhkan informasi keadaan tempat
wisata yang akan dilakukan.

3.5.3 Perancangan Software


Software yang akan digunakan dalam penelitian ini adalah Arduino IDE
pada node, esp8266board pada server, firebase untuk database realtime, dan APK
untuk untuk tampilan data pada smartphone. Program yang akan digunakan akan
di list dibawah ini pada Tabel :
No Letak Koding Penjelasan
. Koding
1 Node Hal pertama
yang
dilakukan
pada saat
memrogram
node adalah
memanggil
perintah dari
library yang
akan
digunakan
pada node
24

No Letak Koding Penjelasan


. Koding
kemudian
mengatur
bilangan
yang dipakai.
Maksudnya
adalah
bilangan
yang dipakai
merupakan
bilangan
integer,
decimal,
minus dan
sebagainya.
Yang paling
sering
dipakai pada
node ini
adalah
integer
dengan nilai
dibelakang
koma untuk
keakurasian
data yang
lebih baik.
Pin yang
digunakan
pada arduino
adalah D2
25

No Letak Koding Penjelasan


. Koding
untuk data
dari sensor
flow, D3
untuk data
dari sensor
suhu, A1
untuk sensor
pH, dan A2
untuk sensor
kekeruhan.
2 Node Pengaturan
satuan untuk
pengukuran
sensor oleh
node.

3 Node perintah
program
untuk
nrf24l01
yang akan
digunakan
pada node.
Disini pin
VCC pada
nrf24l01
dimasukkan
ke pin 3v3
arduino
26

No Letak Koding Penjelasan


. Koding
nano, Gnd ke
Gnd, CE ke
D7, CSN ke
D8, MISO ke
D11, MOSI
ke D12 dan
terakhir SCK
ke D13
arduino
nano.
Pengiriman
radio yang
akan
digunakan
menggunaka
n channel
110 dengan
daya
maksimal.
4 Node Berikutnya
adalah
program
mengatur
pembacaan
sensor flow
oleh pin D2
pada arduino
nano.
27

No Letak Koding Penjelasan


. Koding
5 Node Setelah
program
pembacaan
pada sensor
flow adalah
pembacaan
pada sensor
kekeruhan
untuk pin A2
pada arduino
nano.
6 Node Berikutnya
program
pembacaan
sensor pH
dengan
kalibrasinya
disesuaikan
dengan
kepekaan
alat.
7 Node Sensor
terakhir yang
disetting
berikutnya
adalah sensor
suhu yang
dipasang
pada pin D3
dari arduino
28

No Letak Koding Penjelasan


. Koding
nano.
8 Node Terakhir
yang
diprogram
dalam node
adalah
program
pengiriman
informasi
dari node ke
server.
Dimana data
yang akan
dikirimkan
dipaketkan
dalam
struktur data
dengan
header P.
Setiap
pengiriman
berhasil akan
diberi tulisan
“Send OK”
dan jika
gagal “Send
Failed”
29

No Letak Koding Penjelasan


. Koding
9 Server Hal pertama
yang
dilakukan
pada saat
memrogram
nodeMCU
adalah
memanggil
perintah dari
library yang
akan
digunakan
pada sever.
Kemudian
setelah
memanggil
library dan
memasukkan
alamat
jaringan
internet yang
digunakan
adalah
mengatur
nrf24l01
sebagai
penerima
informasi
dari node.
30

No Letak Koding Penjelasan


. Koding
10 Server Berikutnya
program
pemilah
informasi
yang
diterima dari
node oleh
server.

11 Server Terakhir
merupakan
program
untuk update
ke database
pada firebase
untuk
memberikan
data realtime.

3.4 Alat dan Bahan


Dalam penelitian ini akan digunakan alat dan bahan yang ditunjukan pada
Tabel 3.1 dan Tabel 3.2. Pada Tabel 3.1 akan menampilkan alat atau perangkat
hardware yang akan dibutuhkan diantaranya :
31

Tabel 3.1 Alat dan Bahan Penelitian


Alat Yang Digunakan Jumlah
Sensor pH 1
Sensor Conductifity 1
Sensor Suhu 1
Sensor Flow 1
Node MCU 1
Arduino Nano 1
NRF214 1
Sedangkan untuk softwarenya dapat dilihat pada Tabel 3.2
Tabel 3.2 Software Pendukung
Operating
Kegunaan
System
Untuk OS dari server yang akan digunakan agar
Windows
bisa ditampilkan dalam LCD
Arduino
Untuk memasukan syntax dalam perangkat arduino
Program
APK Untuk tampilan data implementasi alat

Alat dan bahan yang disiapkandigunakan dalam penelitian yang akan


dikembangkan sesuai dengan tugasnya masing-masing.
3.6 Implementasi Hardware

3.6.1 Pemasangan Sensor pada Node Monitoring


Seluruh komponen yang ada akan disambungkan pada arduino sebagai
mikrokontroler. Hal tersebut akan dirangkai sesuai dengan Gambar 3.5 pada alat
monitoring yang akan digunakan. Implementasi node sensor yang telah dirangai
seperti Gambar 3.5.
32

Gambar 3.5 Rangkaian Sensor pada Arduino

Penyambungan pin antar komponen dengan arduino uno sebagai


mikrokontroller pada setiap node sensor di Gambar 3.5 akan dijelaskan pada
Tabel 3.3.

Tabel 3.3 Sambungan Pin antar Komponen pada Arduino Nano


Flow pH Kekeruhan Suhu
Arduino
NRF
Nano Arduino Arduino Arduino Arduino Nano
Nano Nano Nano
2(D2) - D - - -
3(D3) - - - - D+4,7 kOhm
7(D7) CE - - - -
8(D8) CSN - - - -
A1 - - A -
A2 - A
11(D11) MOSI - - - -
12(D12) MISO - - - -
13(D13) SCK - - - -
33

Flow pH Kekeruhan Suhu


Arduino
NRF
Nano Arduino Arduino Arduino Arduino Nano
Nano Nano Nano
GND GND GND G G GND
5V - V V+ V V
3.3V VCC - - - -

3.6.2 Rangkaian Server NodeMCU + NRF24l01


Terdapat komponen NRF24L01 dan nodeMCU pada Gambar 3.6 yang
disambungkan pada server yang menerima seluruh informasi dari node
monitoring. Implementasi dari server tersebut akan dirangkai sesuai dengan Tabel
3.4. Dalam hal ini fungsi NodeMCU adalah server yang akan mengirimkan
informasi ke firebase lalu informasi yang sudah masuk ke firebase akan diambil
oleh aplikasi android untuk menampilkan data pada smartphone. Sedangkan
NRF24L01 berfungsi menghubungkan antara NodeMCU dengan Arduino yang
dipasangi sensor utuk mengolah data pada air.

Gambar 3.6 Server untuk Monitoring

Tabel 3.4 Sambungan PIN Server Node MCU dengan NRF24L01


Server Node MCU NRF 24L01
D1 CE
D2 CSN
D5 MOSI
34

Server Node MCU NRF 24L01


D6 MISO
D7 SCK
GDN GND
3v3 3.3V

3.7 Uji Coba dan Kalibrasi

3.7.1 Pengujian Kalibrasi Sensor Kekeruhan/Turbidity


Pengujian sensor kekeruhan/turbidity bertujuan untuk mengetahui
seberapa akurat hasil data yang terbaca oleh sensor terhadap hasil data yang telah
diuji di Laboratorium Teknik Kimia Politeknik Negeri Malang.Pengujian ini juga
untuk mengetahui seberapa besar tingkat error dari sensor terhadap hasil data
laboratorium. Proses pengambilan data kalibrasi dilakukan mengunakan beberapa
jenis air yang memiliki tingkat kekeruhan berbeda. Pada praktikum ini digunakan
2 jenis sampel air yaitu air mineral dan air larutan kaporit.
Langkah pertama yang dilakukan untuk pengujian kalibrasi sensor
kekeruhan adalah memastikan bahwa alat ukur turbidity meter sudah siap
terpasang dan dalam kondisi ON. Ambil dan masukkan masing-masing sampel air
pada masing-masing gelas ukur. Selanjutnya masukkan gelas ukur pada alat ukur
Turbidity meter bagian atas. Pastikan bahwa simbol segitiga pada gelas ukur tepat
berada pada titik tepat alat ukur. Tutup penutup alat ukur dan tekan tombol read
untuk membaca hasil pengukuran yang terbaca. Ambil dan masukkan masing-
masing sampel air pada masing-masing gelas ukur. Selanjutnya masukkan gelas
ukur pada alat ukur Turbidity meter bagian atas. Pastikan bahwa simbol segitiga
pada gelas ukur tepat berada pada titik tepat alat ukur. Tutup penutup alat ukur
dan tekan tombol read untuk membaca hasil pengukuran yang terbaca.
35

Gambar 3.7 Kalibrasi Sensor Kekeruhan

Kekeruhan memiliki satuan berupa NTU (Nephelometric Tubidity


Unit).Pengujian dimulai dengan melakukan kalibrasi sampel air pada alat ukur
turbidity meter. Proses kalibrasi memaksimalkan dan memberikan nilai ketelitian
yang maksimal terhadap data yang diperoleh.
Tabel 3.5 Kalibrasi Sensor Kekeruhan
Turbidity Meter
Pengujian Jenis Air Sensor (ADC)
(NTU)
1 Air mineral 0.94 0.1 %

2 Air Lumpur 43.4 42 %

3 Air kaporit 60.34 60 %

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.

3.7.2 Pengujian Kalibrasi Sensor pH


Pengujian sensor pH bertujuan untuk mengetahui tingkat akurasi dan
tingkat eror data yang terbaca oleh sensor terhadap hasil kalibrasi sensor
menggunakan alat ukur. Proses pengambilan data kalibrasi dilakukan dengan
menggunakan pH meter dan pH buffer power. Alat ukur pH buffer power yang
digunakan memiliki tingkat kadar pH berbeda agar memudahkan dalam
pengambilan data.

Gambar 3.8 Pengujian Sensor pH

Langkah pertama yang dilakukan untuk mengukur kadar pH yaitu


menyiapkan sampel larutan pH. Sampel ini terdiri dari 2 sampel berbeda yaitu
air yang dilarutkan pada pH buffer powder 4 dan pH buffer powder
6.86.Langkah selanjutnya yaitu menyiapkan alat ukur pH meter.Data hasil
pengambilan sampel ditunjukkan pada tabel berikut.
Tabel 3.6 Data Kalibrasi Sensor pH
Larutan pH pH meter Sensor pH

4 3.5 4.1
6.86 6.1 6.4

Alat ukur pH meter membaca kadar pH yang terlarut dalam masing-masing


sampel air. Dalam pengujian ini, ph meter yang digunakan adalah Ph meter ATC
yang mempunyai perbedaan.0.3 sampai 0.6.
37

3.7.3 Pengujian Kalibrasi Sensor Suhu


Pengujian sensor suhu bertujuan untuk mengetahui seberapa akurat
hasil data yang terbaca oleh sensor terhadap data yang dihasilkan oleh alat ukur
suhu.Pengambilan data kalibrasi delakukan dengan menguji air kolam renang
menggunakan termometer.Dalam penelitian ini, pengujian dilakukan
menggunakan sampel air yang dipanaskan. Proses pengujian dan kalibrasi
sensor suhu dilakukan seperti pada gambar berikut.

Gambar 3.9 Pengujian Sensor Suhu

Langkah pertama yang dilakukan yaitu menyiapakan sampel berupa air


panas. Alat ukur termometer akan menampilkan data dalam satuan derajat
celcius (0C). Data hasil pengambilan sampel menggunakan air panas
ditunjukkan pada tabel berikut.

Tabel 3.7 Data Kalibrasi Sensor Suhu


Sensor Sensor
Termometer Suhu Termometer Suhu
Pengujian Pengujian
(0C) 0
DS18B20 ( C) DS18B20
(0C) (0C)
1 26 26,45 16 61 61,69
2 26 26,23 17 61 61,48
38

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

Pengambilan data dilakukan dengan 29 pengulangan menggunakan termometer


sebagai alat pembanding. Pengulangan sebanyak 30 kali memberikan kualitas
suhu rata-rata sesuai dengan alat pembanding yang digunnakan.
Tabel 3.8 Data Perhitungan Error
Pembacaan Pembacaan
Error
Sensor Thermo
26.41 26.45 15%
26.32 26.23 34%
26.03 26 12%
25.9 25.88 8%
25.42 25.44 8%
25.17 25.12 20%
24.58 24.62 16%
24.37 24.32 21%
24.21 24.2 4%
39

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.

3.7.4 Pengujian sensor flow


Pengujian sensor Flow dibutuhkan air yang mengalir untuk menggerakan
kipas yang ada di dalam sensor Flow.Sensor flow mengukur deras arus air melalui
berapa putaran kipas yang dihasilkan oleh air yang mengalir. Semakin deras kuat
arus air akan semakin cepat kipas sensor fow berputar.

Gambar 3.10 Pengujian Sensor Flow


Langkah pertama mengukur menggunakan sensor flow ialah memutar
kipas yang yang ada di dalam sensor flow menggunakan air yang mengalir atau
dapat mengalirkan air melalui selang. Sehingga air yang melewati sensor flow
akan memutar kan kipas dan mendapat data dari berapa cepat putaran kipas yang
dihasilkan oleh air yang mengalir.
40

Tabel 3.9 Pengujian Sensor Flow


Ambang Sensor Ambang Sensor
Batas Flow Batas Flow
200 120.65 200 104.02
200 110.24 200 155.42
200 111.28 200 104.12
200 112.12 200 118.16
200 113.25 200 124.56
200 120.98 200 111.12
200 124.23 200 101.98
Pengambilan data dilakukan dengan 7 pengulangan menggunakan sensor
flow untuk memastikan sensor flow bekerja dengan baik. Pengulangan sebanyak 7
kali memberikan variasi data yang dihasilkan oleh sensor flow yang membuat
data semakin akurat.
BAB IV
HASIL DAN PEMBAHASAN
Bab 4 berisi tentang pembahasan secara keseluruhan dari hasil desain dan
perancangan alat dan sistem serta membahasa hasil pengujian sistem yang telah
dilakukan. Adapun tujuan pengujian sistem adalah untuk mengetahui sistem yang
dirancang dapat berfungsi dan bekerja sesuai dengan perencanaan pada “SISTEM
MONITORING KEADAAN AIR PADA TEMPAT WISATA COBAN PUTRI
BERBASIS FIREBASE DAN ANDROID”. Pada perencanaan ini akan dijelaskan
mengenai gambaran sistem komunikasi pada pembacaan pada setiap node yang
akan dibuat.
4.1 Hasil pembuatan APK berdasarkan firebase
Hasil pembuatan sistem output digunakan untuk menampilkan data dari
node monitoring yang telah diolah kedalam database firebase. Tampilan database
dari firebase bisa dilihat pada Gambar 4.1.

Gambar 4.1 Tampilan Database untuk Firebase

Setelah firebase untuk database telah dibuat, dibuat aplikasi untuk


menampilkan data yang ada pada database. Tampilan aplikasi yang dibuat terlihat
pada Gambar 4.2.Pada tampilan ada status nilai pH, nilai kekeruhan dalam persen,
nilai arus, dan nilai suhu air saat itu.Selain tampilan nilai monitoring juga ada

41
42

notifikasi untuk menentukan kondisi air saat itu baik atau tidak untuk dikunjung.

Gambar 4.2 Hasil Pembuatan Sistem Output pada Aplikasi


43

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

Tabel 4.2 Pengujian Hari Pertama Pukul 10.00 WIB


Kekeruhan Flow Suhu Waktu
No. pH Status
(%) (ml/s) (OC) (Second)
1 5.1 % 100.13 7.01 18.32 10 Aman
2 4.7 % 95.60 7.03 18.24 20 Aman
3 4.9 % 100.32 7.02 18.07 30 Aman
4 5.6 % 96.14 7.01 18.31 40 Aman
44

Kekeruhan Flow Suhu Waktu


No. pH Status
(%) (ml/s) (OC) (Second)
5 5.4 % 99.30 7.02 18.23 50 Aman
6 5.5 % 92.23 7.01 18.54 60 Aman

Tabel 4.3 Pengujian Hari Kedua Pukul 07.00 WIB


Kekeruhan Flow Suhu Waktu
No. pH Status
(%) (ml/s) (OC) (Second)
1 0.3 % 153.09 7.33 15.33 10 Aman
2 0.8 % 152.64 7.06 15.31 20 Aman
3 0.4 % 151.32 7.21 15.36 30 Aman
4 0.6 % 152.41 7.08 15.34 40 Aman
5 0.8 % 154.4 7.08 15.35 50 Aman
6 0.9 % 151.3 7.11 15.33 60 Aman

Tabel 4.4 Pengujian Hari Kedua Pukul 10.00 WIB


Kekeruhan Flow Suhu Waktu
No. pH Status
(%) (ml/s) (OC) (Second)
1 6.3 % 100.23 6.99 18.21 10 Aman
2 5.2 % 100.40 6.98 18.23 20 Aman
3 5.9 % 100.52 6.99 18.17 30 Aman
4 5.8 % 100.32 7.01 18.15 40 Aman
5 5.8 % 100.21 7.01 18.22 50 Aman
6 5.9 % 100.23 7.01 18.24 60 Aman
Setelah pengujian dilakukan, kemudian dilakukan analisa per parameter
yang diuji. Yang pertama adalah Tabel 4.5 untuk nilai kekeruhannya.jadi akan
dibandingkan nilai per ujicoba. Perbandinganya terlihat dibawah ini:
Tabel 4.5 Perbandingan Nilai Keruh Air
Kekeruhan
Waktu
1 2 3 4
10 0.50% 5.10% 0.30% 6.30%
20 0.70% 4.70% 0.80% 5.20%
45

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%

Grafik Perbandingan Kekeruhan


7.00%

6.00%

5.00%
Persen Kekeruhan

07 Pagi Hari Pertama


4.00%
10 Pagi Hari Pertama
3.00% 07 Pagi Hari Kedua
10 Pagi Hari Kedua
2.00%

1.00%

0.00%
10 20 30 40 50 60

Gambar 4.3 Grafik Perbandingan Suhu

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).Dari tabel diatas bisa dilihat bahwa
kondisi air paling bersih terjadi pada jam 7 pagi baik hari pertama dan kedua
dimana nilai terendahnya 0.5 % hari pertama dan 0.3 % hari kedua.Paling keruh
1.2 % untuk jam 7 pagi hari pertama dan 0.9 % untuk hari kedua. Sementara
untuk jam 10 hari pertama memiliki nilai keruh terkecil 4.7 % dan terbesar 5.6 %.
Untuk jam 10 hari kedua memiliki nilai keruh terkecil 5.2 % dan terbesar 6.3 %.
Penjelasan berikutnya adalah perbandingan data sensor flow yangakan
ditampilkan pada tabel 4.6. 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
46

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

Grafik Perbandingan flow


180
160
140
120
07 Pagi Hari Pertama
Arus ml/s

100
10 Pagi Hari Pertama
80
07 Pagi Hari Kedua
60 10 Pagi Hari Kedua
40
20
0
10 20 30 40 50 60

Gambar 4.4 Grafik Perbandingan Flow

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

Penjelasan berikutnya adalah perbandingan data sensor pH yangakan


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.7 Perbandingan Nilai pH
Nilai pH
Waktu
1 2 3 4
10 7.13 7.01 7.33 6.99
20 7.16 7.03 7.06 6.98
30 7.38 7.02 7.21 6.99
40 7.08 7.01 7.08 7.01
50 6.98 7.02 7.08 7.01
60 7.12 7.01 7.11 7.01

Grafik Perbandingan pH
7.5

7.4

7.3

7.2 07 Pagi Hari Pertama


Nilai pH

7.1 10 Pagi Hari Pertama

7 07 Pagi Hari Kedua


10 Pagi Hari Kedua
6.9

6.8

6.7
10 20 30 40 50 60

Gambar 4.5 Grafik Perbandingan pH

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

Grafik Perbandingan Suhu


20
18
16
14
Suhu (Celcius)

12 07 Pagi Hari Pertama

10 10 Pagi Hari Pertama


8 07 Pagi Hari Kedua
6 10 Pagi Hari Kedua
4
2
0
10 20 30 40 50 60

Gambar 4.6 Grafik Perbandingan Suhu

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

Single chip 2.4 GHz Transceiver nRF24L01


FEATURES APPLICATIONS

• True single chip GFSK transceiver • Wireless mouse, keyboard, joystick


• Complete OSI Link Layer in hardware • Keyless entry
• Enhanced ShockBurst™ • Wireless data communication
• Auto ACK & retransmit • Alarm and security systems
• Address and CRC computation • Home automation
• On the air data rate 1 or 2Mbps • Surveillance
• Digital interface (SPI) speed 0-8 Mbps • Automotive
• 125 RF channel operation • Telemetry
• Short switching time enable frequency hopping • Intelligent sports equipment
• Fully RF compatible with nRF24XX • Industrial sensors
• 5V tolerant signal input pads • Toys
• 20-pin package (QFN20 4x4mm)
• Uses ultra low cost +/- 60 ppm crystal
• Uses low cost chip inductors and 2-layer PCB
• Power supply range: 1.9 to 3.6 V

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.

QUICK REFERENCE DATA


Parameter Value Unit
Minimum supply voltage 1.9 V
Maximum output power 0 dBm
Maximum data rate 2000 kbps
Supply current in TX mode @ 0dBm output power 11.3 mA
Supply current in RX mode @ 2000 kbps 12.3 mA
Temperature range -40 to +85 °C
Sensitivity @ 1000 kbps -85 dBm
Supply current in Power Down mode 900 nA

Table 1 nRF24L01 quick reference data

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Type Number Description Version


nRF24L01 20 pin QFN 4x4, RoHS & SS-00259 compliant D
nRF24L01 IC Bare Dice D
nRF24L01-EVKIT Evaluation kit (2 test PCB, 2 configuration PCB, SW) 1.0

Table 2 nRF24L01 ordering information

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Ω

Figure 1 nRF24L01 with external components.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

PIN FUNCTIONS

Pin Name Pin function Description


1 CE Digital Input Chip Enable Activates RX or TX mode
2 CSN Digital Input SPI Chip Select
3 SCK Digital Input SPI Clock
4 MOSI Digital Input SPI Slave Data Input
5 MISO Digital Output SPI Slave Data Output, with tri-state option
6 IRQ Digital Output Maskable interrupt pin
7 VDD Power Power Supply (+3V DC)
8 VSS Power Ground (0V)
9 XC2 Analog Output Crystal Pin 2
10 XC1 Analog Input Crystal Pin 1
11 VDD_PA Power Output Power Supply (+1.8V) to Power Amplifier
12 ANT1 RF Antenna interface 1
13 ANT2 RF Antenna interface 2
14 VSS Power Ground (0V)
15 VDD Power Power Supply (+3V DC)
16 IREF Analog Input Reference current
17 VSS Power Ground (0V)
18 VDD Power Power Supply (+3V DC)
19 DVDD Power Output Positive Digital Supply output for de-coupling purposes
20 VSS Power Ground (0V)

Table 3 nRF24L01 pin function

PIN ASSIGNMENT

VSS DVDD VDD VSS IREF

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

Digital input pin


1
VIH HIGH level input voltage 0.7VDD 5.25 V
VIL LOW level input voltage VSS 0.3VDD V

Digital output pin


VOH HIGH level output voltage (IOH=-0.25mA) VDD- 0.3 VDD V
VOL LOW level output voltage (IOL=0.25mA) VSS 0.3 V

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Package Type A A1 A3 K D/E e D2/E2 L L1 b


Saw QFN20 Min 0.80 0.00 2.50 0.35 0.18
(4x4 mm) Typ. 0.85 0.02 0.20 0.20 4.0 BSC13 0.5 BSC 2.60 0.40 0.15 0.25
Max 0.95 0.05 REF. min 2.70 0.45 max 0.30

Figure 3 nRF24L01 Package Outline.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

Absolute Maximum Ratings


Supply voltages
VDD............................- 0.3V to + 3.6V
VSS .................................................. 0V
Input voltage
VI .................................. - 0.3V to 5.25V
Output voltage
VO ..................................... VSS to VDD

Total Power Dissipation


PD (TA=85°C) ............................. 60mW

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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 - - -

Table 6 nRF24L01 main modes

An overview of the nRF24L01 I/O pins in different modes is given in Table 7.

Pin functions in the different modes of nRF24L01

Pin Name Direction TX Mode RX Mode Standby Modes Power Down


CE Input High Pulse >10µs High Low -
CSN Input SPI Chip Select, active low
SCK Input SPI Clock
MOSI Input SPI Serial Input
MISO Tri-state SPI Serial Output
Output
IRQ Output Interrupt, active low

Table 7 Pin functions of the nRF24L01

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.

Power Down Mode


In power down nRF24L01 is disabled with minimal current consumption. When
entering this mode the device is not active, but all registers values available from the
SPI interface are maintained during power down and the SPI interface may be
activated (CSN=0). For start up time see Table 13. The power down is controlled by
the PWR_UP bit in the CONFIG register.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Packet Handling Methods


nRF24L01 has the following Packet Handling Methods:
• ShockBurst™ (compatible with nRF2401, nRF24E1, nRF2402 and nRF24E2
with 1Mbps data rate, see page 26)
• Enhanced ShockBurst™

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

Figure 4: nRF24L01 in a star network configuration

An nRF24L01 configured as primary RX (PRX) will be able to receive data trough 6


different data pipes, see Figure 4. A data pipe will have a unique address but share the
same frequency channel. This means that up to 6 different nRF24L01 configured as
primary TX (PTX) can communicate with one nRF24L01 configured as PRX, and the
nRF24L01 configured as PRX will be able to distinguish between them. Data pipe 0
has a unique 40 bit configurable address. Each of data pipe 1-5 has an 8 bit unique
address and shares the 32 most significant address bits. All data pipes can perform full
Enhanced ShockBurst™ functionality.
nRF24L01 will use the data pipe address when acknowledging a received packet. This
means that nRF24L01 will transmit ACK with the same address as it receives payload
at. In the PTX device data pipe 0 is used to received the acknowledgement, and
therefore the receive address for data pipe 0 has to be equal to the transmit address to
be able to receive the acknowledgement. See Figure 5 for addressing example.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Figure 5: Example on how the acknowledgement addressing is done

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.

With Enhanced ShockBurst™ nRF24L01 offers the following benefits:


• Highly reduced current consumption due to short time on air and sharp timing
when operating with acknowledgement traffic
• Lower system cost. Since the nRF24L01 handles all the high-speed link layer
operations, like re-transmission of lost packet and generating
acknowledgement to received packets, it is no need for hardware SPI on the
system microcontroller to interface the nRF24L01. The interface can be done
by using general purpose IO pins on a low cost microcontroller where the SPI
is emulated in firmware. With the nRF24L01 this will be sufficient speed even
when running a bi-directional link.
• Greatly reduced risk of “on-air” collisions due to short time on air
• Easier firmware development since the link layer is integrated on chip

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Enhanced ShockBurst™ Transmitting Payload:


1. The configuration bit PRIM_RX has to be low.
2. When the application MCU has data to send, the address for receiving node
(TX_ADDR) and payload data (TX_PLD) has to be clocked into nRF24L01 via
the SPI interface. The width of TX-payload is counted from number of bytes
written into the TX FIFO from the MCU. TX_PLD must be written continuously
while holding CSN low. TX_ADDR does not have to be rewritten if it is
unchanged from last transmit. If the PTX device shall receive acknowledge, data
pipe 0 has to be configured to receive the acknowledgement. The receive address
for data pipe 0 (RX_ADDR_P0) has to be equal to the transmit address
(TX_ADDR) in the PTX device. For the example in Figure 5 the following
address settings have to be performed for the TX5 device and the RX device:
TX5 device: TX_ADDR = 0xB3B4B5B605
TX5 device: RX_ADDR_P0 = 0xB3B4B5B605
RX device: RX_ADDR_P5 = 0xB3B4B5B605
3. A high pulse on CE starts the transmission. The minimum pulse width on CE is 10 µs.
4. nRF24L01 ShockBurst™:
• Radio is powered up
• 16 MHz internal clock is started.
• RF packet is completed (see the packet description)
• Data is transmitted at high speed (1 Mbps or 2 Mbps configured by MCU).
5. If auto acknowledgement is activated (ENAA_P0=1) the radio goes into RX mode
immediately. If a valid packet has been received in the valid acknowledgement
time window, the transmission is considered a success. The TX_DS bit in the
status register is set high and the payload is removed from TX FIFO. If a valid
acknowledgement is not received in the specified time window, the payload is
resent (if auto retransmit is enabled). If the auto retransmit counter (ARC_CNT)
exceeds the programmed maximum limit (ARC), the MAX_RT bit in the status
register is set high. The payload in TX FIFO is NOT removed. The IRQ pin will
be active when MAX_RT or TX_DS is high. To turn off the IRQ pin, the interrupt
source must be reset by writing to the status register (see Interrupt chapter). If no
acknowledgement is received for a packet after the maximum number of retries,
no further packets can be sent before the MAX_RX interrupt is cleared. The
packet loss counter (PLOS_CNT) is incremented at each MAX_RT interrupt. I.e.
ARC_CNT counts the number of retries that was required to get a single packet
through. PLOS_CNT counts the number of packets that did not get through after
maximum number of retries.
6. The device goes into Standby-I mode if CE is low. Otherwise next payload in TX
FIFO will be sent. If TX FIFO is empty and CE is still high, the device will enter
Standby-II mode.
7. If the device is in Standby-II mode, it will go to Standby-I mode immediately if
CE is set low.

Enhanced ShockBurstTM Receive Payload:


1. RX is selected by setting the PRIM_RX bit in the configuration register to high.
All data pipes that shall receive data must be enabled (EN_RXADDR register),

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

auto acknowledgement for all pipes running Enhanced ShockBurst™ has to be


enabled (EN_AA register), and the correct payload widths must be set
(RX_PW_Px registers). Addresses have to be set up as described in item 2 in the
Enhanced ShockBurst™ transmit payload chapter above.
2. Active RX mode is started by setting CE high.
3. After 130µs nRF24L01 is monitoring the air for incoming communication.
4. When a valid packet has been received (matching address and correct CRC), the
payload is stored in the RX-FIFO, and the RX_DR bit in status register is set high.
The IRQ pin will be active when RX_DR is high. RX_P_NO in status register will
indicate what data pipe the payload has been received in.
5. If auto acknowledgement is enabled, an acknowledgement is sent back.
6. MCU sets the CE pin low to enter Standby-I mode (low current mode).
7. MCU can clock out the payload data at a suitable rate via the SPI interface.
8. The device is now ready for entering TX or RX mode or power down mode.

Two way communication with payload in both directions


If payload shall be sent in both directions, the PRIM_RX register must be toggled by
redefining the device from PRX to PTX or vice versa. The controlling processors
must handle the synchronicity between a PTX and a PRX. Data buffering in both RX
FIFO and TX FIFO simultaneously is possible, but restricted to data pipes 1 to 5. The
third level in TX FIFO shall only be written in RX, TX or Standby-II mode if data is
stored in RX FIFO

Auto Acknowledgement (RX)


The auto acknowledgement function reduces the load of the external microcontroller,
and may remove the need for dedicated SPI hardware in a mouse/keyboard or
comparable systems, and hence reduce cost and average current consumption. Auto
acknowledgement can be configured individually for each data pipe via the SPI
interface.

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.

Auto Re-Transmission (ART) (TX)


An auto retransmission function is available. It will be used at the TX side in an auto
acknowledgement system. In the SETUP_RETR register it will be possible to state
how many times the data in the data register will be resent if data is not
acknowledged. After each sending, the device will enter RX mode and wait a
specified time period for acknowledgement. When the acknowledgement packet is
received, the device will return to normal transmit function. If there is no more unsent
data in the TX FIFO and the CE pin is low, the device will go into Standby-I mode. If
the acknowledgement is not received, the device will go back to TX mode and resend
the data. This will continue until acknowledgment is received, or a time out occurs

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

(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.

Packet Identity (PID) and CRC used by Enhanced ShockBurstTM


Each packet contains a two bit wide PID field to detect if the received packet is new
or resent. The PID will prevent that the PRX device presents the same payload more
than once to the microcontroller. This PID field is incremented at the TX side for each
new packet received via the SPI interface. The PID and CRC field is used by the PRX
device to determine whether a packet is resent or new. When several data is lost on
the link, the PID fields may in some cases become equal to last received PID. If a
packet has the same PID as the previous packet, nRF24L01 will compare the CRC
sums from both packets. If they also are equal, the last received packet is considered
as a copy of the previous and is discarded.

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

New packet PID equal CRC equal


Yes Yes
from MCU? last PID? last CRC?

increment PID Yes


No
No

No

New packet is Discard packet


valid for MCU as a copy

End

End

Figure 6 PID generation/detection

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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.

Stationary Disturbance Detection – CD


Carrier Detect (CD) is set high when an in-band RF signal is detected in RX mode,
otherwise CD is low. The internal CD signal is filtered before presented to CD
register. The internal CD signal must be high for at least 128µs.
In Enhanced ShockBurst™ it is recommended to use the Carrier Detect functionality
only when the PTX device does not succeed to get packets through, as indicated by
the MAX_RT interrupt for single packets and by the packet loss counter
(PLOS_CNT) if several packets are lost. If the PLOS_CNT in the PTX device
indicates to high rate of packet losses, the device can be configured to a PRX device
for a short time (Tstbt2a + CD-filter delay = 130µs+128µs = 258µs) to check CD. If CD
was high (jam situation), the frequency channel should be changed. If CD was low
(out of range), it may continue on the same frequency channel, but perform other
adjustments. (A dummy write to the RF_CH will clear the PLOS_CNT.)

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Byte 4 Byte 3 Byte 2 Byte 1 Byte 0

Data pipe 0 (RX_ADDR_P0) 0xE7 0xD3 0xF0 0x35 0x77

Data pipe 1 (RX_ADDR_P1) 0xC2 0xC2 0xC2 0xC2 0xC2

Data pipe 2 (RX_ADDR_P2) 0xC2 0xC2 0xC2 0xC2 0xC3

Data pipe 3 (RX_ADDR_P3) 0xC2 0xC2 0xC2 0xC2 0xC4

Data pipe 4 (RX_ADDR_P4) 0xC2 0xC2 0xC2 0xC2 0xC5

Data pipe 5 (RX_ADDR_P5) 0xC2 0xC2 0xC2 0xC2 0xC6

Figure 7: Addressing data pipes 0-5


When a packet has been received at one of the data pipes and the data pipe is setup to
generate acknowledgement, nRF24L01 will generate an acknowledgement with an
address that equals the data pipe address where the packet was received.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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.

SPI Instruction Set


The available commands to be used on the SPI interface are shown below. Whenever
CSN is set low the interface expects an instruction. Every new instruction must be
started by a high to low transition on CSN.

In parallel to the SPI instruction word applied on the MOSI pin, the STATUS register
is shifted serially out on the MISO pin.

The serial shifting SPI commands is on the format:


<Instruction word: MSBit to LSBit (one byte)>
<Data bytes: LSByte to MSByte, MSBit in each byte first>
See Figure 8 and Figure 9.

Instruction Name Instruction # Data Operation


Format Bytes
[binary]
R_REGISTER 000A AAAA 1 to 5 Read registers. AAAAA = 5 bit Memory Map Address
LSByte first
W_REGISTER 001A AAAA 1 to 5 Write registers. AAAAA = 5 bit Memory Map Address
LSByte first Executable in power down or standby modes only.
R_RX_PAYLOAD 0110 0001 1 to 32 Read RX-payload: 1 – 32 bytes. A read operation will
LSByte first always start at byte 0. Payload will be deleted from FIFO
after it is read. Used in RX mode.
W_TX_PAYLOAD 1010 0000 1 to 32 Used in TX mode.
LSByte first Write TX-payload: 1 – 32 bytes. A write operation will
always start at byte 0.
FLUSH_TX 1110 0001 0 Flush TX FIFO, used in TX mode
FLUSH_RX 1110 0010 0 Flush RX FIFO, used in RX mode
Should not be executed during transmission of
acknowledge, i.e. acknowledge package will not be
completed.
REUSE_TX_PL 1110 0011 0 Used for a PTX device
Reuse last sent payload. Packets will be repeatedly resent
as long as CE is high.
TX payload reuse is active until W_TX_PAYLOAD or
FLUSH TX is executed. TX payload reuse must not be
activated or deactivated during package transmission
NOP 1111 1111 0 No Operation. Might be used to read the STATUS register
Table 8 Instruction set for the nRF24L01 SPI interface.
The W_REGISTER and R_REGISTER may operate on single or multi-byte registers.
When accessing multi-byte registers one will read or write MSBit of LSByte first. The

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

Figure 8 SPI read operation.

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

Figure 9 SPI write operation.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Tcwh
CSN

Tcc Tch Tcl Tcch


SCK

Tdh
Tdc
MOSI C7 C6 C0

Tcsd Tcd Tcdz


MISO S7 S0

Figure 10 SPI NOP timing diagram.

PARAMETER SYMBOL MIN MAX UNITS


Data to SCK Setup Tdc 2 ns
SCK to Data Hold Tdh 2 ns
CSN to Data Valid Tcsd 38 ns
SCK to Data Valid Tcd 55 ns
SCK Low Time Tcl 40 ns
SCK High Time Tch 40 ns
SCK Frequency Fsck 0 8 MHz
SCK Rise and Fall Tr,Tf 100 ns
CSN to SCK Setup Tcc 2 ns
SCK to CSN Hold Tcch 2 ns
CSN Inactive time Tcwh 50 ns
CSN to Output High Z Tcdz 38 ns

Table 9 SPI timing parameters (CLoad = 5pF).

PARAMETER SYMBOL MIN MAX UNITS


Data to SCK Setup Tdc 2 ns
SCK to Data Hold Tdh 2 ns
CSN to Data Valid Tcsd 42 ns
SCK to Data Valid Tcd 58 ns
SCK Low Time Tcl 40 ns
SCK High Time Tch 40 ns
SCK Frequency Fsck 0 8 MHz
SCK Rise and Fall Tr,Tf 100 ns
CSN to SCK Setup Tcc 2 ns
SCK to CSN Hold Tcch 2 ns
CSN Inactive time Tcwh 50 ns
CSN to Output High Z Tcdz 42 ns

Table 10 SPI timing parameters (CLoad = 10pF).

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

00 CONFIG Configuration Register


Reserved 7 0 R/W Only '0' allowed
MASK_RX_DR 6 0 R/W Mask interrupt caused by RX_DR
1: Interrupt not reflected on the IRQ pin
0: Reflect RX_DR as active low interrupt
on the IRQ pin
MASK_TX_DS 5 0 R/W Mask interrupt caused by TX_DS
1: Interrupt not reflected on the IRQ pin
0: Reflect TX_DS as active low interrupt
on the IRQ pin
MASK_MAX_RT 4 0 R/W Mask interrupt caused by MAX_RT
1: Interrupt not reflected on the IRQ pin
0: Reflect MAX_RT as active low
interrupt on the IRQ pin
EN_CRC 3 1 R/W Enable CRC. Forced high if one of the
bits in the EN_AA is high
CRCO 2 0 R/W CRC encoding scheme
'0' - 1 byte
'1' – 2 bytes
PWR_UP 1 0 R/W 1: POWER UP, 0:POWER DOWN
PRIM_RX 0 0 R/W 1: PRX, 0: PTX

01 EN_AA Enable ‘Auto Acknowledgment’ Function


Enhanced Disable this functionality to be
ShockBurst™ compatible with nRF2401, see page 26
Reserved 7:6 00 R/W Only '00' allowed
ENAA_P5 5 1 R/W Enable auto ack. data pipe 5
ENAA_P4 4 1 R/W Enable auto ack. data pipe 4
ENAA_P3 3 1 R/W Enable auto ack. data pipe 3
ENAA_P2 2 1 R/W Enable auto ack. data pipe 2
ENAA_P1 1 1 R/W Enable auto ack. data pipe 1
ENAA_P0 0 1 R/W Enable auto ack. data pipe 0

02 EN_RXADDR Enabled RX Addresses


Reserved 7:6 00 R/W Only '00' allowed
ERX _P5 5 0 R/W Enable data pipe 5.
ERX _P4 4 0 R/W Enable data pipe 4.
ERX _P3 3 0 R/W Enable data pipe 3.
ERX _P2 2 0 R/W Enable data pipe 2.
ERX _P1 1 1 R/W Enable data pipe 1.
ERX _P0 0 1 R/W Enable data pipe 0.

03 SETUP_AW Setup of Address Widths


(common for all data pipes)
Reserved 7:2 000000 R/W Only '000000' allowed
AW 1:0 11 R/W RX/TX Address field width
'00' - Illegal
'01' - 3 bytes
'10' - 4 bytes
'11' – 5 bytes
LSByte will be used if address width
below 5 bytes

04 SETUP_RETR Setup of Automatic Retransmission


ARD 7:4 0000 R/W Auto Re-transmit Delay
‘0000’ – Wait 250+86uS

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Address Mnemonic Bit Reset Type Description


(Hex) Value
‘0001’ – Wait 500+86uS
‘0010’ – Wait 750+86uS
……..
‘1111’ – Wait 4000+86uS
(Delay defined from end of transmission
to start of next transmission)14

ARC 3:0 0011 R/W Auto Retransmit Count


‘0000’ –Re-Transmit disabled
‘0001’ – Up to 1 Re-Transmit
on fail of AA
……
‘1111’ – Up to 15 Re-Transmit
on fail of AA

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

06 RF_SETUP RF Setup Register


Reserved 7:5 000 R/W Only '000' allowed
PLL_LOCK 4 0 R/W Force PLL lock signal. Only used in test
RF_DR 3 1 R/W Data Rate
‘0’ – 1 Mbps
‘1’ – 2 Mbps
RF_PWR 2:1 11 R/W Set RF output power in TX mode
'00' – -18 dBm
'01' – -12 dBm
'10' – -6 dBm
'11' – 0 dBm
LNA_HCURR 0 1 R/W Setup LNA gain

07 STATUS Status Register (In parallel to the SPI


instruction word applied on the MOSI
pin, the STATUS register is shifted
serially out on the MISO pin)
Reserved 7 0 R/W Only '0' allowed
RX_DR 6 0 R/W Data Ready RX FIFO interrupt. Set high
when new data arrives RX FIFO15.
Write 1 to clear bit.
TX_DS 5 0 R/W Data Sent TX FIFO interrupt. Set high
when packet sent on TX. If AUTO_ACK
is activated, this bit will be set high only
when ACK is received.
Write 1 to clear bit.
MAX_RT 4 0 R/W Maximum number of TX retries interrupt
Write 1 to clear bit. If MAX_RT is
set it must be cleared to enable
further communication.
RX_P_NO 3:1 111 R Data pipe number for the payload

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Address Mnemonic Bit Reset Type Description


(Hex) Value
available for reading from RX_FIFO
000-101: Data Pipe Number
110: Not Used
111: RX FIFO Empty
TX_FULL 0 0 R TX FIFO full flag. 1: TX FIFO full. 0:
Available locations in TX FIFO.

08 OBSERVE_TX Transmit observe register


PLOS_CNT 7:4 0 R Count lost packets. The counter is
overflow protected to 15, and discontinue
at max until reset. The counter is reset by
writing to RF_CH. See page 14 and 17.
ARC_CNT 3:0 0 R Count resent packets. The counter is reset
when transmission of a new packet starts.
See page 14.

09 CD
Reserved 7:1 000000 R
CD 0 0 R Carrier Detect. See page 17.

0A RX_ADDR_P0 39:0 0xE7E7E7E7E7 R/W Receive address data pipe 0. 5 Bytes


maximum length. (LSByte is written first.
Write the number of bytes defined by
SETUP_AW)
0B RX_ADDR_P1 39:0 0xC2C2C2C2C2 R/W Receive address data pipe 1. 5 Bytes
maximum length. (LSByte is written first.
Write the number of bytes defined by
SETUP_AW)
0C RX_ADDR_P2 7:0 0xC3 R/W Receive address data pipe 2. Only LSB.
MSBytes will be equal to
RX_ADDR_P1[39:8]
0D RX_ADDR_P3 7:0 0xC4 R/W Receive address data pipe 3. Only LSB.
MSBytes will be equal to
RX_ADDR_P1[39:8]
0E RX_ADDR_P4 7:0 0xC5 R/W Receive address data pipe 4. Only LSB.
MSBytes will be equal to
RX_ADDR_P1[39:8]
0F RX_ADDR_P5 7:0 0xC6 R/W Receive address data pipe 5. Only LSB.
MSBytes will be equal to
RX_ADDR_P1[39:8]

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Address Mnemonic Bit Reset Type Description


(Hex) Value
1 = 1 byte

32 = 32 bytes

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

17 FIFO_STATUS FIFO Status Register


Reserved 7 0 R/W Only '0' allowed
TX_REUSE 6 0 R Reuse last sent data packet if set high.
The packet will be repeatedly resent as
long as CE is high. TX_REUSE is set by
the SPI instruction REUSE_TX_PL, and
is reset by the SPI instructions
W_TX_PAYLOAD or FLUSH TX
TX_FULL 5 0 R TX FIFO full flag. 1: TX FIFO full. 0:
Available locations in TX FIFO.
TX_EMPTY 4 1 R TX FIFO empty flag. 1: TX FIFO empty.
0: Data in TX FIFO.
Reserved 3:2 00 R/W Only '00' allowed
RX_FULL 1 0 R RX FIFO full flag. 1: RX FIFO full. 0:
Available locations in RX FIFO.
RX_EMPTY 0 1 R RX FIFO empty flag. 1: RX FIFO empty.
0: Data in RX FIFO.
N/A TX_PLD 255:0 X W Written by separate SPI command TX
data payload register 1 - 32 bytes.
This register is implemented as a FIFO
with 3 levels. Used in TX mode only
N/A RX_PLD 255:0 X R Written by separate SPI command
RX data payload register. 1 - 32 bytes.
This register is implemented as a FIFO

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Address Mnemonic Bit Reset Type Description


(Hex) Value
with 3 levels.
All receive channels share the same FIFO

Table 11 Memory map of nRF24L01

Configuration for compatibility with nRF24XX


How to setup nRF24L01 to receive from an nRF2401/nRF2402/nRF24E1/nRF24E2:
• Use same CRC configuration as the nRF2401/nRF2402/nRF24E1/nRF24E2
uses
• Set the PRIM_RX bit to 1
• Disable auto acknowledgement on the data pipe that will be addressed
• Use the same address width as the PTX device
• Use the same frequency channel as the PTX device
• Select data rate 1Mbit/s on both nRF24L01 and
nRF2401/nRF2402/nRF24E1/nRF24E2
• Set correct payload width on the data pipe that will be addressed
• Set PWR_UP and CE high

How to setup nRF24L01 to transmit to an nRF2401/nRF24E1:


• Use same CRC configuration as the nRF2401/nRF2402/nRF24E1/nRF24E2
uses
• Set the PRIM_RX bit to 0
• Set the Auto Retransmit Count to 0 to disable the auto retransmit functionality
• Use the same address width as the nRF2401/nRF2402/nRF24E1/nRF24E2
uses
• Use the same frequency channel as the
nRF2401/nRF2402/nRF24E1/nRF24E2 uses
• Select data rate 1Mbit/s on both nRF24L01 and
nRF2401/nRF2402/nRF24E1/nRF24E2
• Set PWR_UP high
• Clock in a payload that has the same length as the
nRF2401/nRF2402/nRF24E1/nRF24E2 is configured to receive
• Pulse CE to send the packet

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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.

A ShockBurst™ packet compatible to nRF2401/nRF2402/nRF24E1/nRF24E2 devices.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

IMPORTANT TIMING DATA


The following timing applies for operation of nRF24L01.

nRF24L01 Timing Information

nRF24L01 timing Max. Min. Name


Power Down Î Standby mode 1.5ms Tpd2stby
Standby modes Î TX/RX mode 130µs Tstby2a
Minimum CE high 10µs Thce
Delay from CE pos. edge to CSN low 4µs Tpece2csn

Table 13 Operational timing of nRF24L01

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.

Enhanced ShockBurst™ timing


0us 250us

1 2
1 byte payload with ACK (339 us )
ESB cycle

CE high minimum 10 us
PTX: CE

PTX: IRQ (TX_DS)

2 us
PTX: Mode STBY I TX RX TX

Payload (33 us + 4 us /byte) 5 us


128 us ACK (33 us)
Antenna 1 0

PRX: CE

5 us SPI: IRQ Clear


PRX: IRQ (RX_DR)

128 us
PRX: Mode STBY I RX TX RX

Packet:
A ddress : 5 by tes
CRC: 1 by te
Payload: 1 by te

Figure 11 Timing of Enhanced ShockBurst™ for one packet upload (2Mbps).

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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.

Output Power adjustment


SPI RF-SETUP RF output power DC current
(RF_PWR) consumption
11 0 dBm 11.3 mA
10 -6 dBm 9.0 mA
01 -12 dBm 7.5 mA
00 -18 dBm 7.0 mA
Conditions: VDD = 3.0V, VSS = 0V, TA = 27ºC, Load impedance = 15Ω+j88Ω.

Table 14 RF output power setting for the nRF24L01.

Crystal Specification
Frequency accuracy includes initial accuracy (tolerance) and stability over
temperature and aging.

Frequency CL ESR max C0max Frequency accuracy


16MHz 8 – 16 pF 100 Ω 7.0pF ±60ppm

Table 15 Crystal specification of the nRF24L01

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.

The crystal load capacitance, CL, is given by:

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

nRF24L01 sharing crystal with a micro controller.


When using a micro controller to drive the crystal reference input XC1 of the
nRF24L01 transceiver some rules must be followed.

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.

Input crystal amplitude & Current consumption


The input signal should not have amplitudes exceeding any rail voltage, but any DC-
voltage within this is OK. Exceeding rail voltage will excite the ESD structure and the
radio performance is degraded below specification. If testing the nRF24L01 with a RF
source with no DC offset as the reference source, the input signal will go below the
ground level, which is not acceptable.

XO_OUT

Buffer:
Sine to
full swing

Amplitude
controlled
current source

Current starved
inverter:
XOSC core

Vdd Vdd

Vss Vss
ESD ESD

XC1 XC2

Figure 12 Principle of crystal oscillator

The nRF24L01 crystal oscillator is amplitude regulated. To achieve low current


consumption and also good signal-to-noise ratio when using an external clock, it is
recommended to use an input signal larger than 0.4 V-peak. When clocked externally,
XC2 is not used and can be left as an open pin.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

PCB layout and de-coupling guidelines


A well-designed PCB is necessary to achieve good RF performance. Keep in mind
that a poor layout may lead to loss of performance, or even functionality, if due care is
not taken. A fully qualified RF-layout for the nRF24L01 and its surrounding
components, including matching networks, can be downloaded from
www.nordicsemi.no.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

Table 16 Recommended components (BOM) in nRF24L01 with antenna matching


network

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

PCB layout examples


Figure 14 shows a PCB layout example for the application schematic in Figure 13.
A double-sided FR-4 board of 1.6mm thickness is used. This PCB has a ground plane
on the bottom layer. Additionally, there are ground areas on the component side of the
board to ensure sufficient grounding of critical components. A large number of via
holes connect the top layer ground areas to the bottom layer ground plane.

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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.

Table 17. Definitions

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.

LIFE SUPPORT APPLICATIONS


These products are not designed for use in life support appliances, devices, or systems
where malfunction of these products can reasonably be expected to result in personal
injury. Nordic Semiconductor ASA customers using or selling these products for use
in such applications do so at their own risk and agree to fully indemnify Nordic
Semiconductor ASA for any damages resulting from such improper use or sale.

Preliminary Product Specification: Revision Date: 08.03.2006.

Data sheet order code: 080306-nRF24L01

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

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

nRF24L01 Single Chip 2.4 GHz Radio Transceiver

Nordic Semiconductor ASA – World Wide Distributors

For Your nearest dealer, please see http://www.nordicsemi.no

Main Office:
Vestre Rosten 81, N-7075 Tiller, Norway
Phone: +47 72 89 89 00, Fax: +47 72 89 89 89

Visit the Nordic Semiconductor ASA website at http://www.nordicsemi.no

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)
 

Analog pH Meter Kit SKU: SEN0161

Analog pH Meter Kit SKU: SEN0169

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

 Module Power: 5.00V


 Circuit Board Size: 43mm×32mm
 pH Measuring Range: 0-14
 Measuring Temperature: 0-60
 Accuracy: ± 0.1pH (25 )
 Response Time: ≤ 1min
 pH Sensor with BNC Connector
 PH2.0 Interface ( 3 foot patch )
 Gain Adjustment Potentiometer
 Power Indicator LED

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.

 Preservation: Electrode reference preservation solution is the 3N KCL solution.

 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.

NOTE: Differences between the probes, SEN0161 and SEN0169

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.

Method 1. Software Calibration

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.

For NOTE 3. Arduino sample sketch "EEPROM Clear"

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”.

7. Enter “exit” to finish calibration. You will see “Calibration


Successful,Exit Calibration Mode”.

8. Check if the pH meter was calibrated successfully with the solution pH


= 4.00, 9.18, 10.00, if the readings are within the error of 0.1. Congrats!

In Standard acid solution pH = 4.00

In Standard alkali solution pH = 10.00


Sample code: Software Calibration

/***************************************************
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>

GNU Lesser General Public License.


See <http://www.gnu.org/licenses/> for details.
All above must be included in any redistribution
****************************************************/

/***********Notice and Troubleshooting***************


1.Connection and Diagram can be found here http://www.dfrobot.co
m/wiki/index.php/PH_meter%28SKU:_SEN0161%29
2.This code is tested on Arduino Uno.
****************************************************/

#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 SlopeValueAddress 0 // (slope of the ph probe)store at


the beginning of the EEPROM. The slope is a float number,occupies
4 bytes.
#define InterceptValueAddress (SlopeValueAddress+4)
float slopeValue, interceptValue, averageVoltage;
boolean enterCalibrationFlag = 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
}

static unsigned long printTimepoint = millis();


if(millis()-printTimepoint>1000U)
{
printTimepoint = millis();
if(enterCalibrationFlag) // in calibration mode,
print the voltage to user, to watch the stability of voltage
{
Serial.print("Voltage:");
Serial.print(averageVoltage);
Serial.println("mV");
}else{
Serial.print("pH:"); // in normal mode, print th
e ph value to user
Serial.println(averageVoltage/1000.0*slopeValue+interceptValu
e);
}
}
}

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;
}

void phCalibration(byte mode)


{
char *receivedBufferPtr;
static byte acidCalibrationFinish = 0, alkaliCalibrationFinish
= 0;
static float acidValue,alkaliValue;
static float acidVoltage,alkaliVoltage;
float acidValueTemp,alkaliValueTemp,newSlopeValue,newIntercept
Value;
switch(mode)
{
case 0:
if(enterCalibrationFlag)
Serial.println(F("Command Error"));
break;

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;
}
}

int getMedianNum(int bArray[], int iFilterLen)


{
int bTab[iFilterLen];
for (byte i = 0; i<iFilterLen; i++)
{
bTab[i] = bArray[i];
}
int i, j, bTemp;
for (j = 0; j < iFilterLen - 1; j++)
{
for (i = 0; i < iFilterLen - j - 1; i++)
{
if (bTab[i] > bTab[i + 1])
{
bTemp = bTab[i];
bTab[i] = bTab[i + 1];
bTab[i + 1] = bTemp;
}
}
}
if ((iFilterLen & 1) > 0)
bTemp = bTab[(iFilterLen - 1) / 2];
else
bTemp = (bTab[iFilterLen / 2] + bTab[iFilterLen / 2 - 1]) /
2;
return bTemp;
}

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);
}
}

Method 2. Hardware Calibration through potentiometer

If you've taken the Method 1. Software Calibration, you can


ignore this part.

1. Connect according to the graphic, that is, the pH electrode is


connected to the BNC connector on the pH meter board, and
then use the connection lines, the pH meter board is connected
to the analog port 0 of the Arduino controller. When the Arduino
controller gets power, you will see the blue LED on board is on.
2. Upload the sample code to the Arduino controller.
3. Put the pH electrode into the standard solution whose pH value
is 7.00, or directly short circuit the input of the BNC connector.
Open the serial monitor of the Arduino IDE, you can see the pH
value printed to it, and the error does not exceed 0.3. Record
the pH value printed, then compared with 7.00, and the
difference should be changed into the "Offset" in the sample
code. For example, the pH value printed is 6.88, so the
difference is 0.12. You should change the # define Offset 0.00
into # define Offset 0.12 in the sample code.
4. Fine adjustment
 For Acid solution: Put the pH electrode into the pH standard
solution whose value is 4.00. Then wait about a minute, adjust
the Gain Potential device, let the value stabilise at around 4.00.
At this time, the acidic calibration has been completed and you
can measure the pH value of an acidic solution.
 For Alkaline solution: According to the linear characteristics
of pH electrode itself, after the above calibration, you can
directly measure the pH value of the alkaline solution, but if
you want to get a better accuracy, you can recalibrate it with
the standard solution, pH = 9.18. Also adjust the gain potential
device, let the value stabilise at around 9.18. After this
calibration, you can measure the pH value of the alkaline
solution.

Sample Code for Hardware Calibration

/*
# 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?

Or the module is defective?

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

Powered By DFRobot © 2008-2017


Water Flow Sensor
HZ 21 WA
21WA

SIZE:G1/2",58*38*38(L*W*H )mm
L*W*H)mm
",58*38*38(L*W*H

The principle of operation


The main water flow sensor by copper body and plastic forming, water flow
rotor components, steady flow components and hall components. It into water
dispenser, coffee machine and household appliances the water used for
measuring the water flow.

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

NO Item Examination requirement

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

10 Electrical strength AC500V 50Hz(Don't breakdown or flash winding)

In 100 ℃ temperature placed in 72 hours, in the environmental


Electrical
11 temperature back after 1 hour the accuracy of measurement
strength(100℃)
requirements within the plus or minus 5%
In 20 ℃ temperature placed in-72 hours, in the environmental
Cold
12 temperature back after 1 hour the accuracy of measurement
resistance(-20℃)
requirements within the plus or minus 5%
Mode of
13 Red: the positive, black: negative, yellow: pulse signal
connection
Installation instructions

1、When magnetic materials or to flow switch a magnetic force materials near


water flow switch, its characteristics may change.

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)

Operating Temperature Range


-10°C ~ 90°C

Storage Temperature Range


-20°C~ 90°C

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

Released under the Creative Commons Attribution Share-Alike 2.5 License

http://creativecommons.org/licenses/by-sa/2.5/

More information:

www.arduino.cc Rev. 2.3


Arduino Nano Pin Layout

!
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

Pin No. Name Type Description


1-2, 5-16 D0-D13 I/O Digital input/output port 0 to 13
3, 28 RESET Input Reset (active low)
4, 29 GND PWR Supply ground
17 3V3 Output +3.3V output (from FTDI)
18 AREF Input ADC reference
19-26 A7-A0 Input Analog input channel 0 to 7
27 +5V Output or +5V output (from on-board regulator) or
Input +5V (input from external power supply)
30 VIN PWR Supply voltage

!
!
!
!
!
!
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.

DS18B20 Programmable Resolution


1-Wire Digital Thermometer

General Description Benefits and Features


The DS18B20 digital thermometer provides 9-bit to ●● Unique 1-Wire® Interface Requires Only One Port
12-bit Celsius temperature measurements and has an Pin for Communication
alarm function with nonvolatile user-programmable upper ●● Reduce Component Count with Integrated
and lower trigger points. The DS18B20 communicates Temperature Sensor and EEPROM
over a 1-Wire bus that by definition requires only one • Measures Temperatures from -55°C to +125°C
data line (and ground) for communication with a central (-67°F to +257°F)
microprocessor. In addition, the DS18B20 can derive • ±0.5°C Accuracy from -10°C to +85°C
power directly from the data line (“parasite power”), • Programmable Resolution from 9 Bits to 12 Bits
eliminating the need for an external power supply. • No External Components Required
Each DS18B20 has a unique 64-bit serial code, which ●● Parasitic Power Mode Requires Only 2 Pins for
allows multiple DS18B20s to function on the same 1-Wire Operation (DQ and GND)
bus. Thus, it is simple to use one microprocessor to
●● Simplifies Distributed Temperature-Sensing
control many DS18B20s distributed over a large area.
Applications with Multidrop Capability
Applications that can benefit from this feature include
• Each Device Has a Unique 64-Bit Serial Code
HVAC environmental controls, temperature monitoring
Stored in On-Board ROM
systems inside buildings, equipment, or machinery, and
process monitoring and control systems. ●● Flexible User-Definable Nonvolatile (NV) Alarm Settings
with Alarm Search Command Identifies Devices with
Applications Temperatures Outside Programmed Limits
●● Thermostatic Controls ●● Available in 8-Pin SO (150 mils), 8-Pin µSOP, and
●● Industrial Systems 3-Pin TO-92 Packages
●● Consumer Products
●● Thermometers Pin Configurations
●● Thermally Sensitive Systems
TOP VIEW
+
N.C. 1 8 N.C.
DS18B20
N.C. 2 DS18B20 7 N.C.
1 2 3
VDD 3 6 N.C.

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.

19-7487; Rev 5; 9/18


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

Absolute Maximum Ratings


Voltage Range on Any Pin Relative to Ground.....-0.5V to +6.0V Storage Temperature Range............................. -55°C to +125°C
Operating Temperature Range.......................... -55°C to +125°C Solder Temperature................................Refer to the IPC/JEDEC
J-STD-020 Specification.
These are stress ratings only and functional operation of the device at these or any other conditions above those indicated in the operation sections of this specification is not implied. Exposure
to absolute maximum rating conditions for extended periods of time may affect reliability.

DC Electrical Characteristics
(-55°C to +125°C; VDD = 3.0V to 5.5V)

PARAMETER SYMBOL CONDITIONS MIN TYP MAX UNITS


Supply Voltage VDD Local power (Note 1) +3.0 +5.5 V
Parasite power +3.0 +5.5
Pullup Supply Voltage VPU (Notes 1, 2) V
Local power +3.0 VDD
-10°C to +85°C ±0.5
Thermometer Error tERR -30°C to +100°C (Note 3) ±1 °C
-55°C to +125°C ±2
Input Logic-Low VIL (Notes 1, 4, 5) -0.3 +0.8 V

Local power +2.2 The lower


Input Logic-High VIH (Notes 1,6) of 5.5 or V
Parasite power +3.0 VDD + 0.3
Sink Current IL VI/O = 0.4V 4.0 mA
Standby Current IDDS (Notes 7, 8) 750 1000 nA
Active Current IDD VDD = 5V (Note 9) 1 1.5 mA
DQ Input Current IDQ (Note 10) 5 µA
Drift (Note 11) ±0.2 °C
Note 1: All voltages are referenced to ground.
Note 2: The Pullup Supply Voltage specification assumes that the pullup device is ideal, and therefore the high level of the
pullup is equal to VPU. In order to meet the VIH spec of the DS18B20, the actual supply rail for the strong pullup transis-
tor must include margin for the voltage drop across the transistor when it is turned on; thus: VPU_ACTUAL = VPU_IDEAL +
VTRANSISTOR.
Note 3: See typical performance curve in Figure 1. Thermometer Error limits are 3-sigma values.
Note 4: Logic-low voltages are specified at a sink current of 4mA.
Note 5: To guarantee a presence pulse under low voltage parasite power conditions, VILMAX may have to be reduced to as low as
0.5V.
Note 6: Logic-high voltages are specified at a source current of 1mA.
Note 7: Standby current specified up to +70°C. Standby current typically is 3µA at +125°C.
Note 8: To minimize IDDS, DQ should be within the following ranges: GND ≤ DQ ≤ GND + 0.3V or VDD – 0.3V ≤ DQ ≤ VDD.
Note 9: Active current refers to supply current during active temperature conversions or EEPROM writes.
Note 10: DQ line is high (“high-Z” state).
Note 11: Drift data is based on a 1000-hour stress test at +125°C with VDD = 5.5V.

www.maximintegrated.com Maxim Integrated │  2


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

AC Electrical Characteristics–NV Memory


(-55°C to +125°C; VDD = 3.0V to 5.5V)

PARAMETER SYMBOL CONDITIONS MIN TYP MAX UNITS


NV Write Cycle Time tWR 2 10 ms
EEPROM Writes NEEWR -55°C to +55°C 50k writes
EEPROM Data Retention tEEDR -55°C to +55°C 10 years

AC Electrical Characteristics
(-55°C to +125°C; VDD = 3.0V to 5.5V)

PARAMETER SYMBOL CONDITIONS MIN TYP MAX UNITS


9-bit resolution 93.75
10-bit resolution 187.5
Temperature Conversion Time tCONV (Note 12) ms
11-bit resolution 375
12-bit resolution 750
Time to Strong Pullup On tSPON Start convert T command issued 10 µs
Time Slot tSLOT (Note 12) 60 120 µs
Recovery Time tREC (Note 12) 1 µs
Write 0 Low Time tLOW0 (Note 12) 60 120 µs
Write 1 Low Time tLOW1 (Note 12) 1 15 µs
Read Data Valid tRDV (Note 12) 15 µs
Reset Time High tRSTH (Note 12) 480 µs
Reset Time Low tRSTL (Notes 12, 13) 480 µs
Presence-Detect High tPDHIGH (Note 12) 15 60 µs
Presence-Detect Low tPDLOW (Note 12) 60 240 µs
Capacitance CIN/OUT 25 pF
Note 12: See the timing diagrams in Figure 2.
Note 13: Under parasite power, if tRSTL > 960µs, a power-on reset can occur.

DS18B20 TYPICAL ERROR CURVE


0.5
0.4
THERMOMETER ERROR (°C)

0.3 +3s ERROR


0.2
0.1
0
-0.1
-3s ERROR
-0.2
-0.3
MEAN ERROR
-0.4
-0.5
0 10 20 30 40 50 60 70
TEMPERATURE (°C)

Figure 1. Typical Performance Curve

www.maximintegrated.com Maxim Integrated │  3


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

1-WIRE WRITE ZERO TIME SLOT

tSLOT
tREC START OF NEXT CYCLE

tLOW0

1-WIRE READ ZERO TIME SLOT

tSLOT
START OF NEXT CYCLE
tREC

tRDV

1-WIRE RESET PULSE

RESET PULSE FROM HOST

tRSTL tRSTH

PRESENCE DETECT
1-WIRE PRESENCE DETECT tPDIH

tPDLOW

Figure 2. Timing Diagrams

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

www.maximintegrated.com Maxim Integrated │  4


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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

INTERNAL VDD ALARM HIGH TRIGGER (TH)


GND 64-BIT ROM
REGISTER (EEPROM)
AND 1-Wire
CPP PORT ALARM LOW TRIGGER (TL)
SCRATCHPAD
REGISTER (EEPROM)

VDD POWER- CONFIGURATION


SUPPLY SENSE REGISTER (EEPROM)

8-BIT CRC
GENERATOR

Figure 3. DS18B20 Block Diagram

www.maximintegrated.com Maxim Integrated │  5


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

The DS18B20 output temperature data is calibrated in Operation—Alarm Signaling


degrees Celsius; for Fahrenheit applications, a lookup After the DS18B20 performs a temperature conversion,
table or conversion routine must be used. The tempera- the temperature value is compared to the user-defined
ture data is stored as a 16-bit sign-extended two’s comple- two’s complement alarm trigger values stored in the
ment number in the temperature register (see Figure 4). 1-byte TH and TL registers (see Figure 5). The sign bit (S)
The sign bits (S) indicate if the temperature is positive indicates if the value is positive or negative: for positive
or negative: for positive numbers S = 0 and for negative numbers S = 0 and for negative numbers S = 1. The TH
numbers S = 1. If the DS18B20 is configured for 12-bit and TL registers are nonvolatile (EEPROM) so they will
resolution, all bits in the temperature register will contain retain data when the device is powered down. TH and TL
valid data. For 11-bit resolution, bit 0 is undefined. For can be accessed through bytes 2 and 3 of the scratchpad
10-bit resolution, bits 1 and 0 are undefined, and for 9-bit as explained in the Memory section.
resolution bits 2, 1, and 0 are undefined. Table 1 gives
examples of digital output data and the corresponding Only bits 11 through 4 of the temperature register are
temperature reading for 12-bit resolution conversions. used in the TH and TL comparison since TH and TL are
8-bit registers. If the measured temperature is lower than

BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0


LS BYTE 23 22 21 20 2-1 2-2 2-3 2-4
BIT 15 BIT 14 BIT 13 BIT 12 BIT 11 BIT 10 BIT 9 BIT 8
MS BYTE S S S S S 26 25 24

S = SIGN

Figure 4. Temperature Register Format

Table 1. Temperature/Data Relationship


DIGITAL OUTPUT DIGITAL OUTPUT
TEMPERATURE (°C)
(BINARY) (HEX)
+125 0000 0111 1101 0000 07D0h
+85* 0000 0101 0101 0000 0550h
+25.0625 0000 0001 1001 0001 0191h
+10.125 0000 0000 1010 0010 00A2h
+0.5 0000 0000 0000 1000 0008h
0 0000 0000 0000 0000 0000h
-0.5 1111 1111 1111 1000 FFF8h
-10.125 1111 1111 0101 1110 FF5Eh
-25.0625 1111 1110 0110 1111 FE6Fh
-55 1111 1100 1001 0000 FC90h
*The power-on reset value of the temperature register is +85°C.

BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0


S 26 25 24 23 22 21 20

Figure 5. TH and TL Register Format

www.maximintegrated.com Maxim Integrated │  6


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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Ω

1-Wire BUS TO OTHER 1-Wire BUS TO OTHER


1-Wire DEVICES 1-Wire DEVICES

Figure 6. Supplying the Parasite-Powered DS18B20 During Figure 7. Powering the DS18B20 with an External Supply
Temperature Conversions

www.maximintegrated.com Maxim Integrated │  7


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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.

8-BIT CRC 48-BIT SERIAL NUMBER 8-BIT FAMILY CODE (28h)


MSB LSB MSB LSB MSB LSB

Figure 8. 64-Bit Lasered ROM Code

SCRATCHPAD
(POWER-UP STATE)

BYTE 0 TEMPERATURE LSB (50h)


(85°C)
BYTE 1 TEMPERATURE MSB (05h) EEPROM

BYTE 2 TH REGISTER OR USER BYTE 1* TH REGISTER OR USER BYTE 1*


BYTE 3 TL REGISTER OR USER BYTE 2* TL REGISTER OR USER BYTE 2*
BYTE 4 CONFIGURATION REGISTER* CONFIGURATION REGISTER*
BYTE 5 RESERVED (FFh)
BYTE 6 RESERVED
BYTE 7 RESERVED (10h)
BYTE 8 CRC*

*POWER-UP STATE DEPENDS ON VALUE(S) STORED IN EEPROM.

Figure 9. DS18B20 Memory Map

www.maximintegrated.com Maxim Integrated │  8


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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.

BIT 7 BIT 6 BIT 5 BIT 4 BIT 3 BIT 2 BIT 1 BIT 0


0 R1 R0 1 1 1 1 1

Figure 10. Configuration Register

Table 2. Thermometer Resolution Configuration


RESOLUTION
R1 R0 MAX CONVERSION TIME
(BITS)
0 0 9 93.75ms (tCONV/8)
0 1 10 187.5ms (tCONV/4)
1 0 11 375ms (tCONV/2)
1 1 12 750ms (tCONV)

INPUT

XOR XOR XOR

MSB LSB

Figure 11. CRC Generator

www.maximintegrated.com Maxim Integrated │  9


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

1-Wire Bus System Transaction Sequence


The 1-Wire bus system uses a single bus master to con- The transaction sequence for accessing the DS18B20 is
trol one or more slave devices. The DS18B20 is always a as follows:
slave. When there is only one slave on the bus, the sys- Step 1. Initialization
tem is referred to as a “single-drop” system; the system is
“multidrop” if there are multiple slaves on the bus. Step 2. ROM Command (followed by any required data
exchange)
All data and commands are transmitted least significant
bit first over the 1-Wire bus. Step 3. DS18B20 Function Command (followed by any
required data exchange)
The following discussion of the 1-Wire bus system is
broken down into three topics: hardware configuration, It is very important to follow this sequence every time the
transaction sequence, and 1-Wire signaling (signal types DS18B20 is accessed, as the DS18B20 will not respond
and timing). if any steps in the sequence are missing or out of order.
Exceptions to this rule are the Search ROM [F0h] and
Hardware Configuration Alarm Search [ECh] commands. After issuing either of
these ROM commands, the master must return to Step 1
The 1-Wire bus has by definition only a single data line.
in the sequence.
Each device (master or slave) interfaces to the data line
via an open-drain or 3-state port. This allows each device
Initialization
to “release” the data line when the device is not transmit-
ting data so the bus is available for use by another device. All transactions on the 1-Wire bus begin with an initializa-
The 1-Wire port of the DS18B20 (the DQ pin) is open tion sequence. The initialization sequence consists of a
drain with an internal circuit equivalent to that shown in reset pulse transmitted by the bus master followed by
Figure 12. presence pulse(s) transmitted by the slave(s). The pres-
ence pulse lets the bus master know that slave devices
The 1-Wire bus requires an external pullup resistor of (such as the DS18B20) are on the bus and are ready
approximately 5kΩ; thus, the idle state for the 1-Wire to operate. Timing for the reset and presence pulses is
bus is high. If for any reason a transaction needs to be detailed in the 1-Wire Signaling section.
suspended, the bus MUST be left in the idle state if the
transaction is to resume. Infinite recovery time can occur ROM Commands
between bits so long as the 1-Wire bus is in the inactive
After the bus master has detected a presence pulse, it
(high) state during the recovery period. If the bus is held
can issue a ROM command. These commands operate
low for more than 480µs, all components on the bus will
on the unique 64-bit ROM codes of each slave device
be reset.
and allow the master to single out a specific device if
many are present on the 1-Wire bus. These commands
also allow the master to determine how many and what
types of devices are present on the bus or if any device
VPU has experienced an alarm condition. There are five ROM
commands, and each command is 8 bits long. The master
DS18B20
4.7kΩ device must issue an appropriate ROM command before
1-Wire PORT
Rx 1-Wire BUS DQ Rx
issuing a DS18B20 function command. A flowchart for
operation of the ROM commands is shown in Figure 13.
5µA
TYP
Tx
Search Rom [F0h]
100Ω
MOSFET When a system is initially powered up, the master must
Tx
identify the ROM codes of all slave devices on the bus,
Rx = RECEIVE
Tx = TRANSMIT
which allows the master to determine the number of
slaves and their device types. The master learns the
ROM codes through a process of elimination that requires
the master to perform a Search ROM cycle (i.e., Search
Figure 12. Hardware Configuration ROM command followed by data exchange) as many
times as necessary to identify all of the slave devices.

www.maximintegrated.com Maxim Integrated │  10


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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.

www.maximintegrated.com Maxim Integrated │  11


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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.

Table 3. DS18B20 Function Command Set

1-Wire BUS ACTIVITY AFTER


COMMAND DESCRIPTION PROTOCOL NOTES
COMMAND IS ISSUED

TEMPERATURE CONVERSION COMMANDS


DS18B20 transmits conversion status
Convert T Initiates temperature conversion. 44h to master (not applicable for parasite- 1
powered DS18B20s).
MEMORY COMMANDS
Read Reads the entire scratchpad including the DS18B20 transmits up to 9 data bytes
BEh 2
Scratchpad CRC byte. to master.
Write Writes data into scratchpad bytes 2, 3, and Master transmits 3 data bytes to
4Eh 3
Scratchpad 4 (TH, TL, and configuration registers). DS18B20.
Copy Copies TH, TL, and configuration register
48h None 1
Scratchpad data from the scratchpad to EEPROM.
Recalls TH, TL, and configuration register DS18B20 transmits recall status to
Recall E2 B8h
data from EEPROM to the scratchpad. master.
Read Power Signals DS18B20 power supply mode to DS18B20 transmits supply status to
B4h
Supply the master. master.
Note 1: For parasite-powered DS18B20s, the master must enable a strong pullup on the 1-Wire bus during temperature conver-
sions and copies from the scratchpad to EEPROM. No other bus activity may take place during this time.
Note 2: The master can interrupt the transmission of data at any time by issuing a reset.
Note 3: All three bytes must be written before a reset is issued.

www.maximintegrated.com Maxim Integrated │  12


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

MASTER Tx RESET PULSE


INITIALIZATION
SEQUENCE
DS18B20 Tx PRESENCE PULSE

MASTER Tx ROM COMMAND

33h READ N 55h MATCH N F0h N ECh N CCh N


ROM ROM SEARCH ROM ALARM SEARCH SKIP ROM
COMMAND COMMAND COMMAND COMMAND COMMAND

Y Y Y Y Y

DS18B20 Tx BIT 0 DS18B20 Tx BIT 0


MASTER Tx
BIT 0 DS18B20 Tx BIT 0 DS18B20 Tx BIT 0
MASTER Tx BIT 0 MASTER TX BIT 0

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)

Figure 13. ROM Commands Flowchart

www.maximintegrated.com Maxim Integrated │  13


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

MASTER Tx 44h CONVERT N 48h COPY N


FUNCTION COMMAND TEMPERATURE ? SCRATCHPAD ?

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 MASTER DISABLES Y MASTER DISABLES


STRONG PULLUP STRONG PULLUP
MASTER MASTER MASTER MASTER
Rx “0s” Rx “1s” Rx “0s” Rx “1s”

N B4h READ N B8h N BEh READ N 4Eh WRITE


POWER SUPPLY ? RECALL E2 ? SCRATCHPAD ? SCRATCHPAD ?

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 ?

N MASTER TX CONFIG. BYTE


Y
TO SCRATCHPAD
MASTER MASTER
Rx “0s” Rx “1s” N HAVE 8 BYTES
BEEN READ ?

MASTER Rx
SCRATCHPAD CRC
BYTE

RETURN TO INITIALIZATION
SEQUENCE (FIGURE 13)
FOR NEXT TRANSACTION

Figure 14. DS18B20 Function Commands Flowchart

www.maximintegrated.com Maxim Integrated │  14


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

1-Wire Signaling Read/Write Time Slots


The DS18B20 uses a strict 1-Wire communication pro- The bus master writes data to the DS18B20 during write
tocol to ensure data integrity. Several signal types are time slots and reads data from the DS18B20 during read
defined by this protocol: reset pulse, presence pulse, write time slots. One bit of data is transmitted over the 1-Wire
0, write 1, read 0, and read 1. The bus master initiates all bus per time slot.
these signals, with the exception of the presence pulse.
Write Time Slots
Initialization Procedure—Reset And There are two types of write time slots: “Write 1” time slots
Presence Pulses and “Write 0” time slots. The bus master uses a Write 1
All communication with the DS18B20 begins with an ini- time slot to write a logic 1 to the DS18B20 and a Write
tialization sequence that consists of a reset pulse from the 0 time slot to write a logic 0 to the DS18B20. All write
master followed by a presence pulse from the DS18B20. time slots must be a minimum of 60µs in duration with a
This is illustrated in Figure 15. When the DS18B20 sends minimum of a 1µs recovery time between individual write
the presence pulse in response to the reset, it is indicating slots. Both types of write time slots are initiated by the
to the master that it is on the bus and ready to operate. master pulling the 1-Wire bus low (see Figure 14).
During the initialization sequence the bus master trans- To generate a Write 1 time slot, after pulling the 1-Wire
mits (TX) the reset pulse by pulling the 1-Wire bus low bus low, the bus master must release the 1-Wire bus
for a minimum of 480µs. The bus master then releases within 15µs. When the bus is released, the 5kΩ pullup
the bus and goes into receive mode (RX). When the bus resistor will pull the bus high. To generate a Write 0 time
is released, the 5kΩ pullup resistor pulls the 1-Wire bus slot, after pulling the 1-Wire bus low, the bus master must
high. When the DS18B20 detects this rising edge, it waits continue to hold the bus low for the duration of the time
15µs to 60µs and then transmits a presence pulse by pull- slot (at least 60µs).
ing the 1-Wire bus low for 60µs to 240µs. The DS18B20 samples the 1-Wire bus during a window
that lasts from 15µs to 60µs after the master initiates the
write time slot. If the bus is high during the sampling win-
dow, a 1 is written to the DS18B20. If the line is low, a 0
is written to the DS18B20.

MASTER Tx RESET PULSE MASTER Rx


480µs MINIMUM 480µs MINIMUM
DS18B20 DS18B20 TX PRESENCE
WAITS 15-60µs PULSE 60-240µS
VPU

1-Wire BUS

GND

LINE TYPE LEGEND


BUS MASTER PULLING LOW
DS18B20 PULLING LOW
RESISTOR PULLUP

Figure 15. Initialization Timing

www.maximintegrated.com Maxim Integrated │  15


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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

15µs 15µs 30µs 15µs 15µs 30µs

MASTER READ “0” SLOT MASTER READ “1” SLOT


1µs < TREC < ∞
VPU

1-Wire BUS

GND
MASTER SAMPLES > 1µs
MASTER SAMPLES
> 1µs
15µs 45µs 15µs

LINE TYPE LEGEND


BUS MASTER PULLING LOW DS18B20 PULLING LOW RESISTOR PULLUP

Figure 16. Read/Write Time Slot Timing Diagram

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.

www.maximintegrated.com Maxim Integrated │  16


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

VPU
VIH OF MASTER
1-Wire BUS

GND
TINT > 1µs TRC MASTER SAMPLES

15µs

Figure 17. Detailed Master Read 1 Timing

VPU
VIH OF MASTER
1-Wire BUS

GND
TINT = TRC =
SMALL SMALL MASTER SAMPLES

15µs

LINE TYPE LEGEND


BUS MASTER PULLING LOW
RESISTOR PULLUP

Figure 18. Recommended Master Read 1 Timing

Related Application Notes Application Note 162: Interfacing the DS18x20/DS1822


The following application notes can be 1-Wire Temperature Sensor in a Microcontroller
applied to the DS18B20 and are available at Environment
www.maximintegrated.com. Application Note 208: Curve Fitting the Error of a
Application Note 27: Understanding and Using Cyclic Bandgap-Based Digital Temperature Sensor
Redundancy Checks with Maxim iButton Products Application Note 2420: 1-Wire Communication with a
Application Note 122: Using Dallas’ 1-Wire ICs in 1-Cell Microchip PICmicro Microcontroller
Li-Ion Battery Packs with Low-Side N-Channel Safety Application Note 3754: Single-Wire Serial Bus Carries
FETs Master Isolated Power and Data
Application Note 126: 1-Wire Communication Through Sample 1-Wire subroutines that can be used in conjunc-
Software tion with Application Note 74: Reading and Writing iBut-
tons via Serial Interfaces can be downloaded from the
Maxim website.

www.maximintegrated.com Maxim Integrated │  17


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

DS18B20 Operation Example 1 DS18B20 Operation Example 2


In this example there are multiple DS18B20s on the bus In this example there is only one DS18B20 on the bus and
and they are using parasite power. The bus master initi- it is using parasite power. The master writes to the TH, TL,
ates a temperature conversion in a specific DS18B20 and and configuration registers in the DS18B20 scratchpad
then reads its scratchpad and recalculates the CRC to and then reads the scratchpad and recalculates the CRC
verify the data. to verify the data. The master then copies the scratchpad
contents to EEPROM.
MASTER DATA
COMMENTS
MODE (LSB FIRST) MASTER DATA (LSB
COMMENTS
MODE FIRST)
Tx Reset Master issues reset pulse.
Tx Reset Master issues reset pulse.
DS18B20s respond with
Rx Presence
presence pulse. DS18B20 responds with
Rx Presence
presence pulse.
Master issues Match ROM
Tx 55h
command. Master issues Skip ROM
Tx CCh
command.
64-bit ROM Master sends DS18B20 ROM
Tx
code code. Master issues Write Scratchpad
Tx 4Eh
command.
Master issues Convert T
Tx 44h
command. Master sends three data bytes
Tx 3 data bytes to scratchpad (TH, TL, and
DQ line Master applies strong pullup
config).
Tx held high by to DQ for the duration of the
strong pullup conversion (tCONV). Tx Reset Master issues reset pulse.
Tx Reset Master issues reset pulse. DS18B20 responds with
Rx Presence
presence pulse.
DS18B20s respond with
Rx Presence
presence pulse. Master issues Skip ROM
Tx CCh
command.
Master issues Match ROM
Tx 55h
command. Master issues Read Scratchpad
Tx BEh
command.
64-bit ROM Master sends DS18B20 ROM
Tx
code code. Master reads entire scratchpad
Master issues Read Scratchpad including CRC. The master then
Tx BEh
command. recalculates the CRC of the
first eight data bytes from the
Master reads entire scratchpad Rx 9 data bytes scratchpad and compares the
including CRC. The master then calculated CRC with the read
recalculates the CRC of the CRC (byte 9). If they match,
first eight data bytes from the the master continues; if not, the
Rx 9 data bytes scratchpad and compares the read operation is repeated.
calculated CRC with the read
CRC (byte 9). If they match, Tx Reset Master issues reset pulse.
the master continues; if not, the DS18B20 responds with
read operation is repeated. Rx Presence
presence pulse.
Master issues Skip ROM
Tx CCh
command.
Master issues Copy Scratchpad
Tx 48h
command.
DQ line Master applies strong pullup to
Tx held high by DQ for at least 10ms while copy
strong pullup operation is in progress.

www.maximintegrated.com Maxim Integrated │  18


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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.

www.maximintegrated.com Maxim Integrated │  19


DS18B20 Programmable Resolution
1-Wire Digital Thermometer

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

ESP8266 NodeMCU WiFi Devkit

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. Using Arduino IDE

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.

3.1 Install the Arduino IDE 1.6.4 or greater


Download Arduino IDE from Arduino.cc (1.6.4 or greater) - don't use 1.6.2 or lower version! You can use your
existing IDE if you have already installed it.

You can also try downloading the ready-to-go package from the ESP8266-Arduino project, if the proxy is giving you
problems.

3.2 Install the ESP8266 Board Package


Enter http://arduino.esp8266.com/stable/package_esp8266com_index.json into Additional Board Manager URLs
field in the Arduino v1.6.4+ preferences.

Click ‘File’ -> ‘Preferences’ to access this panel.

Next, use the Board manager to install the ESP8266 package.

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.

3.3 Setup ESP8266 Support


When you've restarted Arduino IDE, select ‘Generic ESP8266 Module’ from the ‘Tools’ -> ‘Board:’ dropdown menu.

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

3.4 Blink Test

We'll begin with the simple blink test.

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!

• Hold down the ‘Flash’ button.


• While holding down ‘ Flash’, press the ‘RST’ button.
• Release ‘RST’, then release ‘Flash’

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.

Figure3-1: Connection diagram for the blinking test

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!

3.5 Connecting via WiFi

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:

Don’t forget to update:

const char* ssid = "yourssid";

const char* password = "yourpassword";

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);

// We start by connecting to a WiFi network

Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);

WiFi.begin(ssid, password);

while (WiFi.status() != WL_CONNECTED) {


delay(500);
Serial.print(".");
}

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);

// Use WiFiClient class to create TCP connections


WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}

// We now create a URI for the request


String url = "/projects/index.html";
Serial.print("Requesting URL: ");
Serial.println(url);

// This will send the request to the server


client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
delay(500);

// 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

Why flashing your ESP8266 module with NodeMCU?

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.

ESP8266 Module Breadboard Friendly with Header Connector

4.1 Parts Required:

• ESP8266 Module Breadboard Friendly


• PL2303HX USB-UART Converter Cable
• Some Male-to-Female Jumper Wires

4.2 Pin Assignment:

12 www.handsontec.com
4.3 Wiring:

ESP8266 Pin Description


CH_PD Pull high, connect to Vcc +3.3V
Vcc Power Supply +3.3V
TXD Connect to RXD (white) of PL2303HX USB-Serial converter cable
RXD Connect to TXD (Green) of PL2303HX USB-Serial converter cable
GPIO0 Pull low, connect to GND pin
GND Power Supply ground

4.4 Downloading NodeMCU Flasher for Windows

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:

• Win32 Windows Flasher


• Win64 Windows Flasher

You can find all the information about NodeMCU flasher here.

4.5 Flashing your ESP8266 using Windows

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.

Your ESP8266 module is now loaded with NodeMCU firmware.

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:

• ESPlorer Homepage: http://esp8266.ru/esplorer/


• GitHub Repository: https://github.com/4refr0nt/ESPlorer

5.1 Installing ESPlorer

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:

Here’s a rundown of the features the ESPlorer IDE includes:

• Syntax highlighting LUA and Python code.


• Code editor color themes: default, dark, Eclipse, IDEA, Visual Studio.
• Undo/Redo editors features.
• Code Autocomplete (Ctrl+Space).
• Smart send data to ESP8266 (without dumb send with fixed line delay), check correct answer from ESP8266
after every lines.
• Code snippets.
• Detailed logging.
• And a lot more…

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:

5.3 Writing Your Lua Script

Below is your script to blink an LED.


lighton=0
pin=4
gpio.mode(pin,gpio.OUTPUT)
tmr.alarm(1,2000,1,function()
if lighton==0 then
lighton=1
gpio.write(pin,gpio.HIGH)
else
lighton=0
gpio.write(pin,gpio.LOW)
end
end)

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:

1. Press the Refresh button.


2. Select the COM port for your FTDI programmer.
3. Select your baudrate.
4. Click Open.

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):

The next step is to save your code to your ESP8266!


At the left bottom corner click the button “Save to ESP”.
In your output window, it should start showing exactly which commands are being sent to your ESP8266 and it should
look similar to 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.

Nodemcu ESP8266 Pin Nodemcu dev ESP8266 Pin


dev kit kit
D0 GPIO16 D7 GPIO13
D1 GPIO5 D8 GPIO15
D2 GPIO4 D9 GPIO3
D3 GPIO0 D10 GPIO1
D4 GPIO2 D11 GPIO9
D5 GPIO14 D12 GPIO10
D6 GPIO12

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:

• ESP8266 Lua Nodemcu WIFI Module


• ESP8266 Breadboard Friendly Module
• ESP8266 Remote Serial WIFI Module
• PL2303HX USB-UART Converter Cable

22 www.handsontec.com

Anda mungkin juga menyukai