Sonoff basic

From Let's Control It
Jump to navigation Jump to search

Introduction

The Sonoff Basic is a relay unit to be used as retrofit. It is based on the ESP8266 chip and can control one relay. A small green LED is onboard which can be controlled using PWM or GPIO commands. Other than normal controlling on and off (of what ever you control with the relay) you can use PWM to control the LED to shine less during the night or whatever.

Hardware

Sonoff-Basic-001.jpg

  • ESP chip version: ESP8266 (some uses variants of ESP8285)
  • Flash size: 1M
  • Onboard USB-TTL converter: No
  • GPIO's broken out/available to free use: 14 (via)
  • GPIO tied to onboard hardware: 0 (button), 12 (Relay 10A@230VAC), 13 (LED green)
  • Power supply information: 90-250VAC
  • Antenna: onboard PCB antenna

Sonoff basic GPIO.png

GPIO 14 is available on the far right.

Sonoff basic GPIO14.png

Wiring/flashing

A programmer is needed to flash this device.

  Programmer     ESP
  TX      <-->   RX (2nd via)
  RX      <-->   TX (3rd via)

  Power
  3.3V    <-->   VCC (1st via [square])
  GND     <-->   GND (4th via)

In order to get the unit in flash mode the GPIO-0 needs to be LOW. Hold the button pressed during power on. You can release the button just seconds after you have powered the unit, it's now ready for flash.

ESP Easy

Devices

Sonoff basic1.PNG


Switch

Sonoff basic2.PNG

Push button active high will make the relay pull when button is released, push button active low will pull the relay (instantaneously) when button is pressed. What you prefer.


Relay

Sonoff touch 003.PNG


Message delay

Sonoff basic3.PNG

If you feel that the button is not responding quickly enough when you toggle it you may change the message delay (found under advanced in the tools tab) to 200 ms, from the default 1000 ms.


Switch to Relay rule

 on button#switch do
  if [button#switch]=1
   gpio,12,1
  else
   gpio,12,0
  endif
 endon 

LED rule

Depending if you want the LED to be on or off when the relay is open/closed you may use this rule:

 on relay#switch do
  if [relay#switch]=1 //change this [relay#switch]=0 for LED off when relay is closed
   gpio,13,1 //or pwm,13,700
  else
   gpio,13,0 //or pwm,13,10
  endif
 endon