Sonoff Intercom

A recipe for cheap intercom doorbell and buzzer automation with a Sonoff SV and Home Assistant.

With this you can achieve fun stuff like getting notifications when someone rang your doorbell (e.g. the mailman) while you are away or you can buzz someone in automatically as soon as they ring your doorbell.

Parts list

  • Sonoff SV
  • Transistor (NPN 5V)
  • Resistor (1K)
  • Soldering equipment and various wires

Total cost: <10EUR

Preparing the Sonoff

Desolder the dummy resistors for isolated mode:

Sonoff SV mode

Bridge the input pins (obviously not the 5-24V input) in order to have the relay act as a passthrough when closed.

Solder the resistor to the base of the transistor as a pull-down and connect it to the doorbell line. Connect the collector to GPIO 14 (IO14 S) and the emitter to ground (IO14 G).

Sonoff SV prepared

You may power the Sonoff via the bottom left 5~24V DC input, e.g. with a USB power adapter.

Example: Ritto TwinBus 7630

Do not use the 24V bus line to power the Sonoff (or anything else)!

It will bring down and/or damage your whole doorbell system! These TwinBus systems are very unstable.

Ritto TwinBus 7630 pinout

(TwinBus pinout courtesy of Peter from https://www.nicht-trivial.de)

Connections:

  • Transistor base goes into blue “Klingelsignal” pin (which will have 5V DC when someone rings the doorbell).
  • Top “GND” goes into Sonoff ground.
  • “Öffner” and bottom “GND” goes to the “Out+” and “Out-” on the Sonoff.

Flashing the Sonoff

Make sure to use the 3.3V line for serial connections

Do not connect 5V to the 3V3 pin.

Download latest tasmota.bin: https://github.com/arendst/Tasmota/releases

Connect the 4pin serial header via a USB adapter (e.g. CH340G orf CP2102) and press and hold the PCB button (GPIO 0) while plugging in the USB adapter to bring the device into flashmode.

Then, flash Tasmota to your Sonoff SV (you may have to reenter the flashmode after each step outlined below):

# Verify a working connection
esptool.py -p /dev/ttyUSB0 read_mac

# Erase the flash before continuing
esptool.py -p /dev/ttyUSB0 erase_flash

# Flash the firmware to the device
esptool.py -p /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x0 tasmota.bin

Finally, go through the initial configuration steps outlined in the Tasmota wiki: https://tasmota.github.io/docs/Getting-Started/#initial-configuration

Configuration

Access the Tasmota WebUI and configure your module for use with a intercom doorbell and buzzer.

Configuration > Configure Module:

  • Module type: Sonoff SV
  • GPIO4: Relay2
  • GPIO14: Switch2

We need GPIO4 as a (Pseudo)Relay in order for autodiscovery to work properly. GPIO14 (Switch2) will trigger GPIO4 (Relay2) automatically which will in turn get reported via MQTT.

Configuration > Configure MQTT:

  • Host: <mqtt_host>
  • User: <mqtt_user>
  • Password: <mqtt_password>
  • Topic: <device_name>
  • Full topic: tasmota/%topic%/%prefix%/

Configuration > Configure other:

  • (Optional but recommended) Web Admin Password: <secure_password>
  • MQTT enable: Checked
  • Device name: <device_name>
  • Friendly Name 1: buzzer
  • Friendly Name 2: doorbell

Main Menu > Console:

# Configure switchmode for 3.3V GPIO to ground
SwitchMode2 2

# Debounce for the buzzer relay (3s)
PulseTime1 30

# Debounce for the doorbell pseudorelay (10s safe disengage)
PulseTime2 100

# Turn on MQTT autodiscovery
SetOption19 1

# (Optional) Configure a NTP server
NtpServer1 <ntp_server>

Configuring Home Assistant

Home Assistant should recognize all MQTT entities via autodiscovery now.

You may also configure the doorbell as a binary_sensor (replace intercom_doorbell with the device name you set earlier):

- platform: template
  sensors:
    intercom_doorbell:
      device_class: sound
      value_template: "{{ is_state('switch.intercom_doorbell', 'on') }}"

Et voilá. All you need now is to configure your automations accordingly.