Skip to content

Developed Software

Greg Long edited this page Oct 7, 2015 · 18 revisions

Developed Software

This project has developed an end-to-end demonstration of a sensor network including code for sensor nodes, code for a master node, a HTTP server for processing and uploading sensor data to a cloud service and plugins to visualize the sensor data on the cloud service.

The developed software includes code for :

## Sensor Nodes The software developed for the sensor nodes is an arduino sketch that utilises the RF24 libraries. The sketch runs a timer that will take a reading from an analogue temperature sensor. The temperature reading will then be sent in a HTTP POST request to a configured server address and path.
  1. Installation
  2. Configuration
  3. Running
### Installation
  1. Download the Arduino node sketch from GitHub: https://github.com/rickii/SensorRF24/blob/master/arduino_node/arduino_node.ino
  2. Save it into a folder named the same as the folder.
  3. Open the sketch with your Arduino IDE.
### Configuration
  1. Set the connected CE and CSN pins for the nRF24
  2. Set an IP Address for this node in the same subnet as the master node
  3. Set the IP Address of the lightweight HTTP server that accepts the POST requests.
  4. Set the update interval
### Running

Upload the sketch to the arduino.

Use the Arduino serial port monitor to view the output from the arduino.

## Master Node

The master node is a C++ application that utilises the RF24 libraries. It provides the gateway and addressing functionality to the RF24 wireless modules. At defined intervals the master node will create a list of all the nodes it knows about, including inactive nodes, it will send a HTTP POST request with the list of nodes to a configured HTTP server. The master node creates a virtual network interface on the Raspberry Pi that then enables IP communication with the sensor nodes.

The master node program is based on an example program provided by the developer of the RF24 libraries.

  1. Installation
  2. Configuration
  3. Running
### Installation

Download the master node from GitHub: https://github.com/rickii/SensorRF24/tree/master/master_node

Place in a folder on the Raspberry Pi.

### Configuration

The default IP address for the master node is 10.10.2.2. This can be changed by editing the master_bode.cpp file. Note: this IP address must be in a different subnet to the physical network interface on the Raspberry Pi.

The program needs compiling by running this command:

	sudo .\ make
### Running

To run the program use the command:

	sudo .\master_node

To leave the program running in the background run the command:

	nohup sudo .\master_node&

The nohup will allow the program to continue to run after disconnecting from the shell session, and & tells the program to run in the background. Take note of the process ID reported after running the command so you can use it to kill the process later.

## HTTP Server

The lightweight HTTP server is a node.js application. It uses the express plugin to provide the HTTP server.

The application is designed to accept POST requests from the Arduino node and from the Raspberry Pi master node. It takes the POST requests from the master and nodes and uploads the data to a cloud service called ThingSpeak. See the section on ThingSpeak for details necessary to configure this service.

The application also accepts GET requests from a user and returns a map of all the nodes in the network showing their relationship to each other along with their currently configured address.

Output from the HTTP Server showing the master and two child nodes

  1. Installation
  2. Configuration
  3. Running
### Installation

Download the node/express application from GitHub: https://github.com/rickii/SensorRF24/tree/master/rf24_httpserver

Place the the files and folder in a folder on the Raspberry Pi.

The application uses a set of plugins that need to be installed using the NPM plugin manager. To install the plugins, from within the folder created with the index.js and package.json files run the command:

	npm install

This will read the list of packages from the package.json file and install them into the current folder.

### Configuration

The HTTP server is configured to listen on port 3000. This can be changed within the index.js file if necessary.

The other configuration for the HTTP server is to set the API Keys for the channels within the ThingSpeak cloud service.

If you do not plan on using the ThingSpeak cloud service then no other configuration is necessary. Refer to the ThingSpeak configuration section for details.

### Running

To run the HTTP server use the command:

	sudo node .\index.js

To leave the program running in the background run the command:

	nohup sudo .\index.js&

The nohup will allow the program to continue to run after disconnecting from the shell session, and & tells the program to run in the background. Take note of the process ID reported after running the command so you can use it to kill the process later.

## Thing Speak ## Visualization Plugins
Clone this wiki locally