Wireless Sensor Network Using Arduino and RFM69

by svraut29 in Circuits > Arduino

3951 Views, 0 Favorites, 0 Comments

Wireless Sensor Network Using Arduino and RFM69

wsn-arduino-rfm.png

A Wireless Sensor Network (WSN) is a distributed, wireless network of sensors that communicate remotely to collect certain information. A WSN contains at least 1 or more sink nodes and a number of sensor nodes.

The sensor nodes contain sensors (any sensor of your choice), processing device (Arduino) and communication device (RFM69). The sensor nodes collect information through sensors and send it to the sink node. The sink node is at the edge of the WSN. The role of sink node is to collect all data received from sensor nodes in the WSN and forward it to the database server. The sink node is usually connected to a more powerful computer like Raspberry pi to log data onto cloud/internet.

Supplies

arduino-rfm69.png

Decide Your Network Design

wsn-arduino-rfm.png

Firstly, decide how do you want your wireless sensor network to look like.

Decide on the following:

  1. The number of sink nodes and sensor nodes? You should have minimum 1 sink node and 1 sensor node.
  2. Which sensor(s) to attach on each sensor node? You can also decide to test this tutorial without sensors by sending a simple "Hello" message instead of sensor data.

In our example, we will be having 1 sink node and 3 sensor nodes. You can place these nodes in any location, provided that each node is within range of at least 1 of the nodes in the network. We will be sending a simple "Hello from Node No." message in our example. You can replace this message by sensor data in your project.

Prepare Circuit Connections

arduino-rfm connection.png

Connect your Arduino board with RFM69 using the below links:

Arduino Uno - RFM69 Circuit: https://learn.sparkfun.com/tutorials/rfm69hcw-hookup-guide/all

Arduino Nano - RFM69 Circuit: https://circuitdigest.com/microcontroller-projects/how-to-interface-rfm69hcw-rf-module-with-arduino

Do the above connections for each node in the network. For sensor nodes, you may interface any sensor of your choice with Arduino.

Download Required Libraries in Arduino IDE

rfm69-sunit-raut-lowpowerlab-wsn-libraries-arduino.png

For this project we need a few libraries to setup WSN using Arduino:

  1. RFM69 Lowpowerlab library - For communication between Arduino & RFM69
  2. WSN_RFM69 library - For setting up WSN using Arduino and RFM69

In Arduino IDE, go to Sketch > Include Library > Manage Libraries. In Library Manager, search with "RFM69" and download the above two libraries.

Upload Code in the Nodes

rfm69-arduino-wsn-library-example.png

Go to File > Examples > WSN_RFM69.

There are three examples provided with WSN_RFM69 library. The first example is for unidirectional communication between two nodes. The second example is for bi-directional communication between two nodes. You can use these two examples to test your node circuit connections and to verify the working of RFM69 radios.

Once you have tested your nodes with the above two examples, we can move to the third and most important example which shows you how to create a network of nodes.

In the third example, we have two programs:

  1. Sink Node: This program will be uploaded only to sink nodes in the network.
  2. Node: This program will be uploaded to all nodes except for sink nodes, i.e. sensor nodes.

While uploading each program, you only need to modify the node id. Make sure you give a unique node id from 0 to 1023 to your nodes. You need to modify the node id on the below line in the code. (line 34 in both programs)

#define MYNODEID      1  

Next, You need to modify the frequency of the RFM69 module in the code. Make sure the frequency of your RFM69 module is updated in the program as shown below (line 35 in both programs) [note: all RFM modules should have the same frequency]

#define FREQUENCY     RF69_915MHZ // for 915 MHz (default value in example)
#define FREQUENCY     RF69_315MHZ // for 315 MHz (default value in example)
#define FREQUENCY     RF69_434MHZ // for 434 MHz (default value in example)
#define FREQUENCY     RF69_868MHZ // for 868 MHz (default value in example)

Make the above changes to node id and frequency in your sink node and node example programs.

Now, You simply need to upload the relevant program to your nodes based on the above guidelines.

Example:

Suppose we have 1 sink node and 3 sensor nodes. We would give node id 1 to the sink node, and 2,3,4 to the sensor nodes. We would modify the frequency as per our module frequency in each program. Now we would upload the sink node program in the sink node by changing the node id to 1. Next, we would upload the Node program to the sensor node by changing node id to 2, 3, 4, and so on.

Power Up Your Network!

First, Connect the sink node to your Computer/Laptop and open the COM port.

Now, power up other sensor nodes.

You can check the output of the sink node on your COM port of Arduino IDE. The Sink Node will print messages received from sensor nodes on the COM port.


I hope you build a great project with this tutorial. If this tutorial was helpful, please drop a comment below and tell me what are you building. If you have any doubts about this tutorial, let me know in the comments.