LinkNode_TemperatureAdvertising
Dependencies: LinkNod_TemperatureAdvertising
Dependents: LinkNode_Temperatur LinkNode_TemperatureAdvertising_22
Fork of Sensors by
Sensors.cpp
- Committer:
- helloqi
- Date:
- 2016-03-02
- Revision:
- 5:912a1f021b8d
- Parent:
- 4:ee98296289d0
- Child:
- 6:836584114fd6
File content as of revision 5:912a1f021b8d:
#include "Sensors.h" I2C i2c(P0_17, P0_18); Serial pc(P0_23,P0_25); Ticker ticker1; BMP180 bmp180(&i2c); uint8_t data_1=0; uint8_t i = 0; float data=0; void add_data(void) { if (bmp180.init() == 0) { bmp180.startTemperature(); wait_ms(5); // Wait for conversion to complete float temp; if(bmp180.getTemperature(&temp) == 0) { i++; data = data + temp; if(i==5) { data_1 = (uint8_t)(data/5.0); i = 0; data = 0; printf("The average temperature = %d C\n",data_1); } printf("Temperature = %f C\n",temp); } } } Sensors::tmpSensorValue_t Sensors::get() { uint64_t p_temp = 0; ticker1.attach(add_data,1); p_temp = p_temp|data_1; return p_temp; }