Author Topic: Smart Plugs  (Read 5973 times)

Tim Hall

  • Victoria is my queen
Re: Smart Plugs
« Reply #50 on: 10 May, 2021, 11:29:30 pm »
Resurrecting this thread because I have recently discovered Tasmota.  Open source firmware for myriad internet-of-shit devices that can make them a lot less shitty (speaking MQTT/HTTP locally, without any of that cloud nonsense).
Does the Bold bit mean Jeff Bezos/Sundar Pichai don't get to know when you're turning your kitchen light on? It's all within the Kim & barakta Towers Netjbex?
There are two ways you can get exercise out of a bicycle: you can
"overhaul" it, or you can ride it.  (Jerome K Jerome)

Kim

  • Timelord
Re: Smart Plugs
« Reply #51 on: 10 May, 2021, 11:41:59 pm »
Resurrecting this thread because I have recently discovered Tasmota.  Open source firmware for myriad internet-of-shit devices that can make them a lot less shitty (speaking MQTT/HTTP locally, without any of that cloud nonsense).
Does the Bold bit mean Jeff Bezos/Sundar Pichai don't get to know when you're turning your kitchen light on? It's all within the Kim & barakta Towers Netjbex?

Exactly.  Needless to say I've got all this stuff quarantined on its own VLAN with no access to the outside internet.

To do clever thigns with Tasmota you need a MQTT broker (a simple piece of software that stores and forwards messages between clients).  Sort of thing that's easily run on a Linux server, Raspberry Pi or virtual machine.  And probably some sort of high-level decision-making/user interface stuff.  Don't ask me about that bit, I've just grafted them into my own proprietary system, but I see talk about NodeRed in Tasmota circles.

But, TBH, Tasmota has a lot of useful functionality on its own: Clever timers, event-based rules, sensor thresholds, that sort of thing.  So if you want, say, a light that comes on for 5 minutes when you press the switch and then switches itself off, but only after sunset, you can do that without connecting it to anything[1].  And the HTTP interface is phone-friendly (accessing and resolving it left as an exercise for the reader).  Not that these smart things won't have similar functionality on their stock firmware, but it probably relies on some cloud service at some point.


[1] Well, a time server's probably helpful...

Kim

  • Timelord
Re: Smart Plugs
« Reply #52 on: 15 May, 2021, 12:30:17 am »
Today's adventure in wanky automation was configuring CUPS to tell the smart plug feeding the laserjet to switch on when a job is added to the print queueue.

This is obviously a vast improvement on the previous system of messaging barakta on IRC to tell her to frob the switch...

Kim

  • Timelord
Re: Smart Plugs
« Reply #53 on: 29 September, 2021, 09:18:16 pm »
I've discovered another exciting use for smart plugs:

I fitted one to the microwave so that, like the kettle, the alerting system could provide a visual cue that it had finished (so barakta doesn't unknowingly leave it beeping).  It occurred to me that I could program it to power-cycle at exactly 13:01[1] every day, thereby bodge-synchronising its spectacularly inaccurate clock.   :thumbsup:


[1] For reasons that don't really make sense, the clock is 12-hour and starts from 1:01 at power on.

Re: Smart Plugs
« Reply #54 on: 30 September, 2021, 01:19:59 pm »
Today's adventure in wanky automation was configuring CUPS to tell the smart plug feeding the laserjet to switch on when a job is added to the print queueue.

This is obviously a vast improvement on the previous system of messaging barakta on IRC to tell her to frob the switch...

Ooh I like that one. How much delay did you have to build in before the print job gets sent to allow the printer to boot and dhcp etc? Or does CUPs just keep retrying until the printer comes online?
I think you'll find it's a bit more complicated than that.

Kim

  • Timelord
Re: Smart Plugs
« Reply #55 on: 30 September, 2021, 02:05:58 pm »
Today's adventure in wanky automation was configuring CUPS to tell the smart plug feeding the laserjet to switch on when a job is added to the print queueue.

This is obviously a vast improvement on the previous system of messaging barakta on IRC to tell her to frob the switch...

Ooh I like that one. How much delay did you have to build in before the print job gets sent to allow the printer to boot and dhcp etc? Or does CUPs just keep retrying until the printer comes online?

No delay, I think it just retries for a bit.

tea4CUPS and curl are the special sauce.

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: Smart Plugs
« Reply #56 on: 21 December, 2021, 09:15:02 am »
Warning, very long and picture heavy nerd posts follow.

Soretween's first adventures with Tasmota:

After Kim posted about Tasmotizing a Blitzwolf SHP-11 I ordered a pair.  They sat on the pile of things to be fiddled with until last week as I wanted to monitor the power on our freezer as a) I was sure it was using a lot of power and b) it was about to be replaced.  Following Kim's guide it was dead easy.  I only managed to get the old freezer on it for one full 24 hour period during which time it used 0.743 kWh, the replacement is twice the size and used 0.433kWh it it's first full day of run time.  Neat.

