def bmp_init(): from util.octopus import i2c_init # "-1" > SW for old lib: i2c = i2c_init(1, 100000, -1) from bmp280 import BMP280 bmp = BMP280(i2c) return bmp
def bme280_init(): i2c = i2c_init(1) bme = BME280(i2c=i2c) #print(bme.values) return bme
# MicroPython BH1750 example from time import sleep from lib.bh1750 import BH1750 from util.octopus import i2c_init i2c = i2c_init() sbh = BH1750(i2c) while True: light = int(sbh.luminance(BH1750.ONCE_HIRES_1)) print(light) sleep(1)
# simple basic example - ESP32 + i2c lcd display # cp("examples/lcd2_bme280.py") > main.py from time import sleep from util.octopus import w, i2c_init, lcd2_init, get_hhmm, time_init from util.oc import printTitle from bme280 import BME280 i2c = i2c_init(1) bme280 = BME280(i2c=i2c) 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")
# 2 x pcf 8-bit expander # exb.addr = 58 (010) buttons # exl.addr = 62 (011) leds from time import sleep from util.octopus import i2c_init from util.i2c_expander import Expander8 from util.bits import neg, reverse, int2bin, get_bit, set_bit # int2bin(reverse(b1)) > '10011111' i2c = i2c_init(True, 200) # i2c.scan() > devices: # [35, 58, 62] exb = Expander8(58) exl = Expander8(62) while True: buttons = exb.read() sleep1 = False if (get_bit(neg(buttons), 0)): print("0") sleep1 = True if (get_bit(neg(buttons), 1)): print("1") sleep1 = True if (get_bit(neg(buttons), 2)):
def bme280_init(): i2c = i2c_init(1) bme = BME280(i2c=i2c) return bme