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

Feature request: support for Gosund SP1 #1962

Closed
micropet opened this issue Oct 26, 2018 · 65 comments · Fixed by #3929
Closed

Feature request: support for Gosund SP1 #1962

micropet opened this issue Oct 26, 2018 · 65 comments · Fixed by #3929
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)

Comments

@micropet
Copy link

micropet commented Oct 26, 2018

Is a support of Gosund SP1 planned for ESPEasy.

It is a switchable socket with 16A switching capacity.
It has a voltage and power measurement and costs about 12 EUR in Germany.

Chips seems to be: HJL-01 bzw. BL0937

https://www.amazon.de/Intelligente-Stromverbrauch-Fernsteurung-Schaltbare-kompatibel/dp/B0777BWS1P/ref=sr_1_1?ie=UTF8&qid=1540524622&sr=8-1&keywords=Intelligente+Steckdose+2er+Pack%2C16A+3680W%2C+Stromverbrauch+messen+Timer]

Infos:
https://www.bastelbunker.de/gosund-sp1-mit-tasmota

gosund

Other Names:
Gosund SP1
Blitzwolf BW-SHP2
HomeCube
Wuudi
CNXUS
TECKIN
VANZAVANZU
Ablue
Yosoo
Texsens
Expower
Potok
Geekbes
Swiftrans
TFlag
BricoPlus

@Grovkillen
Copy link
Member

Looks like a good product. We will look into it, need the hardware though.

@Grovkillen Grovkillen added Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin) labels Oct 26, 2018
@TD-er
Copy link
Member

TD-er commented Oct 26, 2018

The Blitzwolff shp version is already on my desk, waiting to be implemented

@micropet
Copy link
Author

Yes, good news!

@micropet
Copy link
Author

So, my 2 Gosund SP1 are arriving today.
I have a 5 pin female connector installed.
Now I do not need to screw on the case for flashing.

The space for the connector is ideal.

dsc03028_dxo

dsc03025_dxo

@TD-er
Copy link
Member

TD-er commented Oct 27, 2018

Probably not for you, but just as a general warning when someone else finds this issue + photo.
Do not flash/connect the node to a PC and leave it plugged in the mains.

Also I am not sure about the safety aspect when you unplug the node and press with your fingers on the pins.
You may get a distance less than 3 mm from your skin to the exposed pins and I'm not sure these are isolated from ground.

@micropet
Copy link
Author

I think it's okay.
All my S20 have the connector.
You can quickly flash a new version without opening the case.

And of course the node is disconnected from the mains voltage when it is flashed.

@s0170071
Copy link
Contributor

s0170071 commented Oct 29, 2018

Here's an image of ESP module the pinout:
arendst/Tasmota#2223
xoseperez/espurna#737

@ingoiot
Copy link

ingoiot commented Aug 1, 2019

is there a working image for the Gosund or compatible plugs now?

@TD-er
Copy link
Member

TD-er commented Aug 2, 2019

There is an 1M build with the same plugins as the Sonoff POW.
But I guess it is too big to perform an OTA, which is rather a pity with these modules since they are so hard to upgrade via serial.

@ingoiot
Copy link

ingoiot commented Aug 3, 2019

i could flash the 1M version, but unfortunately it shows no values.

@TD-er
Copy link
Member

TD-er commented Aug 3, 2019

Do you know the chip and GPIO pins used?

@ingoiot
Copy link

ingoiot commented Aug 3, 2019

the plug works with tasmota Gosund SP1 template.
in hope this pic is enough info:

Anmerkung 2019-08-03 154321

@TD-er
Copy link
Member

TD-er commented Aug 3, 2019

Not really, it looks like 2 chips are used?

@ingoiot
Copy link

ingoiot commented Aug 3, 2019

i can only find a chip labled with bl0937.

i think they might just not have changed the pin names from the old sensor?

IM16CB~1

@uzi18
Copy link
Contributor

uzi18 commented Aug 3, 2019

it looks like old sonoff pow with power to frequency converter, so we need just to know pins and multiplers in equations

@ingoiot
Copy link

ingoiot commented Aug 3, 2019