But back up a moment.  It wasn't only the freezer situation that made me extract digit regarding the Blitzwolf, It was also because when I got home from work at the end of November Mrs Tween asked me to help setting up some smart sockets. She wants to be able to control multiple lights together instead of turning each on/off individually.  These are the beasties she'd bought:

Those are Meross MSS210 smart sockets. And here's one with a Blitzwolf:

Hmmm, cheap chinese copies?  Nah, couldn't be.  2 minutes looking at the crapola software on Mrs Tweens phone and 5 minutes trying to find online if they work direct (phone to gadget) or through somebody else's computer (I needed to know as they'd be on different VPNs depending) and I'd had enough, they'd be jailbroken or binned.

So that was the point at which I Tasmotaized a Blitzwolf to learn the process.  Next I spudgered my way into one Meross.  Exactly as expected I found what I initially thought was the same PCB with the power monitoring devices unpopulated (Blitzwolf on the right):

But flipping the PCB over It becomes obvious the ESP8266 riser is not exactly the same:

Actually, it's not an ESP8266 at all in the Meross:


Ah well - RTL8710 must be effectively the same thing mustn't it?  So supported by Tasmota - yes?  No.
Quote
Tuya Convert

Tuya devices are sold under numerous brand names but they're all identifiable by the fact that they connect with these phone apps: "Smart Life" or "Tuya Smart". They incorporate different types of Tuya Wi-Fi modules internally.
Tuya has begun manufacturing some Wi-Fi modules using a Realtek RTL8710BN Wi-Fi SOC instead of an ESP82xx chip.
Tasmota cannot run on Realtek devices and there are no plans on supporting them.
The RTL devices are cheaper and being Arm based lower power apparantly.

Bum. So I'm snookered?  Nah :-)
2020 targets: None
There is only one infinite resource in this universe; human stupidity.

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: Smart Plugs
« Reply #57 on: 21 December, 2021, 09:35:34 am »
I happened to have some WeMos  D1 mini in stock:

That's an ESP 8266 module (the dark PCB) on a carrier board that provides a USB socket for programming (just visible at the bottom).  Far too big to fit in as is but if I can get the ESP off the carrier... Tasmota went straight on it with a default template and I checked it was visible on the network when powered from 5v from a bench psu.  Then began the difficult job of desoldering the ESP from the carrier.  And that did not go at all to plan.
First attempt I used too much force & ripped a load of pads off both the esp board and the ex-carrier (heat from a paint stripper gun).  I was too worried about overheating it.  2nd attempt went better, all the esp board pads were fine and I only damaged 3 pads off the carrier (no matter).  So I carefully connected it to my bench PSU to see if it had survived.  I don't actually know if it did because it sure as hell didn't survive me switching on the PSU still set to 5V the carrier needs instead of 3.3v the ESP needs. Bum.

New plan needed:  The back of the dead ESP boards were marked with ESP-12-F.  Since I need 4 and I'm down to 2 WeMos left I may as well cut out the hassle,  South American River Co provided 5 ESP-12F for £13.99 next day.  This is the pinout of the ESP-12F from the manual:

The pinout is not exactly the same as the WeMos carrier above.  GPIO15 (yellow wire) isn't a straight connection and EN on the ESP-12F isn't brought out to a pin on the carrier at all.  Since that pad was one of the 3 I'd ripped off the 2nd desoldering attempt I had to trace it back (Blue wire). 


At which point things got really frustrating, it just wouldn't work.  I checked and re-checked the documentation and my soldering and still Tasmotizer just wouldn't connect to program the little sod.  It turned out to be a combination of 2 problems.  Lead free solder (the work of Stan) on the carrier board giving me dry joints, in particular the blue wire to the resistor.  How can a mechanically sound joint made entirely of solder not conduct?  Grr.  2nd, it took a few resets to get Tasmotizer to connect.  With a D1 mini you just plug it in to USB & they wake in programming mode every time.  With the wires between the carrier & ESP12F it took a good few resets with Tasmotizer attempting connection to get it to work.
Once programmed I powered the carrier from the bench psu to confirm it was working & desoldered it from the spiders web.  Then I could start figuring out how to connect it to the Meross.  These are the connections viewed on the underside of the Meross PCB:
Code: [Select]
     Relay |
            |
HWLBL SELi |
            |
           |
            | LED
  Button 1 |
            | BL0937 CF
       GND |
            | HLWBL CFi
       VCC |
So the 12F needs connecting like this.  Connections in brackets are shown for completeness, I don't need them as this PCB doesn't have the power monitoring:
Code: [Select]
    GPIO15 |
            |
  (GPIO03) |
            |
           |
            | GPIO00
    GPIO13 |
            | (GPIO05)
       GND |
            | (GPIO14)
       VCC |
There's no connection for RST and EN.  Those are handled on the riser board, see the 3 little resistors down the bottom (Blitzwolf socket so this is an ESP riser)


So a certain amount of creative bodgery will be required:



And fitted:




And so remembering to adjust and then double check the voltage I ran it off the bench PSU and lo, it was visible on the network.  I blatted Kim's Blitzwolf Template onto it and soldered it back into the socket.  And blow me it works :-)
It is of course spouting garbage related to the power monitoring over mqtt but I'll get to that.  First I need to just rinse and repeat 3 more times.
2020 targets: None
There is only one infinite resource in this universe; human stupidity.

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: Smart Plugs
« Reply #58 on: 21 December, 2021, 10:06:36 am »
Yeah, 'just' repeat 3 more times ::-)  That spiders web fought me every step of the way.  RST was a dry joint when I soldered the 2nd into the programming web, those wires are tinned with lead free.  The 3rd crapped out mid programming (blue light on) and never worked again.  The 4th was just dodgy, there was a bad connection there somewhere but I couldn't find it.  The 5th would not program at all.  Eventually I figured out the resistor I was soldering the blue wire to had cracked (failed open circuit) & replaced it with an external one.  After a good few frustrating hours over a few days I had 3 more ESP-12F programmed with the default template ready to fit.
If ever I need to do some more I will 3D print a pogo pin adapter:

