The WS-2902A is Professional Weather Station that sends real-time data to third-party services to allows you to monitor indoor and outdoor conditions to take smart decisions in real time.

The wireless all-in-one integrated sensor array measures wind speed, wind direction, temperature (F and C), humidity, wind speed, wind direction, rainfall, UV and solar radiation.

Following this guide you will be able to integrate the professional Weather Station with Ubidots IoT Development Platform in order to keep an eye on the outdoor & indoor conditions.

Requirements

Step-by-Step

  1. Hardware setup
  2. WiFi Setup 
  3. Ambient weather & Ubidots Setup 

1. Hardware Setup 

For hardware assembly, we highly recommend checking the official documentation to make sure the proper installation of the Weather Station.

Indoor Console

1. Connect the display console power jack to AC power* adapter with the included power adapter. (See image below) After the console is connected to AC power, the console will display the software version number, two seconds after power up.

The console will display all of the LCD segments for three seconds after power up, the indoor conditions will immediately update, and the outdoor sensor array will register within a few minutes.

IMPORTANT NOTE*: The console can also be powered using batteries, but the  WiFi  feature  only  works  when  plugged  into  AC  power  due  to  higher energy requirements. For this, please keep the console connected directly to the AC power instead of using batteries

For a detailed documentation about the console buttons operations, lights / snooze mode, plus extra configurations refer to the following link.  

With the devices already synchronized, let's connect the indoor console to WiFi to be able to start transmitting the data to Ubidots IoT Development Platform.

2. WiFi Setup

IMPORTANT NOTE: The console have to be connected to the AC power, because the WiFi due higher energy requirements.  

1. To  connect  the  Weather  Station  to  WiFi,  you  must  first  download  the  application  from  one  of  the following choices:

2. Reference to the image below. If the WiFi icon is not flashing rapidly, (1) press and hold the RAIN and ALARM buttons at the same time for four seconds. (2) The WiFi icon will begin flashing rapidly, indicating the console is searching for your WiFi network.

3. Once the WiFi icon is flashing rapidly, run the Ambient Weather Osprey application, and press “Add Device” to connect your mobile device to the display console. 

4. Make sure the WiFi icon is flashing rapidly. If not, press and hold the RAIN and ALARM button for four seconds. 

5. If your mobile device is not connected to your 2.4 GHz WiFi network, launch Settings on your mobile device and connect to the 2.4 GHz band on your router, then return to the Ambient Tool program. 

6. Your router’s name will be listed in the Router SSID field if your phone is connected to WiFi. Enter your WiFi password and press “Save”.

8. Once the console established the connection with your WiFi network, the device MAC address and IP address will be displayed in the app. The WiFi icon on your console will change from flashing rapidly to solid on and the console start updating the values of the weather station. 

9. Compare the MAC address displayed with the one of the console to verify if the device linked is the right one. The MAC address of the console is located in the back side of the device. 

10.  Refer to the upload panel by clicking the device from the list displayed.

11. In the upload panel you will find the various supported servers like  AmbientWeather, Wunderground and WeatherCloud which provides an plug & play pre-built integration. 

The purpose of this guide is to provide the conditions variables to Ubidots in order to be able to monitor and make decisions in real time based on those conditions. For that, we are going to update the data in ambientWeather  to then post the data in the Ubidots side using the ambientWeather API.

For that, choose ambient Weather between the servers supported. 

12.  Enter the upload timer desired (1 to 5 minutes) and select the Auto Upload Switch to ON.  

3. AmbientWeather Ubidots setup 

  1. Go to Ambient Weather to create an account and select Add Device. Then, ingress the MAC address of the console to the empty field where is required:

Once the MAC address is already specified, you should get the successful message below. Then, press Create

2.  Once the console is registered, select the dashboard to view your data updating in the Ambient  Weather Side.

3. Go to the account settings you will find the API Keys required to be able to talk with the Ambient Weather API. If the Application Key is not generated, you have to request it through support@ambientweather.com providing the MAC address of the console.

With the keys required already generated, is time to configure the Ubidots account.  

4. Ubidots UbiFunction Setup

1. Go to your Ubidots account -> Device Management -> UbiFunction

NOTE:  If you cannot see the "Function" module in your account, you will need to enable the add-on in the billing section of your account

2. Click the blue "+" icon in the upper-right corner to create a new function: 

3. Assign a name to the Function, e.g. "WS-2902A". Then, assign the POST as the HTTP method.

4. To finish the Function, press the blue button "Make it live". As you will see, the endpoint URL is generated.

5. Copy and paste the code below into the Ubidots Function's code editor. Once pasted, assign your Ubidots Token, WeatherAmbient apiKey and application Key where is indicated in the code below:

var request = require('request-promise');

// Ubidots Access Credentials
var ubidotsToken = 'xxxxxxxxxxxxxxxx';

// Weather Ambient Access Credentials
var apiKeyWeatherAmbient = 'xxxxxxxxxxxxxxxx';
var applicationKeyWeatherAmbient = 'xxxxxxxxxxxxxxxx';

