Components used
Most of my components were found cheap on AliExpress or on Ebay. It’s amazing what you can get for a few dollars, if you are ready to wait for 1-2 month for delivery 🙂
- ESP8266 12E Module: Find at AliExpress
- Arduino pro mini: Find at AliExpress
- PPD42 Dust sensor: Find at AliExpress
- CCS811 CO2 sensor: Find at AliExpress
- TSL2561 Light sensor: Find at AliExpress
- MAX4466 Microphone: Find at AliExpress
- DHT22 Humidity and temperature sensor: Find at AliExpress
- BMP180 Pressure and temperature sensor:Â Find at AliExpress
- MH-Z19 CO2 sensor:Â Find at AliExpress
Here are the pictures of my components. I only linked to the search on aliexpress, because their products/copies changes all the time. You should be able to identify them by the pictures:
Diagram
The diagram was made pretty fast using Fritzing. Fritzing has a lot of well known components, but most of mine were missing. I made them very fast by this small trick on Youtube.
Splitting things into two microcontrollers
I decided to have two microcontrollers, mainly because the ESP is very time sensitive because it has to handle Wifi. It also has problems with its ADC introducing noise in my readings when the Wifi is transmitting. The ESP only takes care of:
- Three I2C devices: light, pressure/temperature and co2/tvoc
- Talking to the Arduino Pro Mini I2C slave device to get data from it’s sensors
The Arduino Pro Mini takes care of:
- Pir sensor – a simple high/low input. Are people moving or not?
- The temperature/humidity sensor via one-wire.
- Digital input from the dust sensor. This is has to be timed precisely via interrupts
- Microphone analog input. Sampling at 19khz – also pretty timing sensitive.
- Working as an I2C slave answering the ESP with collected data
- Periodically waking up the master for it to send it’s data
Noise
The microphone seems quite sensitive to noise on it’s power supply. When it’s on the same 3.3V supply as the ESP I get noisy readings. I tried decoupling it with a couple of electrolytes and some 100nF capacitors without luck.
The noise issue was fixed by powering the mic from an output pin of the Arduino Mini. Also by sleeping the ESP most of the time, I don’t see this problem anymore
Breadboard
Here is my test setup on a breadboard:
Next
In part 3 I will talk a little about the Aduino code.