This is the uploaded Circuit Python Firmware for an IOT air quality sensor with the UM Feather S2 development board. Currently this project is using Circuit Python V6.3.0 with the ESP32-S2 as a proof-of-concept (POC). This code has been ported to a project in C here.
This Project is designed to create an air-quality sensor using the Feather S2 platform as a prototype. A later version will be created in C with custom hardware and software. This code currently connects to the wifi in the secrets file (change it to yours before using) and gets an IP address from the router. All setup is done in order to use the requests module and immedietly begin making API requests. After connecting to the WiFi, the device sends 'mock' data to the database for logging via http POST request. The data is sent in JSON format.
Example format:
header = {
'User-Agent': 'Mesh Sensor',
'Content-Type': 'application/json;charset=UTF-8'}
payload = {
'DeviceID': 'Sensor001',
'Timestamp': time.time(),
'Temp': '72',
'Humid': '36'}
The feather board should have red LED if it cannot connect to the WiFi after turning on. To connect to WiFi, the secrets.py
file must be changed with relevant WiFi information. This includes the Wifi SSID, (The name of the network), and the password, (The password to the network). These are the first two fields in the secrets.py
file as shown below:
secrets = {
'ssid' : '[YourWifiNameHere]',
'password' : 'password123',
Once the device connects to WiFi, the led may turn orange if the server is unreachable. To specify a server to make a post request to, edit the server
varable in the code.py
script. (As shown below)
# Configuration
server = "http://www.github.com/Nat-As"
The example above will send the sensors data to the address: http://www.github.com/Nat-As
. This will ideally be changed to the server address of the database.
Cool Adafruit Libraries here
Some great examples
The device has an onboard RGB led that can have different colors which correspond to different meanings. A table of these colors and their meanings is shown below.
Color | Meaning |
---|---|
White | Device is booting |
Red | Failed to connect to WiFi |
Orange | Failed to send data |
Green | All systems go |
Rainbow | Default Firmware |