I've been playing around with an Sparkfun ESP32 Thing. It's an little IoT board that works with the Arduino SDK. I wanted to set up an envionment that could potentially become a temperature sensor base for a Smart Home.
Above you can see a diagram of what the current setup looks like.
There are a few pieces to the puzzle at the moment. The Arduino board is just a dumb sensor with Wifi on-board which checks the temperature of the living room and sends what it found out through a POST request to an IP address of my choice. Pretty simple so far.
The Raspberry Pi is the receiver of the POST which runs a simple Node.JS server and stores the current time and the posted message. It also makes a request to a Dark Sky API to get the current temperature outside and stores it in a text file titled with the current date together with the other temperature to see how the outside temperature fluctuations influence my living room. Also to make it available outside I'm using a free service from ngrok to forward my port to an outside domain.
Findings
From a couple of days of recorded data I found out:
- Yes, outside temperature matters and it's directly connected to the inside temperatures (no surprises there).
- Due to a big window daylight heats up the room.
- My heating sucks.
- My heating dries the air in the room, which makes a difference in the real feel, but the temperature does not change too much if the heaters are off either. During the day the temperature in the living room is basically the same if the heaters were on or off.
- I need a humidity sensor to see how much does the heating help.
- Opening or closing the living room door is a big deal. The temperature in the room changes by 4 degrees, which in human terms changes the living room from "I'm freezing my ass off" to "This is quite cosy, I might stay here".
The UI
I'm using Chart.js as the graph framework. It makes it pretty and clean to look at when comparing days. Here's a production snap of how it looks:
I added in a piece of jQuery to get the data from the backend and also to be able to pick a day you'd like to look at to see past performance. It's pretty simple and I wouldn't call it production ready but it's definitelly something you can use at how if you'd like to measure your living room temperature.
The code for the living room temperature sensor is up in a Github repository at https://github.com/piotrekkmt/sparkfun-thing-thermometer with my current code which gets updated whenever something changes on my Pi.
You will need to create a file in the main folder of the sparkfun project called config.json
. It should include your Dark Sky token and your latitude and longitude location so that you'll get the current weather conditions. I only store the current temperature, but you can get a lot more info from it. First 1000 requests a day are free, which is more than enough to run the sensor server.
Sample config.json
{
"WEATHER_API_TOKEN": "YOUR_API_TOKEN",
"WEATHER_LAT_LONG": "YOUR_LAT,YOUR_LONG"
}
My temperature sensor is a DS18b20, here's how to plug it into an Arduino, courtesy of Instructables.
## IMPORTANT ##
In case you're using a copy of the temperature sensor, your pins might be reversed. If you are sure you connected the sensor properly and the arduino keeps returning temperature as -127.0 try reversing the connection. Otherwise you might melt your breadboard and burn your sensor or Arduino.
If you need help or you'd like to get in touch with me to talk about the project or any of the other things I made, leave a comment down below, or give me a shout on Twitter.
If you like it and would like to set it up yourself, leave me a star on Github.
Star
Til next time! Cześć!