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

Support for Homecube/Gosund SP1 #2223

Closed
knopserl opened this issue Mar 21, 2018 · 46 comments
Closed

Support for Homecube/Gosund SP1 #2223

knopserl opened this issue Mar 21, 2018 · 46 comments
Labels
enhancement Type - Enhancement that will be worked on

Comments

@knopserl
Copy link

knopserl commented Mar 21, 2018

The Gosund SP1, also offered from other companies like Homecube etc. ist a very small, cost effectiv WiFI smart plug + Energy monitor. Most plugs only habe switch features or a much more expensive.

It would be extremly attractive to get a support this smart plug SP1 as it would cover many similar brands which use the same base products/design.

I have bought two of them in a bundle for 39€ and the have an ESP8266EX with 1MB Flash and an Energy Monitor chip which is labeled with: HJL-01 J1749CYH D797480E.
I was able to solder the 3,3V and the RX/TX connection and read the chip type and flash size and dump the flash, but don't know what kind of energy monitor chip that is (have not found it in the web).
If anybody could hack that device and get Tasmota working, that would be great.
That are the links to the product:

https://www.amazon.de/Intelligente-Stromverbrauch-Fernsteurung-Schaltbare-Energieklasse/dp/B076WZQS4S/ref=sr_1_1?s=diy&ie=UTF8&qid=1521671822&sr=1-1&keywords=gosund+SP1

https://www.amazon.de/Steckdose-Homecube-intelligente-Verbrauchsanzeige-funktioniert/dp/B076Q2LKHG/ref=sr_1_fkmr0_1?s=diy&ie=UTF8&qid=1521672069&sr=1-1-fkmr0&keywords=homecube+SP1

@knopserl
Copy link
Author

knopserl commented Apr 3, 2018

Meanwhile, with the help of another experienced developer, we have found out the following inputs for the SP1:
This is the wiring of the used ESP8266-S3 board:
grafik
and the energy monitor chips is a HJL-01 which has the same wiring as the HLW8012 but need another driver code.

@knopserl
Copy link
Author

Is nobody interested in suppprting this very common large familiy of SP1 devices (from many different brands like: Gosund, Coosa, Homecube ...).
The only thing which is missing is the support of the energy IC: HJL-01

@nightfly0815
Copy link

Hey it would be great if someone could add the device. There exists a lot of this devices with different names on Amazon for example.
I ordered this.
https://www.amazon.de/Intelligente-Steckdose-Ablue-Funktioniert-Assistant/dp/B076DRFRZC/ref=sr_1_5?s=diy&ie=UTF8&qid=1529908498&sr=1-5&keywords=wlan+steckdose+smart+life
This device worked, not 100% with tasmota. It means that no configuration worked 100% for the device out of the box.
It was added in the newest espurna release named as blitzwolf-bwshp2

@schrej-zz
Copy link

Espurna now supports these plugs including power monitoring.
xoseperez/espurna#737
Would be great, if someone with coding knowledge could implement it in Tasmota.

@arendst
Copy link
Owner

arendst commented Jun 26, 2018

Did you try Tasmota selecting module 06 Sonoff Pow already?

@arendst
Copy link
Owner

arendst commented Jun 26, 2018

After troubling ordering the correct energy monitoring device with Amazon I'll see if Tasmota will work with it.

As far as I can tell this has NO energy monitoring:
https://www.amazon.de/Intelligente-Steckdose-Ablue-Funktioniert-Assistant/dp/B076DRFRZC/ref=sr_1_5?s=diy&ie=UTF8&qid=1529908498&sr=1-5&keywords=wlan+steckdose+smart+life

The below link has energy monitoring:
https://www.amazon.de/Steckdose-Homecube-intelligente-Verbrauchsanzeige-funktioniert/dp/B076Q2LKHG/ref=sr_1_fkmr0_1?s=diy&ie=UTF8&qid=1521672069&sr=1-1-fkmr0&keywords=homecube+SP1

I ordered the second one.

@arendst arendst added the enhancement Type - Enhancement that will be worked on label Jun 26, 2018
@nightfly0815
Copy link

