They are made by KAB, a Chinese company. They are ESP8266 based and are perfect to modify for your own uses. As with the Sonoff module, DO NOT FLASH WHILE PLUGGED INTO A SOCKET!
You will need to remove the 4 screws located on the back of the outlet, then the 3 screws inside on the front half which will expose the ESP8266. You will need to tack-solder 4 connections (either cut piece of resistor wire or other wire) for 3.3v, GND, RXD, TXD from your usual USB to 3.3v data interface.
The pins are noted below, note that it is not a normal ESP8266.
Pin# USE
1 GND
2 Power 3v3
3 CHIP_EN reset sw
4 XPD_DCDC / GPIO16
5 MTMS / GPIO14
6 MTD1 / GPIO12
7 MTCK / GPIO13 power sw, active LOW
8 MTD0 / GPIO15 Y to main board, D8 - Power LED
9 GPIO2 D3- wireless signal LED
10 GPIO0
11 GPIO4
12 DVDD / GPIO5
13 U0RXD
14 U0TXD
15 EXT_RSTB
16 GND
17 TOUT / No Connection?
18 GND
-------------------------------------------
Pin 1 is the top left with antenna at top
Pin 9 is lower left
Pin 10 is lower right
Pin 18 is upper right
Once all your connections are made, you will need to ground GPIO0, then press the reset switch, then remove the ground connection at GPIO0 and flash ver3.0.
when done, remove all the extra connections you made, plug it into a SWITCHED outlet strip, then turn ON the outlet strip.
Look for the familiar AP broadcast, sign in to the settings page, and change the wifi information to suit your environment.
Once you have your new IP adress into the outlet, load the following code:
'Outlet code (based on Sonoff code) to get the device working under Build 3.0 of ESPbasic.
'Continued thanks to Electroguard and Mike - this would have taken much longer.
'A good starting point for some Home Automation?
deviceName = read("DName") 'Outlet device has a name such as "living room fan"
if deviceName == "" then deviceName = "Outlet" 'Filler
RelayPin = 15 'IO pin for the relay
LedPin = 2 'WiFi LED
LocalButton = 13 'The 'power' button
RelayLogic = 0 'Means relay is ACTIVE HIGH
LedLogic = 0 'Means LED is ACTIVE HIGH
[top]
cls
io(po,2,0) 'Turn ON wifi LED so you know we have power, could be used when the outlet actually joins the wireless network
print deviceName & " "
textbox Status
interrupt 13, [Pressed] 'Hardware button pressed? Branch
html "<BR>"
Button "Toggle", [Toggle] 'Web buttons pressed? Branch
Button "ON", [on] 'Web buttons pressed? Branch
Button "OFF", [off] 'Web buttons pressed? Branch
html "<BR>"
button "Settings", [settings] 'Web buttons pressed? Branch
wait
[on] 'Get here by wanting to turn ON
if RelayLogic == 0 then io(po,RelayPin,1) else io(po,RelayPin,0) 'Turn ON the relay and power LED
goto [set.Stat.indicator] 'Go update the status on the web screen
[off] 'Get here by wanting to turn OFF
if RelayLogic == 0 then io(po,RelayPin,0) else io(po,RelayPin,1) 'Turn OFF the relay and power LED
goto [set.Stat.indicator] 'Go update the status on the web screen
[Toggle] 'Get here by wanting to toggle
if io(laststat,RelayPin) = 0 then io(po,RelayPin,1) else io(po,RelayPin,0) 'If ON, then turn OFF and vice versa
goto [set.Stat.indicator] 'Go update the status on the web screen
end if
[Pressed] 'Got here cuz we pressed the hardware button
if io(laststat,LocalButton) = 1 then goto [Toggle] 'Wait until the button is released for debounce
goto [top] 'Done, so start over
[set.Stat.indicator] 'Get here because we need to update the web status
if io(laststat,15) = 0 then Status = "OFF" else Status = "ON" 'Get the correct text on the box
wait
[settings] 'Here because we want to change the settings
cls
html "Device name"
textbox deviceName
button "Save", [save.set]
wait
[save.set] 'To ensure we put something in here
if deviceName == "" then
print "device name must be specified"
wait
else
write("DName",deviceName) 'Write to flash
end if
goto [top] 'Done, so start over
This code functions the same as the Sonoff code except for one thing: THE LOCAL POWER BUTTON DOES NOT WORK!
I have gone through this, it IS connected to GPIO13 (well, pretty sure) but I cannot get it to work.
Anyone who fixes this, please share.
Enjoy!
- Albert Einstein