-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathweb-oled-dht22.bas
51 lines (42 loc) · 1.14 KB
/
web-oled-dht22.bas
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
'web-oled-dht22.bas
' Code is based examples givien in the
' WebMite User Manual, Page 25
' https://geoffg.net/Downloads/picomite/WebMite_User_Manual.pdf
' MIT License
' MMBASIC 5.08
DIM buff%(4096/8)
DIM FLOAT temp, humidity
Const BLK=RGB(BLACK)
Const WHT=RGB(WHITE)
' If you do not have an RTC, comment out RTC GETTIME
' and uncomment WEB NTP -5 to get the time/date from
' the internet instead. The -5 will need to be adjusted
' for your timezone.
'WEB NTP -5
RTC GETTIME
SetPin GP21, DOUT
Pin(GP21) = 1
ipaddr$ = MM.Info(ip address)
CLS
Box 0, 0, 128, 64, 2, WHT, BLK
Text 10, 10, ipaddr$, "L", 1, 1, WHT, BLK
WEB TCP INTERRUPT WebInterrupt
Do
Device HUMID GP27, temp, humidity
f_temp = (temp * 1.8) + 32
temp = f_temp
Text 10, 25, "Temp: " + Str$(temp) + " F", "L", 1, 1, WHT, BLK
Text 10, 40, "Humi: " + Str$(humidity) + " %", "L", 1, 1, WHT, BLK
Pause 1000
Loop
SUB WebInterrupt
LOCAL a%, p%, t%, s$
FOR a% = 1 To MM.INFO(MAX CONNECTIONS)
WEB TCP READ a%, buff%()
p% = LINSTR(buff%(),"GET")
t% = LINSTR(buff%(),"HTTP")
If (p% <> 0) And (t% > p%) Then
WEB TRANSMIT PAGE a%,"index.html"
ENDIF
NEXT a%
END SUB