Part 1 - How to Expand Tasmota/Sonoff Devices with the I2C Protocol - I²C



Our first part of the I2C (I²C) sensor expansion with Tasmota. Add multiple sensors with minimal GPIO pin usage with a wide array of sensors on the market.  Add additional GPIO pins, LUX, Humidity, Pressure, Gas, Etc.

Parts Used in this Video:

NodeMCU
MCP23017 GPIO Expansion
BME280 Temp/Humidity/Pressure
SHT31 Temp/Humidity
Female Jumper Wires
PIR Motion AM312 Sensor
ADS1115 4 Channel Analog Input
Breadboard and Jumper Wires

Tasmota Supported Sensors
https://github.com/arendst/Sonoff-Tasmota/wiki/Sensors-Supported-by-Tasmota

CP2102 USB Drivers:
https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers

Precompiled Tasmota Bin with ADS1115 and MCP23017 i2c Enabled:
https://github.com/digiblur/Sonoff-HydraBasic-Tasmota/raw/master/tasmota_6307_1m_i2c_sensors.bin

MCP23017 Console Commands Used:

sensor29 0,5
sensor29 1,5
sensor29 8,5
sensor29 0,T
sensor29 1,T
sensor29 8,T

sensor29 3,2,0
sensor29 2,2,0

MCP23017 Rules:

rule1 on event#MCPINT_D2=0 do backlog sensor29 0,OFF;sensor29 1,ON endon on event#MCPINT_D2=1 do backlog sensor29 1,OFF;sensor29 0,ON endon

rule2 on event#MCPINT_D3=0 do backlog sensor29 8,OFF;sensor29 1,ON;rule1 1 endon on event#MCPINT_D3=1 do backlog sensor29 8,ON;rule1 0;sensor29 0,OFF;sensor29 1,OFF endon


BH1750 Rule:
Rule1 on BH1750#Illuminance>%var1% do backlog var1 %value%; publish MCU/Lux %value%; var2 %value%; add1 100; sub2 100 endon
      on BH1750#Illuminance<%var2% do backlog var2 %value%; publish MCU/Lux %value%; var1 %value%; add1 100; sub2 100 endon


Sample BH1750 HomeAssistant Configuration:

sensor:
  - platform: mqtt
    name: "MCU Lux"
    state_topic: "tele/MCU-I2C/SENSOR"
    value_template: "{{ value_json['BH1750'].Illuminance }}"
    unit_of_measurement: "lx"
    availability_topic: "tele/MCU-I2C/LWT"
    payload_available: "Online"
    payload_not_available: "Offline"

Comments

  1. How to know the list of Tasmota supported i2c sensors list

    ReplyDelete
  2. Hi can I have the nodered flow in your video? I want to figure out how you did it. I'm a newbie

    ReplyDelete
  3. The ADS1115 has controllable gain so that the inputs can tolerate a greater voltage range (up to about 6 volts). Can this gain be set via the console of the nodemcu?

    ReplyDelete

Post a Comment