---
# System prepended metadata

title: Temperature Station

---

# Temperature Station




### Title, Name, Overview, Time

- Temperature Sensor
- Anton Blomdell, ab225gi
- Simple temperature sensor made with Lopy4 and Tmp36 sensor, which could be accessed from the webplattform Losant with a good interface for the data that is sent from the Lopy4 device.
- 2 weeks on and off.

:rocket: 

### Objective

Describe why you have chosen to build this specific device. What purpose does it serve? What do you want to do with the data, and what new insights do you think it will give?

- [x] Why you chose the project
- I thought it would be nice to have a sensor at home which could read the temperature from my living room when im not around.
- [x] What purpose does it serve
- The purpose of the device i made is to read the temperature from my living room send this data with help of the Sigfox platform to Losant a webplatform where i can make better use of the data instead of reading the raw data from the device. This make it possible to put the data from the device into graphs and other simplified pictures which makes it easier and more fun to view the data.
- [x] What insights you think it will give
- The insights that i have learned from this experience is how you program Lopy4, which code you have to write to get a connection with SigFox and which connection the device can have with the internet. How you can send the data from Sigfox to other platforms which the data can be stored into beutiful graphs. 

:rocket: 

### Material

In this project i used a Lopy4 board coupled with a expansion board 3.0 version which you can see in pictures 1-2. It a programmed decive with MicroPython and has multiple different connections from digital to analog outputs and inputs. Good for a IoT project like mine. Sensor is a simple temperature sensor. Breadboard is used to make right connection to the Lopy4 board which isnt possible directly on the board thats why im using a breadboard seen in picture 5.


