Testing Batteries With a Wemos D1
Fleetingcat<<EOF > /tmp/main.py
#!/usr/bin/env python3
# -*- coding:utf-8 -*-
import machine
import time
import ntptime
import requests
led = machine.Pin(2, machine.Pin.OUT)
led.off() # on
time.sleep(2)
led.on() # off
ntptime.settime()
time.sleep(10) # to have the time to update the program
while True:
now = time.localtime()
h = now[3]
m = now[4]
try:
requests.post(
"http://192.168.1.46:9705/i",
headers={"title": f"{h:02d}:{m:02d} iot battery"},
data=f"""Hello""")
except Exception as e:
pass # most likely the night, when the wifi is off
machine.lightsleep(3600 * 1000)
EOF
webrepl_cli.py -p 0000 /tmp/main.py 192.168.1.123:main.py
op:put, host:192.168.1.123, port:8266, passwd:0000.
/tmp/main.py -> main.py
spawn webrepl_cli.py -p 0000 192.168.1.123
op:repl, host:192.168.1.123, port:8266, passwd:0000.
Remote WebREPL version: (1, 23, 0)
Use Ctrl-] to exit this shell
Traceback (most recent call last):
File "main.py", line 28, in <module>
KeyboardInterrupt:
MicroPython v1.23.0 on 2024-06-02; ESP module (1M) with ESP8266
Type "help()" for more information.
>>>