Close

SensorTile2

A project log for STM32L4 Sensor Tile

Small, connected device for smelling and hearing in any environment.

kris-winerKris Winer 07/30/2017 at 19:120 Comments

07/30/17

Technically, this is SensorTile3 since I changed the original Sensor Tile by replacing the switch and substituting the BMA280 for the MPU6500. But since it was this modified Sensor Tile that was used for initial testing, gathering the first real data and sending that data over the BLE UART bridge as well as starting low power consumption testing, etc I will call the latest incarnation SensorTile2.

SensorTile2 is just like SensorTile1 except I have added two new components. The first is the VEML6040 RGBW ambient light sensor (white arrow) and the second is Maxim's MAX17048 LiPo battery fuel gauge (red arrow). Here is a picture of the SensorTile2:

It's starting to get a little crowded on the pcb!

Both of these components use I2C to communicate to the STM32L432 host. The VEML6040 has no interrupt but the MAX17048 does. Unfortunately, I have no GPIOs left. The VEML6040 measures ambient light resolved as red, green, blue and white (total) counts which, with proper scaling, can return  R, G, and B light intensity in uW/cm^2 and total lux. The VEML6040 takes ~200 uA of power so I have made use of the embedded enable/disable capability to limit overall power usage.

I tried to extend the battery life in this first SensorTile2 experiment by updating the data sent via BLE every ten seconds instead of every second. I only got 70 hours, or an average power usage of 2.1 mA which is higher than the 1.75 mA I measured in a similar experiment using SensorTile1 with BLE update at 1 Hz. The reasons for this include that facts that I had the VEML6040 reading data at 1 Hz (~200 uA), I forgot to disable the green power-on led (just above the USB connector) which unnecessarily burns ~140 uA, I have the microphone powered on even though I am not really using it (~230 uA), and I am performing FFT analysis on the sound data when available at 1 Hz. I'll repeat the experiment after disabling the power-on led, reading the VEML6040 at 0.1 Hz, and turning off the microphone which should save at least ~570 uA and so I am hoping to finally get the average power at or below 1 mA.

In the meantime, I did get some interesting data with these new components. First the ambient light data:

I am plotting red, green, and blue light intensity as well as temperature in Fahrenheit over the seventy hours of the experiment. Note the date and time (24 hour PDT) are finally correctly recorded. The SensorTile2 was located on a metal bench on the back porch, mostly shielded from direct sun except for a short period twice a day, as can be seen by the spikes in both the light data and the temperature. I think there is a conversion error in the program since I am reading the data as int16_t, which can and does go negative occasionally, but I think this should be uint16_t. One more thing to fix. The initial spike in light coincides with sunrise and the second spike with overhead sun. There is a lot of detail in the shape of the light curves having to do with the particular siting of the sensor wrt the trees and house, etc. Not apparent on this scale but there are subtle changes in relative color components of the light that occur; there is more red at sunrise and sunset, for example, while green and blue dominate during mid-day.

The battery fuel guage measures battery voltage, state of charge (in percent) and charge/discharge rate. When I first tried it while using the SensorTile2 to charge the 150 mAH LiPo battery, I was surprised that the charge rate was still positive and the state of charge was less than 100% after the red charging light went out. After another hour or so the charge rate dropped to ~1% and the state of charge reached 100% (actually 101% !). The way the fuel cell works is that it has a model of the battery whose parameters are automatically adjusted over a few battery charge/discharge cycles. So I guess I shouldn't expect the model will be correct at first and, indeed, the recorded data show some odd results:

First the state of charge starts at 101% and steadily drops to 0% over the course of the 70 hour experiment. There are slight excursions when the SensorTile2 is exposed to direct sunlight and heats up a bit but otherwise the data are uninteresting at this scale.

Zooming in to the last 24 hours is more interesting:

The battery voltage is steadily declining reaching ~3.54 V at about the same time the charge remaining reported by the MAX17048 reaches zero! The device was happliy reading data and sending data via BLE up to the time I pulled the plug at 70 hours so I have to conclude the MAX17048 isn't yet properly calibrated to this particular battery. Once calibrated, however, good practice would be to program the SensorTile2 to shutdown once the battery charge reached 2% just to avoid  excessive discharge of the battery that could limit its useful life. if I did that now, I would be losing ~4 hours or ~6% of the available run time.

Ultra-low power management is not easy....

Discussions