The intent is to install the device once and have it be in autonomous service for two or three years. There is not a specific design goal here other than to minimize average power usage, size, and cost. In reality, it will be easier to minimize power usage and size than cost, but the "finished" devices should end up costing about $25 each with the cost dropping rapidly as production volumes increase.

There are practical benefits to small size. The device is more likely to fit into a wider size range of bins, the device is unobtrusive so less likely to be noticed by curious malefactors, the device is less likely to "interact" with the contents of the bin, etc. The reasons for low average power usage are obvious--smaller battery and/or longer battery life. The methods to get there are not. Let's start with the sensors.

We don't necessarily need all of the sensors mentioned above in every application, but it is useful to consider the case where we do. We need to detect and monitor bin level. We need to monitor temperature and humidity inside the bin in the case the contents are organic. Such cases include garbage bins, hospital waste bins, recycle bins, etc. We would like to know when the bin lid has been opened or has been left open, and we would like to know if the bin has been jarred or tipped over. What sort of inexpensive, low-power sensors could do all of this?

The ~$4 Bosch  BME280 (or BME680 in case air quality must be monitored, but this is not an inexpensive or low power sensor) measures temperature, pressure, and humidity. It has a forced mode, meaning the sensor wakes from low power (~1 uA) sleep, takes one measurement, and goes back to sleep upon a single command. Since all of the data we want changes very slowly (with the exception of the light level when the lid is opened) it makes sense to use a timer callback, in my tests every ten minutes, and in the callback the BME280 simply makes one measurement each of temperature, pressure, and humidity. At this duty cycle the power usage is between 1 and 2 uA.

The ~$1 Vishay VEML6040 is an ambient light sensor with four channels, R, G, and B as well as a broadband "white" channel which can be used to estimate IR. The VEML6040 has a standby current of just 0.8 uA and uses 200 uA when in measurement mode. Similarly, there is a forced mode but I have simply been doing this manually; enabling the sensor, reading the sensor for 40 ms (shortest integration time), and then disabling the sensor. This mode of operation uses ~8 uA. The problem is the VEML6040 has no interrupt. Ideally we would like to set a light threshold, have the sensor monitor the light level and wake the MCU when the threshold has been crossed. The purpose of the light sensor in this application is to detect when the bin lid is open. In normal use this occurs irregularly and for only a brief period. So in order to capture this we would have to run the VEML6040 in a continuous mode which would cost a lot of power for little benefit. So we might have to limit its use to detecting when the lid is left open or just not use this sensor at all. An interesting possibility is whether the pressure sensor variations could be used to detect lid opening and closing. This would strengthen the case for dropping the VEML6040.

And of course, there are cheaper and lower power photodiodes for light detection like the $0.50 0805 SFH2716 that would likely be better anyway for this application (what was I thinking with the VEML6040!?). This diode generates ~0.5 uA at 1000 lux (bright sunshine is 20 klux) so the circuit would use a 500 K resistor in a divider circuit to detect when the bin inside is dark (V ~0 V) or light is available (V ~2 V). The divider would be read by a host analog (ADC) GPIO .  This circuit costs almost no power since when dark the photodiode resistance is many GigaOhms. The STM32L082 ADC can be configured as a comparator and trigger an interrupt when the voltage crosses, say 1 V. Maybe the next design iteration will use this method.

The ~$3 Bosch BMA400 accelerometer uses 0.8 uA in continuous low power mode that  monitors motion at 25 Hz. When motion above a user-defined threshold is detected the BMA400 sends an interrupt to wake the MCU and the BMA400 switches automatically to normal mode at a faster sample rate. This is ideal for wake on motion, and for our use case detecting when the bin is jarred and recording the force history (acceleration) in the 1 kByte FIFO for later retrieval by the host.

