Configuring an APC220 RF transceiver with Arduino
May 1, 2013 Leave a comment
For some reason every time I look up tools for playing with electronics they end up to be windows based. For the APC220 it wasn’t any different, the only configuration tool I found was the RF-Magic executable. As I don’t run windows at home, and I don’t feel like booting a VM every time I want to configure my RF module I was looking for a way to do this straight from my Arduino.
It took me a while to find good, relevant material, but I finally found a nice Arduino Sketch that does just that. It also includes setting up a Serial communication over two Digital IO pins so you can keep the Arduino connected to your pc. You can get it here.
Below is a sample script that will set up your APC220 to work over 433.9MHz.
Pinout is as follows:
- 1 SET connected to Arduino Digital 13 (D13)
- 2 AUX not connected
- 3 TXD connected to D12
- 4 RXD connected to D11
- 5 EN noyt connected
- 6 VCC connected to 5V
- 7 GND connected to ground
The Script:
//based on http://www.control.aau.dk/~jdn/edu/doc/arduino/sketchbook/apc220cansat/apc220cansat.ino
#include <SoftwareSerial.h>
const int pinRX = 12;
const int pinTX = 11;
const int pinSET= 13;
SoftwareSerial apc220(pinRX, pinTX); // Crt softserial port and bind
tx/rx to appropriate PINS
void setupSoftAPC(void){
pinMode(pinSET, HIGH);
apc220.begin(9600);
}
void setSettings(void){
digitalWrite(pinSET, LOW); // pulling SET to low will put apc220 in config mode
delay(10); // stabilize please
apc220.println("WR 433900 3 9 3 0"); // ask for data
delay(10);
while (apc220.available()) {
Serial.write(apc220.read());
}
digitalWrite(pinSET, HIGH); // put apc220 back in operation
delay(200);
}
void getSettings(void) {
digitalWrite(pinSET, LOW); // pulling SET to low will put apc220 in config mode
delay(10); // stabilize please
apc220.println("RD"); // ask for data
delay(10);
while (apc220.available()) {
Serial.write(apc220.read());
}
digitalWrite(pinSET, HIGH); // put apc220 back in operation
delay(200);
}
void setup(){
Serial.begin(9600);
setupSoftAPC();
setSettings();
}
void loop(){
apc220.println("Hello World!");
delay(5000);
}
The settings are set by this line
apc220.println(</code><code>"WR 433900 3 9 3 0"</code><code>);
WR Frequency RFDataRate OutputPower UART-Rate Series check
- Frequency: Unit is KHz,for example 434MHz is 434000
- RF Data Rate: 1,2,3 and 4 refer to 2400,4800,9600,19200bps
- Output Power: 0 to 9, 9 means 13dBm(20mW)
- UART Rate: 0,1,2,3,4,5 and 6 refers to 1200,2400,4800,9600, 19200,38400,57600bps
- Series Checkout: Series checkout:0 means no check,1 means even parity,2 means odd parity.