Arduino Playground is read-only starting December 31st, 2018. For more info please look at this Forum Post

XBee Shield (4)

Multiple devices connected at once

This second example is meant to show how a sensor network can be sending data from multiple sources to one single receiver. Note that I am only having three XBee shields, what makes hard for me to simulate a lot of sending devices. I will accomplish this using slightly different code for each board.

/* XBee meshnet sensors
 * --------------------
 *
 * simulates the arrival of data from a mesh network 
 * with sensors each one of them sending 11 digital 
 * and 6 analog values. It is including one character 
 * per object to name the nodes and separates values 
 * with a symbol. It is not optimal for communication, 
 * but makes easy to understand how such a system will 
 * work in education
 *
 * (cleft) 2007 D. Cuartielles for K3
 * in cooperation with:
 *   - Artificial Tourism 
 *   - Central Saint Martins
 * https://0j0.org
 */

int count = 0;
int time = 0;
long randNumber = 0;
int separator = ',';
int maxDigital = 11;
int maxAnalog = 6;

// board number helps to distinguish each board
// CHANGE THIS NUMBER FOR EACH BOARD
int boardNumber = 0;  

void setup() {
  // the speed has to be 19200 to support 
  // wireless reprogramming
  Serial.begin(19200);  
}

void loop() {
  // we are going to use 10 different objects
  // in the simulation, that will be named: A, B, C ...
  time = millis();
  randomSeed(time);
  Serial.print(65 + boardNumber, BYTE);
  for (count = 0; count <= maxDigital - 1; count++) {
    randNumber = random(2) + 48;
    Serial.print(randNumber, BYTE);
    Serial.print(separator, BYTE);
  } 
  for (count = 0; count <= maxAnalog - 1; count++) {
    randNumber = random(1024);
    Serial.print(randNumber);
    if (count < maxAnalog - 1) {
      Serial.print(separator, BYTE);
    }
  } 
  Serial.println();
  delay(500);
}


Figure 7: receiving data in the IDE

In the setup for this experiment there are three boards: one acting as the gateway has no processor and has the jumpers configured at USB, two acting as wireless sensors have the jumpers configured at XBee.

There is a lot of work to be done using wireless sensor networks as tools to gather environmental data, but there is even more when thinking about how to visualize that data. The following picture is just an example of a Processing made application we are preparing to represent graphically the data coming from a wireless network.


Figure 8: visualization tool

The Processing code will be made available here once it is finished in a couple of days - 2007-04-26

<< >>