Connected Devices: Active Thermostat
For the final assignment of the Connected Devices class the task was to build a working thermostat.
It needed to do 3 things:
Have a temperature sensor which reads the temperature.
A physical control for people to interact with(left to interpretation)
Send the temperature data to Tom’s server every one hour.
We had the option of programming the thermostat using Raspberry Pi or an Arduino with a wifi module. I tried tinkering with the Raspberry Pi for sometime. As it was my first time using it I ran into a few issues while trying to set it up. So I decided to use a MKR-1010 for this project.
The first objective was to connect and send some data to dweet to understand & setup the basic circuit.
The first thing was to update the firmware to the latest one.
Wifi - NINA
WIFI - 101
SAMD board manager
Step 1: Getting the MAC address of the device. I used this sketch to get the MAC address of the MKR-1010.
Step2: Connecting to Wifi.
With the ConnectwithWPA sketch from the WIFI NINA library examples I connected with the Wifi network. There was a connection error but it was because the device wasn’t registered on the nyu computer network. After registering the board connected with the network easily.
Step3: Testing the temperature sensor.
On a simple breadboard prototype I tested the TMP-36 sensor using this sketch and saw the readings on the Serial monitor to see if I am getting relatively realistic readings.
Along with it I also prototyped displaying the temperature reading and the temperature set by the user.
Step 4: Sending data to Dweet
Using the dweet example file from the HTTP client library I sent the current temperature data using POST requests to the dweet server.
Step 5: Sending data to the target server.
With the individual pieces ready the next step was to follow the API documentation from the class page and send data to the server. While doing so I encountered a lot of errors. Such as 400, 500, 401 etc. Some of the ones which were tricky to get over were:
As the the host was a HTTPS client the WIFICLIENT needed to change to a WIFISSLCLIENT.
Adding proper certificates for the servername.com:443 in the firmware updater.
JSON formatting errors.
and finally got a success message from the server.
Designing the Box:
In the final assembly I decided to not to show the the actual temperature on the LCD screen but only show the Temperature people are requesting. I wanted to have additional LED’s which would denote if the thermostat was set to heating/cooling/neutral to show what the current action taken by the thermostat.
I put the pieces to-gether:
My final assembly sitting outside Tom’s office.
More insights from the box after week 6 class.