Gosund WiFi dimmer replacing firmware

pete_c

Guru
Testing here a pair of Gosund WiFi dimmer in wall switches.  Removed the cloud based OS and installed control via MQTT.  The prices are very good at this time for these switches.  Build looks OK.
 
This is my first time checking out one of these devices.  
 
Initially was going to JTAB the new firmware and could not.  Read that I have to remove one ZIF cable here for the JTAG.  Went with an OTA firmware update.  Worked well for me.  It gives you a choice of using an Espurna or Tasmota core base firmware and no soldering required or even a take apart.
 
Did this on my linux laptop.
  1. git clone hxxps://github.com/ct-Open-Source/tuya-convert
  2. cd tuya-convert
  3. ./install_prereq.sh
  4. ./start_flash.sh
Read some more and found that the Gosund dimmer switch is not the same as a Tuya dimmer switch over here ==> hxxps://templates.blakadder.com

The switch purchased is known as a Gosund SW2 dimmer.

All dimming and on/off functionality is controlled by an MCU that does not follow the Tuya protocol. Dimming and on/off can be set by Tasmota using simple serial commands. Reading local dimming when set by the capacitive touch panel requires a Script-enabled build and the script below to process serial status codes sent by the dimmer MCU.

So I installed the template and base 18 configuration.

{"NAME":"Gosund Dimmer","GPIO":[255,148,255,149,17,0,255,255,56,158,37,255,255],"FLAG":0,"BASE":18}
 
ooking at the console see the following:

13:25:33 RSL: tele/tasmota_C28A11/STATE = {"Time":"2020-06-30T13:25:33","Uptime":"0T00:05:22","UptimeSec":322,"Heap":26 ,"SleepMode":"Dynamic","Sleep":50,"LoadAvg":19,"MqttCount ":0 ,"POWER":"OFF","Dimmer":27,"Fade":"OFF","Speed":1,"LedTab le" :"ON","Wifi":{"AP":1,"SSId":"ICS-ESPurna","BSSId":"E0:10:7F:XX:XX:XX","Channel":11,"RSSI":94, "Signal":-53,"LinkCount":1,"Downtime":"0T00:00:06"}}
13:27:39 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON"}
13:27:39 RSL: stat/tasmota_C28A11/POWER = ON
13:27:44 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"OFF"}
13:27:44 RSL: stat/tasmota_C28A11/POWER = OFF
13:28:18 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON"}
13:28:18 RSL: stat/tasmota_C28A11/POWER = ON
13:28:21 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON","Dimmer":84}
13:29:08 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON","Dimmer":25}
13:29:10 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON","Dimmer":26}
13:29:13 RSL: stat/tasmota_C28A11/RESULT = {"POWER":"ON","Dimmer":11}
 
[sharedmedia=gallery:images:1377]
 

[sharedmedia=gallery:images:1378]
 

 
 
02, July 2020
 
Was able to load the tasmota scripting bin initially loading the tasmota basic bin gz file then uploaded the script bin.

Adding the script and template found here ==> hxxps://templates.blakadder.com/gosund_SW2.html have the switch working fine now.



>D 100
rng=235
dimh=""
slider=0
power=0
dimval=1
a=""
b=""
c=""
d=0
f=0
;set the hex code below to the largest value possible that will turn off the relay with SerialSend5
off=0x7f

>B
dp0
rng-=off
=#scDim(dimval)

>E
slider=Dimmer
if chg[slider]>0
then
; dim according slider
if slider>0 and dimval!=slider
then
dimval=slider
=#scDim(dimval)
=>SerialSend5 %dimh%
endif
endif

if pwr[1]!=power
then
if pwr[1]==1
then
=>SerialSend5 %dimh%
power=1
else
=>Serialsend5 00
power=0
endif
endif

a=SerialReceived
if sl(a)>0
then
;process the first and second hex nibbles
b=sb(a -8 1)
c=sb(a -7 1)
a=""
;convert the first nibble to decimal – max value is 0x60
f=b
f*=16
;handle second nibble which may be 0x0-0xf
d=c
if d==0
then
switch c
case "A"
d=10
case "B"
d=11
case "C"
d=12
case "D"
d=13
case "E"
d=14
case "F"
d=15
ends
endif
;add first and second nibbles then to Tasmota dimming path
f+=d
=>dimmer %f%
slider=f
endif

#scDim(dimval)
dimh=hn((rng*dimval/100)+off)
=>print Scaled brightness is %dimh%Using the scripting pieces allowed me to be able to manually dim the switch and see it dim in the console and use the GUI to dim and see the switch dimming leds illuminate.

08:50:06 MQT: stat/tasmota_C28A11/RESULT = {"POWER":"ON","Dimmer":50}
08:50:06 MQT: tele/tasmota_C28A11/RESULT = {"SerialReceived":"2403011C23240B011C232428011C23243C011C 232 446011C23244A011C23244C011C23"}
08:50:06 Scaled brightness is b5
08:50:06 Script: performs "SerialSend5 b5"
08:50:06 MQT: stat/tasmota_C28A11/RESULT = {"SerialSend":"Done"}

 
 
02 July 2020 update
 
Configured 2nd Gosund dimmer switch.  Fast and easy using OTA.

0 - updated via OTA wirelessly and utilize powerline. 
1 - update installed Tasmota base with minimal base gz file
2 - install Tasmota script bin
3 - enter your Gosund template
4 - enter your Gosund script

Next going to see if I can install two of these side by side in a metal 4 X 4 box.

The two switches there are for garage and front door coach lamps.
 
I am so excited to see a recent post on the Gosund SW2 with Tasmota.
I bought the 4 pack and installed two side by side in a double box.
Both ran well right out of box, great.
Then I flashed with Tasmota using Tuya-convert, seemed to take no problems.
Then I upgraded to recent Tasmota Firmware 8.3.1
Buttons didn't work but needed to add template still.
Added template from Blakadder for Gosund SW2 dimmer found here (https://templates.blakadder.com/gosund_SW2.html)::
{"NAME":"Gosund Dimmer","GPIO":[255,148,255,149,17,0,255,255,56,158,37,255,255],"FLAG":0,"BASE":18}
No response from switch in Tasmota?
Tried several other random templates, no response from any?
Tried creating template using digiblurDIY example here: (https://www.youtube.com/watch?v=eDoIkd58HRM) - This is cool, worked great for other offbrand switch I had.
There was no response on any of the switch commands during this learning process?
 
I flashed and tried second switch. Exact same (non) response.
 
I was super excited to see a recent discussion with templates for Tasmota here. Looks like same template as Blakadder though.
 
Any advise is GREATLY appreciated as the switches are sort-of dead now and I don't really want to install/flash the remaining two yet.
Thank you in advance.

Any advise is GREATLY appreciated as the switches are sort-of dead now and I don't really want to install/flash the remaining two yet.
 
Great news that you are able to to fit the two switches in one box. 

I have the two switches in place today at families house. Dimming of the outdoor LED lamps flickered a bit so switching the outdoor coach lamps to Philips clear candelabra standard base dimmer LED bulbs today. 
 
This was my first attempt at using Tasmota in a long time as I have only used Espurna mostly.
 
Guessing you used Tuya Convert 2.0 located here ==> hxxps://github.com/ct-Open-Source/tuya-convert
 
 
Here all of my testing was using an old computer power cord to just the power on the switch ==> black (hot) and white (neutral).
 
I did all of the programming here using my laptop running Ubuntu in a terminal session.
 
It is easy to get back to the Tasmota base by pressing the switch until it goes to programming mode.  My LED did not flash when I did this (a couple of times).
 
IE: here put the switch in to Espurna mode first then went to Tasmota.  Once you are in programming mode then you just have to look for the WiFi AP with your laptop and go to the device GUI and reset it to your local home WAP SSID.  Once you do this then restart it a couple of times to check it.
 
Then load up the basic tasmota bin in gz format.  Reboot it again and load up the scripting bin (gz).  Once you have the scripting bin in place then use the template and script found listed in the tasmota templates section.
 
The dimming and on and off physical controls will not work until you have done a copy and paste of the script and the script will not work until you have loaded a scripting bin firmware file.
 
BTW mine wouldn't work right until I used the Tasmota scripting bin and did a copy and paste of the script located under the template.
 
I also watched the youtube videos by digiBlurDIY.  Very good videos.
 
NOTE: Only use the template and script located here ==> hxxps://templates.blakadder.com/gosund_SW2.html
and no other one for this Gosund dimmer switch.
 
Try it it again and post your results here.

A quickie step by step review:

1 - test switch using just a computer cord to power up the switch
2 - switch over to Tasmota firmware using Tuya Convert 2.0 and connect Switch to your local WAP
3 - update firmware on switch over to Tasmota basic bin (GZ file)
4 - update firmware on switch over to Tasmota Scripting bin (GZ file)
5 - copy and paste template from posted web site for specific Gosund dimmer switch
6 - copy and past script from posted web site for specific Gosund dimmer switch
7 - enable template, reboot and test the dimmer touch and switch.

Everything should work fine.
 
Cocoonut- Thank you so much.
I wanted to write back immediately, but the limit of one post per day would not allow me.
 
I have to say I am a bit lazy/stubborn and skipped some steps. but it is all working now.
What I did in relation to your steps:
 
1 - test switch using just a computer cord to power up the switch - didnt do
2 - switch over to Tasmota firmware using Tuya Convert 2.0 and connect Switch to your local WAP - didnt do this one either
3 - update firmware on switch over to Tasmota basic bin (GZ file) - didnt do this one either
4 - update firmware on switch over to Tasmota Scripting bin (GZ file) - this is where I started, but it would not accept the Scripting bin. So I installed the tasmota-minimal.bin.gz and then installed the scripting bin. This allowed for the Scripting option which I had not seen before.
5 - copy and paste template from posted web site for specific Gosund dimmer switch - did this, great
6 - copy and past script from posted web site for specific Gosund dimmer switch - did this (first time), great
7 - enable template, reboot and test the dimmer touch and switch - GREAT IT WORKS!!!
 
This was incredible and greatly appreciated.
 
Great news!
 
This is the second time I have installed Tasmota in a couple of years via OTA.  I have been using mostly Espurna and using the wired method of upgrading the firmware.
 
I too skipped the steps in upgrading the Gosund dimmer switch in the beginning and it did not work until I installed the scripting bin and script per documentation on the templates site.
 
Hey all!
 
I also just bought the 4 pack of the dimmer switches. This was the first flashing method that worked for me. I tried doing the onboard flashing via soldering with no success. The flash seemed to work, but now I am not able to do anything with the switch at all. All I get when I go to the ip address that I believe is the device is {"description":"not authorized"}. Here are the steps I did to get where I am at
  • downloaded and installed tuya-convert
  • was able to find the device and flash it with "Tasmota V8.1.0.2"
  • Connected it to my network via the login page
  • Found the device on my network using FING
However, now I am stuck and do not know what to do. What should be my next steps to resolve this? Thank you in advance and I am so excited to get these working!
 
@nscharich
 
Welcome to the Cocoontech forum.
 
Great news on your Gosund dimmer endeavor.
 
Baby steps.
 
1 - Power off and power on your Gosund dimmer.
2 - clear the cache on your web browser
3 - upload the compressed Tasmota basic bin file
4 - upload the compressed Tasmota Script bin file
 
5 - copy and paste template to Gosund dimmer
6 - copy and paste script to Gosund dimmer
7 - configure to your liking.
 
Do you all have issues with the Dimmer being a little "quirky"? Like when your sliding it up or down, it randomly reverts back to a previous setting.
 
 Like when your sliding it up or down, it randomly reverts back to a previous setting.
 
Yes.  I don't pay attention as it is connected to exterior garage and front door LED coach lamps not at my home and the switch is automated with the built in scheduler using the Tasmota template and script.
 
I was messing around with it for a little bit and watching the Console. Seems like the Dimmer command isn't being sent sometimes. Notice the last entries show that the Scaled brightness changed but it never performs the dimmer command.
 

20:46:10 Scaled brightness is e3
20:46:10 Script: performs "SerialSend5 e3"
20:46:10 MQT: stat/hall_light/RESULT = {"SerialSend":"Done"}
20:46:11 MQT: tele/hall_light/RESULT = {"SerialReceived":"2416012023"}
20:46:11 Script: performs "dimmer 22"
20:46:11 MQT: tele/hall_light/STATE = {"Time":"2020-08-08T20:46:11","Uptime":"0T00:12:17","UptimeSec":737,"Heap":21,"SleepMode":"Dynamic","Sleep":10,"LoadAvg":99,"MqttCount":1,"POWER":"ON","Dimmer":22,"Fade":"OFF","Speed":1,"LedTable":"ON","Signal":-52,"LinkCount":1,"Downtime":"0T00:00:09"}}
20:46:11 MQT: stat/hall_light/RESULT = {"POWER":"ON","Dimmer":22}
20:46:13 MQT: tele/hall_light/RESULT = {"SerialReceived":"2431012023"}
20:46:13 Scaled brightness is 95
20:46:13 Script: performs "SerialSend5 95"
20:46:13 MQT: stat/hall_light/RESULT = {"SerialSend":"Done"}


 
 
I had the very same problem when I just did my Gosund SW2. Really wonky local dimming depending upon how much you slide your finger around. Did an analysis of the data and it appears that the serial buffer is truncated after 47 characters which places the level in the wrong position. Reworked the script to deal with this anamoly and simplified the hex to decimal conversion process.
 
>D 100
rng=235
dimh=""
slider=0
power=0
dimval=1
a=""
b=""
c=""
d=0
f=0
;set the hex code below to the largest value possible that will turn off the relay with SerialSend5
off=0x7f
 
>B
dp0
rng-=off
=#scDim(dimval)
 
>E
a=SerialReceived
if sl(a)>0
then
if sl(a)==47
then
b=sb(a -5 2)
else
b=sb(a -8 2)
endif
a=""
f=hd(b)
=>dimmer %f%
slider=f
dimval=slider
=#scDim(dimval)
=>SerialSend5 %dimh%
else
slider=Dimmer
if chg[slider]>0
then
; dim according slider
if slider>0 and dimval!=slider
then
dimval=slider
=#scDim(dimval)
=>SerialSend5 %dimh%
endif
endif
endif
 
if pwr[1]!=power
then
if pwr[1]==1
then
=>SerialSend5 %dimh%
power=1
else
=>Serialsend5 00
power=0
endif
endif
 
#scDim(dimval)
dimh=hn((rng*dimval/100)+off)
=>print Scaled brightness is %dimh%
 
Dave.
 
Sorry about that code. Forum munged it up. Here is using "code":
 

>D 100
rng=235
dimh=""
slider=0
power=0
dimval=1
a=""
b=""
c=""
d=0
f=0
;set the hex code below to the largest value possible that will turn off the relay with SerialSend5
off=0x7f

>B
dp0
rng-=off
=#scDim(dimval)

>E
a=SerialReceived
if sl(a)>0
then
if sl(a)==47
then
b=sb(a -5 2)
else
b=sb(a -8 2)
endif
a=""
f=hd(b)
=>dimmer %f%
slider=f
dimval=slider
=#scDim(dimval)
=>SerialSend5 %dimh%
else
slider=Dimmer
if chg[slider]>0
then
; dim according slider
if slider>0 and dimval!=slider
then
dimval=slider
=#scDim(dimval)
=>SerialSend5 %dimh%
endif
endif
endif

if pwr[1]!=power
then
if pwr[1]==1
then
=>SerialSend5 %dimh%
power=1
else
=>Serialsend5 00
power=0
endif
endif

#scDim(dimval)
dimh=hn((rng*dimval/100)+off)
=>print Scaled brightness is %dimh%


Hope it helps.
 
Dave.
 
Back
Top