Low Cost WIFI Temperature (DS18B20) Data Logger Based on ESP8266 With Connectivity to Thingspeak.com





Introduction: 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!

Step 1: Part List

  1. ESP-01 board - eBay
  2. DS18B20
  3. Step down voltage converter min. 250 mA - AMS1117-3.3 LDO 800mA or LM2596
  4. > 220 uF / min 6.3 V Capacitor
  5. Vero board
  6. 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.

Step 2: 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:


You get you chip id back..

Done, you have working NodeMcu LUA firmware...

Step 3: 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.

Step 4: 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


Or under Windows 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:


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

Step 5: Building Final Board

You can build final circuit to piece of veroboard.

Step 6: 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:


4 People Made This Project!


  • Epilog Challenge 9

    Epilog Challenge 9
  • Paper Contest 2018

    Paper Contest 2018
  • Science of Cooking

    Science of Cooking

We have a be nice policy.
Please be positive and constructive.




The firmware is not available anymore...can you please post a screenshot or something with the right modules need to create a firmware that works with the DS18B20 from http://nodemcu-build.com/


Thanks for that. I managed to make it work with the normal

nodemcu_integer_0.9.6-dev_20150704 bin

I realized that with the custom build for some reason the http server isnt working properly. It only outputs 1 line of code...weird...but the normal bin with an extra .lua file with the ds18b20 library works fine :)

hi. I also encountered the same thing. strange that with the custom build there is no option to add HTTP.

What do you mean by extra lua file with ds18b20 library? Can you share how to do this?

Sure, I've included all the files in the zip, (its for DHT22 and ds18b20).
You just need to edit: init.lua, and add your access point name and password.
Then in mainscript.lua i've enabled only the lua script for the ds. If you want to have the DHT just enable that --dofile("dht.lua") line and disable the ds instead.
And finally in the send.lua, put your thingspeak.com api key. I've include the schematic i used (without the DHT) and where i got my info from. This script will update your Thingspeak channel every 10 min.


Great addition, this works for me!

I've changed the code a bit since i last posted this. The new one is located here: https://github.com/Sandbird/ESP8266-with-LUA---Thi...

I added a setup page. No need to edit .lua files anymore to add the router/user/pass. You can do that from your mobile. Also i added a safeguard function. If the esp cant find the router anymore, it will enter setup mode again.

Thanks, this works even better! I get a list of AP’s and select one. Also nice how you made it possible to throw away the config file and reselect the Ap.

The only thing is that I have to use a different wiring, with CH_PD pulled up to Vcc with a resistor according to the basic wiring described in http://www.esp8266.com/wiki/doku.php?id=getting-started-with-the-esp8266. When I do not connect it to Vcc nothing happens. I also have to use a 470uF capacitator between Vcc and GND.

It also does not work with 2 AA batteries. My ESP draws more than 100mA. When I connect the batteries the Voltage drops to 2.4 V, which is too low.

To tell you the truth, i dont run it with batteries...this was a diagram i found on the net. I use a jumper to connect vcc with ch, (i soldered the male pins one on each pin and use the jumper on top). I dont use a capacitor....hmm maybe i should? Eventually i might do it with batteries, if i manage to make the 'deepsleep' soldering, and use a step up converter for 2 AA batteries.
I'll probably add the time interval for the loop as an input field in the page...in case people want to be able to change that as well and store the value in the config file.

Works like a dream, thank you for your effort.

I noticed in the ds18b20.lua file that you had a possible option for F readings. Is there a value that I would need to change to allow this?