IoT signal to MS Azure cloud: Raspberry Pi temperature data

Dr. Marco Berta
3 min readJul 17, 2022

A simple experiment with a Raspberry Pi during the summer 2022 heatwave

Terrace view, July 2022 late night

Temperature data: recurrent subject in today’s news

Southern France, 17 July 2022, 4 a.m. So hot and humid [1] that quite a few people cannot sleep, and some neighbours are still enjoying cold drinks and late night talk in their garden. Is this a record? Or simply one point of a scary trend that is constantly going upwards? Many discuss that on social networks, but from the point of view of a Data Scientist / Engineer temperature from a device can be a useful source of information. Being that the weather station is located in a “smart home” or a sensor measuring it for an industrial appliance, real-time data and AI predictions can help decisions connected to power consumption or to improve the production for Industry 4.0.

From Raspberry Pi sensors to MS Azure cloud

A common request from who wants to digitalize production: can we send and process data using our cloud service? (GCP, AWS, Azure…), can you predict future trends?

Cloud technology has evolved very quickly in the last ten years and nowadays such a task can be accomplished with few clicks. But where to start to learn how to do so? You have many online tutorials. The one I chose when I first approached this problem, is that offered by Coursera with a focus on MS Azure cloud [2]. Concise but complete introduction, with hands-on work setting up immediately an IoT Hub on the cloud. For this course, you don’t need to buy your own device: connection is made to a virtual Raspberry Pi [3]. Entering the shared access connection string from Azure [4] into the RPI code and combining it with Azure Synapse Analytics will allow you to obtain and store on the cloud the datastream

Figure 1. IoT hub collecting weather data

When it comes to a physical device instead things get a bit more complicated as you will have to code directly into the Raspberry through the terminal. As I am writing this my little RPI 4.0 can already record the temperature on my balcony (30 °C in the evening, shown below).

Figure 2. Raspberry Pi terminal

All the steps to connect it to Azure IoT hub are well described in this tutorial [5]. The evolution of temperature over time can then be visualised using Power Bi [6].

References

  1. https://www.midilibre.fr/2022/07/17/canicule-des-records-de-temperature-battus-dans-lherault-dans-le-gard-et-dans-laude-10440348.php
  2. https://www.coursera.org/projects/getting-started-with-azure-iot-hub
  3. https://azure-samples.github.io/raspberry-pi-web-simulator/
  4. https://thingspro-programming-guide.netlify.app/application-note/how_to_get_azure_iot_device_connection_string/
  5. https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-c-get-started
  6. https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-live-data-visualization-in-power-bi

--

--

Dr. Marco Berta

Senior Data Scientist @ ZF Wind Power, Ph.D. Materials Science in Manchester University