5 Minutes to Augmented IoT: Leveraging Data Enrichment from the Web with IoT Sensor Data
Working with your IoT data locally has many advantages including reduced costs, lower latency, retention of only selected information and privacy, to name a few. That said, there is a lot of wisdom on the web that is useful to harness and bring into your local IoT system. It’s mind boggling to see the broad variety of APIs that can be called to gather real-time and historic data. Take a look at these sites for a sampling:
Let’s look at an example of how to actually tap into this wealth of information. In our article, 30 Minutes or Less: Build A Universal Sensor Hub and Monitor Anything You Want with a Raspberry Pi, we showed you how to create a local environmental monitoring station. What if you would like to bring in additional information from an external weather service — wind direction, wind speed, dew point, etc.? You can use this information to enrich your dashboards and also factor it into your decisions that drive actions.
In this article, we’ll show you how in four quick steps you can augment your Universal Sensor Hub with data from an external weather information site, Open Weather Map.
Things you’ll need:
- Your own OWM API key. You can get one by signing up for a free OWM (Open Weather Map) account
- Pyowm, is a free Python library that enables easy network communications with OWM’s APIs
- JEDI One
- Universal Sensor Hub
Step One — Install the pyowm Python library
You could write the software to handle all of the network communications necessary to connect with the Open Weather Map server…but who wants to do that? To make life easier, there are often libraries that take care of much of the heavy lifting. Pyowm is one such library for Python that makes tapping into OpenWeatherMap a breeze (pun intended). Install it using this command:
sudo -H pip3 install pyowm
Step Two — Modify the following Python script by adding your OWM API key and desired location for weather monitoring
- Change the first line to point to the location of python3, it varies by system. Use the
which python3
command to find out the path to where it is - Change ‘Tigard,US’ to your desired city (in ’quotes’). You can look up the proper callout HERE
- Change ‘YourAuthKey’ to your actual auth key from OWM ( in ’quotes’)
Step Three — Add the OWM source as a JEDI One custom plug-in data collector
Machinechat’s JEDI One allows any sensor, device or other source to be easily added as a data source via its custom plug-in data collector feature. Configuring the custom plug-in requires two parts:
First, save the script in the JEDI One plug-ins folder:
(Note: the plug-in feature in JEDI One works with code in any programming language, not just Python.)
Next, go into JEDI One and set up the data collector:
Step Four — Incorporate OWM real-time Web information into your data dashboard
Now that JEDI One is collecting data from this source, you can get to the fun stuff — seeing your data in action through dashboards. Below is a video to show how to set up a data dashboard:
You can also use data from the Web to trigger actions and notifications or to set up a system view that shows the visual context of the environment the data is coming from. For example, you could send a text message if your local sensor shows a temperature above 100 degrees AND the wind speed reported from OWM is greater than 25 MPH.
How will you use the wisdom of the web in your next project?
Resources: