Go Down

Topic: cant transmit with Xbee s1 api (Read 768 times) previous topic - next topic

a081483

Sep 09, 2013, 11:29 am Last Edit: Sep 09, 2013, 11:31 am by a081483 Reason: 1
Hi!
I use this library https://code.google.com/p/xbee-arduino/. I only set these :
CH : B
ID : 1234
DL : FFFF
BD : 7 (115200)
AP : 1

PC side > MY : F000
Arduino > MY : A001

and I've already tested these situation :
with AP0 , use X-CTU terminal to talk  ...OK!
with AP0 , use the code below to see if something transmit ...OK!
with AP1 , copy what Arduino send with the code (through FTDI)
              and use X-CTU terminal to type it and send ...OK!
with AP1 , Arduino with the code talk to Xbee on PC ...FAILED!  Cant get anything on PC

By these tests, I think there is no problem with hardware and setting.
But with same code, XBee S2 with API mode works well. (only change function to Tx64)
Please help me to solve it, I've tested for a month. :~ Thanks in advance!
Code: [Select]
#define RATE 500

int val_max = 0;
int val_min = 1023;
float average_val = 0;
long add_time = 0;
int read_count = 0;
int latest_val = -1;
int read_val;
unsigned long timer0;
int current_val;

#include <XBee.h>
XBee xbee = XBee();
uint8_t payload[] = {0, 0};
Tx16Request tx = Tx16Request(0xF000, payload, sizeof(payload));

void setup() {
 Serial.begin(115200);
 xbee.setSerial(Serial);
}

void loop() {
 if(millis() - timer0 > RATE) {
   timer0 = millis();
   current_val = (average_val / add_time) * 18.24;
   average_val = 0;
   add_time = 0;
   
   payload[0] = current_val >> 8 & 0xff;
   payload[1] = current_val & 0xff;
   xbee.send(tx);
 }
 
 read_val = analogRead(0);
 val_min = min(read_val, val_min);
 val_max = max(read_val, val_max);
 read_count++;
 if(read_count == 100) {
   average_val += (val_max - val_min) / 2;
   add_time++;
   val_max = 0;
   val_min = 1023;
   read_count = 0;
 }
}

AhMedina

Hi, have you solved it?

I think I can help you, but I don't understand your question. I've been working with XBees this year using the same library and the wireless protoshield. In lots of post I've seen problems related with hardware, i.e. the board in which the XBee is attached. Check that 1st and then, if you need it, I can help you with your code :)

Go Up