Network Connected Thermostat, trials and accomplishments

The final project for Connected Devices was to create an IOT thermostat that would record the temperature in whatever room it was placed in and then send that temperature to a remote server. The thermostat was required to have a working UI and post the temperature to the server once every hour for a week straight.

After a lot of trial and error I was able to achieve this using the MKR 1010 microcontroller, much assistance from Tom Igoe, and Koji, and a few repos listed below.

https://github.com/tigoe/Wifi101_examples/blob/master/ConnDevClient/ConnDevClient.ino

https://github.com/tigoe/MakingThingsTalk2

The initial setup of the MKR1010 took quite a while. Having to make sure that the most up to date firmware was present on the device, adding the mac address to itpsandbox, and then receiving a static ip address for the device. Once all of this was done and I was assigned a specific session key I could begin really working.

I made the decision to use dweet to test that I was sending data correctly. First I wanted to test the server with a static value and once that sent properly I set up the temperature reading circuit and sent the temperature data to dweet. Both of those worked correctly so I moved onto the real thing.

Screen Shot 2019-02-22 at 3.11.27 PM.png
Screen Shot 2019-02-23 at 11.02.48 AM.png

This is the part of the assignment where I wish I could say everything worked perfectly the first try but I ended up spending more time than I care to admit trying to fix an error that made little sense to me. Multiple people attempted to help and it wasn’t until Tom took a look at my code and realized that in my call to the server address I had added “https://” this created a -2 HTTP Status in my code even when everything looked like it was sending to the server properly.

Once this issue was fixed I got my first 400 Status, this wasn’t ideal but I was still elated because at least I knew that it was because of a JSON formatting error rather than some unknown.

Screen Shot 2019-02-24 at 3.07.31 PM.png

After a lot of tweaking to the JSON I was sending I finally got a 201 status.

Screen Shot 2019-02-24 at 6.57.42 PM.png

Curling to the server proved that I was successful and could focus on doing a bit of fine tuning and working on the UI. I decided not to invest as much time in that aspect so I stuck to a simple LCD screen and potentiometer combination. The LCD displays the current room temperature in Celsius and the potentiometer simply turns the temperature display on or off depending on the state of rotation.

IMG_20190225_192227.jpg

Here is a video of the working device:

A link to the code repo can be found here: Link