Introduction ¶
Santa Cruz is a very beautiful place. We have mountains, rivers, forests and the ocean here. Our ecosystem is incredible, but it is unfortunately under a looming threat, along with every other ecosystem in the world. Climate change continues to be one of the biggest risks to life on our planet. Monitoring GHGs and other sources of pollution is important in quantifying environmental quality. I decided to create a small sensor that I will keep on my balconey to monitor local CO2 concentration.
Design ¶
The ESP-NOW WiFi communication protocol allows for instant and reliable communication between ESP microcontrollers. The only information needed for my setup is the MAC address of the receiver board. In the future I intend to build more sensor modules and place them in different areas of campus, however for this I would most likely need to use LoRa modules or connect the ESP8266s to the internet and send the data over MQTT. The ESP-NOW protocol works for me since I’m sending data over a short distance (the distance from my balconey to my bedroom). Obtaining the MAC address can be done using this script. The MAC address will be printed in the serial monitor.
#ifdef ESP32
#include <WiFi.h>
#else
#include <ESP8266WiFi.h>
#endif
void setup(){
Serial.begin(115200);
Serial.println();
Serial.print("ESP Board MAC Address: ");
Serial.println(WiFi.macAddress());
}
void loop(){
}
The data is sent within a struct.
typedef struct sensorData {
uint16_t eco2;
uint16_t etvoc;
uint16_t errstat;
} sensorData;
The struct I made stores the CO2, volatile organic compound and error status in integer values. These values are then sent to the receiver board that then displays the CO2 and volatile organic compound concentrations on a 80x160 OLED display. Currently the receiver board doesn’t do anything with the error status, however in the future I will add the ability for the receiver board to handle errors caused from internet disconnections and issues with the I2C bus.
Electronics ¶
The electronics for this project were, like most of my previous projects, pretty simple. I connected preassembled modules and dev boards together. The schematics for the CO2 sensor and receiver are shown below.
Case ¶
The case was fairly simple to design. One design trick I enjoy using to avoid having to use screws for mounting OLEDs is to use printed posts inside the case that are the same diameter as the holes in the corners of the OLED circuit board. The technique is shown below.
Overall, these cases weren’t too crazy to design.
Moving Forward ¶
This was a very fun project for me to work on. ESP-NOW is a very effective and easy to use protocol for transferring data between ESP boards and I plan to use it for my custom Battlebot control system. For this sensor system, I plan to connect the analog pin of the sensor board to the battery so that I can monitor battery voltage. I also would like to add a small solar cell so that the sensor can power itself. I also want to add more advanced datalogging so that I can visualize trends in CO2 and VOC concentration in Santa Cruz. I have been pretty strapped for time this school year between classes and work so these may be features that I will implement during winter break.