ESP8266 and ThingSpeak, a match made in IoT heaven

James Trace (a member of Programming Electronics Academy) has been working on an IoT project: wirelessly monitoring the performance of a Solar Geyser.  He is uploading 9 fields of data to ThingSpeak and measuring temperatures, humidity, light exposure, the list goes on.  All with an Arduino Nano and an ESP8266 (ESP01).

While this project is something James has been tinkering on at home, it’s partly driven by work he is exploring for low cost wireless sensors in mining applications.

This project was submitted by one of our members.  You can see more of our member's projects here.

Not a member yet?  Sign up here.

If you like real data graphs, you have to check out James ThingSpeak Channels:

I asked James if he could tell me about his challenges in developing this project, and the first line of his response feels like a golden nugget to me:

Yes many [challenges] – but they are all solved one at a time and it is still work-in-progress.

–James Trace

IoT with ESP8266 monitor solar water pump

That is the kind of attitude that embodies someone who is willing to makes things happen!

Programming Electronics Academy members, check out the Internet of Things (IoT) Course to start programming your own IoT devices.

Not a member yet?  Sign up here.

Here are some of the challenges James has had in his own words.  I have bolded those items that stand out to me:

“The mission is to be able to understand why this [solar water heater] does not perform as well as it should and to compare its type to other types.

I noticed early on that the water temperature was dropping significantly during the nights and suspect that the direct coupled vacuum tubes were sucking the heat out again at night.

So, the plan was to measure and learn as much as possible using a small Arduino Nano and the ESP­01 WiFi chip to communicate with the web.

First issue was to get the thermistors to read the same temperatures when they were all in the same place.

I got the 3rd order polynomial equation converting resistance to temperature from the data sheet. To get them more accurate, I measured the voltage divider resisters individually and set up the sketch to account for this variation as well as the difference in input voltage.

Your courses are excellent; they explain the concepts well and I have learnt why code is there and what it does.

This understanding has allowed me to push the boundaries and measure some cool stuff. Thank you very much and well done.

James Trace
LDR undercover

This got all these thermistors reading within 0.1ºC of each other. They are now more accurate than the analog to digital converter steps available on the Arduino.

The DHT11 and BMP180 sensors were very easy, thanks to great libraries available for them both.

I found the DHT11 temperature steps of 1ºC too large so only use the humidity from that. I use the BMP180 temperature and pressure values.

Finding data on the LDR conversion from resistance to Lux is not so easy. I have just changed the calculation to Lux = 500 / ldrR ^1.3 but will keep an eye on that and may change it if I find a better approximation.

The old equation of Lux = 500/ ldrR was unstable with high light levels where ldrR approaches zero. I may have the same issue – we will see.

The biggest issue was to understand and get the ESP­01 to communicate to ThingSpeak.

I am using the AT commands and need to send data to two ThingSpeak channels as I have 9 fields and would like to add more. I have found that I am running out of local variable memory and have had to really trim the sketch to save space to get these 9 working.

I know I can reduce the accuracy and use some integers in place of floats, but that would be a compromise.

We also have regular power failures, intermittent internet connection, and the threat of lightning strikes so getting the sketch to restart automatically after any of these has been an ongoing problem.

Then it’s been just doing it and work out the issues as you go along. 

It will never be perfect but I have already made progress and understand a lot more now than before.

IoT ESP8266 Arduino Nano with ThingSpeak
Can you find the ESP8266 module?

In addition to showcasing James projects, we are always happy to include his kind plug!

This is what James had to say about our courses:

While I have used the ESP8266 as a stand-alone wireless microcontroller, I have not used it like James has used it, as the wireless bridge between an Arduino and the Internet.  Definitely makes me want to explore it more.

I hope this project inspires you as much as it did me!

installing Arduino libraries

Installing Arduino Libraries | Beginners Guide

IoT sewage project

Pumping poo! An IoT sewage project

ESP32 webOTA updates

How to update ESP32 firmware using web OTA [Guide + Code]

error message Brackets Thumbnail V1

expected declaration before ‘}’ token [SOLVED]

Compilation SOLVED | 1

Compilation error: expected ‘;’ before [SOLVED]

Learn how to structure your code

3 Comments

  1. Michal on November 27, 2016 at 12:49 am

    I have had the same issue trying to get a LDR value translated into lux. Not really an easy task. Instead I decided to use an ambient light sensor (TSL2591, adafruit has a nice breakout board) which gives you a lux value that you can read over I2C.
    Nice project and good luck!

  2. James on November 27, 2016 at 4:53 am

    Thanks Michael, I will take a look at that board, sounds useful.
    Its a pity the LDR manufactures don’t issue any data in their data sheets. I found many articles about how to calibrate it against a proper Lux Meter but thats not an option if you don’t have one to start with. In the end one data sheet had a graph showing Resistance vs Lux both on log scales. Solving for the unknowns and rounding a little it came out to Lux = 500 / ( ldrR )^1.3 which seems to be working correctly. However, I suppose the reason for lack of data is that they must be so variable that its hard to pin the curve down for individual LDR’s.

  3. Michal on November 27, 2016 at 6:38 am

    Hi James, in theory using the curve should work and LDRs are incredibly cheap which makes them perfect for DIY projects like that. Problem is once saturated you get no data. Ambient light sensors on the other hand can be adapted to very wide light conditions by changing gain and measurement time. I managed to get mine to measure down to 0.1 lux and less. I might update the github library for that sensor later as last time I looked at it it was not working properly, particualrly automatic gain adjustment.

Leave a Comment