found this in Tasmotas sonoff_template.h
maybe that helps - not shure where the calculating is done..

  { "Gosund SP1 v23",  // https://www.amazon.de/gp/product/B0777BWS1P
     0,
     GPIO_LEDLNK_INV,  // GPIO01 Serial RXD and LED1 (blue) inv - Link status
     0,
     GPIO_KEY1,        // GPIO03 Serial TXD and Button
     GPIO_HJL_CF,      // GPIO04 BL0937 or HJL-01 CF power
     GPIO_NRG_CF1,     // GPIO05 BL0937 or HJL-01 CF1 current / voltage
                       // 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_NRG_SEL_INV, // GPIO12 BL0937 or HJL-01 Sel output (0 = Voltage)
     GPIO_LED1_INV,    // GPIO13 LED2 (red) inv - Power status
     GPIO_REL1,        // GPIO14 Relay (0 = Off, 1 = On)
     0, 0, 0
  },

@uzi18
Copy link
Contributor

uzi18 commented Aug 3, 2019

that's described in datasheet

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

In the old POW we read some default multipliers from the module which can later be corrected in a calibration.
image

These are the settings used on my POW r1 so they should at least give some voltage value around 230V (if you live in 230V area)

@ingoiot
Copy link

ingoiot commented Aug 4, 2019

i just flashed tasmota to check the hardware -seems to work.
flashed back ESP_Easy_mega-20190803_hard_other_POW_ESP8285_1M.bin

no matte what preset i use, there are no values.

with the Tekin us or Blitzwolf preset i get some weird values,
P076: Read values - V=0 - A=0.00 - W=7123 - Pf%=100

with the others it looks like:
P076: Read values - V=0 - A=0.00 - W=0 - Pf%=0

and the switch doesnt work on any.

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

Can you make a screenshot of the used settings in ESPeasy?

@ingoiot
Copy link

ingoiot commented Aug 4, 2019

only the device tab?
suddenly after a reboot i had some (wrong) values in Voltage.
i changed the voltage multiplier and it was back to zero.
even if i changed everything back.

Anmerkung 2019-08-04 160837

453873: P076: Read values - V=316 - A=0.00 - W=0 - Pf%=0
456792: SaveToFile: free stack after: 2752
456792: P076: Saved Calibration from Config Page
456792: P076: Multipliers Reassigned
456792: P076: PIN Settings curr_read: 0 cf_edge: 2 cf1_edge: 3
456795: SaveToFile: free stack: 3200
457110: FILE : Saved config.dat
457111: SaveToFile: free stack after: 3200
457118: SaveToFile: free stack: 3136
457880: FILE : Saved config.dat
457880: SaveToFile: free stack after: 3136
457893: P076: Init object done
457894: P076: Init Basic Resistor Values done
457899: P076: Saved Calibration after INIT
457899: P076: Applied Calibration after INIT
459281: P076: Read values - V=0 - A=0.00 - W=0 - Pf%=0
461379: P076: Read values - V=0 - A=0.00 - W=0 - Pf%=0

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

You have not set the GPIO pins like in the Tasmota config you quoted.

GPIO_HJL_CF,      // GPIO04 BL0937 or HJL-01 CF power
GPIO_NRG_CF1,     // GPIO05 BL0937 or HJL-01 CF1 current / voltage
GPIO_NRG_SEL_INV, // GPIO12 BL0937 or HJL-01 Sel output (0 = Voltage)

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

After you change the device combo box, you need to save the settings and look at the page again.
It will then base the GPIO pins on a predefined config.
Otherwise you must use the 'custom' config and set the GPIO pins manual

@ingoiot
Copy link

ingoiot commented Aug 4, 2019

to me i t looks like the same

Anmerkung 2019-08-04 184215

only in tasmota ist called SEL_INV,in espeasy only SEL
dont know if thats different.

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

to me i t looks like the same

Sorry you're right. I might have been looking at the wrong image when answering.

SEL_INV suggests the signal may be inverted?
Normally the I2C is also located on GPIO-4 and -5.
Make sure those pins are re-assigned to some other pins.

@ingoiot
Copy link

