How to create and install a network - Kvel2D/ecs193-wireless-sensor-network GitHub Wiki

Tree structure format

Tree network structure is defined in tree_data.h. Each node is assigned 3 variables: "has_sensor", "parent" and "rx_frequency".

  • "has_sensor" has to be set to "true" if the node is connected to sensors, "false" otherwise. (For the purposes of testing or debugging you can set "has_sensor" to "true" even if the node doesn't have any sensors, this will make the node generate fake reading packets)

  • "parent" is the id of the parent node. If the tree is a chain of nodes 1, 2, 3, then "parent" of 1 is 2, "parent" of 2 is 3 and "parent" of 3 is "NO_ID". The parent of the root node is always "NO_ID" to designate that the tree ends there.

  • "rx_frequency" is the frequency on which the node will be listening(receiving) for incoming packets. The children of this node will also be transmitting on this frequency. It is important to avoid frequency overlap because they decrease the perfomance of the network. To achieve this, give each node a unique frequency that is at least 0.25f away from any other frequency. Sensor node frequency doesn't matter because they never receive.

Steps

  1. Plan the layout of the network tree. Which nodes have sensors, which don't. Which nodes are the relays. The connection links between nodes.
  2. Assign each tree a unique id. Nodes that are connected to sensors must have id's between 0 to 128. Other nodes must have id between 129 and 254. 255 is reserved for "invalid" id called "NO_ID".
  3. Write id's to all nodes using the "id-writer" sketch. Id is written to EEPROM and is permanent until changed. It is helpful to label the nodes with their id's.
  4. Fill in variables in tree_data.h for all the nodes in the network.
  5. Now you should flash all of the nodes with the node sketch + tree_data.h that has the tree structure.

Note that id restriction of 0-128 for sensor nodes and 129-254 for relay nodes is caused by the convention in current Raspberry Pi library.

Testing connection link strength

Before actually setting up the network it is recommended to check the quality of connection links. If they are too far away or there are obstacles between them, the connection quality decreases with a possibility of no connection at all. To test this, setup a simple network of two nodes, one sensor child node and one receiving parent and move them in the positions of the connection link. You should also increase the RX_RATE, TX_RATE and PACKET_PERIOD so that transmissions happen more often and you can test quickly.

Updating the tree

If you need to change the layout of the tree, you should repeat the above steps. It is not necessary to reflash the whole network of nodes, especially if the change is small. In general, the most you need to do is reflash the direct neighbors of the node - it's parent and children. If you need to add a new sensor node, then you only need to flash that new sensor node and the parent that it connects to, other nodes in the network will continue working without knowing about the modification. If you are not sure you can always reflash the whole network as a last resort.

If you have changed the software of Arduino boards, you will need to reflash the whole network, otherwise nodes might be incompatible. It depends on the degree of software changes of course but something like changing the format of the packet will require a full reflash for sure.

Troubleshooting

Here are some things you should check for if the a node is not working:

  • Confirm that an id is written to the board and that it's correct.
  • Check that tree_data.h is correct.
  • Check all flags, PRINT_DEBUG off and WAIT_FOR_SERIAL have to be off.
  • Check that the node is on at all. The red LED will be flashing every minute.