Sunday, 22 January 2017

How to establish the communication between ZigBee(Telegesis) and Arduino UNO

The part number of this ZigBee is EXTR357 of Telegesis. 
For convenient, the development board of ZigBee (Telegesis) and Arduino UNO are going be used for testing.

According to the datasheet of Arduino UNO, whose chip number is ATmega328P, it only has one software serial and one hardware serial. For the EXTR357 of ZigBee, it only has one hardware serial also. The hardware serial of them is occupied by the USB port. At the same time, Arduino UNO cannot use software serial to communicate with the hardware serial of ZigBee.
Therefore, the communication between them can only be established by hardware serial.

The connection of the hardware serial will be the diagram below. But at this testing, the power supply of Arduino will be supplied by the battery of ZigBee. So the 3.3 Vcc of Arduino should short with the Vcc of ZigBee together as the standard voltage input of ZigBee is 3.3V. Since the USB port of both of them will occupy the hardware serial, after downloaded the program, they should be plugged out when the ‘Tx’ or ‘Rx’ is using.
Without the USB port, the ZigBee can change to battery power through changing the connection in the development board, referring the picture below.
Therefore, the code for testing the communication between ZigBee and Arduino can be written, referring the code below.
This code is going to write the value stored in the S3B register of ZigBee with increasing the number. As the register of S3B is to contain text, the text inside can be read also for checking. 

Sunday, 15 January 2017

How to use the current sensor of ACS721 (Communicate with Arduino)

According to the datasheet of the current sensor of ACS721, it can be used in AC or DC circuit and even connected with 230Vac directly. Moreover, the reasons for choosing this component are the size of it is small enough and it can communicate with Arduino through Serial Port.


Referring to the picture above, the pin 1 and pin 2 should be shorted together and connected to the positive pole of the AC circuit. The pin 3 and pin 4 should be shorted and connected to the negative pole. The pin 8 is Vcc, which connected to the 5Vdc power supply. And the filter connects with one capacitor then connects to ground. After finished the circuit by following the picture above, the pin 7 (Vout) can connect with anyone of the analog input of the Arduino, as which is analog signal output, referring the Pin Mapping of Arduino below.

After finished the connection, the Arduino UNO and the Current sensor will look like the picture below.

For convenience, the breakout boards of current sensor can be used also. As the connection is easier.



There is the progress code for trying to understand the communication between Arduino UNO and this Current sensor, referring the steps below.

1. It is just to see what value will Arduino UNO received through the Serial Monitor when there is no current pass through. Referring the picture, the raw value appeared in the serial monitor is around 512, 513, and 514.



2. After opened the power supply with AC current (which means got current pass through the current sensor), the raw value is changed abound 5 higher or lower than 513 alternately.



3. These are the final code which will be used.