**Temperature gauge for summerhouse**
Nils Folcker - nf222hv
Tillämpad Internet of Things, Introduktion - 7,5 HP Sommar2021
Linneus universitetet
Lärare Fredrik Ahlgren
The temperature gauge is built from the recommended starter kit from clectrokit and uses pybyte to visualize the data.
The amount of time I spent on the course differes from the amount of time I spent on the IoT device. I got everything to work on my first tries and there as been little to none problem with my setup to estimate to time spent on the device is 5-8 hours in addition to all the hours of lecutures and workshops.
**Objective**
I have chosen to build a temperature gauge for my summerhouse due to that the temperature sensor came with the starting kit. The purpose is that this allows me to track the temperature in the house during winters when the house is more vulnerable in addition I get insights of how the indoor temperature shifts in the summer with open windows.
**Materials**
I bought the recommended starter kit from elektrokit for 949kr
https://www.electrokit.com/produkt/lnu-1dt305-tillampad-iot-lopy4-and-sensors-bundle/
LoPy4 with headers
This component is the one that makes it possible to connect to the internet with the device. This sends the sensor data in my case by Wi-Fi, however it is compatible with bluetooth, SigFox and LoRa as well.
Expansionboard for LoPy4
This is where you attach the cables to the breadboard as well as power the IoT device from via USB cable.
Micro USB cable & Apple 5W Power Adapter
Used to give power to the device.
Breadboard & Jumper Wire
Gives power to the sensor in a easy to see and understand way.
Temperature sensor MCP9700
A temperature sensor that have a accuracy of +-4 degree
Operates from 2.3V to 5.5V
Source: https://www.microchip.com/en-us/product/MCP9700
**Computer setup**
I first chose to work with Visual Studio Code and installaded node.js where I got it to work as well. However when visualizing the data with pybytes the have their own IDE called pymakr which I used and got it to work with the same code python code used to in previous IDE.
**Putting everything together**
As I did only a temperature gauge I only had to follow the tutorial and did the same set up as they did. Below is how the circuit diagram, picture taken from the tutorial.
 Picture from: https://hackmd.io/@lnu-iot/BJnuGmJh_
Picture of my device

**Platform**
The platform that I use is Pybytes and was easy to set up. Pybytes is a free cloud platform and it was a quick setup with nice looking results. However I feel that Pybytes have some flaws and if I where to develop this application further I would use something else. The flaws is that you are not able to delete specific data signals such as the spike shown in my graph where I just tested the temperature in a different location. I also feel that the data table is not so userfriendly as you dont have the rows numbered or know for how long the data is stored. So if I have an application where I would like to filter the data I would use something else.
**The code**
main.py
```
import time
import machine
import pycom
adc = machine.ADC()
apin = adc.channel(pin='P16')
while True:
millivolts = apin.voltage()
celsius = (millivolts - 500.0) / 10.0 #Calcuation according to tutorial
Sending to pybytes in channel 1
pybytes.send_signal(1, celsius)
print("sending: {}".format(celsius))
Send temperature update every 15 minutes
time.sleep(900)
```
pybytes_config.json
```
{
"wifi": {
"ssid": "Wi-Fi name",
"password": "Wi-Fi lösenord"
},
"wlan_antenna": 0,
"dump_ca": false,
"server": "mqtt.pybytes.pycom.io",
"ssl": false,
"lte": {
"apn": null,
"cid": 1,
"reset": false,
"carrier": null,
"band": null,
"type": null
},
"device_id": "329be3c1-8429-46c3-8885-8a5aabbd8b50",
"network_preferences": ["wifi"],
"ota_server": {
"port": 443,
"domain": "software.pycom.io"
},
"pybytes_autostart": true,
"username": "nils.folcker@hotmail.com"
}
```
The transport protocall that is used is MQTT.
As the boot.py is empty I will not upload it.
**Transmitting the data**
Data is sent every 15 minutes as I think that is more than enough to get a understanding of what the temperature is in the summerhouse. More would only require a bigger power consumption would not really serve a purpose for my use. The wireless protocall that I use is WiFi and it is woorking really solid. I was not able to use LoRa as it is not available at the location of my summerhouse.
**Presenting the data**
I use Pybytes to visualize the data. I use both a datatable and a linear graph. Why I choose the Pybyte is due to it simplicity with visualizatioon.

**Conclusion**
I have built a temperature gauge that send data via WiFi to pybytes where I can see a visualization of the temperature differences. I find this interessting as often you know what the temperature is outside howe and not inside. Picture of the device and the data visualization is find above. What I would have done differently in the device would have been that I should have selected a more accurate temperature sensor as well as included some more sensors in the project such as humidity and air quaility so I could have used it as a weather station and not just a temperature gauge. Something I don't have access to is a 3D printer which would have been cool so that I could have made it more like a user friendly device with hiding the wires in a pretty way.