yunqu / iot-hub-c-raspberrypi-client-app

Application collects weather data from a BME280 sensor and sends it to IoT hub, also take actions according to cloud-to-device message, device management.

Home Page:https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-c-get-started

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

services platforms author
iot-hub
C
shizn

IoT Hub Raspberry Pi 3 Client application

Build Status

This repo contains the source code to help you get started with Azure IoT using the Microsoft IoT Pack for Raspberry Pi 3 Starter Kit. You will find the full tutorial on Docs.microsoft.com.

This repo contains an arduino application that runs on Raspberry Pi 3 with a BME280 temperature&humidity sensor, and then sends these data to your IoT hub. At the same time, this application receives Cloud-to-Device messages from your IoT hub, and takes actions according to the C2D command.

Set up your Pi

Enable SSH on your Pi

Follow this page to enable SSH on your Pi.

Enable SPI on your Pi

Follow this page to enable SPI on your Pi

Connect your sensor with your Pi

Connect with a physical BEM280 sensor and LED

You can follow the image to connect your BME280 and a LED with your Raspberry Pi 3.

BME280

Download and setup the client app

  1. Clone the client application to local:

    sudo apt-get install git-core
    
    git clone https://github.com/Azure-Samples/iot-hub-c-raspberrypi-client-app.git
  2. Run setup script:

    cd ./iot-hub-c-raspberrypi-client-app
    
    sudo chmod u+x setup.sh
    
    sudo ./setup.sh

    If you don't have a physical BME280, you can use '--simulated-data' as command line parameter to simulate temperature&humidity data.

    sudo ./setup.sh --simulated-data

Run your client application

Run the client application with root priviledge, and you also need provide your Azure IoT hub device connection string, note your connection should be quoted in the command.

sudo ./app '<your Azure IoT hub device connection string>'

Send Cloud-to-Device command

You can send a C2D message to your device. You can see the device prints out the message and blinks once when receiving the message.

Send Device Method command

You can send start or stop device method command to your Pi to start/stop sending message to your IoT hub.

About

Application collects weather data from a BME280 sensor and sends it to IoT hub, also take actions according to cloud-to-device message, device management.

https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-c-get-started

License:MIT License


Languages

Language:C 89.9%Language:Shell 6.4%Language:CMake 3.6%