Re: Trying to turn on a led with the PC to XBee/Arduino case

88 views
Skip to first unread message

Andrew Rapp

unread,
Apr 13, 2013, 8:20:23 AM4/13/13
to xbee...@googlegroups.com
Hi Diego,

The error you show below (com.rapplogic.xbee.examples.ApiAtExample) is unrelated to the java code that you posted, so you are not running your code. Also you are mixing series 1 and 2 code. You java is using series 1 and Arduino series 2, so that would never work.

Andrew



On Sat, Apr 13, 2013 at 12:19 AM, Diego Turcios <diegotu...@gmail.com> wrote:
Hi
I am trying to combined case 1 and case 2(the ones of the wiki). Turn off a led sending signals from the PC but using arduino.
Still doesn't work. Completely new with the API.

This is my java code

xbee.open("/dev/ttyUSB0", 9600);
XBeeAddress16 destino = new XBeeAddress16(0x0013A200, 0x408B2E54);
                        int[] payload = new int[] { 90, 180 };
                        TxRequest16 tx = new TxRequest16(destino,payload);
                        TxStatusResponse status = (TxStatusResponse)xbee.sendSynchronous(tx);
                        if (status.isSuccess()) {
                            System.out.println("Se conecto");
                        }
                        else
                        {
                            System.out.println("No se conecto");
                            
                        }


And this is my arduino code

XBee xbee = XBee();
uint8_t payload[] = { 1, 0 };

XBeeAddress64 address= XBeeAddress64(0x0013A200, 0x408b2E66);
ZBTxRequest tx = ZBTxRequest(address, payload, sizeof(payload));

TxStatusResponse txStatus = TxStatusResponse();
int BELL = 2;
void setup() {
  xbee.begin(9600);
  pinMode(BELL, OUTPUT);
  digitalWrite(BELL, HIGH);
}

void loop() 
  {
    int signal;
    xbee.send(tx);
    if (xbee.readPacket(5000)) {                 
        if (xbee.getResponse().getApiId() == TX_STATUS_RESPONSE) {
           xbee.getResponse().getZBTxStatusResponse(txStatus);
             
           if (txStatus.getStatus() == SUCCESS) {
                digitalWrite(BELL, LOW);
                delay(10000);
                digitalWrite(BELL, HIGH);
           } else {
              
           }
        }      
    } else {
    
    }
    delay(5000);
  }

Both code compiles, but doesn't work. I am getting this exception in my java code

[ERROR] [com.rapplogic.xbee.examples.ApiAtExample] at command failed 
java.lang.IllegalArgumentException: input value [1286656] is larger than a byte

Thanks for your time

--
You received this message because you are subscribed to the Google Groups "xbee-api" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xbee-api+u...@googlegroups.com.
To post to this group, send email to xbee...@googlegroups.com.
Visit this group at http://groups.google.com/group/xbee-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Diego Turcios

unread,
Apr 13, 2013, 11:50:49 AM4/13/13
to xbee...@googlegroups.com
Hi Andrew I change the code and left it with the same name. I
thought that for using Series 2 was this way

                       XBeeAddress16 destino = new XBeeAddress16(0x0013A200, 0x408B2E54);
                        int[] payload = new int[] { 90, 180 };
                        TxRequest16 tx = new TxRequest16(destino,payload);
                        TxStatusResponse status = (TxStatusResponse)xbee.sendSynchronous(tx);

Still not sure of that
Reply all
Reply to author
Forward
0 new messages