# Making a Temperature Device By @Wael Abosamak (wa222ey at Linneau University) In this project, a lopy4 device and an MCP9700 sensor are used to make a high temperature detector. If the temperature rises, the lopy4 gadget will be set to utilize an app to send a notification to the user. ![](https://i.imgur.com/0MZhFAl.jpg) # Objective You may learn more about the internet of things through these tutorials. This gadget has a thermometer function and may be customized for different usage scenarios. This project may easily be improved into a more sophisticated thermometer and connected to additional sensors to carry out a more focused task. # Material To do this project i needed A LoPy4 and sensor bundle package.A lopy4 device, expansion board, led, resistors, and sensors was included in the package. The following materials is needed: 1) IoT platform, LoPy4 with headers. ![](https://i.imgur.com/sg0S4S0.jpg) 2) An expansion board to attach wires to the loPy4. ![](https://i.imgur.com/qRBhUdS.jpg) 3) A jumper cable to link the breadboard with the expansion board. ![](https://i.imgur.com/SxlacCw.jpg) 4) For a stronger WiFi signal, use antennas.![](https://i.imgur.com/frroWtg.jpg) 5) An micro USB cable. ![](https://i.imgur.com/VKZuVwC.jpg) 6) An temperature sensor. ![](https://i.imgur.com/cSYRtXy.jpg) 7) An breadboard.![](https://i.imgur.com/YUVohcI.jpg) # Computer setup The first step is to download an IDE so you can program the gadget. I used Visual Studio Code as my IDE. Then you must [download](https://code.visualstudio.com/download) a plugin after installing Visual Studio Code in order to run and publish the code on the LoPy4. Start Visual Studio Code, choose Extensions, type "pymakr," and click Download. At this point, you are prepared to begin programming. # Putting everything together Connecting the Experiments Board, Breadboard, and Sensor will be the first step. The yellow wire should be attached to GND, the orange to 3v3, and the red to P16. The wires must be linked as shown in the diagram below, however the sensor can be put wherever on the breadboard.![](https://i.imgur.com/veVFHor.jpg) The antennas are connected to the loPy4 in the last phase, as seen in the image below. Although the project does not require the antennae, I utilized them to get a stronger WiFi signal.![](https://i.imgur.com/vVWJSam.jpg) # Transmitting the data / connectivity To transfer the data from the sensor, the loPy4 has to be connected to the internet. You may connect to the internet through WiFi, Sigfox, or LoRa with the loPy4 device. If you set the device on a farm or in a cottage that doesn't have WiFi or is far from one, Sigfox and LoRa can be utilized. However, since I will be using it at home, which has a Wifi network, it will be OK to connect to the internet in my use case. # Platform You'll need a dashboard to display the data the loPy4 sent when all the hardware was connected and it was connected to the PC. I represented the data using pybytes, which can also function as a database. # Presenting the data You need to be alerted if the room temperature becomes too high. You may use a phone notification as one. You must use IFTTT to create a webrequest in order to get notice. You must adhere to these IFTTT setup instructions. Last but not least, you'll need to download the IFTTT app on your phone. ![](https://i.imgur.com/S8AjWwm.png) # The Code ``` #Author: Wael Abosamak #libraries i used import machine import time import pycom import urequests from network import WLAN #Verify the lopy4's internet connection wlan = WLAN() if wlan.connected(): print("The apparatus has an internet connection.") else: print("The apparatus didn't has an internet connection") phonenoti = "https://maker.ifttt.com/trigger/Event1/with/key/d-FPf2Itm-iYJ8XyTQBg8t" adc = machine.ADC() apin = adc.channel(pin='P16') while True: #data extraction from the sensor mv = apin.voltage() Temp = (mv - 460.0) / 10.0 #The mobile phone will receive a notification if the temperature is equal to or higher than 46°C. if Temp >= 46: print("Temperature is high: " , Temp) req = urequests.post(url=phonenoti, json={'value1': Temp}) time.sleep(15) #The temperature will be printed on the terminal every 15 seconds if it is below 46 °C. else: print("Temperature is low : " , Temp) pybytes.send_signal(1,Temp) time.sleep(15) ```