All Collections
Connect your Devices
Connect an Ambient Weather Professional Weather Station (WS-2902A) to Ubidots
Connect an Ambient Weather Professional Weather Station (WS-2902A) to Ubidots

Learn how to set up your Ambient Weather weather station with Ubidots to start monitoring indoor & outdoor conditions

S
Written by Sergio M
Updated over a week ago

The WS-2902A is professional weather station that sends real-time data to third-party services, allowing you to monitor indoor and outdoor conditions to take smart decisions.

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'll be able to integrate the WS-2902A with Ubidots in order to keep an eye on the outdoor & indoor conditions.

Requirements

Step-by-Step

  1. Hardware setup

  2. Wi-Fi 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 WS-2902A.

Indoor Console

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

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 Wi-Fi 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 Wi-Fi to be able to start transmitting the data to Ubidots.

2. Wi-Fi Setup

IMPORTANT NOTE: The console must be connected to the AC power, because the Wi-Fi feature has higher energy requirements.  

1. To connect the weather station to Wi-Fi, you must first download the application from one of the following options:

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

3. Once the Wi-Fi 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 Wi-Fi 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 Wi-Fi 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 Wi-Fi. Enter your Wi-Fi password and press “Save”.

8. Once the console established the connection with your Wi-Fi network, the device MAC address and IP address will be displayed in the app. The Wi-Fi icon on your console will change from flashing rapidly to static and the console will 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 a plug & play pre-built integration. 

The purpose of this guide is to provide the weather 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 Ambient Weather to then post the data in the Ubidots side using the Ambient Weather API.

For that, choose Ambient Weather between the supported servers. 

12.  Enter the desired upload time (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, enter the MAC address of the console in the empty field:

Once the MAC address is already specified, you should get the successful message shown 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, there you will find the API Keys required 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 necessary keys already generated, it's time to configure the Ubidots account.  

4. Ubidots UbiFunction Setup

1. Go to your Ubidots account Devices Functions

NOTE:  The Functions module is available to all Professional (and higher) plans. 

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 it's indicated in the code below:

const axios = require('axios');

// Ubidots Access Credentials
var ubidotsToken = "BBFF-xxxxxxxxxxxxxxxxx";

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

// This function build the HTTP GET request to Weather Ambient
async function weatherAmbientRequest() {
let config = {
method: 'get',
//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,
}
const response = await axios.request(config);
return response.data;
}

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

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

async function main(args) {
var waResponse = await weatherAmbientRequest();
var deviceLabel = waResponse[0]['macAddress'];
var waResponse = waResponse[0]['lastData'];

var actualTimestamp = waResponse['dateutc'];
let res;

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}]
};

return ubidotsGetRequest(deviceLabel, 'winddir')
.then(response => {
let ubidotsLastTimestamp = response.data['last_value']['timestamp']
if (actualTimestamp != ubidotsLastTimestamp) {
return ubidotsPostRequest(deviceLabel, payload)
}
})
.catch(err => {
if (err.response.status == 404) {
return ubidotsPostRequest(deviceLabel, payload)
}
})
.then(res => {return {parser_status: "OK"}});
}

6. In the runtime, select NodeJS as programming language.

7. Now we have to assign how often we want to trigger the UbiFunction. To do this, activate the toggle "Time based trigger" and assign the required time to trigger the function in minutes.

  • Deactivated:

  • Activated:  

 

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

8.  After making the function, data will be updated in your account at the chosen interval. To verify functionality, click on the Devices dropdown menu → Devices and locate the new Ambient Weather 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 stay as the MAC address so that no devices are confused. 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  

In just a couple of minutes, you successfully integrated your Ambient Weather WS-2902A 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?