Exemplo n.º 1
0
def wget(urlApi ="http://www.octopusengine.org/api"):
    # get api text / jsoun / etc
    from util.octopus import w
    try:
        w()
    except Exception as e:
        print("Exception: {0}".format(e))

    from urequests import get
    urltxt=urlApi+"/text123.txt"
    try:
        response = get(urltxt)
        dt_str = response.text
    except Exception as e:
        print("Err. read txt from URL")
    return dt_str
Exemplo n.º 2
0
# ESP32board with "BUILT_IN_LED" and OLED display

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")
Exemplo n.º 3
0
# simple basic example - ESP32 + i2c lcd display
# cp("examples/lcd_clock.py") > main.py

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:
Exemplo n.º 4
0
# --- test ---
print("--- test --- RAM free: " + str(mem_free()))
print("test: led")
built_in_led.on()
sleep(1)
built_in_led.off()

print("test: RGB led")
ws.simpleTest()

print("test: display 7 digit")
d7 = disp7_init()
sleep(2)
d7.show("")

print("test: bmp")
bmp = bmp_init()
temp = show_temp()
net = w()
send_boot()
send_bmp()
solar_adc()

# rtc = RTC() # real time
tim1 = Timer(0)  # for main 10 sec timer
timer_init()

# --- run ---
print("--- run --- RAM free: " + str(mem_free()))
Exemplo n.º 5
0
Debug = True

print("sensor_log2 - version: " + str(ver))
print(getVer())
#print(getGardenLibVer())
#deviceID = str(get_eui())

startLight = 0
stopLight = 1

sleep(1)
if not button3.value():
    from util.octopus import web_server
    print("Starting webserver > ")
    try:
        w()
        web_server()
    except Exception as e:
        print("timeDisplay() Exception: {0}".format(e))
        # todo:  Exception: memory allocation failed

    print("> stop main program")
    while True:
        sleep(10)


def timeDisplay():
    xt = 88  # display time possition
    yt = 38
    if not isOLED:
        return
Exemplo n.º 6
0
startLight = 0
stopLight = 1

piezzo = None
isOLED = False
ts = None
sbh = None
pwmLed = None
relayPump = None

sleep(1)
if not button3.value():
    from util.octopus import web_server
    print("Starting webserver > ")
    try:
        w()
        web_server()
    except Exception as e:
        print("timeDisplay() Exception: {0}".format(e))
        # todo:  Exception: memory allocation failed

    print("> stop main program")
    while True:
        sleep(10)


def timeDisplay():
    xt = 88  # display time possition
    yt = 38
    if not isOLED:
        return
Exemplo n.º 7
0
# octopusLAB test - 2019
from time import sleep
from util.octopus import button_init, button, w, web_server, ap_init
from util.led import Led

led = Led(2)
button0 = button_init(0)
debounce = 9
ap = False

print("esp32 web server - start >")
for id in range(10):
    print(10 - id)
    led.blink()
    if button(button0)[0] >= debounce:
        print("button > AP_start")
        ap = True
        for id in range(5):
            led.blink(100, 100)
        break

sleep(1)
if ap: wc = ap = ap_init()
else: wc = w()

sleep(1)
web_server()