#AzureIoT – Using a Raspberry Pi Grove Sensor in an ☁ Azure IoT Edge Module (1/N)

Buy Me A Coffee

Hi !

I’m a big fan of SeeedStudio Grove products. When you are prototyping IoT devices, the grove connectors are super fast way to work. You basically avoid all the wiring, and just connect cables betwen a IoT device like a Raspberry Pi, and sensors like a Temperature and Humidity monitor. Again, no wiring, no proto-boards, just plug and play.

I started with Grove back in Spain, mostly working with Arduino, thanks to Ramon (my former boss). And today I really enjoy the suite of sensors / actors that we have in other platforms, like Raspberry Pi, Azure Sphere, and more.

All the grove devices usually come with code sample, and libraries in C++ for Arduino based devices, and also in Python for the Raspberry Pi family. And this is my main goal for these posts:

Show how we can use a grove sensor in a Raspberry Pi, in an Azure IoT Module.

Let’s start with a simple scenario using these elements

  • Raspberry Pi
  • Grove Base Hat for Raspberry Pi
  • Grove – Temperature&Humidity Sensor (DHT11)

And about the sensor

This Temperature&Humidity sensor provides a pre-calibrated digital output. A unique capacitive sensor element measures relative humidity and the temperature is measured by a negative temperature coefficient (NTC) thermistor. It has excellent reliability and long term stability. Please note that this sensor will not work for temperatures below 0 degree.

Next step is to follow the instructions to install the python dependencies, and then we can run this code to get the values from the sensor.

import time
import seeed_dht
def main():
 
    # for DHT11/DHT22
    sensor = seeed_dht.DHT("11", 12)
    # for DHT10
    # sensor = seeed_dht.DHT("10")
 
    while True:
        humi, temp = sensor.read()
        if not humi is None:
            print('DHT{0}, humidity {1:.1f}%, temperature {2:.1f}*'.format(sensor.dht_type, humi, temp))
        else:
            print('DHT{0}, humidity & temperature: {1}'.format(sensor.dht_type, temp))
        time.sleep(1)
 
 
if __name__ == '__main__':
    main()

And the output is as expected

So 1st step is easy, in the next posts I’ll share some of the challenges and lesson learned moving this to an Azure IoT Module.

References

Happy coding!

Greetings

El Bruno



¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.