Go Down

Topic: How to send value from one Arduino to another using XBEE (Read 759 times) previous topic - next topic

filip

I have a CAN bus shield stacked on one of my arduinos. I retrieve the value from this shield using CAN shield library command with this command

Canbus.ecu_req(ENGINE_RPM,buffer)

I want to send this value, buffer, over to another arduino. Both of them have xbee shields with xbees on them programmed to transmit and receive properly. I just need to know how to send this value buffer. On the other arduino i have this code:

if (Serial.available()) {   //If there is data in the Serial Line
      int dataByte = serReadInt();
      //char dataByte = Serial.read(); //save data into integer variable dataByte
    Serial.println(dataByte); //Print to screen the variable received

My question is, what line do i use to ge that buffer value over to the other arduino so that it works properly?

i have tried this and it hasnt worked

serial.print(buffer);

PaulS

Quote
I just need to know how to send this value buffer.

Can't tell you that without know how buffer is defined.

filip

#2
Mar 30, 2012, 08:49 am Last Edit: Mar 30, 2012, 08:56 am by filip Reason: 1
this is how buffer is defined:

char buffer[512];

However i should mention that obviously the engine RPM is an integer value, so I'm not sure when or how this is converted back and forth. As long as i can get the value onto the other arduino though I'll be a very happy man :)

PaulS

What Arduino are you using to get the data in buffer? 512 characters is 1/4 of the memory on most Arduinos.

Why do you need to send the entire array to the other Arduino? Get the data that the other one needs, and send just that data.

In any case, if buffer is a char array, rather than a byte array (that is, it does not contain embedded NULLs), then Serial.print(buffer); should send all the data in buffer, up to the first NULL, to the XBee to broadcast.

Quote
i have tried this and it hasnt worked

Something happened. You expected something to happen. All we now know is that those two somethings are not the same thing. You'll have to be far more descriptive than that.

Other things that might be helpful: What baud rate are you using to talk to the XBee? What baud rate are the XBees using to talk to each other? What kind of XBees are they? How often does the Canbus object get data? What does the rest of the code look like? What is the other XBee/Arduino doing?

Go Up