-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
48 lines (41 loc) · 1.4 KB
/
main.py
File metadata and controls
48 lines (41 loc) · 1.4 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
# Required Libraries"
# micropython-bme280
from data import Data
from machine import Pin
import time
import random
import machine
import gc
import os
start_btn = Pin(7, Pin.IN, Pin.PULL_UP)
stop_btn = Pin(8, Pin.IN, Pin.PULL_UP)
s = os.statvfs('/')
with Data() as data:
local_ip = data.wlan.ifconfig()[0]
try:
while True:
time.sleep(1)
if start_btn.value() == 0:
while True:
time.sleep(2)
if stop_btn.value() == 0:
break
payload = {
"id": random.randrange(60000000),
"picow": {
"local_ip": local_ip,
"temperature": data.get_board_temperature(),
"free_storage_kb":s[0]*s[3]/1024,
"mem_alloc_bytes":gc.mem_alloc(),
"mem_free_bytes":gc.mem_free(),
"cpu_freq_mhz": machine.freq()/1000000,
},
"bme280": data.read_bme280(),
}
data.display()
data.remoteHost_send(payload)
except Exception as e:
print(f"[*Exception]: {e}")
except KeyboardInterrupt:
print("[*] Keyboard Program Interrupted.")
print(f"Exception(KeyboardInterrupt)")