Air Quality Monitoring System In Schools (AQUAMS). Use to read the Air Quality around school area. The system will read the air quality and send the cloud server. It uses ESP32/8266 or Raspberry Pi Pico W as a microcontroller with micropython firmware.
Technology Stacks:
- MQTT
- Micropython
- DFRobot Sensors
- OTA Update using github repository
- Raspberry Pi as a file server and MQTT broker
On The Air Update for Micropython using Github repository on Raspberrypi http server.
- Must have a github account
- Have created github personal access token
- Follow the config-sample.json
- Replace the details with your details
- create a folder /home/pi/file_server/ESP32
# Create a pip virtual environment
python -m venv venv
# Activate the virtual environment
source /venv/bin/activate
# Install required libaries
pip install -r requirements.txt# 1. Add inject node interval 10 minutes
# 2. Add this command into a script node
cd <project-directory>/epd-aquams-electronics/ && bash run.sh- For Windows must install CP210x USB to UART Bridge
MicroPython distributions for other RP2040- and RP2350-based boards are available on the MicroPython download page.
To program your device, follow these steps:
-
Push and hold the BOOTSEL button while connecting your Pico with a USB cable to a computer. Release the BOOTSEL button once your Pico appears as a Mass Storage Device called RPI-RP2.
-
Drag and drop the MicroPython UF2 file onto the RPI-RP2 volume. Your Pico will reboot. You are now running MicroPython.
- Download the latest Micropython Firmware
- Setup python pip environment
# create a python environment
python -m venv env
# activate the python environment
source env/bin/activate
# install esptool.py
pip install esptool
# install setuptools
pip install setuptools
# check if esptool working
esptool.py --help- Flash the Micropython
# erase the flash first
esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash
# flash the .bin file into ESP32/8266
# Hold down the “BOOT/FLASH“, before running the flash command.
esptool --chip esp32 --port <serial_port> write_flash -z 0x1000 <esp32-X.bin>- Download the latest Micropython Firmware
- For easy flash install Thonny IDE.
- Open Thonny IDE Tools > Interpreter.
- Choose the MicroPython ESP32 as interpreter.
- Choose port that your ESP32 connected to.
- Click Install or update firmware at the bottom right.
- Choose port that your ESP32 connected to.
- Browse the firmware that you download.
- Click install. if its error, check your thonny IDE if its access sudo/administrator privilege.
ampy --port /dev/ttyXX ls- Open Thonny IDE make sure the intrepreter is Micropython ESP32.
- Create new file named main.py and write a simple python print hello world code.
- Save it choose on MicroPython Device.
- And run the script on Thonny IDE. We will see the hello world is displayed on terminal thats mean the MicroPython is successfully installed.
- We were follow this tutorials for installing MQTT client: https://randomnerdtutorials.com/micropython-mqtt-esp32-esp8266/
- reference here: https://randomnerdtutorials.com/esp32-esp8266-dht11-dht22-micropython-temperature-humidity-sensor/
- IP address has set to static to prevent IP address from conflict between ESP32.
- CO = 192.168.0.120
- DHT22 = 192.168.0.121
- NO2 = 192.168.0.122
- SO2 = 192.168.0.123
- PM2.5 = 192.168.0.124
- O3 = 192.168.0.125
| gasType | Unit | Concentration | Voltage | Temperature | Range | |
|---|---|---|---|---|---|---|
| CO | ppm | float | float | float | 0-1000 | |
| SO2 | ppm | float | float | float | 0-20 | |
| NO2 | ppm | float | float | float | 0-20 | |
| O3 | ppm | float | float | float | 0-10 | |
| Temp_C | ℃ | float | float | float | -40-80 | |
| Temp_F | ℉ | float | float | float | 40-176 | |
| Humidity | %RH | float | float | float | 0-100 | |
| PM2.5 | µg/m³ | float | - | - | 0-1000 | |
| PM10 | µg/m³ | float | - | - | 0-1000 |
The Architectures:
