arendst / Tasmota

Alternative firmware for ESP8266 and ESP32 based devices with easy configuration using webUI, OTA updates, automation using timers or rules, expandability and entirely local control over MQTT, HTTP, Serial or KNX. Full documentation at
https://tasmota.github.io/docs
GNU General Public License v3.0
22.29k stars 4.82k forks source link

NX-SP201 #5215

Closed awk2019 closed 5 years ago

awk2019 commented 5 years ago

I have flashed two NX-SP201 dual switch with Tasmota via tuya-convert on one and cracked on open for wired serial flash. When I use power monitoring via a custom template(HLW8012) I get a software watchdog resets about every 40-60 minutes. Do any one have any ideas on this.

Pin out per tuya-convert compatible device list. GPIO0: Led1i, GPIO4: Button1, GPIO5: HLW8012 CF, GPIO12: Relay1, GPIO13: Button2, GPIO14: HLWBL CF1, GPIO15: Relay2, GPIO16 HLWBL SEL

andrethomas commented 5 years ago

@molpie Thanks for the feedback. The bug was isolated to around 6.4.1.15-6.4.1.16 and assumed stable from 6.4.1.18. Appreciate the feedback.

cmccambridge commented 5 years ago

@DavinKD From a mechanical side, how did you do your wiring for the SP201? I've got an SP201 that failed OTA conversion, and am trying to work out a reasonable wiring method to access the UART pins on the daughter board... At the moment I think I'll either need some very long probes, or to desolder the AC plug itself if I want to avoid permanently cutting away the back plastic housing. Any tips?

DavinKD commented 5 years ago

I only used OTA. I've never tried to open these.

cmccambridge commented 5 years ago

Oops, I'm sorry about that, thanks for the heads up. I lost track of who was who during the thread. I actually meant to ask @awk2019 for physical access tips based on the comment about:

tuya-convert on one and cracked on open for wired serial flash.

(FWIW, so far this does not look to be a very physical-modification-friendly device... have to break a glue seal to open it initially, and still TBD what the best serial access route is. OTA on my other one was vastly preferable :) )

ed-war-d commented 5 years ago

Hi! Could't you tell me where I can find the pinouts (Rx,Tx, 3.3V) for flashing the NX-SP201?

Jason2866 commented 5 years ago

@ed-war-d if you provide photos probably yes

ed-war-d commented 5 years ago

1559214516484_1 1559214501699_2

Jason2866 commented 5 years ago

A photo of the blue Module from the other side will give the needed infos

ed-war-d commented 5 years ago

1559220839014_3

cmccambridge commented 5 years ago

Heh, you definitely took the smarter approach to this one @ed-war-d :) I struggled with desoldering the AC connector to free the PCB, so I ended up reprogramming mine with the assistance of a very long needle point logic probe reaching all the way under the PCB between the PCB and the back case plastic to reach the TX pin from behind, and used a GND connection at one of the small headers for the buttons and LEDs on either side.

The pinout can be found on page 6 of this datasheet for the ESP8266-S3: https://fccid.io/2AKBPESP8266-S3/User-Manual/User-Manual-3594791

Overlaid on your image, it looks like this: 58634157-3b982000-82f3-11e9-8504-89be614d1e27_LI (2)

Note that the signals are named here with respect to the ESP8266. Meaning: the TX pin here is ESP8266's transmit pin, and you'd want to connect it to your UART adapter's RX pin.

ed-war-d commented 5 years ago

Thanks

ed-war-d commented 5 years ago

Where is the GPIO0: Led1i ?

cmccambridge commented 5 years ago

For completeness for future readers, here are a couple photos of how I did my reflash without removing the AC ground pin.

Needle point logic probe to 2nd pin (TX) underneath PCB: sp201_probe sp201_tx

Soldered on to IO0 (Brown wire), RX (Orange wire) and VCC (Black wire) at board edge: sp201_io0_rx_vcc

Plugged into GND in switch/LED daughterboard connector: sp201_gnd

cmccambridge commented 5 years ago

Where is the GPIO0: Led1i ?

Sorry about that... until I pulled out those photos I had forgotten this device didn't route it to a button and I had to solder directly to it. Updated the annotated photo above, or in my photos it's the brown wire.

GPIO0 is very likely also exposed as one of the pins in that same daughterboard header which could save doing one solder joint, but unfortunately I did not trace that out.

ed-war-d commented 5 years ago

I've done it! Thanks!

ed-war-d commented 5 years ago

What device I should select in Module type menu?

cmccambridge commented 5 years ago

I configured mine using an SP-201 template from here: https://blakadder.github.io/templates/sp201dual.html

