Project: Shelly 1PM with HW patch

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Project: Shelly 1PM with HW patch

#1 Post by Ath » 12 Jul 2020, 22:19

I recently bought me a Shelly 1 PM WiFi switch with the intention of using the Power, Voltage and Current measurements. After receiving the aparatus, I realized I didn't do my due diligence properly, as this specific device doesn't actually support Voltage and Current measuring :o
Luckily, a user of the Tasmota firmware found a way of modifying the hardware, as there are 'merely' 2 connections missing to enable those readings: https://github.com/arendst/Tasmota/issues/5716 and it includes rather detailed instructions on how to patch this.

Yesterday I finally calmed my nerves enough, and my really small soldering tip (0.2 mm) arrived a few days earlier, so I took a stab at it:

The 'doable' wires on the BL0937:
Shelly1PM-3.jpg
Shelly1PM-3.jpg (4.17 MiB) Viewed 21559 times
The 'hard' soldering, directly at the ESP chip:
Shelly1PM-2.jpg
Shelly1PM-2.jpg (3.14 MiB) Viewed 21559 times
And the Shelly put to the scale:
Shelly1PM-1.jpg
Shelly1PM-1.jpg (1.47 MiB) Viewed 21559 times
Next issue is to get all measurements to actually work... the Power is measured, though I had to increase the Power multiplier by a factor of 3.48 to get the correct reading.

This is the configuration I use: (it has the fixes from PR 3166)
Screenshot - 12-07-2020 , 22_18_27.png
Screenshot - 12-07-2020 , 22_18_27.png (31.46 KiB) Viewed 21559 times
Any suggestions are greatly appreciated.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Project: Shelly 1PM with HW patch

#2 Post by TD-er » 13 Jul 2020, 15:34

Are you certain about the correct factor for the power?
As far as I know (have not looked in the source of that plugin), the multipliers are read from the sensor.
Quite often those power measurement chips only output the VA and not the power in Watt.
So they don't take the power factor in mind to calculate the real power and only give the apparent power.

It is best to measure with a pure resistive load, like a heating element.
Modern devices often have some switching power supply and unless those have APFC (Active Power Factor Correction) you will have a lousy power factor and thus a reported power which is way too high.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Project: Shelly 1PM with HW patch

#3 Post by Ath » 18 Jul 2020, 13:52

TD-er wrote: 13 Jul 2020, 15:34 Are you certain about the correct factor for the power?
Well, with a 53 watt 'eco' bulb (halogen) I got a power value of around 180, so I corrected for that. The other values are the sensor defaults.
TD-er wrote: 13 Jul 2020, 15:34 Quite often those power measurement chips only output the VA and not the power in Watt.
So they don't take the power factor in mind to calculate the real power and only give the apparent power.
The reported powerfactor is 100, and according to the plugin source that's a percentage.

I still don't get voltage and current readings, most likely because my micro-soldering skills haven't been good enough :shock: so I'll only be measuring power from this device. Assuming 230V and knowing the powerfactor, it is still usable. Maybe if I buy another Shelly 1PM, I'll try to get that one working, most of this project's fun has been in the journey of trying to get those tiny wires in place without frying the device, and that part succeeded :D


As a side-project I added the Domoticz MQTT helper plugin to the ONLY_SWITCH plugin set, (adding only 444 bytes to the .bin size), to make configuring this device, and other switch-only configs, really easy when using Domoticz, as I used the 'hard_shelly_pow_s' .bin as its firmware, and that does support OTA flashing, as Shelly's are quite hard to get into flash-mode.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Project: Shelly 1PM with HW patch

#4 Post by TD-er » 18 Jul 2020, 14:49

Hmm, is the Shelly bin file not 2M flash prepared?
53 watt 'eco' bulb (halogen)
That one probably has a switching power supply in it, which very likely has a very poor power factor.

If you do have one of those old fashioned light bulbs with a glowing wire in them, then you could try to measure those to see if you get a similar reading compared to the power labelled on the bulb itself.
You can also place one parallel to your own load to see if the reported load will be closer to the expected load.
The glow wire in the light bulb will make the power factor closer to 1, even when you place a switching power supply parallel to it.
For this you may need quite a significant powered old fashioned light bulb as it needs to draw more power then the parallel mounted device with the bad power factor.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Project: Shelly 1PM with HW patch

#5 Post by Ath » 19 Jul 2020, 09:58

I'm pretty confident the bulb doesn't have a switching powersupply, but I don't think it's halogen either, that may be from my imagination, or some text on the box it came in, I can't recall that, and the box went down the paper 'archive'.
It's this closeup:
20200719_095212.jpg
20200719_095212.jpg (1.71 MiB) Viewed 21457 times
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Project: Shelly 1PM with HW patch

#6 Post by TD-er » 19 Jul 2020, 10:23

Yep, that's a halogen bulb, running at 230V, so it is as close to a perfect power factor as you can get.

For this, the unit should have no problem at all measuring its power and thus it is rather strange you need to apply such a big correction factor.
Maybe the Shelly unit uses a different shunt resistor value to measure the current and usually corrects it in its own firmware?

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Project: Shelly 1PM with HW patch

#7 Post by Ath » 19 Jul 2020, 14:37

When looking at the shunt (first photo, above) it most likely has a 1 mOhm resistance, at least the print on R20 can be read as '0.1'. That is also the defined value in the source, and should result in the correct factor. My multimeter isn't accurate enough to effectively measure that kind of resistance... That's why I recalculated it, based on the bulb shown.
I'll connect some thicker wires and hook up some heating equipment, with a much higher load, for validation.
/Ton (PayPal.me)

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Project: Shelly 1PM with HW patch

#8 Post by TD-er » 19 Jul 2020, 19:48

0.1 sounds like 100 mOhm.
Still hard to measure using normal tools.
For those resistances you need a 4-wire measurement.

Using that halogen lamp is a good way to calibrate the sensor.
So having 2 (or more) of them parallel should also be a good check to see if it still shows the correct value.

Don't try to measure high currents with these kind of units.
10A is already more than I would be using on those kind of compact boards.

User avatar
Ath
Normal user
Posts: 3417
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Project: Shelly 1PM with HW patch

#9 Post by Ath » 19 Jul 2020, 20:29

Well, as said, I mostly took up this project to try and apply the hardware 'patch' on the shelly, and even though I still can't measure voltage and current, the original challenge succeeded for most part. Voltage and current would have been 'nice to have', but I can live without it :)

I haven't been able to change the load (only own one of these bulbs..., and no alternative resistive load found yet), it may take a few days before I can report on that.
/Ton (PayPal.me)

edstobi
Normal user
Posts: 39
Joined: 28 May 2020, 20:33

Re: Project: Shelly 1PM with HW patch

#10 Post by edstobi » 18 May 2022, 17:41

Hallo
if I now want to flash a Shelly plus 1pm am I d right with ESP_Easy_Mega_20211105_custom _esp32_4M316?
Thx

TD-er
Core team member
Posts: 8643
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: Project: Shelly 1PM with HW patch

#11 Post by TD-er » 18 May 2022, 18:19

Well for initial flash via serial, you need to flash a bin file with "factory" in the name.
It does seem to use an ESP32, but since I could not find any specs on the site of Shelly, I looked at the Tasmota template site: https://templates.blakadder.com/shelly_plus_1PM.html
It states this node needs a "Solo1" build.
This does sound like it might perhaps have a single core ESP32???
If that's correct, then right now you cannot run ESPEasy on it as I have not yet made a build for single-core ESP32 chips.

Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests