In Part 1 of this series you learned how to connect a DHT temperature/humidity sensor directly to your WeatherStation and to display the readings as an additional frame in the carousel rotation. In this second part I will show you how to setup a sensor node and post the readings to a free cloud service before fetching them on a WeatherStation (in another room) and displaying them there.
Programming the Climate Node
Especially the Wifi settings and the Thingspeak API key have to be updated. Take the Write API key from the previous step here. For testing you might also play with the update interval which is a number in seconds. Please be aware that the minimum update interval in Thingspeak is about 15 seconds. Below your updates will just be ignored.Now flash your program to the Node MCU and your Climate node should start logging. To check the results you can go back to Thingspeak and look at the charts:
Displaying the data on the WeatherStation
Look for these lines in the demo and replace the read api key and the channel ID with the ones you got in the Thingspeak step. If you didn’t remove the climate node section in your weather station code you just need to flash your WeatherStation with the updated API key and channel ID and voilà: you just successfully sent the temperature and humidity data from the next room once around the world just to display it on a tiny OLED display. I know some people (including my wife) who wouldn’t be impressed by that at all;-).Explanation: This last step might have been a bit confusing, since the tv cook had prepared everything hours before the TV show actually started, so here the summary in slow motion: the Weather Station library now comes with a class called Thingspeak client which does all the leg work. You pass in the channel id and API key and it downloads a JSON object and picks out just the last data set, since we are currently interested only in that. Have a look at https://github.com/squix78/esp8266-weather-station/blob/master/ThingspeakClient.cpp to understand what happens and maybe adapt/ extend it to your needs. Why not display the chart of the last 24 hours on the OLED display?
A ridiculous amount of coffee was consumed in the process of building this project. Add some fuel if you'd like to keep me going!