May 2020
Intermediate to advanced
262 pages
6h 48m
English
The main.py file is run after boot.py whenever a MicroPython microcontroller is turned on. In our code, we have a continuous loop that checks the temperature every 60 seconds and compares it to the temperature threshold. If the temperature is too low, the heater is turned on and a cycle counter is incremented. Once the counter reaches the maximum number of cycles, the heater is turned off for 6 hours and a LoRa message is sent out indicating that the heater has been disabled.
The following is a diagram of the main.py file:

Our code reads the value from a temperature sensor using the DHT11 class. The LoRaMessage ...