STM32F103C8T6 a demo with esp8266 pust onenet
Dependencies: cJSON_lib Common_lib EdpKit_lib DHT ESP8266 wifi_example
Revision 3:296161f9baf9, committed 2020-12-28
- Comitter:
- dadangjia
- Date:
- Mon Dec 28 14:25:58 2020 +0000
- Parent:
- 2:1dbc3aa8ae3a
- Commit message:
- stm32103c8T6 with n5110 esp8266 dh11 pust onenet
Changed in this revision
diff -r 1dbc3aa8ae3a -r 296161f9baf9 DHT.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/DHT.lib Mon Dec 28 14:25:58 2020 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/teams/components/code/DHT/#df22ddf10d75
diff -r 1dbc3aa8ae3a -r 296161f9baf9 driver_mbed_HP20x.lib --- a/driver_mbed_HP20x.lib Wed Mar 29 03:14:41 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/TaylorGy/code/driver_mbed_HP20x/#2ee0bc82e7b8
diff -r 1dbc3aa8ae3a -r 296161f9baf9 driver_mbed_TH02.lib --- a/driver_mbed_TH02.lib Wed Mar 29 03:14:41 2017 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/users/TaylorGy/code/driver_mbed_TH02/#89151affda00
diff -r 1dbc3aa8ae3a -r 296161f9baf9 main.cpp --- a/main.cpp Wed Mar 29 03:14:41 2017 +0000 +++ b/main.cpp Mon Dec 28 14:25:58 2020 +0000 @@ -9,66 +9,42 @@ /************************************************************/ #include "mbed.h" #include "wifi_example.h" -#include "driver_mbed_TH02.h" -#include <driver_mbed_HP20x.h> -#include <driver_mbed_KalmanFilter.h> + + +//指示灯闪亮 +DigitalOut RedLed(PC_13); // 工作指示灯,每秒闪灭一次 -unsigned char ret = 0; +//dh11引脚定义 +#include "DHT.h" +#define DHT_DATA_PIN PB_7 +DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype) +float h = 0.0f, c = 0.0f; -KalmanFilter p_filter; //Kalman filter for pressure -KalmanFilter a_filter; //Kalman filter for altitude -float temperature = -999.999; -float humidity = -999.999; -float pressure = -999.999; -float pressure_filtered = -999.999; -float altitude = -999.999; -float altitude_filtered = -999.999; +void DH11_data() +{ + if (!sensor.readData()) + { + c = sensor.ReadTemperature(CELCIUS); + h = sensor.ReadHumidity(); + } +} -void getSensorDat(void); +void stm32c8t6_ticker() +{ + RedLed=0; + DH11_data(); + RedLed=1; +} -/** -* @brief main -**/ int main() { connectInit(); - devLink(DEVICEID,APIKEY); - while(1) { - getSensorDat(); - if(!checkSocketStatus()) { - sendJsonDat("humidity ", humidity); - wait_ms(500); - sendJsonDat("temperature", temperature); - wait_ms(500); - sendJsonDat("pressure", pressure_filtered); - wait_ms(500); - sendJsonDat("altitude", altitude_filtered); - wait_ms(500); - } - } + devLink(DEVICEID,APIKEY); + while(!checkSocketStatus()) { + stm32c8t6_ticker(); + sendJsonDat("hump ", h); + sendJsonDat("temp", c); + } + } - -/** -* @brief get sensor data -**/ -void getSensorDat(void) -{ - int ret; - temperature = myTH02.ReadTemperature(); - humidity = myTH02.ReadHumidity(); - wait_ms(50); - HP20x.begin(); - wait_ms(100); - - ret = HP20x.isAvailable(); - if(OK_HP20X_DEV == ret) { - long p_data = HP20x.ReadPressure(); - pressure = p_data/100.0f; - pressure_filtered = p_filter.Filter(pressure); - - long a_data = HP20x.ReadAltitude(); - altitude = a_data/100.0f; - altitude_filtered = a_filter.Filter(altitude); - } -} \ No newline at end of file
diff -r 1dbc3aa8ae3a -r 296161f9baf9 wifi_example.lib --- a/wifi_example.lib Wed Mar 29 03:14:41 2017 +0000 +++ b/wifi_example.lib Mon Dec 28 14:25:58 2020 +0000 @@ -1,1 +1,1 @@ -https://developer.mbed.org/users/TaylorGy/code/wifi_example/#cbe8a0553d45 +https://os.mbed.com/users/dadangjia/code/wifi_example/#8512a7d76959