Yes I tried the pow module. I´m not 100 % sure how it worked. As I can remember I think the relay doesn´t worked when you switch on and off. The led also hasn´t worked with the pow configuration, and the energy monitor displays wrong values.
No you where wrong the Ablue has definitely the energy monitor inside!! I have checked it bevor with the original software. And the espurna blitzwolf.bin also worked well on the device with the energy monitor!!

Ok yes I think all the different brands with the same factor of the sockets have the same hardware inside. If it is mentioned in the description, then they have a energy monitor too.

@knopserl
Copy link
Author

knopserl commented Jun 26, 2018

I opened the SP1 thread in espurna and tasmota and the espurna team solved it first with some contribution from my side (see also the pin layout at the beginning of the post).
I guess the HLW8012 library with the seetings in hardware.h from espurna could be used for tasmota too, as the latest HLW8012 modification supports also the HJL01/BL0937 from the SP1 or similar devices. If someone does the work, tasmota could benefit and would support a plenty of other smart plugs with engery monitoring.

@knopserl
Copy link
Author

@arendst I would be surprised if the Ablue has no energy monitoring. I assume it's the same SP1 based product as used by: Gosund, Homecube, Coosa, Blitzwolf and many others companies (mostly the same product). If you open it and it has a HJL-01, it has energy monitoring

@schrej-zz
Copy link

Yes, I think all of these low cost china plugs are utilizing this HJL01/BL0937.
In Tasmota, you can use the on/off, but currently the values for power and voltage are crap.
This library might solve this as it did for Espruna.

@fnordsh
Copy link

fnordsh commented Jun 28, 2018

I was surprised when I ordered one with energy monitoring and found out that it was identical to two that I already had. Turns out, all three can do energy monitoring, although I am pretty sure that this feature was not advertised when I bought the first two. So, this was a pleasant surprise!

So I can confirm that these can do energy monitoring:
https://www.amazon.de/gp/product/B07CDCYLQ6/ref=oh_aui_detailpage_o00_s00?ie=UTF8&th=1
And these as well:
https://www.amazon.de/gp/product/B078LV94CZ/ref=oh_aui_detailpage_o01_s01?ie=UTF8&psc=1

@fnordsh
Copy link

fnordsh commented Jun 28, 2018

@arendst: The Ablue has energy monitoring, but it's quite well hidden further down in the description: "Senken Sie Ihre Rechnungen mit Energieüberwachung / Sie wissen genau, wie viel Strom jedes Gerät verwendet und wie effektiv Geräte verwaltet werden."

It seems like they don't see it as an important feature, but for me it is indeed a major selling point. Especially at this price there really is no reason to buy one without energy monitoring any more.

@knopserl
Copy link
Author

knopserl commented Jun 29, 2018

@arendst, @nightfly0815 as I wrote there are many (10+) companies selling it under different names but it is always a SP1 with HJL01 and energy monitoring.
Thus, makes it interesting to support it and that's why I opened this thread :-)
I did the same in espurna (actually I created both threads in parallel) and got it supported soon (I also contributed).

@arendst
Copy link
Owner

arendst commented Jul 1, 2018

Working on implementation...

@arendst
Copy link
Owner

arendst commented Jul 1, 2018

How about this:

image

Thx to Xose for his ratio work.

Need some finishing touch before release.

@fnordsh
Copy link

fnordsh commented Jul 1, 2018

Awesome, thank you!

@knopserl
Copy link
Author

knopserl commented Jul 1, 2018

@arendst I'm impressed. You enabled a lot of device families with switch and energy monitoring. Probably not less than with support of the Sonoff devices.
Thanks a lot for adressing my proposal of this issue post. Seems that you made also a lot of other people happy!

