In the folder 'raspberrypi_app' you will find the application we want to run on our Pi, so it sends us the temperature data we wish to collect. This is a node.js application and you need to set up your Pi so the application can be run there.
- Connect to your Pi, if you are not already connected to it via SSH, remote desktop or by attaching desktop, mouse and keyboard. If you are connected to it via the last two options, please open a terminal.
- In the Bash navigate to root of this repo - AzureIotHack and pull any changes.
git pull
- Now you are going to need the Azure IoT Hub connection string.
It might still be stored in the shell on your local machine. Copy it!
If it is not get the connection string again:
echo $connection
In the bash of your Pi paste the string:az iot hub device-identity connection-string show --device-id myPi --hub-name $prefix'iotpihub' --output tsv
export DeviceConnectionString="<YOUR CONNECTION STRING>"
- We need to install a package for our code to work on your Pi.
If you cannot use 'pip' or 'pip3' on your Pi install it entering the following:
pip3 install azure-iot-device
sudo apt install python3-pip
- Now we can run the application. Make sure you are in the 'raspberry_app' folder and run the following:
Temperature and humidity data are send to the Azure IoT Hub and displayed on the Sense Hat's LEDs.
python3 temphumid.py
- The data from your Sense Hat is now sent to Azure. But we still need to connect it to our Machine Learning service.
- To see what is happening in the Azure IoT Hub navigate to the Azure portal. There, find your Azure IoT Hub. On the
Overview
site you will see the messages received: - Let's open the Azure Cloud Shell:
- There enter the following to see the messages comming in:
az extension add --name azure-iot
az iot hub monitor-events --hub-name $prefix'iotpihub'
- In the terminal of your Pi press ctrl + C to stop the device from sending the data to Azure.
Go to the next steps