Pages: [1]   Go Down
Author Topic: Wireless RF APC220  (Read 3152 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The info below is the closest thing i can find on how to set this up.
My question:
Does anyone used this and how do you wire this on the arduino uno?



Quote
On PC side.

On the USB-TTL converter, CP2102 chips is used. We can download driver from Silicon Laboratories, or here is the driver I used. Unzip and run the exe file, follow step by step processes to install the driver.

Plug in USB adapter to PC, Windows will recognize it automatically.

Now we can attach the APC220 module onto the USB adapter. Due to difference in number of pins, please make sure it is attached correctly as shown.

Download and run RF-ANET, it will detect the APC220 module with USB adapter on COM port. Click "Read R". If it show "read succeed!", that means it can be used for communication


On Arduino side.

Copy the following code and upload to arduino. Please note that serial communication is used in both code upload and APC220 communication, so we MUST unplug the APC220 during code upload
Code:

int val = 0;
int ledPin = 13;
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  val = Serial.read();
  if (-1 != val) {
   if ('A' == val || 'a' == val) {
     Serial.println("Hello from Arduino!");
   }else if ('B' == val || 'b' == val) {
      digitalWrite(ledPin, HIGH);
      delay(500);
      digitalWrite(ledPin, LOW);
    }
  }
}




For the same reason of serial communication used for APC220, we cannot connect Arduino to PC with USB even for power supply reason, so external power is needed for this test.

Effective distance for APC220 is 1000M, so we can put Arduino with APC200 module away with external power supplied

On PC side, APC220 is communicating with Windows on serial COM port, so we can use Arduino's software as serial platform. As we are not talking to Arduino on this software this time, change of serial port is needed. In "Tools" -> "Serial Ports", select the COM port used by the APC220(the one with USB adapter connected to PC). Then click "Serial Monitor", type "A" and send, signal will be sent from PC to Arduino through the APC220 modules.

When Arduino receive this "A" signal, it will return a "Hello from Arduino!" signal and it will be shown on the Serial Monitor. When "B" is typed, LED on pin 13 of Arduino will be lighted up for 0.5 second.
Logged

Buena Vista, CO
Offline Offline
Full Member
***
Karma: 0
Posts: 180
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I have been using this protocol with APC220, for some time. It work great over distance of 80 feet through 2 walls.

Jim
Logged

8000ft above the average

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Can you help me set this up? how to wire it? i think thats the problem right now.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

anyone?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Try Mike McCauley's VirtualWire library. The latest version is accessible at:
<http://www.open.com.au/mikem/arduino/>
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is my first attempt at communicating wirelessly between 2 Arduino's using 2 APC220. Code is as follows as per above and no joy...Please help!!!

Transmitter-
Quote
const int StartPin = 2;      // the number of the start pushbutton pin
const int StopPin = 3;       // the number of the stop switch pin

// variables will change:
int StartPinState = 0;        // variable for reading the pushbutton status
int StopPinState = 1;         // variable for reading the pushbutton status
int PumpRunState = 1;         // variable for reading the pumprun status

void setup() {                // initialize the LED pin as an output
  Serial.begin(9600);
  pinMode(StartPin, INPUT);   // initialize the pushbutton pin as an input
  pinMode(StopPin, INPUT);    // initialize the pushbutton pin as an input
}

void loop(){
  StartPinState = digitalRead(StartPin);    // read the state of the pushbutton value
  StopPinState = digitalRead(StopPin);      // read the state of the pushbutton value
  if (StopPinState == HIGH && (StartPinState == HIGH || PumpRunState == HIGH))  {
  Serial.print(1);
  PumpRunState = HIGH;
  }
  else   
  Serial.print(0);
  PumpRunState = LOW
  }



Receiver-
Quote
const int ledPin =  13;      // the number of the LED pin

int PumpRun = 0;
int val = 0;
void setup() {                // initialize the LED pin as an output
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);    // initialize the pushbutton pin as an input

}

void loop(){
val = Serial.read();
  if (-1 != val) {
   if ('1' == val || 'a' == val) {
   digitalWrite(ledPin, HIGH);
   }
   else if ('0' == val || 'b' == val){
   digitalWrite(ledPin, LOW);
   }
}
}


I should expect output 13 to turn on when switches 2 & 3 are closed, but nothing. I'm a newb to this.... any assistance would be appreciated.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm in the same boat, want to wirelessly communicate between 2 arduinos using 2 APC220's, I can communicate fine from PC to arduino but arduino to arduino is no go so far, I can't find any documentation or examples except one french guy in 2010 that never documented any of it in a comprehensible way, he has example code but it's commented in french and it's mostly stuff completely unrelated to wireless APC220 communication.

His video:

His relevant code: (I think) http://arduino.cc/forum/index.php/topic,33147.msg241865.html#msg241865

Here is my non-functional code:
Code:
// RX

// Press 1 to light the LED, and 2 to turn it off

void setup() {                
      pinMode(13, OUTPUT);  
      Serial.begin(9600);
    }
    
    
    void loop() {
      if (Serial.available()){
        char input = Serial.read();
        switch (input){
          case '1':
            digitalWrite(13, HIGH);  
            delay(100);
            break;
          case '2':
            digitalWrite(13, LOW);
            delay(100);
            break;
        }
      }  
    }

Code:
// TX

// Alternate sending 1 and 2 to make RX arduino blink

void setup() {                
  Serial.begin(9600);
}

void loop() {
  Serial.println("1");
  delay(250);
  Serial.println("2");
  delay(250);
}

That code works over a wired connection (0->1 gnd->gnd) but does nothing what so ever with the RF modules attached instead.

