STM32F103C8T6 a demo with esp8266 pust onenet

Dependencies:   cJSON_lib Common_lib EdpKit_lib DHT ESP8266 wifi_example

Committer:
dadangjia
Date:
Mon Dec 28 14:25:58 2020 +0000
Revision:
3:296161f9baf9
Parent:
2:1dbc3aa8ae3a
stm32103c8T6 with n5110 esp8266 dh11 pust onenet

Who changed what in which revision?

UserRevisionLine numberNew contents of line
TaylorGy 2:1dbc3aa8ae3a 1 /************************************************************/
TaylorGy 2:1dbc3aa8ae3a 2 /* (C) 2016 Beijing ARM Accelerator Technology Co., Ltd. */
TaylorGy 2:1dbc3aa8ae3a 3 /* Description: Demo for ASC Platform. */
TaylorGy 2:1dbc3aa8ae3a 4 /* Performed an example for getting data form Sensors, */
TaylorGy 2:1dbc3aa8ae3a 5 /* then send data to OneNet Cloud by using EDP protocol */
TaylorGy 2:1dbc3aa8ae3a 6 /* Author: ss.pan */
TaylorGy 2:1dbc3aa8ae3a 7 /* Version: 1.01 */
TaylorGy 2:1dbc3aa8ae3a 8 /* Date: 2017-03-28 */
TaylorGy 2:1dbc3aa8ae3a 9 /************************************************************/
TaylorGy 2:1dbc3aa8ae3a 10 #include "mbed.h"
TaylorGy 2:1dbc3aa8ae3a 11 #include "wifi_example.h"
dadangjia 3:296161f9baf9 12
dadangjia 3:296161f9baf9 13
dadangjia 3:296161f9baf9 14 //指示灯闪亮
dadangjia 3:296161f9baf9 15 DigitalOut RedLed(PC_13); // 工作指示灯,每秒闪灭一次
group-ESP8266 0:b887535f68bf 16
dadangjia 3:296161f9baf9 17 //dh11引脚定义
dadangjia 3:296161f9baf9 18 #include "DHT.h"
dadangjia 3:296161f9baf9 19 #define DHT_DATA_PIN PB_7
dadangjia 3:296161f9baf9 20 DHT sensor(DHT_DATA_PIN, DHT11); //DHT(PinName pin, eType DHTtype)
dadangjia 3:296161f9baf9 21 float h = 0.0f, c = 0.0f;
group-ESP8266 0:b887535f68bf 22
group-ESP8266 0:b887535f68bf 23
dadangjia 3:296161f9baf9 24 void DH11_data()
dadangjia 3:296161f9baf9 25 {
dadangjia 3:296161f9baf9 26 if (!sensor.readData())
dadangjia 3:296161f9baf9 27 {
dadangjia 3:296161f9baf9 28 c = sensor.ReadTemperature(CELCIUS);
dadangjia 3:296161f9baf9 29 h = sensor.ReadHumidity();
dadangjia 3:296161f9baf9 30 }
dadangjia 3:296161f9baf9 31 }
group-ESP8266 0:b887535f68bf 32
dadangjia 3:296161f9baf9 33 void stm32c8t6_ticker()
dadangjia 3:296161f9baf9 34 {
dadangjia 3:296161f9baf9 35 RedLed=0;
dadangjia 3:296161f9baf9 36 DH11_data();
dadangjia 3:296161f9baf9 37 RedLed=1;
dadangjia 3:296161f9baf9 38 }
TaylorGy 2:1dbc3aa8ae3a 39
TaylorGy 2:1dbc3aa8ae3a 40 int main()
group-ESP8266 0:b887535f68bf 41 {
TaylorGy 2:1dbc3aa8ae3a 42 connectInit();
dadangjia 3:296161f9baf9 43 devLink(DEVICEID,APIKEY);
dadangjia 3:296161f9baf9 44 while(!checkSocketStatus()) {
dadangjia 3:296161f9baf9 45 stm32c8t6_ticker();
dadangjia 3:296161f9baf9 46 sendJsonDat("hump ", h);
dadangjia 3:296161f9baf9 47 sendJsonDat("temp", c);
dadangjia 3:296161f9baf9 48 }
dadangjia 3:296161f9baf9 49
group-ESP8266 0:b887535f68bf 50 }