예제 #1
0
import machine
from time import sleep
from util.octopus import Env, w, time_init, get_hhmm, get_hhmmss
from util import printTitle
isOled = False
isDisp7 = True

printTitle("examples/deep_sleep1.py")
from util.led import Led
led = Led(2)

if get_hhmm() == "00:00":
    print("first time setup > ")
    w()
    time_init()

print(get_hhmmss())


def sendValue(val=0, urlPOST="http://your_server/add_item_to_database.php"):
    from urequests import post
    header = {}
    header["Content-Type"] = "application/x-www-form-urlencoded"
    deviceID = Env.uID
    place = "octoPy32"
    value = int(float(Env.ver) * 100)
    try:
        postdata_v = "device={0}&place={1}&value={2}&type={3}".format(
            deviceID, place, value, "val")
        res = post(urlPOST, data=postdata_v, headers=header)
예제 #2
0
from time import sleep
from util.octopus import w, lcd2_init, get_hhmm, time_init
from util import printTitle

w()  # wifi connect
lcd = lcd2_init()  # 8 x 7segment display init

lcd.clear()
lcd.move_to(3, 0)
lcd.putstr("octopusLAB")


def clock():
    lcd.move_to(5, 1)
    lcd.putstr(get_hhmm(":"))
    sleep(0.5)
    lcd.move_to(5, 1)
    lcd.putstr(get_hhmm(" "))
    sleep(1)


time_init()  # server > time setup

printTitle("examples/clock.py")
print("this is simple Micropython example | ESP32 & octopusLAB")
print()

while True:
    clock()