
Conceptualizing the Sensor
The idea was simple: build a compact, reliable, and customizable sensor that could collect environmental data in real-time. The ESP8266 microcontroller was the obvious choice due to its affordability, versatility, and built-in WiFi capabilities. However, the ESP8266 couldn't connect to the university's eduroam network, so I had to rely on local data storage using a micro SD card.
The sensor needed to measure three key parameters: sound levels, light intensity, and nearby devices (as a proxy for occupancy). Each required careful hardware selection and software configuration.
Hardware Design
The hardware setup was built around the NodeMCU ESP8266 12.0. Here's a breakdown of the components:
- Sound Sensor: MAX9814 — Measures sound pressure levels, convertible to decibels. Calibration was required for accurate readings.
- Light Sensor: BH1750FVI — Measures ambient light intensity via I2C. A light-ball diffuser was added for consistent readings.
- Device Counting: The ESP8266 was put into promiscuous mode to detect WiFi probe requests and estimate occupancy.
- Micro SD Card Adapter: Used for local data storage with encrypted files.
Software Implementation
The software was developed using PlatformIO in VSCode. Key features:
- Data Collection: Sensor readings every minute, stored on the SD card in encrypted form.
- Sound Level Calculation: Raw voltage readings from the MAX9814 converted to decibels via a logarithmic formula.
- Light Intensity: BH1750FVI provided lux readings written directly to the SD card.
- Device Counting: WiFi probe requests processed to estimate occupancy levels.
- Data Encryption: AES encryption for stored data, with a Python script for decryption during analysis.
Data Processing and Analysis
Once the sensor had collected enough data, I transferred and decrypted the files and processed them using statistical and machine learning techniques:
- Sound Levels: Excessive noise negatively impacted comfort and focus; moderate background noise was generally well-tolerated.
- Light Intensity: Brighter light was associated with more positive emotions, especially during group activities.
- Device Counts: Higher occupancy created a lively atmosphere but could also lead to overcrowding.
Challenges and Lessons Learned
- Hardware Compatibility: Not all SD card brands worked reliably with the ESP8266 — testing different options was essential.
- Sensor Calibration: Calibrating the MAX9814 microphone was tricky but crucial for accurate readings.
- Privacy: Anonymized device counting required careful consideration to ensure no personal data was collected.
Conclusion
Building this custom sensor was a rewarding challenge. From hardware design to software implementation and data analysis, the project pushed me to explore new technologies and problem-solving techniques. Its modular design makes it adaptable to many other applications beyond the original research purpose.
If you're interested in building your own environment sensor or have questions about the technical process, feel free to reach out.