Datasheet: http://www.dfrobot.com/image/data/TEL0005/APC220_Datasheet.pdf (engrish warning)
User Manual: http://www.dfrobot.com/image/data/TEL0005/APC220_Manual_en.pdf (engrish warning)
Wiki: http://www.dfrobot.com/wiki/index.php?title=APC220_Radio_Data_Module%28SKU:TEL0005%29

None of them mention arduino to arduino communication, but it kinda has to be possible right? I've connected 1(GND) to ground, 2(VCC) to 5+, 4(rx) to 1(tx) and 5(tx) to 0(rx) and as said works fine between my computer and arduino, use the RX code on my arduino and connect a APC220 using the USB adapter board and a new serial port shows up in the arduino IDE, use the serial monitor and send 1/2 turns the LED on/off

Advise would be greatly appreciated.
« Last Edit: September 12, 2012, 11:39:14 am by ChrisGBG » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

IRC helped me out some but frankly my wiring was wrong on the TX arduino, since you need to unplug the APC220 from the serial ports to re-program the arduino using the IDE I kept unplugging the tx/rx lines and at some point got them backwards on the TX arduino... *facepalm* anyway corrected that and it now works, both using "raw" serial and EasyTransfer library, code bellow.



Image for reference, I'm using the regular LED on #13 though and tactile push button switch on #10, I use the same button setup as the button tutorial/example except on pin 10 (push = high)

I'm running stock configuration on both modules, I'm considering upping the baudrate but for now I've left it at it's default speed of 9600, no other settings modified.

Wiring:

Ground -> APC220 1

+5 -> APC220 2

Arduino 1 (UART RX) -> APC220 4 (TX)

Arduino 0 (UART TX) -> APC220 5 (RX)

Wiring is identical on both ends except the button is of course redundant on RX end, and LED on TX end.

Here is my code for "raw" serial:

Code:
// TX

// Alternate sending 1 and 2 to make RX arduino blink

const int buttonPin = 10;     // the number of the pushbutton pin

int buttonState = 0;         // variable for reading the pushbutton status


void setup() {                
  Serial.begin(9600);
}

void loop() {  
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed.
  // if it is, the buttonState is HIGH:
  if (buttonState == HIGH) {    
    // turn LED on:    
    Serial.println("1");
  }
  else {
    // turn LED off:
    Serial.println("2");
  }
  delay(100);

}

Code:
// RX

int led = 13;

void setup() {                
  pinMode(led, OUTPUT);
  Serial.begin(9600);
}


void loop() {

  if (Serial.available()){
    char input = Serial.read();
    switch (input){
    case '1':
      digitalWrite(led, HIGH);  
      delay(100);
      break;
    case '2':
      digitalWrite(led, LOW);
      delay(100);
      break;
    }
  }  
  else // blinks if there is no serial connection available
  {
    digitalWrite(led, HIGH);
    delay(200);
    digitalWrite(led, LOW);
    delay(200);
  }
}

Here is my code for EasyTransfer:

Code:
// TX ET

#include <EasyTransfer.h>

EasyTransfer ET;

struct SEND_DATA_STRUCTURE{
  int buttonState;
};

SEND_DATA_STRUCTURE mydata;

const int buttonPin = 10;     // the number of the pushbutton pin

void setup() {                
  Serial.begin(9600);
  ET.begin(details(mydata), &Serial);
}

void loop() {  
  mydata.buttonState = digitalRead(buttonPin);
  ET.sendData();
}

Code:
// RX ET

#include <EasyTransfer.h>

EasyTransfer ET;

struct RECEIVE_DATA_STRUCTURE{
  int buttonState;
};

RECEIVE_DATA_STRUCTURE mydata;

int led = 13;

//-- TIMING

long previousMillis = 0;
long interval = 500;
unsigned long currentMillis;

void setup() {                
  pinMode(led, OUTPUT);

  Serial.begin(9600);
  ET.begin(details(mydata), &Serial);
}

void loop()
{
  currentMillis = millis();
  if(ET.receiveData())
  {
      // we got a data packet, can use yet another LED to visualize the data rate, set to HIGH here, flashes like an ethernet port does (yellow in my case)
      previousMillis = currentMillis; // reset deadman timer
      
      digitalWrite(led, mydata.buttonState); // LED matches TX's button state, push the button and the LED ligths up, let go and it darkens
  }
  else
  {
    // no data packet this loop, loop might be going faster than baud rate, not an issue, set your packet visualizer LED to LOW here (yellow in my case)
  }
  if(currentMillis - previousMillis > interval) {  

    //-- No packet for 500ms, DEADMANSWITCH! (required for remote control etc, don't want your robot to keep executing it's last command forever if it looses signal, lets say full speed ahead)

    // Flashing to indicate no signal, I use a red LED

    digitalWrite(led, HIGH);
    delay(200);
    digitalWrite(led, LOW);
    delay(200);
  }
  else
  {
    // we got signal, can use a secondary LED to show that (green)
  }
}

I actually use a red yellow and green LED on my robot which I use for status, green lights up when there is a signal, yellow flashes in time with packets, red lights up if the deadmanswitch triggers due to no packets for 500ms

I'm fairly new to arduino, my code might not be very neat but it works, feel free to use, tweak and improve it, hope it's of use to you.

My unmodified RX code with 3 LEDs: http://pastebin.com/3ppKB7uf (TX is identical) I'm using a mega hence the 40 range LEDs (end connector)

Here is a quick and rough video showing that linked RX ET code and the TX ET code above running on an Uno and Mega (disregard the robot, mega is a bit stuck to it, not really part of the example, only the LEDs and APC220 is)



Red is +5 green is ground white/yellow data
« Last Edit: September 12, 2012, 02:12:26 pm by ChrisGBG » Logged

Pages: [1]   Go Up
Jump to: