I recently set up an ESP8266 to monitor 3 Dallas DS18B20 temperature sensors and act as a web server to allow viewing of the data on a smart phone.
This was an experiment to try a few things:
- How can I connect to the ESP8266 via my phone to assign it to my WIFI network.
- How can I read multiple temperature sensors
- How can I provide the data via a phone readable website
This is the first time I’ve played with IoT hardware in a couple years now. I found it has become way easier to locate and install libraries and those libraries just work. In the past it was all a crap-shoot and took much more work. The resulting program for this project really just glues together libraries that do all of the hard work.
This blog post is a summary of those experiments which provided a workable little monitor:
These are the primary websites I used when developing this software:
Soft Access Point Examples:
Arduino WIFI examples:
Wiring Multiple Sensors to Arduino:
Covers installing libraries into esp8266, reading a single sensor, reading multiple sensors
Programming ESP8266 with Arduino IDE
These instructions discuss getting Arduino IDE running for ESP8266:
Once followed, I compiled and downloaded the standard blink program into my NodeMCU (0.9) to verify connectivity.
Soft Access Point Set up
My first goal was to allow configuring the ESP8266’s WIFI connection to my LAN using my phone which is now the common method for handling a device like this.
I assumed I would be writing a fair amount of code. Not true, ends up there is a library that handles the process completely. After you call, wifiManager.resetSettings, your ESP8266 is connected to the LAN. It handles everything for you.
The primary resource I used to figure this out is
which uses the code in this git library
Creating a Web Server
Arduino web servers are nothing new and I’ve created a few myself. I set up a test server using instructions from
When creating the HTML for this server, at first everything was showing up small on my phone. I wanted it to fill the phone. I found the following HTML code solved that problem:
<head> <meta name="viewport" content="width=device-width, initial-scale=1">
Further, I wanted the content to refresh every 15 seconds so I also needed:
<meta http-equiv="refresh" content=15>
Reading Multiple Dallas DS18B20 Temperature Sensors
Once I had a running web server that was formatting, the next step was to wire up some sensors and read them.
I primarily used this resource to get the wiring correct:
My schematic is as follows:
Once the code for the temp sensors was running, I merged that also into the final project code.
The final code can be found here: