# Temperature and Humidity sensor Tutorial
###### tags: IoT Examination
>Name: **Majed Haj Hussein**
Student credentials: **Mh225th**
Time estimation following this tutorial:**6h**
Operating system: **macOS**
## Project overview
This project is about generating vital pieces of information concerning the functioning of these electronic devices. Simultaneously, this information will transmit these vital statistics from the transmitting device as well as save the same on the cloud to access by the applications and supplementary procedures to use them. This scrutiny associates the outcomes of the environmental observances like the humidity and temperature measurements using sensors. The gathered information could be profitably used to produce actions like distantly dominant cooling, heating devices, or long term statistics, which will be useful to control the same. The detected data are uploaded to the cloud storage through network.
## Objective
### Why this project and what purpose does it serve
The reason why I chose this project is because of my interest to understand how to use IoT to transmit data from a sensor on the internet and actually automate and optimize a physical object by the data. For me this project was more about understanding the powerful technology of IoT.
### What insights you think it will give
This is a good project to start with for someone who wants a straight forward and easy project for an introduction to IoT.
This project is easy to start with it and will understand how IoT technology can be used for optimization and It also gives a good overview of how all elements from the sensor, protocols, databases, and internet are connected.
This project will give you the base of knowledge to develop more complex projects later on.
## Material
### List of material
| Item |Purchased | Price |
| ----------------- |--------------------- |--------|
| LoPy4 - With Headers |[:link:][1] | 366 kr |
| Expansion Board 3.0 |[:link:][2] | 167 kr |
|LoRa (868MHz/915MHz) & Sigfox Antenna Kit (Optional) |[:link:][3] | 95 SEK |
|DHT11 Sensor|[:link:][4] | 99 SEK |
|Breadboard|[:link:][5] | 59 SEK |
[1]: https://pycom.io/product/lopy4/
[2]: https://pycom.io/product/expansion-board-3-0/
[3]: https://pycom.io/product/lora-868mhz-915mhz-sigfox-antenna-kit/
[4]: https://www.kjell.com/se/produkter/el-verktyg/arduino/moduler/temperatur-och-luftfuktighetssensor-for-arduino-p87086
[5]: https://www.electrokit.com/produkt/kopplingsdack-400-anslutningar/
### Short specifications
**1. LoPy4 with headers**
LoPy4 is a combination of wireless radios (WiFi, Bluetooth, LoRa, SigFox) and a MicroPython development platform that helps to get started with making Internet of Things (IoT) endpoints. The device has different inputs and outputs which is necessary to understand before setting up a project. The LoPy4 documentation is shown on pycom.io.
**2. Expansion board 3.0**
The board is where code is being handled. Here is also where you power your device through USB or batteries.
**3. Antenna Kit**
A universal LoRa & Sigfox Antenna that can be used with the LoPy, SiPy, LoPy4 and FiPy IoT Development boards. This project uses WiFi and micro USB to the computer, so this antenna is optional. But, using a LoRa or Sigfox radio without the external antenna can lead to damage to the device.
**4. DHT11 sensor**
A module that measures and provides data. The component contains three pinouts: 3-5V, GND, Data. Product specification for this sensor is a temperature range of 0-50 °C , error of +/- 2 °C, and humidity range of 20-90 %, error +/- 5 %.
**5. Breadboard**
A neat tool to let you create simple and organized circuits.
## Computer setup
### Update your Expansion Board
You first need to update the firmware on the expansion board, you can check that by follow the linked documentation under Expansion board 3.0 [:link:][bord]. When you have downloaded the recommended files. You need to follow the guide and execute all the steps in the computer terminal.
[bord]: https://docs.pycom.io/index.html
### Atom and PyMakr plugin
As IDE I use Atom, which can be downloaded at https://atom.io.
1. Download Atom, and install the package pymakr.

Atom basics, how to upload code and structure your files.

2. Connect the pycom device to the computer via micro USB and press the reset button on the lopy. You should now be able to execute code directly on the device!
### Update Firmware
1. Download Pycom Firmware Update, the link under updating firmware.
[:link:][bord]
[bord]: https://docs.pycom.io/index.html
2. Connect your Pycom device to the computor and open Pycom Firmware Update Tool. Remember to first close Atom before update, it will not work otherwise.
Pybytes is the easiest choice when getting started. They already have their libraries installed in “type” pybytes.

## Putting everything together
Power source for the Pycom device is through micro USB connected to computer.

## Platform
I started by presenting data on the Pybytes platform. Where data is automatically stored in the cloud. Pybytes is a user-friendly platform that is automatically connected to the device through the Pycom library, that you get if you update your device with “type” Pybytes.




## code

## Transmitting the data/connectivity
The data is transmitted to the internet through WiFi as a wireless protocol. WiFi means that the wireless protocol can handle high data rates and also is able to consume a lot of battery power. But, that comes to a cost of low range. Therefore this project actually is more suitable for the usage of LoRa as a wireless protocol.
DHT11 sensor sends temperature and humidity values of low data rate, which means that I don´t need the big data rate advantage the WiFi gives. Therefore it´s better to use the range and mobility advantage through the LoRa protocol which also is less battery consuming.

## Presenting the data
My dashboard in Grafana contains the process of inside temperature and humidity in a room.


## Finalizing the design


the main purpose of the project was to get a general understanding about the IOT specially the pycom devices how they work, how do they communicate with each other and how we can use them in our daily life to facilitate it and make it easier ofcourse there was many other cool things that we could add to this project to make it more advanced but as a beginers course i think that we learned alot of good stuff we got better understanding about IOT world and the different areas that have already implemented the IOT technology which allowed them to improve their work.