1

I try to send serial data RPM to XBee series1 and then from XBee to another XBee wirelessly in API with Escapes Mode. I think I have to send the data Frame.But not very sure. Any help?

Following is the code to read RPM and send to XBee?

#include <XBee.h>
#include <SoftwareSerial.h>
/* Serial communication with Xbee.
On Arduino pin 9 is Rx connect to Xbee Tx, 
pin 8 is Txconnect to Xbee Rx*/
SoftwareSerial xbeeSerial(9, 8); // RX, TX
XBee xbee = XBee();
int pin = 7; //7
float rpm;
float duration;
float y;
unsigned long val,time;
float rps;
float read_rpm;
uint8_t start_data[] = { 0x7E, 0x00, 0x50, 0x01, 0x01, 0xff, 0xff,0x00, 0x05, 0x00,0x01,0x03, 0x84, 0x00 };
void setup() 
{
 Serial.begin(9600);
 pinMode(pin, INPUT);
 Serial.println("I am ready to send some RPM!");
 xbeeSerial.begin(9600);
 time = millis();
}
void loop()
{
void loop()// run over and over
{
 val = pulseIn(pin, LOW,70000000);
 duration=(float)val/1000000.00;
 rps= 1.00/duration;
rpm=60.00*rps;
/* Sending float to Xbee
Float is 4 byte size*/
serialFloatPrint(rpm);
int floatToInt = (int)rpm;
/* To send INT to XBEE
Int is 2 byte size*/
xbeeSerial.write(highByte(floatToInt));
xbeeSerial.write(lowByte(floatToInt));
 Serial.write(0x03);
 delay(2000);
}
void serialFloatPrint(float f) {
 byte * b = (byte *) &f;
 //xbeeSerial.print("f:");
 xbeeSerial.print(b[0]);
 xbeeSerial.print(b[1]);
 xbeeSerial.print(b[2]);
 xbeeSerial.print(b[3]);
 /* DEBUG */
 Serial.println();
 Serial.print(b[0],BIN);
 Serial.print(b[1], BIN);
 Serial.print(b[2], BIN);
 Serial.println(b[3], BIN);
 //*/
}
}
asked Oct 28, 2014 at 6:50
10
  • As @TMa showed, download this library and first test the communication without any RPM calculation. When you will be sure you get good messages on another arduino, then add rpm and etc... In Xbee-Arduino library there are examples Commented Oct 28, 2014 at 11:47
  • Please use the code tag. Commented Oct 28, 2014 at 13:40
  • @werner, where is the code tag? Commented Oct 28, 2014 at 23:23
  • couldn't find the example what I want. I tried the following. Though can't recevive any serial data. Commented Oct 29, 2014 at 7:04
  • I got stucked with this. Any help? Commented Oct 29, 2014 at 7:10

1 Answer 1

1

You are using it as in non-API mode when data are passed to Xbee wireless transparently. To use Xbee in API mode use e.g. Xbee-Arduino library.

answered Oct 28, 2014 at 8:31

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.