General instructions on templates here: https://github.com/arendst/Sonoff-Tasmota/wiki/Templates#importing-templates

ed-war-d commented 5 years ago

With the template {"NAME":"SP-201","GPIO":[31,0,0,131,17,134,0,0,21,18,132,22,0],"FLAG":0,"BASE":45} I have 3 switches (not 2). Is this OK?

ed-war-d commented 5 years ago

2019-05-30 4

ed-war-d commented 5 years ago

It seems I should to have got 2 switches

DavinKD commented 5 years ago

The third "relay" is for the led.

meingraham commented 5 years ago

The new LedLink feature in 6.5.0.12 may allow removal of this virtual relay for the LED. If you have questions on its use, ping me over on Discord.

P.S. @DavinKD I was able to clean up the KS-604S config using this new feature.

ed-war-d commented 5 years ago

Thanks

rlowens commented 5 years ago

For future reference for any others that need to manually-flash an "NX-SP201" Smart Plug 2-in-1, there are 2 versions that I have just flashed. The Type A version pictured above in this thread with the 14-pin ESP8266-S3 module (with metal shield as pictured) can most easily be flashed with these connections: Programmer RX solder to front of module, 2nd pad from the right. Programmer TX bend a small hook into the tinned end of the wire and hook behind that pad you just soldered to. Programmer 3.3V connect to pin 1 on the left or right end headers (left pin 1 is furthest from the module, right pin 1 is closest to the module). Programmer GND connect to pin 5 on the left or right end header. Jumper pin 4 (GPIO 0 for the blue status LEDs) to pin 5 (GND) on the left or right end header. Only needed during boot to put the chip in programming mode, but it is fine to leave it connected while you program. Dilisens SP201 type A module wires Dilisens SP201 type A pins

The (newer or knock-off?) Type B version has a green module without metal shield (or onboard LED that the ESP8266-S3 has) labeled "E2S-B, 20XX.1X.17" on the back, with 15 staggered contacts (vs the 14 even contacts on the ESP8266-S3 module). And the header's on the left and right have very different pinout. Here's the comparison: Dilisens SP201 type A vs B top Dilisens SP201 type A vs B side

The pinout on this module matches the 11-pad Tuya TYWE2S module except with 4 more pads on the left side (2 more on the front and back). Here's the full pinout of the "E2S-B": Dilisens SP201 type B module wires And the pads on the back of the module: Dilisens SP201 type B module back Side view: Dilisens SP201 type B side view front

And the labels of the headers: Dilisens SP201 type B left end Dilisens SP201 type B right end

To flash the Type B version, I had to chop some plastic to access the bottom of the module since 3 of the pads we need are on the back: Programmer RX solder to back of module, 4th pad from the right. Programmer TX solder to back of module, 3rd pad from the right. Programmer 3.3V solder to back of module, furthest pad on the right. Programmer GND connect to pin 2 on the left or right end header. Use a wire to touch from GND (pin2 on the left or right end header) to the "IO0" test pad on the back of the module while you power on the programmer.

rlowens commented 5 years ago

The current Tasmota template for "Type A" is https://blakadder.github.io/templates/sp201dual.html though I would update the Template from {"NAME":"SP-201","GPIO":[31,0,0,131,17,134,0,0,21,18,132,22,0],"FLAG":0,"BASE":45} to: {"NAME":"NX-SP201 A","GPIO":[158,0,0,131,17,134,0,0,21,18,132,22,0],"FLAG":0,"BASE":45} (so the blue LEDs are LedLinki instead of Relay3i)

The current template for "Type B" is https://blakadder.github.io/templates/dilisens_SP201.html but I'd update the Template from {"NAME":"Dilisens SP201","GPIO":[0,0,131,0,133,132,52,21,18,22,17,0,0],"FLAG":0,"BASE":18} to {"NAME":"NX-SP201 B","GPIO":[0,0,131,0,134,132,157,21,18,22,17,0,0],"FLAG":0,"BASE":45} (Base on BlitzWolf SHP (45) instead of Generic (18), use LedLink instead of Led1, use BL0937 CF (134) instead of HLW8012 CF (133) since it uses a BL0937 not an HLW8012).

Oh, and the Type A uses a voltage divider (R_upstream + R_downstream) / R_downstream of (2.4Mohm x2 + 1Kohm) / 1Kohm = 2401 where the Type B uses (1Mohm x2 + 1Kohm)/1Kohm = 2001. They both use a 1ohm current sense resister. But I just used a Kill-a-watt type device to manually calibrate the voltage/current/power when running my window AC.