More Related Content
Similar to Sensor Networking
Similar to Sensor Networking (20)
Sensor Networking
- 6. 3 Result
We have chosen and built the hardware according to our background research. The
nodes are made up of a sensor, mesh network module, programmable microcontroller board
and a microcontroller board shield. The shield acts as an extension to the board in order to
attach a wireless module. We set up an Arduino IDE software in order to program the boards.
The code is written and compiled on the computer and uploaded to the board via a USB cable.
Arduino provides its own libraries for use. We programmed the hardware in C. Each Wireless
Mesh Module had to be configured via USB prior to installing it on the board.
Code example for an end node:
void setup(void)
{
Serial1.begin(19200);
}
This function sets the baud rate and starts the main loop.
void loop(void)
{
DHT22_ERROR_t errorCode;
delay(2000);
errorCode = myDHT22.readData();
switch(errorCode)
{
case DHT_ERROR_NONE:
char buf[128];
sprintf(buf, "%d,%hi.%01hi,%i.%01i", ID,
myDHT22.getTemperatureCInt()/10, abs(myDHT22.getTemperatureCInt()%10),
myDHT22.getHumidityInt()/10, myDHT22.getHumidityInt()%10);
Serial1.println(buf);
break;
…
}
}
- 9. We created an algorithm to detect if a sensor is disconnected or reconnected. Data is
updated every time an input is received (2 seconds per sensor, average input every second). We
created a counter in the update loop to increment every run. Each sensor also has its own
counter which increments based on the ID of the received input. If the counters have a
difference larger than d (d=5) then it is safe to assume the lower counter belongs to the
disconnected sensor. In order to be able to detect if a sensor reconnects the counters need to
be synchronized periodically, every s (s=8) inputs for example. After which the counter checks if
the difference is still larger than d. If not, then the sensor is assumed to be reconnected. The
period between the synchronization and a valid disconnection period is undefined, therefore
while awaiting confirmation the status bar is set to “Updating”.
But with only using the algorithm above, there is a problem in detecting if both sensors
are disconnected because there is no input, which means no counters are incremented or
functions executed. For this issue, we figured out a solution below.
First, we create a timer, if there is no input within t (t=5) seconds then it is assumed
both sensors are disconnected. Once input is received the timer is disabled, this happens
repeatedly if a sensor is connected and therefore the timer does not go off. This is the one of
two ways to bypass a case of no input in Java since the program does not come back from the
input function unless there is any input. A timer forces it to terminate and continue the loop.
Another way is to have a thread continuously sending “empty” information to the program to
trigger a return from the input function, but that would require a more sophisticated
configuration of the detection counters as well as empty cycles of computing power which
should be avoided if the SN is running on a battery.
- 15. References
[1] Techopedia, “Wireless Sensor Network”,
https://www.techopedia.com/definition/25651/wirelesssensornetworkwsn
Accessed: Feb 7, 2016.
[2] ACM Digital Library, “Long distance wireless mesh network planning: problem formulation
and solution”, http://dl.acm.org/citation.cfm?id=1242693.
Accessed: Mar 20, 2016.
[3] jSerialComm Java Library, http://fazecast.github.io/jSerialComm/.
Accessed: Mar 13, 2016.
[4] JFreeChart Java Library, http://www.jfree.org/jfreechart/.
Accessed: Mar 13, 2016.
[5] Digi, XBee™ Gateway User's Guide,
http://ftp1.digi.com/support/documentation/html/90001399/90001399_A/Files/XBeeconcept
s.html#_Toc384719516.
Accessed: Feb 14, 2016.
[6] Digi, XBee ZigBee Mesh Kit,
https://docs.digi.com/display/XBeeZigBeeMeshKit/How+to+set+up+a+ZigBee+mesh+network.
Accessed: Feb 14, 2016.
References 5 and 6 were not directly referenced in this report. They were used for research and
setup of our hardware.