Low Cost WIFI Temperature (DS18B20) Data Logger Based on ESP8266 With Connectivity to Thingspeak.com
by ok1cdj in Circuits > Sensors
284305 Views, 202 Favorites, 0 Comments
Low Cost WIFI Temperature (DS18B20) Data Logger Based on ESP8266 With Connectivity to Thingspeak.com
Temperature data logger based on ESP8266 and DS18B20 1-Wire temperature sensor.
Just only $5 ESP-01 board and DS18B20 sensor.
Software is written in LUA language and is running directly in ESP8266.
No other MCU needed!
Part List
- ESP-01 board - eBay
- DS18B20
- Step down voltage converter min. 250 mA - AMS1117-3.3 LDO 800mA or LM2596
- > 220 uF / min 6.3 V Capacitor
- Vero board
- Some wires, PIN headers
USB to UART 3.3 V converter - only for programming
Be careful, the max. voltage for ESP8266 for all pins is 3.3V. If you are using adjustable voltage regulator, carefully set voltage to 3.3V.
The power consumption of ESP module is around 250mA when transmitting. You need proper power supply.
Flashing LUA Firmware
Check that your ESP8266 has some firmware through any serial terminal program (coolterm, putty, serial monitor in arduino) at 115200 (most probable default speed) Type AT+GMR and you get version of actual firmware.
Congrats, you’ve got a working ESP8266 with a espressif firmware in it.
Now to burn LUA firmware:To Burn a firmware: CH_PD pin must be always connected to HIGH and GPIO0 pin to GROUND (LOW).
Download NodeMCU firmware from: https://github.com/nodemcu/nodemcu-firmware/tree/master/pre_build/0.9.2/512k-flash
Download flashing tool for Windows:https://github.com/nodemcu/nodemcu-flasher
or for Linux: https://github.com/themadinventor/esptool/blob/master/esptool.py
Run windows app for upload firmware or in Linux type:
./esptool.py -p /dev/ write_flash 0x000000 nodemcu_512k.bin
After burning it, GPIO0 pin should be disconnected from ground in order to reboot in normal mode. Otherwise it will be reboot in UPLOAD mode. So power it OFF, disconnect GPIO0 pin from ground…
Now connect serial terminal with 9600 baud and check if Lua firmware working with:
print(node.chipid())
You get you chip id back..
Done, you have working NodeMcu LUA firmware...
Setting Up Thinkspeak.com Account
Thingspeak is open data platform for the Internet of Things.
All data are stored in thingspeak.com. You need thingspeak account. Please register here:
Set up one channel and get write API key.
Uploading Software
You need some upload tool, you can do it with basic terminal program, but with upload tool is uploading of files much easier.
You can use ESPlorer (need JAVA 8 for running), works on Linux and Windows
http://esp8266.ru/esplorer/#download
Or under Windows Lualoader:
http://benlo.com/esp8266/index.html#LuaLoader
You can get sotware from my github - https://github.com/ok1cdj/ESP8266-LUA/tree/master/Thermometer-DS18B20-Thingspeak
init.lua - this scrip is executed after start
Please modify your WIFI settings in this file here:
wifi.sta.config("SSID","PASSWORD")
ds1820.lua - measure and post data to thingspeak.com
Change you thingspeak API key here:
conn:send("GET /update?key=YOURKEY&field1="..t1.."."..t2.." HTTP/1.1\r\n")
You can change upload period here (default is 1 minute):
tmr.alarm(0, 60000, 1, function() sendData() end )
Upload both files to ESP...
Building Final Board
You can build final circuit to piece of veroboard.
Final Testing
With terminal app check output from ESP and you will see your IP address after reset and then value of temperature every upload period...
You can see your data in thingspeak like mine: