ESP8266 Temp Sensor Monitor Lab Notes

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:

Resources

These are the primary websites I used when developing this software:

TCP library:
https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/readme.html

Soft Access Point Examples:
https://arduino-esp8266.readthedocs.io/en/latest/esp8266wifi/soft-access-point-examples.html

Arduino WIFI examples:
https://42bots.com/tutorials/esp8266-wifi-tutorial-arduino-ide/

Wiring Multiple Sensors to Arduino:
https://lastminuteengineers.com/multiple-ds18b20-arduino-tutorial/

Covers installing libraries into esp8266, reading a single sensor, reading multiple sensors
https://randomnerdtutorials.com/esp8266-ds18b20-temperature-sensor-web-server-with-arduino-ide/

WDT:
https://techtutorialsx.com/2017/01/21/esp8266-watchdog-functions/

Programming ESP8266 with Arduino IDE

These instructions discuss getting Arduino IDE running for ESP8266:

https://dzone.com/articles/programming-the-esp8266-with-the-arduino-ide-in-3

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

https://www.digikey.com/en/maker/blogs/2017/configure-your-esp8266-wifi-module-with-new-wifi-manager

which uses the code in this git library

https://github.com/tzapu/WiFiManager

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

https://randomnerdtutorials.com/esp8266-web-server/

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:

https://lastminuteengineers.com/multiple-ds18b20-arduino-tutorial/

My schematic is as follows:

With the hardware configured, I then installed the OneWire and Dallas temp sensors libraries as outlined here:

Guide for DS18B20 Temperature Sensor with Arduino

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:

http://www.xyfyx.com/files/esp8266-tempSensorMonitor.zip

Advertisements
This entry was posted in c-esp8266. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.