Error display of data packet recieved by coordinator xbee

Hey guys, sorry for my bad english.

I working a project with arduino, inclinometer, and xbee pro s2b. I use Xbee shield to plug the end device xbee to my arduino, so i can make it communicate wirelessly with my coordinator xbee that connected to my laptop.
I've made the arduino code to measure the inclination with my inclinometer and it's work :D.
In my program, i make the arduino to read data every 8 seconds, and send it to my coordinator xbee as a data packet.

i use cool term win to display the data packet that recieved by my coordinator xbee.
But the problem is the data that recieved by my coordinator xbee is like this

SAH%M -10.42
Y Axis: 0.24

Temperatur = 4.00 Celcius

SAis: -10.42
Y Axis: 0.31

Temperatur = 4.00 Celcius

Y Axis: 0.17

Temperatur = 4.00 Celcius


but i actually want to make it like when i use the terminal to display the data before it sent to my coordinator, just like this

X Axis: -10.42
Y Axis: 0.42

Temperatur = 4.00 Celcius

X Axis: -10.45
Y Axis: 0.35

Temperatur = 4.00 Celcius

i guest that when is use the terminal for my coordinator xbee, it also display the start delimiter, length packet, 64-bit address of my end device xbee, frame type and etc, so the data has become a mess. I try to find a way to make the data is become like what i want, but still not figure it out.

so it will be great for any help or guidance to solve this problem.
thanks :smiley:

I use Xbee shield

One of the half dozen XBee shields available, some of which are junk, but I’m not going to tell you which one.

to plug the end device xbee

That I have configured somehow, but I’m not going to tell you how.

I’ve made the arduino code

But I’m not going to share it with you, even though it doesn’t do exactly what I want and all my questions are about why not.

so it will be great for any help or guidance to solve this problem.

There might be some hints above. Or not.

Hi Paul,

i use xbee shield from seeedstudio.

But I'm not going to share it with you, even though it doesn't do exactly what I want and all my questions are about why not.

sorry i didn't get it

i use xbee shield from seeedstudio.

That link doesn't work.

sorry i didn't get it

I'll make it really simple, then. POST YOUR CODE!

Hi paul.

That link doesn’t work.

can you recommend me the shield that work

Oh sorry, this is the code

#include <avr/sleep.h>
#include <avr/wdt.h>
#include <SPI.h>

// Set pins
const int dataINPin = 12;     //MISO
const int dataOUTPin = 11;    //MOSI
const int chipSelectPin = 10;//Chip Select Pin
const int serialClockPin = 13;//CSK

const byte MEAS  = B00000000; //Measure mode (normal operation mode after power on)
const byte RWTR  = B00001000; //Read and write temperature data register, ONLY WRITE COMMAND, note currently in use
const byte RDSR  = B00001010; //Read status register
const byte RLOAD = B00001011; //Reload NV data to memory output register
const byte STX   = B00001110; //Activate Self test for X-channel
const byte STY   = B00001111; //Activate Self test for Y-channel
const byte RDAX  = B00010000; //Read X-channel acceleration through SPI
const byte RDAY  = B00010001; //Read Y-channel acceleration through SPI

void bacaSudut()
  //read X axis
  float xAxisData = readCommand(RDAX);
  float xAxisData1 = asin(-(xAxisData - 1024)/1638)*(180/3.14);
  Serial.print("X Axis: ");

  //read Y axis
  float yAxisData = readCommand(RDAY);
  float yAxisData1 = asin((yAxisData - 1024)/1638)*(180/3.14);
  Serial.print("Y Axis: ");

  //read sensor temperature
  float temp = readCommand(RWTR);
  float temp1 = ((temp - 197)/(-1083));
  float temp2 = (-0.0011)*(temp1*temp1)+(0.0022*temp1)+0.0408;
  float temp3 = 4*(1 + (temp2/100));
  Serial.print("Temperatur = ");
  Serial.print("  Celcius");

// watchdog interrupt
ISR (WDT_vect) 
   wdt_disable();  // disable watchdog
}  // end of WDT_vect
void setup ()
  digitalWrite(2, HIGH);
  // inisialisasi SPI:

  // set input & output;
  pinMode (dataINPin, INPUT);
  pinMode (dataOUTPin, OUTPUT);
  pinMode (chipSelectPin, OUTPUT);
  pinMode (serialClockPin, OUTPUT);


void loop () 
  // disable ADC
  ADCSRA = 0;  

  // clear various "reset" flags
  MCUSR = 0;     
  // allow changes, disable reset
  WDTCSR = bit (WDCE) | bit (WDE);
  // set interrupt mode and an interval 
  WDTCSR = bit (WDIE) | bit (WDP3) | bit (WDP0);    // set WDIE, and 8 seconds delay
  wdt_reset();  // pat the dog
  set_sleep_mode (SLEEP_MODE_PWR_DOWN);  
  noInterrupts ();           // timed sequence follows

  // turn off brown-out enable in software
  MCUCR = bit (BODS) | bit (BODSE);
  MCUCR = bit (BODS); 
  interrupts ();             // guarantees next instruction executed
  sleep_cpu ();  
  // cancel sleep as a precaution
  } // end of loop
word readCommand(byte Command) {

  byte inByte = 0;
  word result = 0;   // result to return

  digitalWrite(chipSelectPin, LOW);


  result = SPI.transfer(MEAS);

  result = result << 8;
  inByte = SPI.transfer(MEAS);

  result = result | inByte;

  result = result >> 5;

  digitalWrite(chipSelectPin, HIGH);

  // return the result:

i set the my end device xbee become end device AT, and my coordinator xbee become coordinator API.

can you recommend me the shield that work

The one you have might work. Find the manufacturer's site (not an ebay ad where you bought it) and post a link, using the link icon.

word readCommand(byte Command) {

The readCommand() function returns a type that I always have to go look up, to see what the hell it is. It SHOULD return a standard type, like int, long, byte, uint8_t, etc. What I do know is that word is NOT a float.

  float xAxisData = readCommand(RDAX);

So, storing the value in a float doesn't make sense.

  float xAxisData1 = asin(-(xAxisData - 1024)/1638)*(180/3.14);

In general, arithmetic involving floats should involve ONLY floats. xAxisData is, but shouldn't be, a float. Since it should be an integral type, you should cast it to a float.

All the integral constants should be floats (1024 -> 1024.0).

There are VERY few times when Serial.flush() should be used. The only one that really makes sense is making sure that all the serial data has been sent BEFORE going to sleep.

You are not doing that, so the serial data gets sent when the Arduino wakes up, all groggy and disoriented. Use Serial.flush() before going to sleep, to be sure that when the Arduino wakes up is has no serial data to send.

When tracking serial data sending/receiving issues, it is far better to stay awake and alert until you KNOW that the data is sent and received correctly. Only when you know that the data is sent and received correctly should you consider napping. If napping introduces problems, you have an idea where to look for a solution.

Trying to debug code that can hardly stay awake is more challenging.