Close
0%
0%

STM32L4 Sensor Tile

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

Similar projects worth following
This is a 20 mm x 20 mm four-layer pcb tile full of interesting sensors (ICS43434 I2S Digital Microphone, MPU6500 acclerometer/gyro, BME280 pressure/temperature/humidity, and CCS811 air quality) with a Rigado BMD-350 UART BLE bridge for sending data to a smart phone all managed by a STM32L432 host MCU.

The STM32L432 is programmed using the Arduino IDE via the USB connector and serial data can be displayed on the serial monitor to verify performance and proper function, etc. But it is intended to be powered by a small 150 mAH LiPo battery for wireless sensing applications. The STM32L4 is a very low power MCU and with proper sensor and radio management it is possible to get the average power usage down to the ~100uA level, meaning a 150 mAH LiPo battery can run the device for two months on a charge.

There is a 1 MByte SPI flash memory on board which allows either data storage for very low duty cycle BLE radio transmission and/or to store a firmware upgrade for OTA reprogramming of the STM32L4.

There is a MAX1555 LiPo battery charger on board, a power switch that controls the enable on the NCV8170 LDO, and 3V3, GND, SDA, and SCL are exposed as through holes on the board for ease of testing and in case another I2C sensor needs to be added.

The pcbs are available at OSH Park in the shared space.

Arduino-programmable STM32L432 development boards can be purchased here.

Update February 12, 2017

I assembled the first three pcbs I received from OSH Park. and on at least one of them I got almost everything working. Assembly was difficult since the board is crowded on both sides with not a lot of edge to grab onto. I guess this is the price of a small, compact board with lots of sensors!

I verified that the STM32L4 can be programmed via the USB using the Arduino IDE, of course, and that I can blink the on-board led on pin 13, read the internal temperature sensor and VDD voltage, as well as get time and date from the embedded RTC.

I also verified that the BME280 pressure/humidity/temperature sensor, ICS43434 microphone, 1 MByte SPI flash, and MPU6500 accel/gyro work as expected.

I had a bit of trouble with the CCS811 air quality sensor, partly because it is new to me and mostly because the land pattern is pretty tight for a LGA package. I might have to redo the footprint to make it more likely to make a good connection to the board. Of the three boards I (partially) assembled, one has a short between 3V3 and GND due to the poor soldering of the CCS811, one functions well enough but the I2C address of the CCS811 is 0x5B when it should be 0x5A since I set the ADO pin to GND in the design. So there is obviously some kind of connection problem on that one too. The third one seems fine, the I2C address of the CCS811 is 0x5A as it should be. I can't get proper data out of either of these last two and the heater current shows zero Amps and the heater voltage shows 0.83 V so the heater circuit doesn't seem to be working properly. I have asked AMS for access to the application notes so I can figure out how to properly configure this sensor.

The battery charger works as does the battery voltage monitor connected to an ADC of the STM32L432. The 12-bit ADC makes it possible to detect changes in battery voltage of 0.01 V, so one can watch the battery voltage slowly rise in just a few minutes as it charges. The temperature measured by the BME280 and internal STM32L432 temperature both rise several degree when the battery is being charged. I guess this draws a lot of current through the MAX1555 (~100 mA IIRC).

The Rigado BLE module is missing since Digikey won't have them in stock for another week or two. I have two samples from Rigado I assembled into breakouts for testing; I suppose I could harvest one of these to add to the Sensor Tile but I think I will just wait to get a real supply of them.

So what is the rationale for these sensors, are they chosen at random? Not really. The device will find first applications in sensing emplaced capital machinery. The idea is that there are a lot of expensive industrial machines operating in production lines that do not have adequate monitoring of their function and performance. Or such data needs to be manually accessed and printed out of a controller designed twenty years ago, etc. So this sensor tile is designed to be mounted to these machines, and return data wirelessly, automatically, and remotely. So it has to last a long time on a LiPo battery, has to send data that can be funneled up to the cloud or to a server, and has to measure things worth knowing.

One thing worth knowing is whether the machine is operating or not. This is easy to tell just be monitoring the vibrations detected by the accelerometer, which tend to have normal modes at the 60, 120, and 240 Hz supply voltages of AC motors that run them. In...

