Analyzing sensor readings with an XBee wireless connection

Pair Networks

After you have loaded each module with both the coordinator and the router firmware (ZNet 2.5 Router/End Device AT Version 1247), you need to configure the network by setting the Network ID in the Networking section. The same ID must be used for all devices in the network. The standard ID, 234, ensures that all modules work in the same network according to the standard configuration. If no other XBee modules are running in the immediate environment, nothing needs to be changed.

Addressing is the next important section of the file. This section displays serial numbers in the SH and SL settings. You should remember these values; all others will stay the same. When the end device is also active – for example, because the USB adapter is providing power or the power is coming directly from pin 1 (+3.3V) and pin 10 (GND) – then the device can be loaded wirelessly via the coordinator module. To Discover radio nodes in the same network, click on the blue symbol in the middle of the module.

One click on the connected module loads its configuration (Figure 6). Enter the values from SH and SL of the coordinator in the DH and DL settings of the end device because the end device has to send the measurement data to the coordinator. This is how the end device figures out the target address (Destination Address) for sending the data that has been captured.

Figure 6: The XCTU configuration software for XBee modules makes it possible to perform a detailed setup of the firmware.

Capturing the Measurement Data

The following example shows the import of the measurement data on the D3 data port. Because this involves measuring voltage, you need to configure the ADC[2] setting. If all you want to do is to find out whether there is any voltage present, set it to DI[3]. The other two values DO High[5] and DO Low[4] are used to configure the port as an output that either holds voltage and switches off (High) or is switched off and will be switched on (Low).

For the measurement to occur at a rate of once per second, set the IR setting to 1000. One click on the pencil symbol next to a setting transmits the configuration to the module. To read the incoming data, first select the coordinator on the left and then the console from the menubar. One click on the plug contact icon connects the console with the coordinator (Figure 7). Another click on a data packet displays the packet in the Frame details window.

Figure 7: Measurement and other data are displayed on the XCTU application console.

Figure 8 shows the structure of the contents of the data packet chosen in Figure 7. The start value 7E is followed by 2 bytes that encode the length of the data packet (the checksum is not included). The hexadecimal value 00 14 corresponds to a length of 20 bytes. The following byte 92 designates the data packet as a data frame, that is, an input or output data packet of the port. The next 8 bytes represent the ID of the transmitting device; the following two bytes contain the 16-bit network address.

Figure 8: The diagram illustrates the structure of an I/O frame.

The next bytes designate the receiver options and the number of data packets (e.g., 01 here). The following mask bytes indicate the evaluated digital (2 bytes) and analog (1 byte) ports. This is followed by 2 bytes of data per port. The last byte is a checksum for the data packet.

Every bit in the analog mask corresponds to an analog port. For example, the hexadecimal mask value 08, which is binary 00001000, indicates that the fourth bit from the right is set, which means that the analog values from the AD3 port were read. Thus, bit 1 corresponds to AD0, bit 2 to AD1, bit 3 to AD2, and so forth. A glance at the handbook shows that AD3 lies on pin 17.

Buy this article as PDF

Express-Checkout as PDF

Pages: 8

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

SINGLE ISSUES
 
SUBSCRIPTIONS
 
TABLET & SMARTPHONE APPS
Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content