THe BME280 temperature, pressure and humiditty sensor, and similar devices, can be used with some existing sample Azure Sphere projects with and without modification, to stream telemetry data to an Azure IoT Hub. This article looks at a project using the Seeed Grove version of the sensor mounted on a MT3620 Grove shield, as well as a project for when the sesnor is directly connected to the MT3620 Azure Sphere without the shield.

Previous posts covered .Net Core projects on the RPi using the dotnet/io GitHub repository for implementing GPIO, 1-wire and I2C communications for enviroment sensors connected to a RPi, acting as an IoT Device. The focus was upon streaming telemetry data to an Azure IoT Hub and monitoring that from a client side service, all using .Net Core. In particular the BMP180 and BME280 sensors were using in that context to generate the data to stream. The DHT22 sensor was also used. The focus here is upon using the same IoT Hub and client service app but with an Azure Sphere acting as the IoT Device.

The MT3620 and Shield

The MT3620 was the first Azure Sphere reference board. Whereas later Az Sphere boards (eg Avnet) have inbuilt sensors, this board only provided GPIO an UART, initially. I2C and SPI came later at or prior to GA. In the interim, Grove produced the MT3620 Grove Shield that provides some GPIO but also provides ADC, I2C and SPI all through the standard Grove 4 pin sockets. This physical arrangement, the sockets, means that subject to suitable drivers being available, the vast range of Grove Sensors and Actuators can be used with some physical plug and play simplicity.

For this shield there is the GitHub repository Azure Sphere MT3620 Grove Shield Library which implements drivers for many Grove devices as well as a selection of sample projects. The shield presents only 4 of the Az Sphere GPIO pins for use by plugin devices. They are GPIO0,1,4 and 5. GPIO66 and 68 are also available but are used as a UART for devices. Other Az Sphere GPIO pins are used to control a SC18IM700 and AD7992. The first one of these provides I2C for plugins and the second ADC for plugins. The Az Sphere communicates with all I2C devices via a second UART (Az Sphere pins GPIO26 and 28). The AD7992 piggybacks onto the SC18IM700 for Az Sphere interations via I2C but also uses two Az Sphere pins for conversion control. Most Grove Shield Library communications with the Az Sphere are via the UART. I2C is wrappered around this. The shield schematics is here.

Grove MT3620 Shield
The Grove MT3620 Shield

BME280 via the Shield

The library contains sample projects for the 5 devices provided in the Grove Starter Kit for Azure Sphere MT3620 Development Kit. There are though drivers for other Grove devices such as the BME280. This though is only for temperature. I have forked the library here, and extended the functionality for that device for pressure and humidity and have implemented a saample project for the sensor in the repository. The ReadMe page there has been modified from the original, which showed the SHT31 temperature and humidity sensor API, to exemplify the BME280 functionality. It will be extended to send telemetry data to an IoT Hub (2Do).

If using this project, please read my notes wrt the device addressing in the repository (0x77«1 or 0x76«1))

Reading BME280
Temperature: 15.6C
Humidity: 52.9%
Pressure: 1010.4hPa

Reading BME280
Temperature: 15.7C
Humidity: 53.1%
Pressure: 1010.4hPa

The Debug Output

BME280 Direct I2C

The Azure/azure-sphere-samples contains an I2C sample app. Given that the Az Sphere now directly supports I2C I modified that sample to communicate with a BME280 directly connected to the Az Sphere without the shield. This was able to correctly identify the BME280.

The thought was to fully implement the direct I2C libary for the BME280. The full general C code for the device is listed here at Bosch.

Luckily there is an existing sample project that wrappers this library around I2C for the Azure Sphere. It also provides telemetry data for an IoT Hub via Azure IoT Central . The sample project Connecting an I2C sensor (Bosch BME280) and send telemetry to Azure IoT Central is part of the GitHub Hub repository JuergenSchwertl/AzureSphereSamples from Juergen Schwertl .. Thx 😄.


 TopicSubtopic
  Next: >  
<  Prev:   az-iothub-ps
   
 This Category Links 
Category:Azure Sphere Index:Azure Sphere
  Next: > Azure Sphere Projects
<  Prev:   Azure Sphere