ingoiot commented Aug 4, 2019

now im getting something.
i disabled i2c in the hardware menu, i think its not needed?

unfortunately the values are all over the place and not consistent off by a certain value.

65090: P076: Read values - V=318 - A=0.00 - W=0 - Pf%=0
65093: EVENT: 937#Voltage=318.00
65102: EVENT: 937#Current=0.00
65110: EVENT: 937#Power=0.00
65123: EVENT: 937#PowerFactor=0.00

P076: Read values - V=5675 - A=0.00 - W=0 - Pf%=0
11216: EVENT: 937#Voltage=5675.00
11228: EVENT: 937#Current=0.00
11237: EVENT: 937#Power=0.00
11245: EVENT: 937#PowerFactor=0.00

i added a rule to switch on the realis on boot,
on System#Boot do GPIO,14,1 timerSet,1,3 endon
(copied from the website) - it turns on but not off after 30 sec. as i expected...

anyway, it seems like only voltage is measured.
it looks like this must be altered with the CF1 input by the software.
maybe thats why the value are so different.

P076: Read values - V=318 - A=0.00 - W=2425 - Pf%=100
19983: EVENT: 937#Voltage=318.00
19992: EVENT: 937#Current=0.00
20000: EVENT: 937#Power=2425.00
20008: EVENT: 937#PowerFactor=100.00

@TD-er
Copy link
Member

TD-er commented Aug 4, 2019

Yep, looks like the signal for the SEL line should be used inverted.
That's a bit more than just a very quick fix, so I will not alter it right now.

@uzi18
Copy link
Contributor

uzi18 commented Aug 4, 2019

it looks like hlw8012 lib does not support BL0937 chip correctly (inverted sel)

@TD-er
Copy link
Member

TD-er commented Aug 5, 2019

As long as the Amp reading is 0, I don't think we can compute proper values

@uzi18
Copy link
Contributor

uzi18 commented Aug 5, 2019

@ingoiot please paste also sysinfo, are you able to test custom image?
have bought one of these gosund sp1, will. be at the end of week in. my hands =)

@ingoiot
Copy link

ingoiot commented Aug 5, 2019

Build:⋄
20103 - Mega
System Libraries:⋄
ESP82xx Core 2_5_2, NONOS SDK 2.2.1(cfd48f3), LWIP: 2.1.2 PUYA support
Git Build:⋄
mega-20190803
Plugins:⋄
7 [Normal] [Sonoff POW R1/R2]
Build Time:⋄
Aug 3 2019 02:44:22
Binary Filename:⋄
ESP_Easy_mega-20190803_hard_other_POW_ESP8285_1M.bin

are you able to test custom image

i thought i already am^^

i have solderd on wires to flash

@uzi18
Copy link
Contributor

uzi18 commented Aug 5, 2019

@ingoiot try multipliers like these:
current 25740
voltage 313400
power 3414290

@uzi18
Copy link
Contributor

uzi18 commented Aug 6, 2019

@ingoiot any update?

@ingoiot
Copy link

ingoiot commented Aug 6, 2019

just back from work.
looks promising, but power current still missing

the voltage jumps around qiet a bit

02440: EVENT: 937#Voltage=228.00
102454: EVENT: 937#Current=0.00
102462: EVENT: 937#Power=387.00
102471: EVENT: 937#PowerFactor=100.00
105632: P076: Read values - V=214 - A=0.00 - W=386 - Pf%=100
105636: EVENT: 937#Voltage=214.00
105649: EVENT: 937#Current=0.00
105657: EVENT: 937#Power=386.00
105665: EVENT: 937#PowerFactor=100.00
108833: P076: Read values - V=228 - A=0.00 - W=388 - Pf%=100
108838: EVENT: 937#Voltage=228.00
108868: EVENT: 937#Current=0.00
108877: EVENT: 937#Power=388.00
108885: EVENT: 937#PowerFactor=100.00
111964: P076: Read values - V=225 - A=0.00 - W=388 - Pf%=100
111967: EVENT: 937#Voltage=225.00
111982: EVENT: 937#Current=0.00
111990: EVENT: 937#Power=388.00
111998: EVENT: 937#PowerFactor=100.00

