Code for collecting sensor data
Dependencies: SX1276Lib_inAir mbed
Fork of Sensors by
Diff: main.cpp
- Revision:
- 1:059293827555
- Parent:
- 0:b4b76706c8c3
- Child:
- 2:804e04f4f217
--- a/main.cpp Wed Aug 10 02:23:53 2016 +0000 +++ b/main.cpp Wed Aug 10 03:22:58 2016 +0000 @@ -1,13 +1,15 @@ +#include <stdio.h> #include "mbed.h" #include "sx1276-inAir.h" +#define STRING_LENGTH 10 +#define SUPPLY_VOLTAGE 3.3 + Serial pc(USBTX, USBRX); //Create a serial connection to the PC AnalogIn ain(PA_0); //Configure pin PA0 as an analog input for the temperature sensor //DigitalIn din(PC_7); //Configure pin PC2 as a digital input for the reed switch -const float SUPPLY_VOLTAGE = 3.3; float reading_float; -int reading_int; //Return the temperature from the sensor, in degrees celsius float get_temp() { @@ -29,9 +31,11 @@ while(1) { + char reading_string[10]; reading_float = get_temp(); - reading_int = (int)(reading_float); - pc.printf("Temperature = %d \r\n\r\n", reading_int); + sprintf(reading_string, "%.8f\r\n", reading_float); + pc.printf(reading_string); + //pc.printf("Temperature = %.2f \r\n\r\n", reading_float); wait_ms(500);