Turta IoT HAT is a multi-sensor add-on to Raspberry Pi for fast prototyping and learning. It makes reading and combining different sensor measurements easy. In this example, we're going to connect a Raspberry Pi to Azure IoT Central, then send sensor readings to the IoT Central.
- Raspberry Pi 3 running with Raspbian OS
- Turta IoT HAT
- Azure IoT Central account
- Internet connection
To make the example easier, we're going to use Python over Raspberry Pi. Here is the step by step guide.
1. Create a Device Template, and add "humidity", "pressure" and "temp" fields as telemetries. (There is a post here describes creating device template.)
2. Copy the following code to your computer.
3. From IoT Central device window, click Connect on the top-right of the device screen.
Grab scopeId, deviceId and primary key, fill the necessary parts on the "azureiothat.py" file.
4. Install "iotc" Python client using the following command using SSH.
pip install iotc
5. Copy the "azureiothat.py" file to your Raspberry Pi, and run it using the following command.
After a few seconds, you'll see a connected message on the terminal. Then, your Raspberry Pi will send environmental readings continuously. You can see the data graph from the "Device Explorer" menu.
To quit the application, press CTRL+C.