Hi,
i have a arduino uno, xbee pro series 2 b and a temperature sensor: tmp 36.
i want to send the temperature data through xbee to the serial monitor from arduino.
tmp 36--> xbee - xbee-->xbee shield-->arduino uno
i configure my first xbee as a router in AT Modus with sample rate 1000ms and my coordinator in API.
the sketch i used look like this:
int analogValue;
float c;
//=================== SETUP =================================
void setup() {
Serial.begin(9600);
delay(1000);
Serial.print("Starting..........");
Serial.println();
}
//==================== LOOP =================================
void loop() {
readPacket();
}
//==================== podprogramy XBEE ======================
void readPacket() {
if (Serial.available() >= 21) {
if (Serial.read() == 0x7E) {
for(int i=0;i<18;i++){
byte discard = Serial.read();
}
int analogHigh = Serial.read();
int analogLow = Serial.read();
analogValue = analogLow + (analogHigh * 256);
}
int reading = analogValue; // pin 19 [0] is pin 20
// convert reading to millivolts
float v = ((float)reading /(float)0x3FF) * 1200.0;
// convert to Celcius. 10mv per Celcius degree with 500mV offset at 0 celcius
float c = (v - 500.0) / 10.0;
Serial.print("Temp: ");
Serial.println(c);
Serial.flush();
}
}
i took this code in an example in arduino forum.
The data i received in the serial monitor is 10.29. This value doesn´t change even when i touch the sensor.
Why?
Am i doing something wrong.
I need your help.
Thanks