コード例 #1
0
printTitle("lcd init")
from lib.esp8266_i2c_lcd import I2cLcd
lcd = I2cLcd(i2c, 39, 2, 16)
lcd.putstr("octopusLab")


def influx_write(temp, humi, press, gas):
    print(gc.mem_free())
    gc.collect()
    print(gc.mem_free())
    return influx.write(temp=temp, humi=humi, press=press, gas=gas)


printTitle("WiFi + influx")
w()
influx = InfluxDB.fromconfig()

printTitle("main loop")
while True:
    temp = bme.temperature
    humi = bme.humidity
    press = bme.pressure
    gas = bme.gas
    print(temp, humi, press, gas)
    print("influx write: ", influx_write(temp, humi, press, gas))
    lcd.move_to(0, 0)

    lcd.putstr(
        str(round(temp, 1)) + chr(223) + "C | " + str(round(humi, 1)) + "%")
    lcd.move_to(0, 1)
コード例 #2
0
from components.iot import Thermometer
tt = Thermometer(32)  # DEV1 pin 
tx = tt.ds.scan()
print(tt.get_temp(0))
# tt.get_temp(1)

print("---wifi---")
def influx_write():
    print(gc.mem_free())
    gc.collect()
    print(gc.mem_free())
    temp = tt.get_temp()
    return influx.write(relay=statusRelay,tempset=tempX,temperature=temp)


net = w()
ip = net.sta_if.ifconfig()[0]
oled_show(oled,strB="IP:" + ip,num=0)
sleep(2)

print("---button-ftp---")
from machine import Pin

btnum = 0
button = Pin(35, Pin.IN)
print("press right button / CTRL+C or continue")
sleep(1)

for i in range(12):
    print("-",end="")
    btnum += button.value()
コード例 #3
0
ファイル: clock.py プロジェクト: octopusengine/octopuslab
from shell import clear

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

rtc = RTC()


def add0(sn):
    return "0" + str(sn) if int(sn) < 10 else str(sn)


def get_hhmm_sep(separator=":", rtc=rtc):
    #get_hhmm(separator) | separator = string: "-" / " "
    hh = add0(rtc.datetime()[4])
    mm = add0(rtc.datetime()[5])
    return hh + separator + mm


w()  # wifi connect
settime()  # server > time setup
setlocal(1)  # 1: time zone +1h

while True:
    clear()
    print(get_hhmm_sep(":"))
    sleep(1)
    clear()
    print(get_hhmm_sep(" "))  # blinking ":"
    sleep(1)
コード例 #4
0
print("--- octopusLAB: test_WiFi ---")

print("-> init")
from utils.octopus_lib import w
net = w()  # wifi connection

ip = net.sta_if.ifconfig()[0]

print("--- IP: ", ip)
コード例 #5
0
# simple basic example - ESP32 - Micropython - EDU_KIT1
# RTC settime / zone

from ntptime import settime
from machine import RTC
from utils.octopus_lib import w, setlocal, get_hhmm

print("--- octopusLAB: test_rtc_ntp ---")
rtc = RTC()
w(logD=False)
settime()
print(get_hhmm(rtc))

# + 1/2 h.
setlocal(1)
print(get_hhmm(rtc))
コード例 #6
0
from utils.octopus_lib import w
from esp import espnow

wc = w()

# A WLAN interface must be active to send()/recv()
# w0 = network.WLAN(network.STA_IF)
# w0.active(True)

print("--- espNow init ---")
e = espnow.ESPNow()
e.init()
# peer = b'0\xae\xa4XC\xa0'   # MAC address of peer's wifi interface
mac = ""
e.add_peer(mac)

print(e.irecv())
for msg in e:
    print(msg)
    if (msg[1] == b'end')
        break