XBee Frames from Arduino not working

XBee projects like the adapter, xBee tutorials, tweetawatt/wattcher, etc. from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

XBee Frames from Arduino not working

Post by mustang65 »

Project Summary:

Arduino to send Frames to Xbee 2 that will set the city water valve to either open or close (DPDT relay), then turn the supply voltage on or off to complete the process (SPDT relay). I currently have the circuit working between the Xbee coordinator and router perfectly (simulating the valve using leds). I have the Digital (DIO4, DIO5) pins of the Coordinator setup with the same pins of the Router. I now need to get the Arduino to send Frame packets to the Xbee Coordinator using serial communications. I copied the frames out of XCTU. I originally tried to use Arduino's pins 2 and 3, so I could keep pins 0 and 1 open for Arduino updates, but that did not seem to work. Well neither does using pins 0 and 1 for data. I am trying to get one of the processes working before adding the second one.

So here is the breakdown of the hardware indicators:

Arduino - TX LED is flashing at regular intervals (and verified that data is being sent through the serial monitor)
Xbee Coordinator (API) - Yellow LED on, Green LED is on, Red LED is flashing
XBEE Router (AT) - Yellow LED on, Green LED is on

XCTU sending-
Coordinator - BLUE LED
Router - Blue LED (LED's on/off as requested)

Arduino sending
Arduino - Flashing Tx LED

XTCU receiving?
Coordinator - No LED's responding

The TX and RX jumpers are correct
Changed baud rate to 9600, just to try, no luck
**** Tried using XTCU unable to activate Remote Xbee while Arduino is sending Frames

Thanks in advance for any assistance.

Code: Select all


// Write API Frame packet from Arduino to Xbee
// http://forum.arduino.cc/index.php?topic=119463.0

// include <Wire.h>
// #include <SoftwareSerial.h>

// #define rxPin 2
// #define txPin 3
// SoftwareSerial mySerial =  SoftwareSerial(rxPin, txPin);
// byte pinState = 0;

// Frame for 'Valve' Open or Valve Close Position (Activates DPDT relay which reverses polarity (+ -) to pump)

byte Valve_CLOSE4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5E};
byte Valve_OPEN4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5D};

// Frame for 'Valve' Power "ON" or Power "OFF" (After Valve position is selected, power is then supplied)

byte Valve_Power_ON5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5E};
byte Valve_Power_OFF5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5F};


void setup()
{
// pinMode(rxPin, INPUT);
// pinMode(txPin, OUTPUT);
// mySerial.begin(19200);
 Serial.begin(9600);
}
void loop()
{

  Serial.write(Valve_OPEN4,20);
    delay(3000);
  
  Serial.write(Valve_CLOSE4,20);
    delay(3000);

////////////////////////////////////////////////////////
///////   RESET VALVE POWER TO OFF /////////////////////
//////////////////////////////////////////////////////  
  
}
Last edited by mustang65 on Tue Jan 22, 2019 1:22 pm, edited 1 time in total.

User avatar
pmseattle
 
Posts: 6
Joined: Wed Dec 12, 2018 11:32 am

Re: XBee Frames from Arduino not working

Post by pmseattle »

It isn't entirely clear what you are trying to do here. Are you trying to communicate wirelessly between two Arduinos ? If so, how are you connecting your XBee modules to the Arduinos ?
If you want to communicate sending frames in API mode, both ends should be set up as API. You should use a library such as xbee-arduino rather than attempting low level programming tasks such as constructing frames for transmit or extracting payload from received frames.
For serial communication using a software serial port, the AltSoftSerial library is recommended, or better yet use an Arduino Leonardo with an extra hardware serial port that does not conflict with the usb programming port and serial monitor used by the Arduino IDE.

If you are only communicating between two devices, take a look at the Feather M0 or 32U4 with RFM69 radio, sold on this website. These are simpler to set up and use than an Arduino/shield/XBee combination since the microcontroller and radio modem are integrated on a single circuit board, and also they cost a lot less.

User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

Re: XBee Frames from Arduino not working

Post by mustang65 »

If at all possible could someone look at the below sketch and verify that this is all the code that I need to pass the following XBee API frames from Arduino to the XBee using Arduino pins 0 and 1. I am wondering if there is some other code needed in the script. Using this method for sending a frame would make my code additions so much easier as I add on other Xbee responsibilities. The frames work perfectly in CTXU, but the XBee does not seem to be accepting the frames. Arduino Serial Monitor shows data being transferred when the TX LED is functioning. I get no errors in Arduino, so seems like it should be working "AS IS". Currently, LED's are being used in place of the actual valve.
Xbee Coordinator (API)
XBEE Router (AT)
Thanks,

Code: Select all


// Write API Frame packet from Arduino to Xbee

// Frame for 'Valve' Open or Valve Close Position (Activates DPDT relay which reverses polarity (+ -) to pump)

byte Valve_CLOSE4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5E};
byte Valve_OPEN4[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5D};

// Frame for 'Valve' Power "ON" or Power "OFF" (After Valve position is selected, power is then supplied to the valve relay)

byte Valve_Power_ON5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x05,0x5E};
byte Valve_Power_OFF5[] = {0x7E,0x00,0x10,0x17,0x01,0x00,0x13,0xA2,0x00,0x40,0x8B,0x2D,0x60,0xFF,0xFE,0x02,0x44,0x34,0x04,0x5F};


void setup()
{

 Serial.begin(9600);

 // Give the Xbee enough time to get the data
 delay(5000);
}
void loop()
{

  Serial.write(Valve_OPEN4,20); // Turn on LED
    delay(3000);

  Serial.write(Valve_CLOSE4,20); // Turn off LED
    delay(3000);

}
Attachments
XBee - Arduino Bread Board.jpg
XBee - Arduino Bread Board.jpg (115.51 KiB) Viewed 1977 times

User avatar
mustang65
 
Posts: 54
Joined: Sat Jan 26, 2013 9:29 pm

Re: XBee Frames from Arduino not working

Post by mustang65 »

Problem Resolved... CheckSum problem...
LED's working as programmed.. waiting for PCB board to get here so I can get the CityWaterValve up and running.

Have a GREAT Day Everyone!!!

Locked
Please be positive and constructive with your questions and comments.

Return to “XBee products (discontinued)”