Read more »

  • First revision of the Sensor Tile

    Kris Winer06/18/2017 at 06:33 0 comments

    06/16/2017

    I redesigned the Sensor Tile slightly replacing the power switch with a smaller ALPS SSAJ110100 switch, replacing the 3 mm x 3 mm MPU6500 with a 2mm x 2 mm BMA280 accelerometer but otherwise it's still the same concept. The accelerometer change is to reduce the cost and improve the performance. The BMA280 has two multiply-configurable interrupts, is much lower power than the MPU6500 (I never really had a use for the gyro anyway) and offers a rich variety of interrupt configurations (single and double tap, pan, tilt, portrait and landscape detection), as well as a high-pass and low pass filter. It is much more versatlie than the MPU6500 and a better choice for a low-power wearable device.

    The goals of the project remain the same. And I expect the BMA280 will make achieving them a little easier since I can run the accelerometer at 2 kHz (unfiltered) which means I can detect vibration and sound up to 1 kHz or so. This nicely complements the ICS43434 I2S digital microphone (50 - 20,000 Hz).

    While the board has been slightly modified, I finally got around to learning how to construct "proper" C++ libraries and rewrote the single, integrated Arduino sketch I started with into a series of individual sensor libraries (with .h and .cpp files) and now I am able to contol the I2C sensors with proper constructors resulting in a slimmer main code (still ~400 lines) that is a little easier to manage. Here is the library.

    I am using interrupts wherever possible (BMA280, CCS811, and RTC) but for the devices that have no interrupt (ICS43434 and BME280) I am using the RTC alarm to interrupt in order to set the duty cycle for reading and reporting data, either to the serial monitor or to the smartphone via the UART bridge provided by the BMD-350 (nRF52) BLE module.

    I still need to figure out how to efficiently transfer the data via BLE so I can run the Sensor Tile at the lowest CPU clock speeds (~1 MHz) and use the lowest power mode (STM32.stop between interrupts) to cut the average power usage down as low as possible while still getting useful data via BLE to a laptop.

    To this end I have designed an nRF52 add-on for the Butterfly (STM32L433 development board, sister to the STM32L432 used as host MCU for the Sensor Tile) that wil allow the nRF52 to operate in central role and pass data to the Butterfly via its own UART bridge and then on to the laptop via the USB cable. Thus I expect to have a wireless Sensor Tile spewing lots of data wirelessly to the laptop for capture and analysis.

    Still a lot to do but the path is getting clearer and I see no showstoppers along the way to prevent eventual success.

  • Update for March 9, 2017

    Kris Winer03/10/2017 at 05:04 0 comments

    I finally got back to this project and made some progress today on several fronts.

    First on the anomalous I2C address of the CCS811, which occasionally shows 0x5B even though I connected the ADO pad to GND in the design. I discovered that since this pad is connected to the large ground pad in the center of the CCS811 that the solder will wick away from the ADO pad during assembly and result in no contact between the address pad and GND, and a subsequent setting of the I2C address to 0x5B which seems to be the default. That is, the pad is pulled up by default. The solution is to butter this pad with solder paste either before (best) or after assembly (what I did) to ensure good contact. This kind of thing is a common problem with LGA packages, as I have learned the hard way on the LSM303D.

    Secondly, I was getting weird results from the CCS811. I got CO2 levels way above what should have been the maximum range and the VOC always showed 144 ppb. Well, it turns out I had the register indices reversed, and now I am getting ~400 ppm CO2 and ~10 ppb VoC, unless I breathe on the Sensor Tile, and then these values go up in a pleasingly responsive way-- I have a bad breath detector!

    Lastly, I took advantage of the BLE modules I finally received and assembled and started to set up broadcast of the data to the Rigado toolbox. So far I have battery voltage, BME280 pressure and humidity being written to the UART console on my iPhone every second via BLE and the BMD-350 UART bridge. It is not elegant but for the first step in a remote environmental sensor it will do.

    Next step is to package all of the relevant data into a data packet and send the packet every 20 - 50 ms to the laptop, where the packet sniffer Wireshark will allow me to grab it for parsing and display. Packaging pressure, humidity, temperature, acceleration (or vibration), CO2 and VOC along with time and date will need a packet of about 60 bytes or so, small enough for BLE to handle. But there is an I2S microphone on the Sensor Tile and apart from analyzing normal modes via FFT and passing these along with the data packet, it will take some more thought to allow sound recording to be sent via BLE. There is a 1 MByte SPI flash on the board so I could simply record the I2S data from the microphone and then send it periodically in a dedicated bit stream via BLE. Preferable would be real time voice/sound transmission, but this might require wifi, as in the ESP8285, to be practical. There are a lot of possibilities in this sector, and the least mature aspect of the Sensor Tile.

    The Sensor Tile is sort of a combination Start Trek Tricorder and Communicator rolled into one, but it will take me a bit longer and a lot more work to get the most utility out of it.

  • Added Rigado BMD-350 BLE module

    Kris Winer02/26/2017 at 04:24 0 comments

    February 25, 2017-Finally got a hold of some of the Rigado BMD-350 nRF52 BLE modules; Digikey finally had some in stock so I bought 100 for prototyping, etc. Soldering them onto the board was a piece of cake. They are very small, and the pcb that supports the module is quite thin, I think 0.5-mm.

    I had written a program last year when I got a couple of samples from Rigado to test the functionality of the UART bridge. The Arduino sketch (run on the STM32L432 on the Sensor Tile) instantiates two serial ports, one between the STM32L432 and the BMD-350 and one between the STM32L432 and the laptop through the USB cable.

    The program starts by putting the module into AT command mode. There I check the module, bootloader, and firmware version numbers set the baud rate, query and/or set various parameters like flow control, parity and whatever else I need to configure the UART bridge parameters. Then the program puts the module back into UART bridge mode and the program waits for valid data to be sent from the laptop console, which is then sent on to a UART console running from Rigado's toolbox on my iPhone as a UART console app. Whatever I type in the UART console on the iPhone app shows up after some delay on the laptop and vice versa.

    The speed of the transmission is surprisingly slow. The top speed I expect per Rigado's data sheet is 1 kByte/s, appallingly slow compared to wifi, for example. But the words that appear on either console take a second or two to spell themselves out so the rate seems even slower than this.

    Next to do is to package the sensor data and have it sent by the program to the console. I think I am going to have to figure out how to write iOS apps if I want to have a custom interface to accept my Sensor Tile data. Well, at least all of the hardware is working as it should!

  • February 14, 2017

    Kris Winer02/15/2017 at 05:14 0 comments

    I received an application note from AMS on how to interface with and program the CCS811 Air Quality sensor and discovered the missing bit of information, which was I needed to write to the application ready register to take the CCS811 out of boot mode (into which it enters on power up) and into application mode. Once I did this I stopped getting I2C read and write errors and started getting data as well as a data ready bit in the status register. I got the interrupt working as well as the humidity and temperature compensation from the BME280 sensor to improve CCS811 accuracy. Over all the sensor seems to be working as designed. I need to let it stay on for a while to "burn in" before I can get reliable readings, but overall the initial phase of the sensor tile is a success. All sensors on board are functioning and returning data.

    I measured the current used by the Sensor tile with no great effort to minimize power usage yet and found that when the BME280 and MPU6500 are running normally as well as having the STM32L4 host run at 80 MHz the current is about 6.25 mA, more or less what I expect. However, when the CCS811 air quality sensor is enabled once every 10 seconds in the present operating mode the current jumps to about 25 mA. If it takes ~1 second to get the air quality data, this is an additional ~25/10 ~ 2.5 mA for a total of almost 9 mA average current. Way too high to be practical as a remote sensing device. So as I work towards lowering the average power used by this device I will have to pay close attention to how long I enable the CCS811. In the application note there is an example of enabling it just long enough to read I2C data, but I think the best method is to take advantage of the rather long duty cycle (once per 60 second measurement) available and interrupt on threshold capability to save power.

  • First build

    Kris Winer02/12/2017 at 19:14 0 comments

    February 12, 2017:

    I added some details about the results of the first assembly of the Sensor Tile. Overall everything works, but I haven't got the CCS811 air quality sensor to work properly yet and I am still waiting for the Rigado nRF52 BLE modules to become available.

View all 5 project logs

Enjoy this project?

Share

Discussions

Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates