Difference between revisions of "Sonoff basic"

From Let's Control It
Jump to navigation Jump to search
Line 57: Line 57:
  
 
<pre style="color: #0077dd">
 
<pre style="color: #0077dd">
  on touch#switch do
+
  on button#switch do
   if [touch#switch]=1
+
   if [button#switch]=1
 
   gpio,12,1
 
   gpio,12,1
 
   else
 
   else

Revision as of 21:36, 2 December 2017

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-Touch-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: None
  • GPIO tied to onboard hardware: 0 (button), 12 (Relay 10A@230VAC), 13 (LED green)
  • GPIO free to use: 14 (via)
  • Power supply information: 90-250VAC
  • Antenna: onboard PCB antenna

Sonoff-Touch-002.jpg

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.


Soldered pin headers.

ESP Easy

Devices

Sonoff touch 001.PNG


Switch

Sonoff touch 002.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


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