Difference between revisions of "OZWI Smart Plug"

From RECESSIM, A Reverse Engineering Community
Jump to navigation Jump to search
(Created page with "thumb ==Description== This is a dirt cheap "smart" plug with ESP8266 inside. It's designed for 230V and 10A max current, but other regional versions exist.")
 
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
[[File:OZWIPlug1.jpg|thumb]]
 
[[File:OZWIPlug1.jpg|thumb]]
 +
[[File:OZWIplug3.jpg|thumb]]
 
==Description==
 
==Description==
 
This is a dirt cheap "smart" plug with ESP8266 inside. It's designed for 230V and 10A max current, but other regional versions exist.
 
This is a dirt cheap "smart" plug with ESP8266 inside. It's designed for 230V and 10A max current, but other regional versions exist.
 +
 +
It didn't have any identification or a sticker on it.
 +
==What's inside==
 +
There's an unknown ESP8266 module, YUANZE Y32F-SS-105HM Relay<ref>[https://www.lcsc.com/product-detail/Power-Relays_YUANZE-RELAY-Y3F-SS-105D_C674561.html LCSC page for the relay]</ref> and power supply components.
 +
 +
[[File:OZWIplug inside1.jpg|frameless]][[File:OZWIplug inside2.jpg|frameless]]
 +
==ESP8266 Board Pinout==
 +
[[File:OZWIplug pins.png|frameless]]
 +
==Flashing custom firmware==
 +
You'll need to connect some kind of UART interface device to your PC or other capable device. '''RX''' pin of this device goes to board pin marked "'''U0 TX'''", '''TX''' pin -- to "'''U0 RX'''". '''GND''' to '''GND'''.
 +
 +
Connect '''GND''' and '''3.3V''' pins from diagram above to 3.3V PSU (up to 0.2A was needed during my test).
 +
 +
Connect '''GPIO0''' to '''GND''' and power on the device with PSU.
 +
 +
Flash the chip using [https://github.com/espressif/esptool ESPTool] or other preferred method.
 +
 +
Remove the power and disconnect GPI0 tie to the ground.
 +
 +
Done!
 +
 +
==Example ESPHome config==
 +
<syntaxhighlight lang="yaml">
 +
substitutions:
 +
  display_name: "ozwi-plug"
 +
  friendly_name: "ozwi Smart Plug"
 +
 +
esphome:
 +
  name: "ozwi-plug"
 +
 +
esp8266:
 +
  board: esp01_1m
 +
 +
# Enable logging
 +
logger:
 +
 +
# Enable Home Assistant API
 +
api:
 +
 +
ota:
 +
 +
wifi:
 +
  ssid: !secret wifi_ssid
 +
  password: !secret wifi_password
 +
  on_connect:
 +
      - light.turn_on: blue_led
 +
  on_disconnect:
 +
      - light.turn_off: blue_led
 +
  ap:
 +
    ssid: "${display_name} Fallback Hotspot"
 +
    password: !secret wifi_AP_password
 +
    ap_timeout: 3min
 +
 +
captive_portal:
 +
 +
output:
 +
  - platform: gpio
 +
    pin: GPIO4
 +
    inverted: False
 +
    id: red_led_gpio
 +
  - platform: gpio
 +
    pin: GPIO14
 +
    inverted: False
 +
    id: blue_led_gpio
 +
  - platform: gpio
 +
    pin:
 +
      number: GPIO12
 +
      inverted: false
 +
    id: relay1
 +
 +
binary_sensor:
 +
  - platform: gpio
 +
    internal: true
 +
    pin:
 +
      number: GPIO13
 +
      mode: INPUT_PULLUP
 +
      inverted: true
 +
    name: ${display_name} Switch
 +
    on_press:
 +
      - switch.toggle: load
 +
 +
light:
 +
  - platform: binary
 +
    name: "Red LED"
 +
    id: red_led
 +
    internal: true   
 +
    output: red_led_gpio
 +
  - platform: binary
 +
    name: "Blue LED"
 +
    id: blue_led
 +
    internal: true   
 +
    output: blue_led_gpio
 +
 +
switch:
 +
  - platform: output
 +
    name: ${friendly_name} Load
 +
    id: load
 +
    # internal: true
 +
    output: relay1
 +
    on_turn_on:
 +
      - light.turn_on: red_led
 +
    on_turn_off:
 +
      - light.turn_off: red_led
 +
</syntaxhighlight>

Latest revision as of 17:31, 18 December 2023

OZWIPlug1.jpg
OZWIplug3.jpg

Description

This is a dirt cheap "smart" plug with ESP8266 inside. It's designed for 230V and 10A max current, but other regional versions exist.

It didn't have any identification or a sticker on it.

What's inside

There's an unknown ESP8266 module, YUANZE Y32F-SS-105HM Relay[1] and power supply components.

OZWIplug inside1.jpgOZWIplug inside2.jpg

ESP8266 Board Pinout

OZWIplug pins.png

Flashing custom firmware

You'll need to connect some kind of UART interface device to your PC or other capable device. RX pin of this device goes to board pin marked "U0 TX", TX pin -- to "U0 RX". GND to GND.

Connect GND and 3.3V pins from diagram above to 3.3V PSU (up to 0.2A was needed during my test).

Connect GPIO0 to GND and power on the device with PSU.

Flash the chip using ESPTool or other preferred method.

Remove the power and disconnect GPI0 tie to the ground.

Done!

Example ESPHome config

substitutions:
  display_name: "ozwi-plug"
  friendly_name: "ozwi Smart Plug"

esphome:
  name: "ozwi-plug"

esp8266:
  board: esp01_1m

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  on_connect:
      - light.turn_on: blue_led
  on_disconnect:
      - light.turn_off: blue_led
  ap: 
    ssid: "${display_name} Fallback Hotspot"
    password: !secret wifi_AP_password
    ap_timeout: 3min

captive_portal:

output:
  - platform: gpio
    pin: GPIO4
    inverted: False
    id: red_led_gpio
  - platform: gpio
    pin: GPIO14
    inverted: False
    id: blue_led_gpio
  - platform: gpio
    pin:
      number: GPIO12
      inverted: false
    id: relay1

binary_sensor:
  - platform: gpio
    internal: true
    pin:
      number: GPIO13
      mode: INPUT_PULLUP
      inverted: true
    name: ${display_name} Switch
    on_press:
      - switch.toggle: load

light:
  - platform: binary
    name: "Red LED"
    id: red_led
    internal: true    
    output: red_led_gpio
  - platform: binary
    name: "Blue LED"
    id: blue_led
    internal: true    
    output: blue_led_gpio

switch:
  - platform: output
    name: ${friendly_name} Load
    id: load
    # internal: true
    output: relay1
    on_turn_on:
      - light.turn_on: red_led
    on_turn_off:
      - light.turn_off: red_led