Finally, there is level detection. We use the ~$3  VL53L0 time-of-flight ranging sensor that pulses 940 nm laser light, measures time of flight to and from a surface, and converts the measured time pulses to distance from ~1 to 2000 mm range accurate to +/-1 mm. The VL53L0 can measure absolute distances independent of target reflectance in less than 30ms. I use the single measurement mode for this sensor and a time integration of 20 ms. The data sheet lists a rather scary 19 mA for active ranging for this sensor but I am measuring something more like the 16 uA listed in the data sheet for "timed ranging inter measurements". So is this a low power sensor or not?

This is sort of a sore point for me. The VL53L0 (and VL53L1) is a fine and useful sensor and I have been using and selling breakout boards for it for a long time. However, ST refuses to publish a register map, insisting that users must use ST's C-based API and live with whatever happens to be in there. This is not quite as bad as the terror of the binary blob (see MPU9250 DMP) since one can actually read the functions and guess a fair bit of how the device works and is supposed to be used. And since Pololu has made a nice version of the API for Arduino it is possible to use the VL53L0 API as a black box and get it to work well. So why all the whining? Well, in this case even trying to estimate basic power usage from the data sheet is confusing. I simply had to measure it. 

Now there is a particular problem here that turns out to be interesting and a challenge to solve. The VL53L0 will measure the distance to any surface.  In a bin environment where organics and muck might interfere with the device innards, we need to have the device work behind a cover or in a container. So how does one measure distance to surfaces outside of the container and avoid the surfaces of the container itself? There is a handy application note on ths subject. Turns out the recommendation is to use a PMMA lens cover, available from Hornix Optical Technology Inc. in Taiwan (I bought 100 of them, $0.80 each). The lens cover fits over the VL53L0 with a small enough air gap that the PMMA doesn't register in the distance estimation. The lens cover then needs to be incorporated into the container proper to allow muck-free operation of the VL53L0. So there is a packaging challenge associated with this design.

Three remaining aspects of the device design are crucial to project success.

First, I am using the ~$12 Murata CMWX1ZZABZ (STM32L082 + SX1276) LoRa/LoRaWAN module as the host processor and connectivity engine. I described devices based on this module elsewhere on Hackaday. A development board with this module can be found on Tindie. The benefits of this module include Arduino IDE programmability, full LoRaMAC-compliant stack, ultra-low-power (1.65 uA) deep sleep mode, up to 20 GPIOS and all the usual serial peripherals.

Secondly, I am using inexpensive (~$1) Hammond boxes (1551P) as the container for the device. I designed the main pcb to mount inside the box on the mounting pegs. I designed the VL53L0 breakout to be off the main board and mount on the side of the Hammond box. I will have an appropriate hole machined in the box side to accomodate the PMMA lens cover for the VL53L0. This requires that I solder 5 wires connecting the main board and VL53L0 breakout board, at least for the initial build. I would like to find an interboard connector system that might work for this case as a later design revision. I'd really like to make assembly simple since I am hoping to produce and use these units in some quantity as bin level monitors.

The Hammond box sides have a ~5-10 degree flare so simply mounting the VL53L0 flush to the box side should give enough of an angle to push the measuring point toward the center of the bin. In the canonical round bin of height 3 feet a 10 degree angle puts the laser at 0.5 feet from the container edge. Far enough from the edge to be able to measure fill height reasonably well.

Lastly, while the teeny Hammond box meets the small size goal, the box is too small to accomodate AA or AAA batteries. So I designed the main pcb to use a Renata CR2477NAH coin cell battery with 950 mAH capacity, which should just fit inside the box.. My initial tests show the average power usage with all of these sensors measuring data and sending updates via LoRaWAN at 10 minute intervals is ~40 uA. I expect that the simplified design I am using with no LDO or battery charger, no SPi Flash and replacing the BMA280 (~6.5 uA low power mode) with the BMA400 (~0.8 uA low power mode) accelerometer should cut this further. Even so, at ~40 uA average power the 950 mAH coin cell should last for 2.7 years.

I have submitted a first design of the Bin Level Monitor pcbs to OSH Park and expect to get the boards back and assembled in a few weeks. I will discuss the initial build,  its power usage, and performance in the first log, probably toward the end of March.