IoT Prototyping with Qwiic Sensor Modules from SparkFun Electronics

The link at the end of this post describes how I interface to sensor boards from SparkFun Electronics. These particular sensors are of interest to us for use in upper atmospheric research.


Balloon launch from January 2019. Electronics are housed in pods tethered to the ballon.


IMP004m connected to a carrier board with connectors.

These are the sensor boards I have written drivers for so far.

  • SparkFun UV Light Sensor Breakout - VEML6075 (Qwiic)
  • SparkFun Spectral Sensor Breakout - AS7263 NIR (Qwiic)
  • SPARKFUN AMBIENT LIGHT SENSOR BREAKOUT - APDS-9301
  • SPARKFUN TRIPLE AXIS MAGNETOMETER BREAKOUT - MLX90393 (QWIIC)
  • SPARKFUN TRIPLE AXIS ACCELEROMETER BREAKOUT - MMA8452Q (QWIIC)

Click on the link for detailed discussion.
https://www.evernote.com/l/AC9A4TJcWpFMpYGU-UFsau6VptE_YqG47QI

If you need engineering help with interfacing to Electric Imp devices, please contact me.:grinning:

Nice write-up. What’s the carrier board? A custom board, or something you re-purposed?

The carrier board is a custom board I designed to fit in the balloon pod. On the underside are FRAM chips and a buck-boost converter.


Here’s the topside with the serial port connected to a GPS unit.


Here’s the bottom side, showing the buck-boost converter (https://www.sparkfun.com/products/10255) The battery is a LiPoly, which can survive extremely low temperatures. (LiIon batteries do not function much below freezing.)

Gotta love the folks at pcbway.com. I got 10 boards made for under $30, with delivery in 1 week.


In this image, you can see the Imp mounted inside the pod. There is actually another Imp mounted on the top, upside down. The two vials are filled with water and antifreeze, so the students could study the freezing properties of different liquids. You can see other sensors, and the GPS attached.

There are analog temperature sensors, LM135s, inserted into the vials. The electronics are conformal coated to protect them from moisture. After the flight, the vials will be damp from condensation, which is also why I put them on an absorbent blue towel.


This image shows the outer housing installed. This pod is then attached to other pods for the flight.


In this image, you can see the pods suspended under the balloon, just prior to launch.

SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)

This SparkFun combo board contains two sensors. The BME280 is a temperature, pressure and humidity sensor. The CCS811 is a digital gas sensor designed to measure Total Volatile Organic Compounds (TVOC) or equivalent CO2 (eCO2) levels, where the main causes of VOCs is from humans. There’s an incredible amount of environmental information packed into these two tiny sensors, mounted on a 1” x 1” board.

Squirrel Device Driver

I just finished adding the SparkFun Environmental Combo board (see pictures below) to the list of boards I have written drivers in Squirrel for the Electric Imp IMP004m. The combo board contains two I2C connected sensors, the BME280 and CCS811. All the details of the board, including data sheets, schematics and Arduino libraries on GitHub can be found at: https://www.sparkfun.com/products/14348. Click on the “Documents” tab.

When I write a device driver, I start by establishing basic communication with the device. Most all devices have an internal identification register that can be queried that supplies an ID value. Once this is established, communication with other control and data registers is developed.

I also find it convenient to grab register addresses and enums from Arduino code. For example the Arduino C++ code will have a long list of registers, which for example might include #define statements like:

#define BME280_DIG_T1_LSB_REG 0x88

These are easily converted to Squirrel statements as follows:

const BME280_DIG_T1_LSB_REG = "\x88”;

I generally don’t try to copy the functions and code directly from the Arduino C++ code, but use it as a guideline for the Squirrel driver interface. Also, for reference here is the article on how to port Arduino code to the Imp: https://developer.electricimp.com/resources/arduinoport.

BME280

The BME280 is a pressure and humidity environmental sensor. As with the other sensor drivers I’ve developed, I studied the published data sheets and Arduino drivers on GitHub. The BME280 data sheet is published by Bosch and would seem to contain the customary collection of registers for control, along with access to data registers. The problems and challenges with the BME280 sensor is that it requires substantial computation effort to determine the temperature, pressure and humidity. Additionally, those computations are based, not only on the A/D readings from the sensor, but also on 18 compensation parameters stored on the device.

Troubleshooting the BME280

What this means is that troubleshooting is extremely complicated. The equations from the data sheet for the temperature, humidity and pressure are complex, and need at least 32 bit integer support. The 18 compensation parameters are split among the calculations for temperature, humidity and pressure. Each of the values used in the computation must be assembled into Squirrel 32 bit integers from bytes retrieved from the device registers. If one of the computations isn’t working, there’s no good way to know if the problem is with the equation or with one of the compensation parameters.

In my case I tracked down a programming error which had caused errors in the compensation parameters for the humidity calculation. Since I didn’t know what a normal set of compensation parameters looked like, and I wasn’t sure if the equations were correctly implemented, troubleshooting took considerable time. Problems with the BME280 computations were also discussed on GitHub, so I’m not the only one to have experienced problems.

Even after getting readings from the BME280, there isn’t a good way to confirm the readings for humidity. It is possible to compare it against local weather reports, but that doesn’t seem to be a good way to confirm the accuracy of the readings. In general, the readings seem to be low, for local conditions. If I exhale on the sensor, the humidity goes up to about 70% or 80%, but that isn’t an accurate calibration either. Again, it seems it should be higher. I’ll continue testing.

CCS811

The CCS811 wasn’t nearly so difficult to implement, because there are no compensation parameters or equations to implement. The eCO2 and TVOC information is read from registers in final form. The difference with this chip, is that you need to supply it with temperature and humidity information (conveniently from the BME280) in order for it to produce accurate results.

Since there is no way to easily compare the CCS811 sensor with known eCO2 or TVOC readings, you just have to assume the values are correct. This also assumes that the humidity and temperature information from the BME280 is correct. If you exhale on the sensor you can see the values climb, which means the sensor is functioning.

Conclusion

Sensor size continues to shrink to incredible small sizes, while functionality and capability continue to grow for each device. These are tiny sensor computers that offload the main processor of many of the sensing tasks, such as managing A/D converters, multiplexers and gain control. To top it off they run at ultra low power.

SparkFun has provided a great way to probe the capabilities of these small sensors with their Qwiic system of connected boards. I’ll be continuing my testing of these boards with the Electric Imp, and if you have any questions, please drop me a line.


SparkFun Environmental Combo Breakout - CCS811/BME280 (Qwiic)

SEN-14348

This board contains two sensors. The BME280 is a temperature, pressure and humidity sensor. The CCS811 is a digital gas sensor designed to measure Total Volatile Organic Compounds (TVOC) or equivalent CO2 (eCO2) levels, where the main causes of VOCs is from humans.

In order for the CCS811 to accurately measure TVOCs, it needs temperature and relative humidity information, which it can get from the BME280.