loading

Build a Weather Station using Wia, Raspberry Pi and Node.js

This simple device is the perfect way to demonstrate how easy it is to set up an IoT project powered by the Wia platform. The project also comes with some simple project files to get you started.

Live Demo

Project files

Wia Weather Station Node.js

Wia Weather Station web app

Step 1: Project Requirements

Step 2: Setting Up the Wia Node.js SDK

  1. First thing you will want to do is to create a folder for your weather device. Let's call it "wia-weather-device".
  2. Go into the folder and initialise the project by creating a package.json file using the command "npm init" (use defaults for everything).
  3. Install the Wia SDK using the command "npm install --save wia".a

Step 3: ​Using the Sensehat With Node.js

  1. Install the nodeimu addon for accessing the Sensehat sensors using the command "npm install --save nodeimu"
  2. Your package.json file should look something like below.

Step 4: Create Your Weather Device

  1. Go to the Wia dashboard and select Devices.
  2. From here, click on the + symbol and the Add New Device modal will appear.
  3. Enter 'Weather Station' as the name and click Add Device.
  4. Click on View device to go to the device's overview page.
  5. Take a note of the device's secret key, we'll need this later.

Step 5: Write Code for the Weather Station

  1. We need to create a file for our program, let's call it "index.js".
  2. Copy the code from the example below add to the index.js file.
  3. Replace the device-secret-key on line 3 with your device's secret key that you made a note of earlier.
  4. Now to test that you have done your setup correctly, simply run "node index.js".
  5. Your device should have updated in the dashboard under the Sensors tab, with your sensor readings. You can also view in in real-time in the Debugger tab.

Step 6: Setting Up Our Weather App

We’ve included a folder in the project files which includes the Wia JavaScript SDK and the basic template for the weather app, index.html.

  1. First thing we need to do is initialise our application with an application key from the Wia Dashboard. So, go to My account and then go to the Applications tab.
  2. Click the Create Application Key button and give your application a name (e.g. Weather Station App) and select the type Desktop from the dropdown menu.
  3. Next let’s update the initialise function by replacing the placeholder with our new application key.
  4. Now let’s update the “Device Id” placeholder in the Wia.sensors.subscribe function with our “Device Id” from the Wia dashboard. This can be located in under the name of our device in the device list, in the page header, or finally in the Settings tab of our device.
  5. Now if you copy the path of your index.html file and open it in chrome, we should see a live feed from our weather device.

<p>Neat! There are a lot of weather apps out there but most of them are better at reporting specific things. I like the idea of a customizeable one. :)</p>

About This Instructable

718views

13favorites

License:

Bio: Domo arigato Mr. Roboto, Domo... Domo...
More by Cormac Chisholm:Weather Station using Wia, Raspberry Pi & Node.js 
Add instructable to: