Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NX-SP201 #5215

Closed
awk2019 opened this issue Feb 13, 2019 · 75 comments
Closed

NX-SP201 #5215

awk2019 opened this issue Feb 13, 2019 · 75 comments
Assignees
Labels
awaiting feedback Action - Waiting for response or more information template missing/incomplete Action - Template Missing or incomplete (issue will be closed) troubleshooting Type - Troubleshooting

Comments

@awk2019
Copy link

awk2019 commented Feb 13, 2019

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

@Jason2866
Copy link
Collaborator

Status 0 is missing. I have no crystal ball :-)

@awk2019
Copy link
Author

awk2019 commented Feb 13, 2019

What information is needed from status 0
ie. all or just part of the status.

@Jason2866
Copy link
Collaborator

All. Just copy paste from webconsole.

@awk2019
Copy link
Author

awk2019 commented Feb 13, 2019

18:26:53 CMD: status 0
18:26:53 MQT: stat/DualOutLet2/STATUS = {"Status":{"Module":61,"FriendlyName":["DualOutlet2A","DualOutlet2B"],"Topic":"DualOutLet2","ButtonTopic":"0","Power":1,"PowerOnState":3,"LedState":1,"SaveData":1,"SaveState":1,"SwitchTopic":"0","SwitchMode":[0,0,0,0,0,0,0,0],"ButtonRetain":0,"SwitchRetain":0,"SensorRetain":0,"PowerRetain":0}}
18:26:53 MQT: stat/DualOutLet2/STATUS1 = {"StatusPRM":{"Baudrate":115200,"GroupTopic":"sonoffs","OtaUrl":"http://thehackbox.org/tasmota/sonoff.bin","RestartReason":"Software Watchdog","Uptime":"0T00:17:30","StartupUTC":"2019-02-13T17:09:23","Sleep":50,"BootCount":81,"SaveCount":454,"SaveAddress":"F7000"}}
18:26:53 MQT: stat/DualOutLet2/STATUS2 = {"StatusFWR":{"Version":"6.4.1(sonoff)","BuildDateTime":"2019-02-13T11:03:23","Boot":4,"Core":"2_4_2","SDK":"2.2.1(cfd48f3)"}}
18:26:53 MQT: stat/DualOutLet2/STATUS3 = {"StatusLOG":{"SerialLog":2,"WebLog":2,"SysLog":0,"LogHost":"","LogPort":514,"SSId":["SECRET",""],"TelePeriod":15,"SetOption":["00208009","558180C0","00000400"]}}
18:26:53 MQT: stat/DualOutLet2/STATUS4 = {"StatusMEM":{"ProgramSize":571,"Free":432,"Heap":14,"ProgramFlashSize":1024,"FlashSize":1024,"FlashChipId":"1440A1","FlashMode":3,"Features":["00000809","1FDAE794","000383A0","23B617CE","0001BBC0"]}}
18:26:53 MQT: stat/DualOutLet2/STATUS5 = {"StatusNET":{"Hostname":"Benlink","IPAddress":"192.168.1.90","Gateway":"192.168.1.1","Subnetmask":"255.255.255.0","DNSServer":"192.168.1.1","Mac":"SECRET","Webserver":2,"WifiConfig":4}}
18:26:53 MQT: stat/DualOutLet2/STATUS6 = {"StatusMQT":{"MqttHost":"SECRET","MqttPort":1883,"MqttClientMask":"DVES_%06X","MqttClient":"DVES_F9D903","MqttUser":"SECRET","MqttType":1,"MAX_PACKET_SIZE":1000,"KEEPALIVE":15}}
18:26:53 MQT: stat/DualOutLet2/STATUS7 = {"StatusTIM":{"UTC":"Wed Feb 13 17:26:53 2019","Local":"Wed Feb 13 18:26:53 2019","StartDST":"Sun Mar 31 02:00:00 2019","EndDST":"Sun Oct 27 03:00:00 2019","Timezone":"+01:00","Sunrise":"08:02","Sunset":"18:06"}}
18:26:53 MQT: stat/DualOutLet2/STATUS9 = {"StatusPTH":{"PowerDelta":80,"PowerLow":0,"PowerHigh":0,"VoltageLow":0,"VoltageHigh":0,"CurrentLow":0,"CurrentHigh":0}}
18:26:53 MQT: stat/DualOutLet2/STATUS10 = {"StatusSNS":{"Time":"2019-02-13T18:26:53","ENERGY":{"TotalStartTime":"2019-02-07T03:09:41","Total":0.166,"Yesterday":0.040,"Today":0.125,"Power":51,"ApparentPower":63,"ReactivePower":37,"Factor":0.81,"Voltage":123,"Current":0.514}}}
18:26:53 MQT: stat/DualOutLet2/STATUS11 = {"StatusSTS":{"Time":"2019-02-13T18:26:53","Uptime":"0T00:17:30","Vcc":3.423,"SleepMode":"Normal","Sleep":50,"LoadAvg":19,"POWER1":"ON","POWER2":"OFF","Wifi":{"AP":1,"SSId":"SECRET","BSSId":"SECRET","Channel":4,"RSSI":100}}}

@Jason2866
Copy link
Collaborator

Try precompiled version from http://thehackbox.org/tasmota/sonoff.bin
Probably your selfcompiled is buggy...
Before flashing Tasmota erase whole flash with esptool erase_flash

@awk2019
Copy link
Author

awk2019 commented Feb 13, 2019

I had the same problem with the precompiled dev tasmota on both devices,and the released version dose not have a template for the nx-sp201 dual plug switch. Also its a glued to together device.

@Jason2866
Copy link
Collaborator

Try reset 2 Probably fragments left in flash from original firmware causes your issues
It erases all flash behind tasmota and resets to defaults.

@awk2019
Copy link
Author

awk2019 commented Feb 13, 2019

After tasmota update and reset 2, I configured the device per (NX-SP201)
GPIO0: Led1i, GPIO4: Button1, GPIO5: HLW8012 CF, GPIO12: Relay1, GPIO13: Button2, GPIO14: HLWBL CF1, GPIO15: Relay2, GPIO16 HLWBL SEL
then when I celebrated the voltage it started resting every 2-10 seconds.
When I use it with out power monitoring it will work with out a problem.

@Jason2866
Copy link
Collaborator

"SP201",
GPIO_LED1_INV, // GPIO00 Led (1 = On, 0 = Off) - Power status
GPIO_NRG_SEL_INV, // GPIO03 HLWBL HJL-01 Sel output (1 = Voltage)
GPIO_KEY1, // GPIO04 Button 1
GPIO_HJL_CF, // GPIO05 HLW8012 BL0937 or HJL-01 CF power
GPIO_REL1, // GPIO12 Relay1 (0 = Off, 1 = On)
GPIO_KEY2, // GPIO13 Button 2
GPIO_NRG_CF1, // GPIO14 HLWBL BL0937 or HJL-01 CF1 current / voltage
GPIO_REL2, // GPIO15 Relay2 (0 = Off, 1 = On)

@Jason2866
Copy link
Collaborator

I dont see you have configured GPIO3

@andrethomas2 andrethomas2 added question Type - Asking for Information awaiting feedback Action - Waiting for response or more information labels Feb 13, 2019
@awk2019
Copy link
Author

awk2019 commented Feb 14, 2019

no good I tried multiple variations of the sensor pin settings and reset 2 the NX-SP201 with no improvement, I have two devices behaving exactly the same way.
I can get power readings for a 30 to 60 minutes before a software watchdog reset, and the power readings are correct in comparison to a KILL A WATT meter with BL0937 sensor.

@Jason2866
Copy link
Collaborator

I am out of ideas. Since we (support team) dont own this device we cant help you further...

@ascillato2
Copy link
Collaborator

Please, try http://thehackbox.org/tasmota/020500/sonoff.bin and then do a reset 5

@ascillato2 ascillato2 added troubleshooting Type - Troubleshooting template missing/incomplete Action - Template Missing or incomplete (issue will be closed) and removed question Type - Asking for Information labels Feb 15, 2019
@awk2019
Copy link
Author

awk2019 commented Feb 15, 2019

no good ether, I just going to give up on power monitoring for now.

@Jason2866
Copy link
Collaborator

Have you tried the preconfigured template for this model?
It is in latest dev firmware....

@DavinKD
Copy link

DavinKD commented Feb 16, 2019

I just flashed a couple of these and have the same issue when power monitoring is configured.

@Jason2866
Copy link
Collaborator

Out of luck, since we dont have this device..
Maybe someone finds a solution.

@DavinKD
Copy link

DavinKD commented Feb 16, 2019

I'm digging into the code and will report back if I figure out the issue.

@DavinKD
Copy link

DavinKD commented Feb 16, 2019

Started up Syslog server and caught this.

sonoff-7484 ESP-RSL: INFO3 = {"RestartReason":"Fatal exception:2 flag:2 (EXCEPTION) epc1:0x3ffff140 epc2:0x00000000 epc3:0x00000000 excvaddr:0x3ffff140 depc:0x00000000"}

@DavinKD
Copy link

DavinKD commented Feb 16, 2019

Not 100% sure yet, but the issue seems to be caused by running a status 0 command, perhaps while it's in the middle of taking a power reading. When I removed that command from my SmartThings device handler, the issue seems to have stopped. I need to let it run for a while to be sure.

@DavinKD
Copy link

DavinKD commented Feb 17, 2019

Ok, so when I disable the 200ms ticker for energy checking, I can run status 0 many times with no crashing. There's definitely something there.

@DavinKD
Copy link

DavinKD commented Feb 18, 2019

FYI, today I rebuilt from the latest dev branch and it all seems to be working.
/shrug

Using the following GPIO Pin arrangement (please note I prefer to control the blue LED as a separate relay instead of it being GPIO_LED1_INV since there is already a red led that turns on with the relays).

{ "SP201", // Orange Tech 2 in 1 Smart Socket Wifi Mini Outlet with Energy Monitoring
// https://www.amazon.com/gp/product/B07L63S731
// used https://github.com/arendst/Sonoff-Tasmota/wiki/Tuya-OTA for flashing Tasmota via OTA
GPIO_REL3_INV, // GPIO00 Led (1 = On, 0 = Off) - Power status
0, 0,
GPIO_NRG_SEL_INV, // GPIO03 HLWBL HJL-01 Sel output (1 = Voltage)
GPIO_KEY1, // GPIO04 Button 1
GPIO_HJL_CF, // GPIO05 HLW8012 BL0937 or HJL-01 CF power
// GPIO06 (SD_CLK Flash)
// GPIO07 (SD_DATA0 Flash QIO/DIO/DOUT)
// GPIO08 (SD_DATA1 Flash QIO/DIO/DOUT)
0, // GPIO09 (SD_DATA2 Flash QIO or ESP8285)
0, // GPIO10 (SD_DATA3 Flash QIO or ESP8285)
// GPIO11 (SD_CMD Flash)
GPIO_REL1, // GPIO12 Relay1 (0 = Off, 1 = On)
GPIO_KEY2, // GPIO13 Button 2
GPIO_NRG_CF1, // GPIO14 HLWBL BL0937 or HJL-01 CF1 current / voltage
GPIO_REL2, // GPIO15 Relay2 (0 = Off, 1 = On)
0, 0
}

@Jason2866
Copy link
Collaborator

Could you add your setup to the wiki with a template and close this issue?
Thank you
https://github.com/arendst/Sonoff-Tasmota/wiki/User-created-templates

@DavinKD
Copy link

DavinKD commented Feb 18, 2019

Sorry, I didn't open the issue. I'll get the template added shortly unless @balvant813 already did. I copied from his merge request.

@Jason2866
Copy link
Collaborator

Ahh, yes. we will close. Thx for adding in wiki

arendst added a commit that referenced this issue Feb 21, 2019
6.4.1.18 20191221
 * Fix some exceptions and watchdogs due to lack of stack space - part 1 (#5215)
@arendst
Copy link
Owner

arendst commented Feb 21, 2019

Caused by lack of stack space it might intermittent go in exception or watchdog. the latest dev frees some stack space and should be more stable.

Give it a try and let me know if it fails again.

@DavinKD
Copy link

DavinKD commented Feb 21, 2019

I'll try it tonight. I didn't bring one to work with me today.

@DavinKD
Copy link

DavinKD commented Feb 24, 2019

Sorry for the slow reply. I had ordered a few more of these and they just came in today. That way I didn't have to mess with ones I already had in use. I just flashed with the latest dev build (6.4.1.18(41a342c-sonoff)). I am unable to make it crash by running a status. Looks like we're good now. Thanks for the fix.

@molpie
Copy link

molpie commented Feb 26, 2019

Hello, two days ago I installed version 6.4.1.19 on Blitzwolf smart sockets. The hardware and software watchdogs that caused the restart have disappeared. I often use TasmoAdmin and don't see any problems.

@andrethomas
Copy link
Contributor

andrethomas commented Feb 26, 2019

@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
Copy link

@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
Copy link

DavinKD commented Mar 28, 2019

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

@cmccambridge
Copy link

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
Copy link

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

@Jason2866
Copy link
Collaborator

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

@ed-war-d
Copy link

1559214516484_1
1559214501699_2

@Jason2866
Copy link
Collaborator

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

@ed-war-d
Copy link

1559220839014_3

@cmccambridge
Copy link

cmccambridge commented May 30, 2019

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
Copy link

Thanks

@ed-war-d
Copy link

Where is the GPIO0: Led1i ?

@cmccambridge
Copy link

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
Copy link

cmccambridge commented May 30, 2019

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
Copy link

I've done it! Thanks!

@ed-war-d
Copy link

What device I should select in Module type menu?

@cmccambridge
Copy link

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
Copy link

ed-war-d commented May 30, 2019

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
Copy link

2019-05-30 4

@ed-war-d
Copy link

It seems I should to have got 2 switches

@DavinKD
Copy link

DavinKD commented May 30, 2019

The third "relay" is for the led.

@meingraham
Copy link
Collaborator

meingraham commented May 30, 2019

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
Copy link

Thanks

@rlowens
Copy link

rlowens commented Sep 6, 2019

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
Copy link

rlowens commented Sep 6, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting feedback Action - Waiting for response or more information template missing/incomplete Action - Template Missing or incomplete (issue will be closed) troubleshooting Type - Troubleshooting
Projects
None yet
Development

No branches or pull requests