arendst added a commit that referenced this issue Jul 2, 2018
Add support for BlitzWolf BW-SHP2 (and Homecube, Gosund SP1) Energy
Monitoring Smart Socket (#2223)
@arendst arendst closed this as completed Jul 2, 2018
@nightfly0815
Copy link

Hey nice to hear. I have a Ablue SP1 Socket.
I have compiled the firmware with the standard settings from the git.
I just changed the the espressif library to 2.4.1. The firmware compiled and I flashed it to all of my sonoff devices basics with 1MB and 4MB flash and the worked without problems. On the socket I flashed the firmware with a USB FTFI device. (I used the esptool commandline tool for that. ) I grounded the GPIO 0 to enter the flash mode. The problem is, that the socket doesn,t start the wifi. I also tried another selfcompiled firmware where I added the wifi accespoint settings from my accespoint. Both versions doesn´t work. ( I can´t find the wifi of the sonoff) I also tried a precompiled firmware. I always get the same result.
The onboard switch doesn´t switch the relais on. (I think this is OK because the switch and led will not work until I change the right type of the sonoff in the webinterface). I also tried to simulate a button press 4 times to start the AP mode of the sonoff. ( I grounded the GPIO 0) When I ground the GPIO 0 the Led glow red. Before that I had the espurna firmware running on the device.
I have some questions: Is there a way to predefine witch device I wan´t to use when I compile the firmware by myself.
Is there a way to log per serial what went wrong when the socket starts up?
Or does anyone have other tips what I can try? I also erased the flash with the espool, and tried to ground the GPIO 0 for 40 seconds.

Thank you for the hard work! :-)

@schrej-zz
Copy link

Try to use WPS. Worked for me.

@nightfly0815
Copy link

I will try it, when I´m at home. But without any led notification it will be hard to find out how the device worked and in witch modus the device is. On witch GPIO is the standard led configured who shows the status of the device? Is it the GPIO 13? Maybe I can try to connect an extra led to the GPIO to indicate the status of the device.

@schrej-zz
Copy link

Just enable WPS on your router and power up SP1. Should find an IP-Adress and you should find the sonoff-xxxx device in the listof devices.

@nightfly0815
Copy link

Yes the WPS had worked!! It looks like that there is a wifi bug with tasmota and the socked.
Is there a way to set the red led too, when the socket is switched off?? (blue led on/ red led off)
The red led is orignal connected to the GPIO0.

@knopserl
Copy link
Author

knopserl commented Jul 3, 2018

@schrej-zz and @nightfly0815 WPS shall not be required as the SP1 will provide it's own hotspot when it can't connect to a another WiFi AP. It will offer a hotspot with 192.168.4.1. At least All 7 devices I have used (with espurna so far) behave that way and tasmota should have the same behavior.

@nightfly0815
Copy link

@knopserl yes I know, all my other devices worked and open a wifi AP if the lost the normal wifi connection. This is why I asked that I don´t know this behavior that I can´t find the sonoff wifi from the socked.
I will test it on the second socked. Maybe there are some old firmware rests from the espurna firmware on the flash, because first I tried to flash the tasmota firmware over the espurna firmware in the webif of espurna. After that I erased the flash with esptool. For the second socket I will flash a blank 1mb file first with the espool. After this I will flash the new tasmota firmware. I report If the second socked worked without wps. What´s about the red led? Is it possible to use it?

@arendst
Copy link
Owner

arendst commented Jul 3, 2018

Tasmota default is WPS. Using the button as described in the wiki should make wifimanager available. No visible feedback though.

@myiotcenter
Copy link

myiotcenter commented Jul 13, 2018

Hi,
I flashed my SP1 smart socket with release 6.1.0 and having a problem with wifi connection...

Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.205: bytes=32 time=1ms TTL=128
Reply from 192.168.1.205: bytes=32 time=2ms TTL=128
Reply from 192.168.1.205: bytes=32 time=2ms TTL=128
Reply from 192.168.1.205: bytes=32 time=1ms TTL=128
Reply from 192.168.1.205: bytes=32 time=4ms TTL=128
Reply from 192.168.1.205: bytes=32 time=15ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.131: Destination host unreachable.
Request timed out.
Request timed out.
Reply from 192.168.1.205: bytes=32 time=35ms TTL=128
Request timed out.
Reply from 192.168.1.205: bytes=32 time=1ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.205: bytes=32 time=4ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.205: bytes=32 time=135ms TTL=128
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Reply from 192.168.1.205: bytes=32 time=191ms TTL=128

this socket is just few feet away from my Ubiquity AP Pro so signal quality should not be an issue.

I used the source code and set my ip and ssid in user_config.h compiled in Arduino IDE and flash with esptool. Should I change the CFG_HOLDER value and recompile? Anything specific I should look into ?

Thanks !

@schrej-zz
Copy link

I think you haven't searched for comparable issues.
Arduino IDE. Which version are you using.
Try flashing the precompiled version. Still issues?

@crassus12
Copy link

Hello, is it possible under firmware 6.1.1 to integrate the HJL01 / BL0937 chip also under generic module? I can not find the chip in the selection.

@Pfriemler
Copy link

Pfriemler commented Aug 17, 2018

@crassus12: As far as I understand, it's only possible to use "user gpios" - the GPIO_HLW_CF & GPIO_HLW_CF1 & GPIO_HLW_SEL are "ProgramSelectablePins" - not chooseable in the dropdown at all.
If you want to make more settings than the GPIO1/3 at the "BlitzwolF SHP2", try to change the "sonoff_template.h" and recompile.

Before I struggle with that myself, here are my questions:
a) as I understand, the red LED cannot be used as "switch on" led due to wiring issues?
b) the voltage measuring (probably all measurings) is stopped when the switch is off (-> 0V). In the original firmware, the plug continues to show voltage when off. What do I have to do to get it back?
What does the original sonoff pow do when switch is off?

@arendst
Copy link
Owner

arendst commented Aug 17, 2018

b - look for the correct SetOption command in the wiki.

@Pfriemler
Copy link

That was easy, BIG THANKS! SetOption21 was "OFF", but should be 1/on by default?
Nevertheless: it works. I have my mains reading in FHEM.

