How to integrate APC220 with arduino?

Release time:2016-07-03


APC220 communicate with arduino via serial port TX and RX. APC220 can use not only peer to peer communication but also for one to multiple communication.



One APC220 with USB adaptor connects with PC. One APC220 connects with arduino extension board with arduino mainboard.



APC220 feature:
1, Frequency: 415MHz to 455MHz (1kHz step)  2, GFSK modulation  3, Channel spacing 200KHz
4, Output power: 20mW (10 level adjustable)   5, Sensitivity: -117dB@1200bps
6, Air data rate: 1200 to 19200bps. 7, UART baud rate: 1200 to 19200bps.
8, Serial parity: 8E1/8N1/8O1   9, data buffer: 512bytes
10 Humidity: 10%~90%  11, Temperature: -30℃ - 85℃
12, Supply voltage: 3.4 – 5.5V (the ripple is ±50mV )
13, Transmit current: 35mA   14, Receiving current:32mA
15, Sleeping current: 5uA   16, RF line-in-sight range:1000m
Users just need link 4 wire with arduino. TX, RX, VCC, GND




Connect Arduino MEGA1280 with PC through USB cable. Install the drive

http://s10.sinaimg.cn/middle/6575a3c2g99b1a337ae59&690. After that, users can see the device in the device manager. Check the serials ports ‘COM4’,



mind.



APC220 has 7 pins. These are SET, AUX, TXD, RXD, EN, VCC, GND. It only need four pins connect with arduino board. It is shown in the chart.



In order ensure APC220 pairs working normal, two APC220 should have the same parameters, especially frequency.
Users utilize the RF-tool by PC. Firstly, connect APC220 with PC, than doubleclick the RF tool . The UI shown below is the interface of setting tool. Choose the PC serial as ‘COM5’, then the tool will show ‘Found device’. Configure the parameter of ‘Frequency’ to 470MHz, ‘RF air date rate’ to 19200bps, serial rate to 19200bps. Lastly click the ‘Write W’. The parameter configuration is completed.


The next step is testing the program.

Start Arduino-0022 and choose the type of the control board. My choice is MEGA 1280.



Then set the serial port of control board, It is COM4 shown above.


Test one:

Program function test: when user read the string ‘B’ from the serial port of arduino mega. D13pin LED will blink one time.

Download the program before it compiled.

Caution: Disconnect the RX and TX pin with arduino before download program, otherwise it can make the program download failed.




int ledPin=13; // Definition D13 PIN
int val; //
void setup()
{
pinMode(ledPin,OUTPUT); //

Serial.begin(19200); // Definition UART port rate 19200, according to serial port of APC220
}
void loop()
{
val=Serial.read(); //
if(-1!=val) //

{
if(´B´==val) //
{
Serial.print(val); //
digitalWrite(ledPin,HIGH);  // Control D13pin, output level High
LED is ON.
delay(500);                 // Delay 500ms
digitalWrite(ledPin,LOW);   //  Control D13pin, output level Low
LED is OFF.
delay(500);                 // Delay 500ms

}
}
}

Open serial debug too


http://s3.sinaimg.cn/middle/6575a3c2g99b2a32507f2&690 The serial port is COM5. Another serial port is COM4. Users can see the two output ‘B’ of two windows by ASCII’66’.


Cautions: Users should close the RF toolbefore using the serial debug tool, otherwise the two serial ports could conflict.



Test two:
Program function test: When the PC send ‘a’ or ’A’, Arduino board give the string’ CQ CQ CQ DE BG4KLT,Welcome to my Blog!’ for responds. When the PC send ‘b’ or ‘B’, the D13 pin LED will on for 1 second.
Like the test one, firstly compile the test program and download to Arduino controller. Power on the arduino board, then connect APC220 with PC through USB adaptor. Open Arduino-0022, in the menu of ‘Tools’ -> ‘Serial Ports’ users choose the serial port ‘COM5’ like before. Then open the serial monitor ’ http://s16.sinaimg.cn/middle/6575a3c2g99baa2391eaf&690’. Input the command ’A’ or ‘a’ and click ‘send’.

The arduino board will respond ‘CQ CQ CQ DE BG4KLT,Welcome to my Blog!’. When input ‘B’ or ‘b’, the D13 pin LED will be on for one second and then get off:



int val = 0;
int ledPin = 13;    //  Definition D13 PIN
void setup()
{
Serial.begin(19200);    //  Definition UART port rate 19200, according to serial port of APC220
}
void loop()
{
val = Serial.read();     // read the serial port and return the parameter to variable val
if (-1 != val)           // -1 stand for register has no data
{
if (´A´ == val || ´a´ == val)   // If input is ‘A’or ‘a’, executive the code below
{
Serial.println("CQ CQ CQ DE BG4KLT,Welcome to my Blog!");  // Output the string
}
else if (´B´ == val || ´b´ == val)  // If the input is ‘B’or ‘b’, executive the code below
{
digitalWrite(ledPin, HIGH);   // set pin D13 to High Level,Power on LED
delay(1000);                  // delay 1000ms(1s)
digitalWrite(ledPin, LOW);    // set pin D13 to Low Level, Power off LED
}
}
}

NOTE: We have released RF4432 for alternative APC220 with higher sensitivity and max power output. RF4432 can cover the 868MHz and 915MHz band. They are Pin to Pin compatible.