Arduino Weather Station Project - Software

Getting Data from the Weather Station

Now that we have assembled the weather station the next part of the project is to look at different ways to get data from the controller.

Listed below is the data that is available and what units they are presented in. The data that is collected is pretty raw. Most of the data collected would normally be averaged over a time period such as 2,5 and 10 minutes. At this stage we do not do any averaging. The wind speed is sampled over a 2.5 second period, everything else is what was read from the sensor at the time the data is sent from the controller.

Available Data

  • Temperature (celsius)
  • Humidity (percentage)
  • Barometric Pressure (millibars)
  • Rain Gauge (mm)
  • Wind Speed (mph)
  • Wind Direction (degrees)

How Do I Get the Data

We have many options but we are implementing the following for this project

  • Basic Web Server - Local Network Only
  • Web Server - Internet Accessible using Static Public IP
  • Web Server - Internet Accessible using Dynamic Public IP
  • Web Client - Send Data to the Cloud

Option 1) Basic Web Server - Local Network Only

This is the simplest method for accessing the data from the weather station. The Arduino board is configured as a web server. We assign it a static IP address (192.168.1.45). The web server will listen on port 80 and if a request from a browser is received will return a simple html page that displays all the data values from the weather sensors.

To access the weather station from the browser you use this url: http://192.168.1.45

Basic Web Server Network

For all of the software projects we use the internal network range of 192.168.1.X. This is a private IP range and many routers use this range as the default.

The limitations with this configuration is that it only works with computers attached to the internal network. You can not access the weather station from the Internet.


Option 2) Web Server - Internet Accessible using Static Public IP

When the home / office router connects to the Internet Service Provider (ISP) it is allocated a public IP address. Generally this will be a dynamic address that can change everytime the router is rebooted or a disconnection occcurs. This is handled in option 3 below.

Some ISP's might allow you to obtain a static IP address for an additional fee. Business or corporate accounts provided by ISP's can be supplied with a static ip address.

The advantage of a static IP address is essentially it does not change. So you can either access the weather station by directly entering the IP address into the url of the browser. Another alternative is to register a name through DNS and assigning it to the ip address. So instead of using 1.127.48.156 we could use aws.cactus.io.

Web Server to Internet Client

When the ip address is entered into the browser it will connect to the router via the public IP address. The router will then translate the data packets on port 80 (HTTP) and redirect it to the internal IP address 192.168.1.45. This port address translation is configured using the router management console.


Option 3) Web Server - Internet Accessible using Dynamic Public IP

This is the most complicated method. It requires several components to provide the functionality. The first thing that needs to be setup is a Dynamic DNS (DDNS) Service through a third party supplier. The home / office router needs to be configured to update the DDNS service everytime the public IP address on the router WAN interface is changed. Port address translation is also configured on the router.

Web Server to Internet Client

When an account is setup with the DDNS provider you would normally get a domain name to use. Here we used cactusio.dydns.com. To access the weather station controller we enter cactusio.dydns.com into the browser. The browser will do a DNS lookup on that name which should respond with the public ip address of the router. The router will then forward the data packet onto the weather controller using PAT.


Option 4) Web Client - Send Data to the Cloud

An easier way to access data from the weather station is to upload it to a cloud server. You can access the data from anywhere on the internet by accessing this cloud server to view the data. This eliminates messing around with router configurations to enable NAT / Port forwarding. It also eliminates having to use a static IP address or dynamic DNS services.

The Arduino board is configured as a web client. Using a POST request with the sensor data in the body of the message. The message body is formatted using JSON. This request is sent to the cloud. In this case we are using the url of data.nevixa.com.au which is the cloud service we use at cactus.io. The data is sent and if okay the server will respond with 200 OK.

Basic Web Client to Cloud Server

You can now view the data on the cloud server from anywhere or device connected to the Internet.

There will be a cost involved with the cloud server data services.


Next Step

In part 9 of this project we create a basic web server. This is option 1 as described above. You can connect to the weather station using a browser on the same network the weather station is connected to.



License