@uzi18
Copy link
Contributor

uzi18 commented Aug 6, 2019

@ingoiot ok but this is another issue that need fix

@uzi18
Copy link
Contributor

uzi18 commented Aug 6, 2019

@micropet @Grovkillen @s0170071 please test #2534 fix?

@uzi18
Copy link
Contributor

uzi18 commented Aug 8, 2019

@TD-er have received my gosund sp1 so now need to reflash it with espeasy somehow, maybe I will try to upgrade esp module to esp8266 with 4MB flash from nodemcu.
After that will try to do some cleanup and maybe some improvements here :)

as #2534 merged, we have working hardware

little to do:

  • cleanup
  • stabilize reading / simple filtering
  • add predefined multipliers
  • add suggestion/warning about calibration
  • something more?

@TD-er
Copy link
Member

TD-er commented Aug 8, 2019

Documentation :)

@coelner
Copy link

coelner commented Apr 6, 2020

Hello, documentation sounds perfect. It is not simple to follow the different settings over the different pcb versions. Which pcb version do you support? I'm searching for V3.3

@dersparkiie
Copy link

dersparkiie commented May 20, 2020

I would like to use an SP111 V1.1 with ESPEasy.
Which build should I try? These didn't work:
ESP_Easy_mega-20200426_hard_other_POW_ESP8285_1M
ESP_Easy_mega-20200426_hard_SONOFF_POW_4M1M

@TD-er
Copy link
Member

TD-er commented May 21, 2020

@uzi18 Maybe you can help out @dersparkiie with this one?

@dersparkiie
Copy link

No version possible?

@dersparkiie
Copy link

Nothing new?

@Sminter4
Copy link

Hello everyone, I would like to run espeasy on the Gosund SP1 instead of Tasmota.
Unfortunately, the ...ESP8285_1M... does not include the "Energy (AC) - HLW8012/BL0937" plugin.
Can someone recommend me the appropriate BIN?

@uzi18
Copy link
Contributor

uzi18 commented Jan 24, 2022

@dersparkiie @Sminter4 hard_other_POW_ESP8285_1M should be ok for SP1 and SP111
ESP_Easy_mega_20220124_hard_other_POW_ESP8285_1M.bin.zip
unzip it before flash :)

@Sminter4
Copy link

Thank you for your quick response. I tried your file. However, only the P076 plugin is included here. I need the plugin P075 for the chip "BL0937" for the SP1. Is there a bin based on ESP8285_1M that includes plugin P075?

@tonhuisman
Copy link
Contributor

You can use an ESP8266 bin file on the ESP8285, they are compatible.

Plugin P076 supports both the HLW8012 and the BL0937.
Plugin P075 is a Nextion display, I guess you are pointing at Plugin P077 for CSE7766, that should also be included in that 'POW' build.

@Sminter4
Copy link

Sorry my fault. Here is the plugin list: https://espeasy.readthedocs.io/en/latest/Plugin/_Plugin.html
On your bin is only the plugin P077 for CSE7766.
But I need the plugin P076 for HLW8012/BL0937.
I hope you can see the screenshot:
image
I had already tried two ESP8266 bin files on the ESP8285. Unfortunately without success. The SP1 then does not make a WLAN AP.

@tonhuisman
Copy link
Contributor

Ah, now I understand, that plugin is disabled in the LIMIT_BUILD_SIZE check, and all 1M builds are in that 'regime' 😞
I think it needs an exception for the POW builds.

@tonhuisman
Copy link
Contributor

There you go, a POW build that should have P076 included (can't check atm, not at my normal workstation)

ESP_Easy_mega_20220124_hard_other_POW_ESP8285_1M.zip

@Sminter4
Copy link

Many thanks. Your build worked! :-)
Unfortunately, the current display jumps very sharply on most devices. Do you have a tip/rule to reliably calculate the kwh?
Or the consumption per day as in Tasmota.

@tonhuisman
Copy link
Contributor

I didn't re-read this thread, but I think to remember that one of the issues is the unstable readouts, but I don't know how to fix that.

@TD-er
Copy link
Member

