Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
12 years ago.
Asking send data using mbed+xbeepro
hello everyone, i have been trying to send data from ADXL345, ITG3200, and LM35 using mbed+xbeepro in transmit side and xbeepro+xbeeexplorer+software xctu. this is my code
ADCScode
#include "ADXL345.h"
#include "ITG3200.h"
//determine pinout
ADXL345 accelerometer(p5, p6, p7, p8);
Serial pc(USBTX, USBRX);
ITG3200 gyro(p9, p10);
Serial xbee1(p13, p14);
AnalogIn LM35(p19);
//also setting unused analog input pins to digital outputs reduces A/D noise a bit
DigitalOut P16(p16);
DigitalOut P17(p17);
DigitalOut P18(p18);
//DigitalOut P19(p19);
DigitalOut P20(p20);
int main() {
int readings[3] = {0, 0, 0};
int tempC;
char send[7];
pc.printf("Institut Teknologi Telkom Satellite Society :)");
pc.printf(" DOA MAMA ", accelerometer.getDevId());
//Go into standby mode to configure the device.
accelerometer.setPowerControl(0x08);
//Full resolution, +/-16g, 4mg/LSB.
accelerometer.setDataFormatControl(0x0B);
//3.2kHz data rate.
accelerometer.setDataRate(ADXL345_3200HZ);
//Measurement mode.
accelerometer.setPowerControl(0x08);
gyro.setLpBandwidth(LPFBW_42HZ);
while (1) {
//conversion to degrees C - from sensor output voltage per LM61 data sheet
tempC = ((LM35*3.3)-0.6)*100.0;
//convert to degrees F
//tempF = (9.0*tempC)/5.0 + 32.0;
//print current temp and count the time
pc.printf("%i C\n\r", tempC);
wait(1);
accelerometer.getOutput(readings);
//13-bit, sign extended values.
pc.printf("%i , %i , %i\n\r", (int16_t)readings[0], (int16_t)readings[1], (int16_t)readings[2] );
//Arbitrary wait for printf clarity
pc.printf("%i , %i , %i\n", gyro.getGyroX(), gyro.getGyroY(), gyro.getGyroZ());
//convert integer to char
send[0]=(int16_t)readings[0]&0xFF;
send[1]=(int16_t)readings[1]&0xFF;
send[2]=(int16_t)readings[2]&0xFF;
send[3]=gyro.getGyroX()&0xFF;
send[4]=gyro.getGyroY()&0xFF;
send[5]=gyro.getGyroZ()&0xFF;
send[6]=tempC&0xFF;
//send data throudh serial
xbee1.putc(send[0]);
xbee1.putc(send[1]);
xbee1.putc(send[2]);
xbee1.putc(send[3]);
xbee1.putc(send[4]);
xbee1.putc(send[5]);
xbee1.putc(tempC);
}
}
i converted all the integer output into char using mask ($0xFF), and then i transmitted all the results of the sensors over xbee. but in xctu software, all the datas appear as a "dot"(like this: "......."). i sent 7 datas and result 7 dots long. is there any idea to show as their meant to be? thank you
eduemon