ZigBee technology is currently in the field of IoT and RFID, with a very high degree of concern. Recently, the CAS Shanghai Institute of Micro-Systems and information technology, Wuxi Internet industry and other sensor Network standards team member units jointly released the name of VW628, WSNS1_SCBR two China's independent intellectual property rights of the wireless sensor network SOC chip, which wsns1_ SCBR is China's first IEEE802.15.4G-compliant fully integrated sensor network node SOC chip.
In fact, the encapsulation of good ZigBee module, using the same as the operation of the serial port, in particular, we have its communication mode set to transparent transmission mode, at this time we have not felt that is in the use of ZigBee module, and feel is in the use of a serial line. In the previous written "ZigBee in the. Net Micro Framework System Application," Bowen in a relatively detailed introduction of the ZigBee related module application, interested netizens, you can refer to.
A single ZigBee module is very small, its serial pin for the TTL level, the need to connect directly with the MCU, the specific wiring pins are as follows (simple period, we only receive 4 pins):
Serial number |
ZigBee Module |
Red Bull Development Board |
1 |
3 (RX0) |
PA2 (USART2_TX) |
2 |
4 (TX0) |
PA3 (USART2_RX) |
3 |
6 (GND) |
GND |
4 |
7 (VCC) |
3.3v |
The control program on the Development Board is as follows (very simple, is the serial receiving and the Trolley Control program):
Open the serial port and set the ZigBee module to transparent transfer mode
serial = new SerialPort ("COM2", 115200, Parity.none, 8, Stopbits.one);
Serial. Open ();
Serial. DataReceived + = new Serialdatareceivedeventhandler (serial_datareceived);
String strcommand = "---2-";
byte[] Bytedata = System.Text.Encoding.UTF8.GetBytes (strcommand);
Serial. Write (bytedata, 0, bytedata.length);
Reading data
static void Serial_datareceived (object sender, Serialdatareceivedeventargs e)
{
if (serial. Bytestoread > 0)
{
byte[] Bytdata = new byte[serial. Bytestoread];
Serial. Read (bytdata, 0, bytdata.length);
Serial. Write (bytdata, 0, bytdata.length);
string keyname = "";
Switch (bytdata[0])
{
Case 48://' 0 '
KeyName = "Forward";
Moveforward ();
Break
Case 49://' 1 '
KeyName = "Left";
MoveLeft ();
Break
Case 50://' 2 '
KeyName = "right";
MoveRight ();
Break
Case 51://' 3 '
KeyName = "Back";
Moveback ();
Break
Case 52://' 4 '
KeyName = "Stop";
Movestop ();
Break
}
Debug.Print (KeyName);
}
}