forked from secoworld/LTempTest
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
69 lines (51 loc) · 1.33 KB
/
main.c
File metadata and controls
69 lines (51 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "dht11.h"
#include "oled.h"
#include "onenet.h"
#include "pitemp.h"
int main(void)
{
int socke1;
int len;
float Pitemp;
char pitempStr[7];
char tempStr[5];
char humiStr[5];
char HTTP_Buf[400]={0};
wiringPiSetup();
uint temp,humi,temp1,humi1;
socke1=socket_statr();
OLED_Pin_Init();
dht11_pin_init(7);
LCD_Init();
//LCD_CLS();
OLED_CLS();
LCD_P6x8Str(2,1,"hello world");
Pitemp=read_cpu_temp(); //pi3 cpu temp
if(dht11_read_data(&temp,&humi,&temp1,&humi1))
{
printf("DHT11 error!!");
OLED_P6X8Str(20,4,"DHT11 ERROR");
OLED_Write();
return 1;
}
OLED_P6X8Str(20,0,"raspberry pi3");
OLED_P6X8Str(0,1,"*********************");
//OLED_Write();
sprintf(pitempStr,"%.2f",Pitemp);
sprintf(tempStr,"%d",temp);
sprintf(humiStr,"%d",humi);
OLED_P6X8Str(2,3,"Pi3 temp: C");
OLED_P6X8Str(70,3,pitempStr);
OLED_P6X8Str(2,5,"Temp : C");
OLED_P6X8Str(50,5,tempStr);
OLED_P6X8Str(2,6,"Humi : %RH");
OLED_P6X8Str(50,6,humiStr);
OLED_Write();
printf("The pi3 CPU temp is %.3f °C\r\n",Pitemp);
printf("The temp is %d.%d °C\r\n",temp,temp1);
printf("The humi is %d.%d RH\r\n",humi,humi1);
len=HTTP_PostPkt(HTTP_Buf,APi,Id,"dht11_temp",tempStr,"dht11_humi",humiStr,"pi3_cpu_temp",pitempStr);
write(socke1,HTTP_Buf,len); //write to https
socket_close(socke1);
return 0;
}