Close

Power Testing

A project log for Bin Level Monitoring

Designing an IoT device to monitor and report the fill level of bins for holding recyclable discards of various kinds.

Kris WinerKris Winer 03/18/2019 at 02:580 Comments

17 March 2019

I took the plunge and used my drill bits and round file and made a hole in one of the Hammond boxes that the lens cover and VL53L0 could mount into.

Not great, but it will do. I soldered 30 gauge-silicone-insulated wires between the VL53L0 daughter pcb and the main board, deciding that just 3V3, GND, SDA, and SCL were enough since: 1) using hardware shutdown only saves ~1 uA over software shutdown and 2) it takes time to initialize the VL53L0 when exiting hardware shutdown whereas the latency for software shutdown is quite low, and 3) I am using one-shot measurement, no real need for a data ready interrupt here. I should have moved the hole over to the left another 100 microns since there is a tiny interference between the VL53L0 pcb and the mounting screw for the main board. Nothing serious though. And I used too long wire length, so I ended up with a bunch of wire I have to tuck into a corner.  Overall, this works. But on the next iteration I need a better scheme for board-to-board connections!

The white jumper is a poor man's switch. It connects the coin cell battery anode with board power, so I just need to install the battery and close the jumper to turn on the device.

I modified an existing program specifically for the Bin Level Monitoring application. The basic architecture is to configure all of the sensors and LoRaWAN parameters, and create timer callbacks in the setup function. Then in the main loop everything is based on an interrupt-triggered flag and the default state is MCU in deep sleep (STOP) mode until something happens to wake it up. This can be a sensor interrupt, an RTC alarm interrupt or timer interrupt. Here I am using the BMA400 interrupts set for wake-on-motion and sleep-on-no-motion. So flags are set whenever these interrupts trigger, but I am not really using these for anything yet.  I could use a simple counter to display the number of times the BMA400 detects a wake condition as a bin collision indicator, or simply keep track of the number of times and when the bin has been moved. This is still TBD.

I am using the single measurement modes of the BME280 and VL53L0 and I am manually measuring the ambient light with the VEML6040 by enabling the sensor, waiting the integration time, and then disabling before reading the RGBW data. I tried to use the trigger mode for single meaurement but I didn't get this to work at first. I will have to work this out on the breadboard where programming is more convenient.

The idea is to set two timers, one for LoRaWAN and one for reading all of the sensors. These could have different duty cycles in the case the sensor data is to be logged, for example. But in this case, there is no SPI flash on the board, so I set them both to either one minute or ten minute intervals, the latter is the likely setting for actual use in monitoring bin level.

When the sensor timer triggers, the readSensors flag is set to TRUE in the callback, the MCU is woken up, and the main loop executes. When the main loop gets to the if(readSensors == TRUE) test, the main loop enters the section where all of the sensor data is read. I have this timed to occur two seconds before the LoRaWAN timer triggers an interrupt. If there is no other business to attend to the MCU goes back to sleep and waits for another event.

When the LoRaWAN timer triggers, the callback constructs the LoRaWAN data packet from the last data entries and sends it.  The MCU wakes from sleep just long enough for the LoRaWAN modem to operate and then returns to sleep. I am using CayenneLPP protocol to send the data so it can be conveniently displayed on the myDevices dashboard.

Fortunately, everything works. The range is in cm, battery level in Volts. I am measuring ambient light through the blue translucent box.  I think the accelerometer is reading zeroes because I calibrated offset biases with the device standing vertical instead of flat as the function expects. This dashboard is from one of the power tests on my workbench, where I used ST's X-Nucleo-LPM01 to measure average current usage at 3.0 V power input.

I ran two power tests for a total of either one or two hours. The first test with the sensor read and LoraWAN Tx duty cycles at one minute and the second test at ten minute intervals. At one minute duty cycle, the average current usage after one hour run time was 174 uA and the sleep current (when the MCU is in STOP mode and all sensors are at standby) was 7.2 uA. Obviously, the average current is going to depend on the duty cycle. At ten minute duty cycle, I measured 37 uA average current usage after one hour and 30 uA after two hours. I expected (174 - 7)/10 + 7 uA ~24 uA since the ten-minute-duty-cycle case should use ~1/10th the power of the one-minute case. And maybe when averaging over even longer times that is what I would measure, but I got tired of waiting...

So let's just say that at ten minute duty cycle, the average current usage is less than 30 uA. Then the 950 mAH coin cell battery should last at least 950 mAH/(0.03 mA x 24 H/day) ~ 1319 days or 3.6 years.

Well, maybe a one week real-world test in an actual bin would be in order before we get too carried away....

Discussions