Xbee S1 with Arduino Uno transmitter and PC with Xbee S1 receiver

Hi ,

I am trying to implement this electrical energy consumption project ( Using an Arduino to Track My Electricity Consumption Cost in Real-Time). except for the servo part. My project is to detect the LED blink on the energy meter and send it to PC with XBee s1 through Xbee s1 mounted on arduino uno board.

At the PC side I have a java program to read the raw bytes received to insert in to database.

I am looking for help in xbee s1 configuration. First i tried following configs in xbee s1 on arduino and PC side resp.

Arduino side
AP 1
MY 1
ID 1977
DL 2
CH C

AP 1
MY 2
ID 1977
DL 1
CH C

But I am not getting any data on the Java application using above xbee . My arduino configuration is giving desired results.
Can you suggest best possible way to configure xbee . Also in the process i have bricked one of the xbee , any suggestions to unbrick. I have tries some methods stated in other sites like selecting the No baud change option (9600,NONE,8,NONE,1) & always update firmware option selected (under Modem configuration ) in X-CTU but no success.
Is there a sure shot way to unbrick xbee. ?

But I am not getting any data on the Java application using above xbee .

Then, the problem is likely in how the Arduino is sending data or how the Java application is receiving data or how the XBees are connected to the Arduino/PC - details that you failed to provide.

my arduino code is .

#include <XBee.h>
#include <SoftwareSerial.h>

XBee xbee = XBee();

// allocate two bytes for to hold a 10-bit analog reading
uint8_t payload[] = { 0 };

// 16-bit addressing: Enter MY address of remote XBee, typically the coordinator

Tx16Request tx = Tx16Request(0x02, payload, sizeof(payload));
TxStatusResponse txStatus = TxStatusResponse();

int val = 0;
int maxVal = 0;
unsigned short count = 0;
unsigned long lastWrite = 0; //timer
unsigned long writeInterval= 1000*60; // 1 minute

void setup() {
pinMode(13, OUTPUT);
//xbee.begin(9600);
Serial.begin(9600);
xbee.setSerial(Serial);
}

void loop() {
// read the state of the lightsensor
val = analogRead(0);

//maxVal = max(maxVal, val);

if (val >= 10){
count++;
digitalWrite(13, HIGH);
delay(1000);
} else {
digitalWrite(13, LOW);
}

if (millis() >= lastWrite+writeInterval){ // write period has passed
payload[0] = count;
//Serial.println(count);
xbee.send(tx);
count = 0;
lastWrite = millis(); // save when write occured
}
}

I have TSOP 1738 & LED photo transistor (on a PCB which has GND, +5V & OUT pins) connected to GND,5V and A0 pins of arduino respectively.

How is the XBee connected to the Arduino? Why is it connected to the hardware serial port?

Xbee is connected though Xbee shield on arduino

Xbee is connected though Xbee shield on arduino

So? WHICH XBee shield? There are at least 3 commonly used XBee shields that are completely different.

This one XBee Shield for Arduino - rhydoLABZ : rhydoLABZ INDIA

From that site:

The shield is provided with a DPDT sliding switch which helps XBEE module to connect either PC via USB or UART Pins of Arduino microcontroller. This feature helps you to configure the XBEE module before using in your project.No need for separate XBEE development board or XBEE explorer. Power is taken from the 5V pin of the Arduino and regulated on-board to 3.3VDC before being supplied to the XBee. The shield also takes care of level shifting on the DIN & DOUT pin of the XBee.There is another option(Jumper Selectable) which allows you to connect XBEE module to either Digital UART or Software UART.

I suggest that you move the switch from the hardware UART position to the software UART position, and figure out which pins it is connected to (probably pins 2 and 3). Then, create a SoftwareSerial instance to talk to the XBee and use Serial to talk to the PC, so you can debug your code.

That shield has LEDs that show transmit and receive activity. It would be nice to know what they are doing.

And, of course, one XBee is useless. We need to know how the other one is connected to the PC.

PC side I am using XBee Explorer Dongle - rhydoLABZ : rhydoLABZ INDIA

Xbee shield is already in Software UART mode it self, but result is same . Do i need to change my arduino code ?

Xbee shield is already in Software UART mode it self, but result is same . Do i need to change my arduino code ?

Of course you do. You are reading from/writing to the hardware serial port. You need to read from/write to a software serial port, and add debug messages (sending them to the hardware serial port).

So, now we know that both ends have TX and RX leds, but not whether they are doing anything. Sooner or later, I'm sure you'll provide all the answers.

Can you please send code changes