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 weather monitoring station. What if you would like to bring in additional information from an external weather service - wind direction, wind speed, dew point, etc.?
Machinechat's JEDI One makes it easy to gather sensor data, visualize it and act on it all from a local machine that you own and control. Sometimes you may find it useful to tap into the ‘wisdom of the web’ and include data from the Internet on your JEDI One dashboards and use this outside info along with local sensor data to influence actions or notifications. JEDI One’s custom plug-in capability makes this easy - just a few simple steps.
The web has so much information, both historical and real-time that you can tap into, often for free. Using APIs (Application Programming Interfaces) within a JEDI One plug-in is your ticket to gaining access to this info. For some idea of what’s available, have a look at these websites:
In this article, we’ll show you how in five 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 ‘Your_Auth_Key’ to your actual auth key from OWM ( in ’quotes')
(See attachment to download source code)
Step Three - Set this script up as a JEDI One plug-in
As shown in the picture below:
- Open a terminal window
- Make the script executable (“owm_jedi.py” in the example below). Copy it to the JEDI One plugins sub-directory
- Test the Python script from the command line
Step Four - Setup a JEDI One Data Collector for OWM
Step Five - Incorporate OWM real-time web information into a JEDI One Data Dashboard
You can also use data from the web to trigger actions and notifications. 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 JEDI One based project? Drop us a line, we would love to hear from you! Machinechat Community