---
# System prepended metadata

title: Untitled

---

**Tutorial for the IoT kurs on how to build a temperature and humidity sensor**

Kristina Cordova kc222fw

In this project I connect  temperature and humidity sensor that sends data to cloud plattform to create meaningfull information. I am going to place my sensor over the fridge to control when fridge opens. 

It takes about 2-6 hours to finish the project

**Objective**

In my case I use received data to check if my kid is taking the icecream from the fridge that he is not supposed to touch :) It will help me to keep his teethe healthy thats why I chose this project. It may gives some ideas to other innovative parents and lots of fun for kids, who are interested in technologies. They may try to huck my device, but in order to be able to do it, they have to learn first how it works. It can be good approach for learning IoT.

**Material**

Materials that I used:
- Pycom extansion board
- Pycom LoPy4
- Lora anthena
- DHT11 Sensor
- USB cable

Pycom LoPy4 is a device that helps to program in MicroPython and has a lots of possibilities and connections, as well as different inputs and outputs, LED, Boot etc

The picture of the materials:

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

Computer setup

Device is programmed in Python and I used Atom as IDE. I uppload code through the Atom from the project library. 
Those steps are needed to follow:
1. Install Atom on your computer
2. Install Python
3. Install Pymakr plug-in to Atom
4. Use Pybytes as cloud plattform
5. Create a directory for the code and upload code to Atom
6. Upload code using Pymakr
7. Run the project, check your data in Pybytes

**Putting everything together**


Sensor is connected like in the picture below:

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

**Plattform**

I used Pybytes plattform, it is super easy to use and connect. For network installation you may need to use activation auto generated key. 

**The code**

I used the code that was provided by kurs.

```
import time
from machine import Pin
from dht import DHT # https://github.com/JurassicPork/DHT_PyCom

# Type 0 = dht11
# Type 1 = dht22

th = DHT(Pin('P23', mode=Pin.OPEN_DRAIN), 0)
time.sleep(2)

while True:
    result = th.read()
    while not result.is_valid():
        time.sleep(.5)
        result = th.read()
    print('Temp:', result.temperature)
    print('RH:', result.humidity)
    pybytes.send_signal(1,result.temperature)
    pybytes.send_signal(2,result.humidity)

    time.sleep(5)

```

**Transmitting the data / connectivity**

Data is send every 5 seconds and I used both Wifi and Lora, but Wifi was the first choice, transport protocols was MQTT

**Presenting the data**

I chose to see my data in the table, see picture bellow. And the important parts is where receved data is changed. 

![](https://i.imgur.com/FB3jP7B.png)

**Finalizing the design**

I assume that the result of my project is my kids healthier theeth and a good experience of where IoT can be used in practice. 


