11 years, 2 months ago.

Print function to xbee

Hi,

I am having trouble trying to print the right output for my temperature and pressure values from my xbee. Does anyone know what may be the problem with my code below. By the way the values in my mbed data logger is correct.

snprintf(B, sizeof(B), buf, sizeof(buf), "%X", B ,localtime(&seconds)); snprintf(A, sizeof(A), "Temperature: %d*0.1 Deg C\r Pressure: %d Pa\r Altitude: %f metres\r\n", A ,alt_sensor.get_temperature(),alt_sensor.get_pressure(),alt_sensor.get_altitude_ft());

xbee1.puts(B); xbee1.puts(A);

Values from xbee:

Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.415822 metres .00:10:04Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.163348 metres .00:10:06Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 113.173281 metres .00:10:08Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.163348 metres .00:10:10Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.331663 metres .00:10:12Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.499981 metres .00:10:13Temperature: 268435948*0.1 Deg C Pressure: 250 Pa Altitude: 112.163348 metres .00:10:15Temperature: 268435948*0.1 Deg C Pressure: 249 Pa Altitude: 112.499981 metres .00:10:17Temperature: 268435948*0.1 Deg C Pressure: 250 Pa Altitude: 112.499981 metres

Values from mbed:

[00:09:52]Temperature: 249*0.1 Deg C Pressure: 99980 Pa Altitude: 112.836625 metres [00:09:53]Temperature: 249*0.1 Deg C Pressure: 99978 Pa Altitude: 112.920788 metres [00:09:55]Temperature: 249*0.1 Deg C Pressure: 99988 Pa Altitude: 112.584141 metres [00:09:57]Temperature: 249*0.1 Deg C Pressure: 99983 Pa Altitude: 112.415822 metres [00:09:59]Temperature: 249*0.1 Deg C Pressure: 99980 Pa Altitude: 112.584141 metres [00:10:01]Temperature: 249*0.1 Deg C Pressure: 99985 Pa Altitude: 112.920788 metres [00:10:02]Temperature: 249*0.1 Deg C Pressure: 99982 Pa Altitude: 112.415822 metres [00:10:04]Temperature: 249*0.1 Deg C Pressure: 99985 Pa Altitude: 112.415822 metres [00:10:06]Temperature: 249*0.1 Deg C Pressure: 99973 Pa Altitude: 112.415822 metres [00:10:08]Temperature: 249*0.1 Deg C Pressure: 99985 Pa Altitude: 113.004952 metres [00:10:10]Temperature: 249*0.1 Deg C Pressure: 99983 Pa Altitude: 112.584141 metres [00:10:12]Temperature: 249*0.1 Deg C Pressure: 99981 Pa Altitude: 112.499981 metres [00:10:13]Temperature: 249*0.1 Deg C Pressure: 99985 Pa Altitude: 112.836625 metres [00:10:15]Temperature: 250*0.1 Deg C Pressure: 99981 Pa Altitude: 112.752463 metres [00:10:17]Temperature: 250*0.1 Deg C Pressure: 99981 Pa Altitude: 112.584141 metres

Put code between <<code>> and <</code>>, now it is unreadable (and do the same with your data)

posted by Erik - 22 Oct 2013
Be the first to answer this question.