Мар 302021
 

Schematic_MQTT-Relay-8_2021-04-05

Настройка Tasmota (MCP23017) 16 Input/Output Ports

# Port D0-D7 OUTPUT

sensor29 0,5,0; sensor29 1,5,0; sensor29 2,5,0; sensor29 3,5,0
sensor29 4,5,0; sensor29 5,5,0; sensor29 6,5,0; sensor29 7,5,0

# Port D8-D15 INPUT

sensor29 8,2,1; sensor29 9,2,1; sensor29 10,2,1; sensor29 11,2,1
sensor29 12,2,1; sensor29 13,2,1; sensor29 14,2,1; sensor29 15,2,1

# Enable for binary Sensor
SetOption59 1

Май 222020
 

 

from machine import Pin, I2C
import ssd1306
from time import sleep

# 1 3 Busy

GREEN = Pin(0, Pin.OUT)    
GREEN.on()

BLUE_OLED = Pin(2, Pin.OUT)   
BLUE_OLED.on()

def do_connect():
    import network
    wlan = network.WLAN(network.STA_IF)
    wlan.active(True)
    if not wlan.isconnected():
        print('connecting to network...')
        wlan.connect('ssd', 'pass')
        while not wlan.isconnected():
            pass
    print('network config:', wlan.ifconfig())
    
do_connect()

i2c = I2C(-1, scl=Pin(4), sda=Pin(5))

print(i2c.scan())

oled_width = 128
oled_height = 64
oled = ssd1306.SSD1306_I2C(oled_width, oled_height, i2c)

oled.text('Hello, World 1!', 0, 0)
oled.text('Hello, World 2!', 0, 10)
oled.text('Hello, World 3!', 0, 20)
        
oled.show()