I also Tasmotized the 2nd Blitzwolf and (stupidly, without testing it) refitted it to the socket.  Nuffink.  So I had to remove it again and reconnect to Tasmotizer.  Where it works fine.  Try as I might I cannot get it to work in run mode (powering the Blitzwolf PCB).  More frustration.

Fitting the 3 ESPs to the three remaining Meross was straight forward.  Then I just needed a template:
Code: [Select]
{"NAME":"Mehross MSS210","GPIO":[320,0,0,0,0,0,0,0,0,32,0,224,0,0],"FLAG":0,"BASE":18}
I still need to fix the 2nd Blitzwolf.  I'll have one more go at fixing the fitted ESP module and if that fails I'll put an ESP-12F into it instead.  I have a feeling though the 3 extra connections and the non-staggered PCB pads will make that difficult.
2020 targets: None
There is only one infinite resource in this universe; human stupidity.

Kim

  • Timelord
Re: Smart Plugs
« Reply #59 on: 21 December, 2021, 12:17:47 pm »
Nice bodging.  I replaced the ESP module in an old 'open source' smart bulb that never worked properly, which made it behave.  I think sometimes you do just get dodgy modules.  I've got a D1 Mini that's weirdly fussy about what WiFi networks it will connect to, using firmware that works fine on other modules.


New favourite smart plug: https://templates.blakadder.com/athom_PG04-UK16A.html

Functionally equivalent to the Blitzwolf, but pre-flashed with Tasmota, so no mucking about to get access to the serial pins, calibrating the power monitoring, etc.  Button on the top rather than the side, which is more convenient in most socket scenarios.  Only the single (blue) blinkenlight though.  Overall slightly smaller.

(I was shocked to discover a proper Bussmann BS1363 fuse inside.)

Other Athom products with Tasmota pre-flashed are available.  I've got a couple of their smart bulbs.  The warm-white's a bit meh, but (after installing a custom Tasmota build that allows PWM at 20kHz for barakta-compliance) it's fine for the stairs.

SoreTween

  • Most of me survived the Pennine Bridleway.
Re: Smart Plugs
« Reply #60 on: 21 December, 2021, 01:53:59 pm »
Thanks.  Calibration is still to be done, those power readings above should be treated as comparative rather than reliable.

Tasmota Device Groups are really jolly neat, getting the 4 Meross to turn on and off together was ridiculously simple.
2020 targets: None
There is only one infinite resource in this universe; human stupidity.