Hive Monitor v4: Custom PCB
Iāve learned from my previous prototypes (v1, v2, v3) that the ideal system for monitoring hive conditions would be small and battery operated so that it can be placed inside the hive. My third prototype was the smallest yet, but required cutting away a secion of the beeās functional honeycomb. Moreover, I had to make them by hand, which doesnāt scale very well. So for this version, Iām going to try and make a printed circuit board with the same functionality.
ā”ļø Electronics
The basic requirements for this thing are:
- An ESP32, which already has WiFi and Bluetooth built in
- a microphone
- a temperature and humidity sensor
- a method of storing large amounts of data
Based on my previous prototype, I drew up a circuit that seemed like it would work. Then I paid a guy on Fiverr to draw up a PCB to implement that schematic, then had them fabricated somewhere in China. Hereās what the PCB looks like:
As you can see, thereās a microphone, a temp/humidity sensor, and a micro-sd card slot. Initially, I was going to include a micro USB connector, but that wouldāve complicated the circuit, and added cost. So instead I decided to use pogo pins on a 3d-printed jig to program the boards.
š¦ Enclosure
My previous design required that the honeycomb be cut away, but this one is thin enough that the PCB and battery can be slipped between the frames of the beehive. I modeled the enclosure in Fusion 360, then 3d printed it in yellow PLA.
Firmware
If youāre not interested in software, feel free to skip this section. My prime objective with this version was to reduce power consumption. I ended up spending a lot of time on this, primarily because the ESP32 is a power-hungry monster. Donāt get me wrong, itās amazingly powerful and dirt cheap, but itās not well suited for low power battery-operated IoT devices.
Some of the tricks I used to reduce power consumption:
- Using the deep sleep functionality of the ESP32, and using a hardware interrupt timer
- Re-compiling the bootloader to prevent checksumming the program memory on every wake
- Not syncing with WiFi on every wake
- Not writing to the SD card on every wake. Writing to disk is super slow, and thereās a lot of overhead to mount the disk. Iām saving the sensor readings to RTC memory, and pooling disk writes.
- Reducing the size of the audio buffer. This means the sound recording takes up less time (and makes the computation faster). The tradeoff is that you are effectively losing resolution in the output frequency domain (the frequency bin size is higher) but thereās a happy medium.
After all those optimizations, I was able to get the average wake time to under 200mS, which for this hardware is pretty good! Hereās the current on my oscilloscope.
Based on some experimentation and calculations, a 1000mAh battery would power this thing for 1.5 years!
Data Analysis
Iām still collecting data from these sensors, so I think Iāll save the data analysis for another time. Stay tuned!