// This function build the HTTP GET request to Weather Ambient
async function weatherAmbientRequest() {
    var options = {
        //url: 'https://private-anon-dfc32a6826-ambientweather.apiary-proxy.com/v1/devices?apiKey=' + apiKeyWeatherAmbient + '&applicationKey=' + applicationKeyWeatherAmbient,
        url: 'https://api.ambientweather.net/v1/devices?applicationKey=' + applicationKeyWeatherAmbient + '&apiKey=' + apiKeyWeatherAmbient,
json: true
    };
    return await request.get(options);
}

// This function build the HTTP POST request to Ubidots
async function ubidotsPostRequest(deviceLabel, data) {
    var options = {
        method: 'POST',
        url: 'https://industrial.api.ubidots.com/api/v1.6/devices/' + deviceLabel,
        body: data,
        json: true,
        headers: {
            'Content-Type': 'application/json',
            'X-Auth-Token': ubidotsToken
        }
    };
    return await request.post(options);
}

// This function build the HTTP GET request to Ubidots
async function ubidotsGetRequest(deviceLabel, variableLabel) {
    var options = {
url: 'https://industrial.ubidots.com/api/v1.6/devices/' + deviceLabel + '/' + variableLabel,
        json: true,
        headers: {
            //'Content-Type': 'application/json',
            'X-Auth-Token': ubidotsToken
}
    };
    return await request.get(options);
}

async function main(args) {

var waResponse = await weatherAmbientRequest();
var deviceLabel = waResponse[0]['macAddress'];
    var waResponse = waResponse[0]['lastData'];

var actualTimestamp =  waResponse['dateutc'];
var ubidotsLastTimestamp = await ubidotsGetRequest(deviceLabel, 'winddir');
ubidotsLastTimestamp = ubidotsLastTimestamp['last_value']['timestamp'];

var payload = {
"winddir": [{"value": waResponse['winddir'], "timestamp": actualTimestamp}],
"windspeedmph": [{"value": waResponse['windspeedmph'], "timestamp": actualTimestamp}],
"windgustmph": [{"value": waResponse['windgustmph'], "timestamp": actualTimestamp}],
"maxdailygust": [{"value": waResponse['maxdailygust'], "timestamp": actualTimestamp}],
"tempf": [{"value": waResponse['tempf'], "timestamp": actualTimestamp}],
"hourlyrainin": [{"value": waResponse['hourlyrainin'], "timestamp": actualTimestamp}],
"dailyrainin": [{"value": waResponse['dailyrainin'], "timestamp": actualTimestamp}],
"weeklyrainin": [{"value": waResponse['weeklyrainin'], "timestamp": actualTimestamp}],
"monthlyrainin": [{"value": waResponse['monthlyrainin'], "timestamp": actualTimestamp}],
"totalrainin": [{"value": waResponse['totalrainin'], "timestamp": actualTimestamp}],
"baromrelin": [{"value": waResponse['baromrelin'], "timestamp": actualTimestamp}],
"baromabsin": [{"value": waResponse['baromabsin'], "timestamp": actualTimestamp}],
"humidity": [{"value": waResponse['humidity'], "timestamp": actualTimestamp}],
"tempinf": [{"value": waResponse['tempinf'], "timestamp": actualTimestamp}],
"humidityin": [{"value": waResponse['humidityin'], "timestamp": actualTimestamp}],
"uv": [{"value": waResponse['uv'], "timestamp": actualTimestamp}],
"solarradiation": [{"value": waResponse['solarradiation'], "timestamp": actualTimestamp}],
"feelsLike": [{"value": waResponse['feelsLike'], "timestamp": actualTimestamp}],
"dewPoint": [{"value": waResponse['dewPoint'], "timestamp": actualTimestamp}],
"lastRain": [{"value": 1, "context":{"lastRain": waResponse['lastRain']},  "timestamp": actualTimestamp}]
};
if (actualTimestamp != ubidotsLastTimestamp) {
await ubidotsPostRequest(deviceLabel, payload);
}

return {parser_status: "OK"}
}

6. In the runtime select NodeJS as programming language.

7. Now we have to assign how often we desired to trigger the UbiFunction. To do this, active the flag "Time based trigger" and assign the time desired to trigger the function in minutes.

  • Deactivated:
  • Activated:  

 

To finish, save the changes by pressing "Make it live"

8.  After making the function live, data will being updating in your account at the set interval. To Verify functionality go to Device Management -> Devices and located the new AmbientWeather device created using UbiFunctions.

9.  Don't like the MAC address as your device's name in your Ubidots display? Don't worry! You can change the name to a more friendly one, but the device label will be stay as the MAC address to never get confused which device is which. Check out this help center article to better understand Device Labels and Device Names in Ubidots.

10. With the data already in our Ubidots account it's time to create Ubidots Dashboards to visualize and understand your data to make better decisions simply and intelligently.

Learn more about Ubidots powered App(s), white-label branding, user-management, and how they all work together to deliver IoT Solutions, here.

5. Summary  

I just a couple of minutes, you successfully integrated your AmbientWeather Weather Station to stream live data to Ubidots where the data can go to work in your Ubidots powered App. Now it's time to assemble dashboards and add users who can see and engage with your Apps' data. :) 

Other readers have also found useful...

Did this answer your question?