curzon01 pushed a commit to curzon01/Tasmota that referenced this issue Sep 7, 2018
Add support for BlitzWolf BW-SHP2 (and Homecube, Gosund SP1) Energy
Monitoring Smart Socket (arendst#2223)
@Mace404
Copy link

Mace404 commented Sep 15, 2018

I flashed a Homecube SP1 with Tasmota (using VC and PlatformIO) but after flashing the led just blinks once when I plug it into a socket and nothing else happens.
Also used esptool to erase everything and flash again with a precompiled binary (and all those steps went fine) but same result.
Verifying the flash with the binary gives a match:

esptool.py --port com4 verify_flash 0x0 sonoff.bin
esptool.py v2.5.0
Serial port com4
Connecting.....
Detecting chip type... ESP8266
Chip is ESP8266EX
Features: WiFi
MAC: ec:fa:bc:xx:xx:xx
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Verifying 0x75cd0 (482512) bytes @ 0x00000000 in flash against sonoff.bin...
-- verify OK (digest matched)
Hard resetting via RTS pin...

Any ideas?

@mtdcr
Copy link

mtdcr commented Sep 15, 2018

I guess the button doesn't work in Tasmota, so you can't switch between different configuration modes. I tried it with a Gosund SP1, which is probably identical to yours. Eventually I flashed espurna.

@knopserl
Copy link
Author

If you don't get it to work, I would also try ESPurna. we worked together to get all SP1 families running. It definitly works with Homecube, Gosund, Ablue, Coosa, Blitzwolf (I have tested it with all of them)

@schrej-zz
Copy link

schrej-zz commented Sep 16, 2018

Tasmota works with Gosund SP1 (and Wuudi). I have 2 of each running successfully incl. energy monitoring with Tasmota 6.1.1

@Pfriemler
Copy link

gosund SP1 uses a different GPIO (not the GPIO0 like sonoff devices), therefore you have to use a bridge on GPIO0 to GND to choose a wifi configuration mode, if you are unhappy with the default - which now is the WiFi-Manager beginning with 6.2.x.
After the gosund SP1 button is assigned (by using the BlitzWolf setting), the button can be used to set configuration mode if necessary - as usual with sonoff devices.

@knopserl
Copy link
Author

Hmmm, I had all devices open and they have all the same SP1 HW with the same ESP8266 board and same PCB,. I can't remember that different GPIO's for relay, button, LED's and energy monitor are used. But at least all work fine.

@Mace404
Copy link

Mace404 commented Sep 17, 2018

gosund SP1 uses a different GPIO (not the GPIO0 like sonoff devices), therefore you have to use a bridge on GPIO0 to GND to choose a wifi configuration mode, if you are unhappy with the default - which now is the WiFi-Manager beginning with 6.2.x.

I added WiFi config the the user_config.sh script, so it should just start up and use those settings.
Are you saying that when it's in a power socket I should short GPIO0 and GND instead of using the power button?
Also from the 'button usage' page regarding the WiFi manager: "The LED will blink during the config period."
I don't get that behavior either. Is there a way to check that Tasmota is actually starting?

@knopserl
Copy link
Author

knopserl commented Sep 17, 2018

you have to connect GPIO0 to ground to get into the flash mode and restart. The red LED will then be on.
After first time flashing Tasmota, you have to disconnect the GPIO0 from ground and restart to get into the normal program startup. That will start Tasmota in a AP mode to configure the device for your Home WiFi. The AP address will be 192.168.1.4. You can connect via a mobile phone or tablet or notbook to do the very first configiguration, password changes and WiFi connection settings.
Further updates are done ove WiFi.

@Pfriemler
Copy link

Pfriemler commented Sep 18, 2018

Are you saying that when it's in a power socket I should short GPIO0 and GND instead of using the power button?

OMG, never do anything inside when connected to a power socket, if you love your life. What I meant:
Like knopserl said: after doing the flash, you have to remove the GPIO0 - GND bridge (and a short power off) to start Tasmota. sonoff devices have the "power button" on GPIO0, so there's no need to tamper with a bridge.
First start went into WPS mode until 6.1.1. - to get into the wifi manager, you had to shorten GPIO0 with GND 4x in about a second. This is due to the default [https://github.com/arendst/Sonoff-Tasmota/wiki/Button-usage](Button usage).
With > 6.2., WPS is removed, Tasmota gets into wifi manager - no need to edit user_config.sh (only if you want to skip wifi configuration).
After the SP1 is configured to "BlitzWolf", the power button can be used due to the button behavior, since now Tasmota knows the button port.

@Mace404
Copy link

Mace404 commented Sep 18, 2018

I didn't. But your comment suggests that to choose the config mode.
As I edited the user_config.sh it should skip the WiFi manager but like I said, the device isn't doing anything but a short flash from the led after powering it.
Thanks for the instructions on how to configure it, but it won't come to that point even.
So there is no logging or whatsoever during startup? Hard to troubleshoot then.
Going to give espurna a try.

@Mace404
Copy link

Mace404 commented Sep 18, 2018

Got it working. Removed the WiFi info from user_config.sh and just let it run a while after flashing/resetting and an ad-hock sonof WiFi network showed up.
Connected and was able to configure the device.
Thanks for the replies 👍

@mtdcr
Copy link

mtdcr commented Sep 19, 2018

Thanks for all the explanations! I had tried to use a version prior to 6.2. Nice to hear that current versions behave differently.

@Pfriemler
Copy link

So there is no logging or whatsoever during startup? Hard to troubleshoot then.

Of course there is. I used my CP2303 based USB adapter to flash and for configuration. Serial monitor is active for about 5 minutes.
Not sure, I think I used 115200 8N1. Or try 74888 and do a short power off (=reset). The ESP should show its boot messages, before switching to 115200.
I guess there is something gone wrong with the flash. Did you try that some times?

@jult
Copy link

jult commented Oct 8, 2018

I currently have 4 GoSund Smart Socket SP1 units, the ones from https://www.amazon.de/gp/product/B07B911Y6V/ and just wondering if firmware flash is possible without the app contacting the cloud or breaking it open?
My units all say

"Firmware is the latest version
Wi-Fi module: 1.0.0
MCU module: 1.0.0"

and the app is Tuya Inc.'s Smart Life - Smart Living, which seems mostly open source.
The fact that they're still on firmware 1.0.0 seems odd to me. They're probably already vulnerable to remote access exploits and nobody at GoSund is doing anything about it.

@schrej-zz
Copy link

No need to break them. You need a special tool to open the screws, that's it.
I replaced the screws afterwards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Type - Enhancement that will be worked on
Projects
None yet
Development

No branches or pull requests