- [x] List of material 
![](https://i.imgur.com/0o8Riur.png)
- LoPy4
![](https://i.imgur.com/I4qFRNI.png)
- Expansion Board 3.0-How is the device programmed. Which IDE are you using. Describe all steps from flashing the firmware, installing plugins in your favorite editor. How flashing is done on MicroPython.
![](https://i.imgur.com/R0YfZ0N.png)
- Sigfox Antenna Kit
![](https://i.imgur.com/S3VNZaj.gif)
- TMP36 Temperature
![](https://i.imgur.com/4H24ofS.jpg)
- Hard cables
![](https://i.imgur.com/e6vaHPG.jpg)
- Breadboard





- [x] What the different things (sensors, wires, controllers) do - short specifications
- TMP36 Temperature sensor, hard cables for connection between breadboard and Lopy4. Breadboard used to connect sensor with right connection on Lopy4 board.
- [x] Where you bought them and how much they cost
- Digikey.se and Kjellcompany.se was the stores that i bought my materials from.
Expansion board 3.0 around 250 sek.
Lopy4 board around 350 sek.
Sensor and hard cables did i get from a Arduino Starter Kit from kjell company.

:rocket: 
## Computer setup

- I downloaded firmware from Lopy4 own website and used usb connection to flash lastest firmware onto the device. Follow Lopy4 own guide to install IDE and the extension Pymakr. Followed the guide how to use pymakr https://docs.pycom.io/gettingstarted/programming/first-project/. 
- From this weblink i installed correctly pymakr and node.js. https://docs.pycom.io/pymakr/installation/vscode/

- [x] Chosen IDE
- Visual Code Studio. 
- [x] How the code is uploaded
- USB connection and with Visual code studio extension pymakr using port COM3.
- [x] Steps that you needed to do for your computer. Installation of Node.js, extra drivers, etc.
- Installation of node.js and extension on Visual code studio pymakr.

:rocket: 
## Putting everything together
- As seen in Material and the picture of temperature sensor it got 3 connections. 2.7 - 5.5 V in, Analog voltage out and ground. As seen in the pictures below i wired on Lopy4 one hard cable with P16 , one with 3V3 pin and last one with the pin GND.
- [x] Circuit diagram (can be hand drawn)
 ![](https://i.imgur.com/T0Mjbxo.png)


## Platform
- [x] Describe platform in terms of functionality
- Im using as said before the platform Losant with a local installation from my own computer where i upload the code i want directly to the device through USB connection. Link to Losant : https://www.losant.com/ I use the wireless protocol Sigfox to transfer the data to Losant.Link to Sigfox : https://www.sigfox.com/en All webplatforms im using is free to use with limitiation on ammount of messages i can send per day from the device to the cloud platform/ website platform. Scaling up the project with more data it would need a paid subscription of Sigfox to handle more messages per day because of the increased amount of data you would send.
## The code
- Import your code here, and don’t forget to explain what you have done!
![](https://i.imgur.com/OFx7jmp.png)
- When using Sigfox as medium for transmitting the data to Sigfox because of  Sigfox being low power. You can only send small chunks of information every mionutes. You can only send 140 message a day. Which means you gonna lose some data if you dont but the value to around 15 min delay between the messages.
- The first picture showing the code for setting up the connection with Sigfox. The important thing from this code is the rcz-=Sigfox.RCZ1 which is setting up the zone from where the device is sending data from RCZ1 means from Europe. The othes code sections is setting up sockets and which pin im using on Lopy4 board and so on.
![](https://i.imgur.com/TfgAHHs.png)
- In picture 2 you can the code raw = bytearray(struct.pack("f", degC)) and s.send(raw). This is where you send raw data to Sigfox. Sigfox works by sending maximum of 12 bytes per transmission. First line of code is convering our temperature floating point value to raw bytes. And second is just how you send it. time.sleep(300) time for how long the device should wait before sending new data to Sigfox.

## Transmitting the data / connectivity
- How is the data transmitted to the internet? Describe the package format. All the different steps that are needed in getting the data to your end point. Explain both the code and choice of wireless protocols
- Sigfox platform takes care of transmitting data from the device Lopy4 to their cloud backend server. But the data you are sending from Lopy4 is in raw form or to say in floating numbers. Its not pretty and if you want to use it i any useful form you have to forward it somewhere else. Thats why im using Losant platform to make a graph of the data. Losant works as a enablement playform which provides an easy to use serivce to visualize and build good products from this data. Its free to use. Be using webhook a transport protocol for invoke a callback from Sigfox which is a way to forwarding data from Sigfox to other platforms. Callbacks can accept a webhook URL then when a message is send to Sigfox cloud it forwards this message to Losant in this case. In this section can you see a picture of this setup for making a callback to a other platform. How i setup which data should be send and to which URL and so on. Its important to have wait for reply from workflow in this setup. Its important because the platform Losant uses a workflow that sends a message back to Sigfox to confirm that the message was sent and deliviered safe.
- [x] How often is the data sent?
-  300 seconds.
- [x] Which wireless protocols did you use (WiFi, LoRa, etc …)?
-  Sigfox
- [x] Which transport protocols were used (MQTT, webhook, etc …)
-  Webhook
  ![](https://i.imgur.com/pjYqlE0.png)

## Presenting the data
- Describe the presentation part. How is the dashboard built? How long is the data preserved in the database?
- To present that data im using the platform Losant that i talk about in sections before. Its a platform easy to use for visualizing data sent from different IoT devices and makes for a good interface for these devices. For this to work you have to make a callback setup on Sigfox platform before that works with the webhook protocol. After that you setup a new device on the platform and give it attributes which data you want to visualize on the platform. When you have done it you can setup a workflow which you can see in picture 1 in this section. The first step in the workflow is the webhook which is the protocol connecting this platform with Sigfox. After this i have a function and Math function which converts rawdata from Sigfox to degrees(C). The device state step provides a way to record data onto our device. Two last steps is Debug step and Reply of webhook to Sigfox as i explained in the section before.
- [x] Provide visual examples on how the dashboard looks. Pictures needed.

![](https://i.imgur.com/PUnxQEj.png)
- [x] How often is data saved in the database.
- 24 hours with new updates every 5 mins.
## Finalizing the design
- Im glad that i was able to make a device that are connected with the internet that i can remotly acess data from with a good interface showcasing the data. It was fun to make this device and i plan to make more fucntions to device. Gonna add this summer hummidty sensor and a (shake) sensor to it.

- [x] Pictures

 ![](https://i.imgur.com/SUeDZLp.jpg)
