Sonoff BASIC R1 & ESPHome

About a year ago, I purchased a couple of Sonoff Basic units. After some issues with WiFi, I finally got them to work properly with ESPHome. Here is how.

My Sonoff BASIC units are equipped with an ESP-8266EX processor and 1MB flash.
Flashing it with the sample configs of ESPHome (cf. here and here), my units could not connect to a wifi network or didn’t even find a network to connect to in the first place.

Using “nodemcu” (note: not v2!) as board identifier finally resolved all of my issues.

The full code below. This uses the Sonoff BASIC to make a lamp smart

esphome:
  name: lightstand
  friendly_name: lightstand
  platform: ESP8266
  board: nodemcu


wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  reboot_timeout: 0s
  fast_connect: true

# Enable Home Assistant API
api:
  encryption:
    key: "yourkey"

ota:
  password: "your ota passwd"

# Enable logging
logger:
  level: VERBOSE

output:
  - platform: gpio
    pin: GPIO12
    id: main_relay
    
switch:
  - platform: restart
    name: "Reboot lightstand"
    id: lightstand_restart

light:
  - platform: binary
    name: "lightstand"
    id: lightstand
    output: main_relay
    
binary_sensor:
  - platform: gpio
    pin: 
      number: GPIO2
      mode: INPUT_PULLUP
      inverted: True
    name: "lightstand Switch Sensor"
    on_press:
      then:
        - light.toggle: lightstand
    on_multi_click:
    - timing:
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at least 0.2s
      then:
        - switch.turn_on: lightstand_restart

Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.