TD-er commented Jan 25, 2022

Only thing I can think of right now, is to average the readings over a longer time before sending it out to the task output.

@uzi18
Copy link
Contributor

uzi18 commented Jan 26, 2022

@Sminter4 please show your device config and some data with "spikes"

@chromoxdor
Copy link
Contributor

chromoxdor commented Feb 26, 2022

Many thanks. Your build worked! :-) Unfortunately, the current display jumps very sharply on most devices. Do you have a tip/rule to reliably calculate the kwh? Or the consumption per day as in Tasmota.

I got a couple of gosund sp1 yesterday and i compiled an image from the latest main branch as an custom_esp8266_1m.
it works fine. With my devices there are also rare value spikes. but only voltage and powerfactor. fortunately it doesn’t affect the power reading so it doesn’t matter for calculation of kwh.
i made a quick and dirty rule for kwh:

on power#voltage do
let,1,[var#1]+[power#power]
let,3,[var#3]+[power#power]
if [var#2]%5 = 0
taskvalueset,data,1,[data#kwh_10s]+[var#3]/1800000 //value update every 10s
let,3,0
endif
endon

on Clock#Time=All,**:** do
let,6,[var#6]+[var#1]/1800000
taskvalueset,data,2,[var#6] //value update every minute
let,5,[var#1]/1800000
SendToHTTP,api.thingspeak.com,80,/update?api_key=S1D1Z1WS9VUMFZOU&field1=[var#5]
let,1,0
endon

the "power" task runs every 2 seconds so you need to divide by 1800 (number of runs per hour) and by 1000 (to get kw)...so all in all by 1800000.
Bildschirmfoto 2022-02-26 um 14 03 42

To keep the values:

  • you could send and sum the kwh value every now and then to the level control plugin to store the values in flash (but this must happen not to often because of the limited flashwrite cycles!... in tasmota it is done something like ever 5 or 10 minutes i think)
  • i upload every minute the kwh value to thingspeak and sum every value in a second field:

Bildschirmfoto 2022-02-26 um 14 08 17

therefore you need two apps:
  • create a "React":

    Bildschirmfoto 2022-02-26 um 14 39 44
  • and link it to a Matlab Analysis with following code (maybe there is a better solution for summing up the values but i couldn’t find one so i came up with this...):


% TODO - Replace the [] with channel ID to write data to:
channelID = [yourchannelid];

% TODO - Enter the Write API Key between the '' below:
writeAPIKey = 'yourapikey';


%% Read Data %%
field1 = thingSpeakRead(channelID,'Fields',[1],'NumPoints',1)
field2 = thingSpeakRead(channelID,'Fields',[2],'NumPoints',1)

% thingspeak fails sometimes to run this code and summing NaN values doesn´t work 
% so go back further to get field2 data 
TF = isnan(field2);
if TF
    field2 = thingSpeakRead(channelID,'Fields',[2],'NumPoints',2)
    field2 = field2(1);
end
TF2 = isnan(field2);
if TF2
    field2 = thingSpeakRead(channelID,'Fields',[2],'NumPoints',3)
    field2 = field2(1);
end
TF3 = isnan(field2);
if TF3
    field2 = thingSpeakRead(channelID,'Fields',[2],'NumPoints',4)
    field2 = field2(1);
end
TF4 = isnan(field2);
%% Visualize Data %% 
display(field1);
display(field2);
%pause because of writing limit
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
pause(1);
% if field2 is still NaN it must be the very first value so give it the value of field1
if ~TF4
    kwh_sum = field2 + field1;
    display(kwh_sum);
    thingSpeakWrite(channelID,'Fields',[2],'Values',[kwh_sum], 'WriteKey', writeAPIKey);
else
    thingSpeakWrite(channelID,'Fields',[2],'Values',[field1], 'WriteKey', writeAPIKey);
end

Extra: i will eventually add an option to my dashboard where you can create a tile that displays the last value of a field of thingspeak...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Plugin Related to supported sensors Type: Feature Request Add a completely new feature (e.g. controller/plugin)
Projects
None yet
Development

Successfully merging a pull request may close this issue.