Reliable Embedded CPU - Page 1
Forum section: electronics / general

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 05:36:28 am
content: I have an AC power switch to control various devices and would like to use a few more, but they seem to be other than 100% reliable. The one I'm using does on occasion seem to lose it's clock setting or something, so that it mucks up the times it's supposed to turn on and off. The UI is not bad, but it gives no visibility into figuring out what might be wrong. So I'm thinking of rolling my own.I would prefer to use an off the shelf device like an rPi or ESPxxxx or similar, but I have no idea how robust they are. I don't want to jump from the frying pan into the fire. Anyone have enough experience to say which embedded unit with wifi would be reliable enough to run for a year or two without getting bollixed up? It doesn't need a battery backup, but does need some form of non-volatile storage for the settings. I guess I would be concerned about an SD card being messed up on power failures.The nice thing about the power switch I'm using is the power measurement, although I've never measured the accuracy of it. I've got a Fluke power meter. I should calibrate it sometime. I might take it apart to check out the design.

author: brucehoult
author_rank: Super Contributor
timestamp: April 27, 2021, 12:36:11 pm
content: I don't understand what you're asking for.A Raspberry Pi is not a power switch.What do you need WIFI for? I don't think I'd trust any WIFI or BlueTooth stack to be bug-free. Ethernet, maybe.If you need reliable then the simpler the better.Reliability can to some extent be increased by a regular program of rebooting or, better, power cycling.The hardware is almost never the problem.

author: oPossum
author_rank: Super Contributor
timestamp: April 27, 2021, 12:39:22 pm
content: https://sonoff.tech/

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 02:26:49 pm
content: Quote from: brucehoult on April 27, 2021, 12:36:11 pmYes, I don't expect the hardware is the problem, but that is not certain. A device that plugs into a wall outlet must be tolerant of power spikes as well as simply working 100%. There's no small percentage of low cost, embedded devices that simply don't stay running any better than a Windows 95 computer simply because the hardware is not 100%.This is the sort of thing I'm looking to replace.https://www.amazon.com/s?i=tools&k=Wi-Fi%20Smart%20Plug&ref=nb_sb_noss_2&url=search-alias%3Dtools

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 02:27:31 pm
content: Quote from: oPossum on April 27, 2021, 12:39:22 pmInteresting. I wasn't looking to hard wire it in, but that's an option.

author: langwadt
author_rank: Super Contributor
timestamp: April 27, 2021, 02:32:37 pm
content: Quote from: gnuarm on April 27, 2021, 02:27:31 pmthey also have plugs,https://sonoff.tech/product/smart-plug/s31-s31lite/very cheap and they use an ESP so you can do your own software if you feel adventurous

author: oPossum
author_rank: Super Contributor
timestamp: April 27, 2021, 02:33:35 pm
content: Quote from: gnuarm on April 27, 2021, 02:27:31 pmThey have "smart plug" type products. I can't provide a direct link due to the poor design of their web site.

author: PlainName
author_rank: Super Contributor
timestamp: April 27, 2021, 03:49:38 pm
content: The control you have, if it's a cloudy smart switch, is likely OK and the problem is elsewhere. We have quite a few of these and they would sometimes fail by falling offline, but over time the firmware updates fixed those and they are not all reliable. We did have some timer issues, but I worked out that they were either user errors (mostly down to not-quite-intuitive user interface) or cloud issues (although these are pretty rare now, providing the intertubes is working).I would suggest going for the Sonoff smart plugs , like the S26(at Amazon)which you can use the ewelink app to control. The useful thing is that if the cloud connection drops you can still control this via the LAN, albeit only to turn on and off rather than set timers.However, for your requirements you can go further and replace the firmware so you can then tie the sockets into OpenHAB and similar. They are ESP based, so feasibly it is reasonably trivial to write your own firmware and program however the hell you like if the whim takes you.The Sonoffs are proven designs and would save you making your own mistakes en route to a reliable switch, plus have all the awkward parts already done (like the housing, plug prongs, etc).

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 04:00:45 pm
content: Quote from: langwadt on April 27, 2021, 02:32:37 pmI've ordered a couple of the S31 with the energy measuring feature. We'll see how good they are. My Ankuoo unit seems to be working... opps, "unit has been reset and is no longer under control". That's the sort of crap I'm talking about.

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 04:02:04 pm
content: Quote from: oPossum on April 27, 2021, 02:33:35 pmYeah, if you think that's a bad one, try using the Tesla site to find any info. It's all color glossies like ads in a magazine. I'm sure there's fine print somewhere.

author: ralphrmartin
author_rank: Frequent Contributor
timestamp: April 27, 2021, 05:48:56 pm
content: You can always install the open source Tasmota firmware on the sonoff devices, so you are not reliant on their cloud.https://tasmota.github.io/docs/

author: gnuarm
author_rank: Super Contributor
timestamp: April 27, 2021, 06:33:59 pm
content: One of the things I'd like to do down the road is to add a relay to control a 240V device such as a water heater or an EV. I have ToU billing on my electric and the Tesla can't deal with the concept properly. They claim to have an awareness of ToU, but it is very, very limited and doesn't work as you would expect. Very odd for such a high tech company to be so lame when it comes to this issue. In the Tesla forums they say it may suck, but it sucks less than other EVs. lol!

author: brucehoult
author_rank: Super Contributor
timestamp: April 28, 2021, 12:15:32 am
content: Quote from: gnuarm on April 27, 2021, 06:33:59 pmAbout ten years ago I used some of these remote control 240V outlets to control my hot water heater, 2400W oil column heater, and a great big fan directed at the heater.https://www.jaycar.co.nz/remote-controlled-3-outlet-mains-controller/p/MS6147I used an Arduino Uno to schedule and control it all, and run PID control for the heater (using a thermistor on a shield daughterboard I made myself). With 100x a second analogRead() and exponential averaging with a few second time constant I got very smooth and reliable temperature sensing to 0.01 C resolution. I was able to make any reasonable temperature change (up to a couple of degrees C) in the room in about 20 minutes (twice the thermal constant of the heater) accurately and without significant overshoot. I was just turning the heater on and off on a 30 second interval.These outlets are controlled on 433 MHz. It's one-way and sometimes (about once a day) there would be radio noise at the same moment so the command will be missed. I just sent the command for the current desired state every 30 seconds so if one was missed it was no big deal. Not receiving two commands in a row was extremely rare.At first I hacked the supplied remote to fake pressing the buttons, but after a couple of months I reversed engineered the protocol and switched to using a $3 433 MHz transmitter board from dealextreme, which I added to my protoboard.I used this system every winter for four or five years until I moved from NZ to Moscow. My winter heating bill went down NZ$500 compared to my previous controlling the heater with a Honeywell mechanical thermostat AND the comfort level improved a lot because I was getting 0.05 C temperature swings (up to 0.2 C with a big transient such as starting cooking or stopping cooking in the same open-plan area), instead of 2 C with the Honeywell.The Honeywell itself had been a huge improvement, 15 years earlier, over manual control of the heater, or using a heater's built in thermostat.Sigh. And in the rented house I'm in since June, temperature control is adding another log to the wood fire, or not, or stirring what's already in it. Electricity now (at least in this remote region) is 40 c/kWh, vs 18-20 c/kWh in Wellington in 2010-2015 before I went overseas for five years. And there is an abundance of cheap firewood.

author: gnuarm
author_rank: Super Contributor
timestamp: April 28, 2021, 03:09:26 am
content: Interesting, but that device is only rated for 10 amps and my water heater circuit breaker is 30 amps and the present heater (30 years old) has been measured at 18 amps. Ideally it would be a 50 amp device so that it could be connected to control any device in the panel. That's why I'm thinking a home brew device at one level or another, would be good. 50 amp relays are a lot more money than 30 amp units for some reason. That's probably why it's hard to find higher current switches. But I can always find a relay.Did your Arduino keep good time? How did you deal with power fluctuations? Did you need to reset the clock on power glitches and outages?

author: brucehoult
author_rank: Super Contributor
timestamp: April 28, 2021, 01:42:43 pm
content: Quote from: gnuarm on April 28, 2021, 03:09:26 amPower outages or glitches are *extremely* rare in the city in NZ, certainly anywhere with underground cables. Much much better than I experienced when I lived in California.The Arduino kept as good time as a typical digital watch once I checked how many seconds a day it was gaining or losing and put in compensation. Probably it would vary with temperature, but the whole purpose of the device was to maintain a steady temperature in the room, so ...

author: gnuarm
author_rank: Super Contributor
timestamp: April 28, 2021, 04:08:30 pm
content: Power glitches may be minimal for you, but that's not true for people in general. Once the unit is power cycled and on some regular period the device has to set the time to stay accurate. Even my PC reaches out over the Internet to set it's clock. Without that (as well as cleanly recovering from power issues, the short ones can be the worst) any sort of timing device requires manual setting which is what I want to avoid.

author: ralphrmartin
author_rank: Frequent Contributor
timestamp: April 28, 2021, 05:23:56 pm
content: One issue with sonoff's own software is it is not aware of summer time, which was my initial motivation for reflashing with Tasmota.There are various tasmota options for how to set set state after a power up.

author: Doctorandus_P
author_rank: Super Contributor
timestamp: April 29, 2021, 04:51:42 pm
content: I would also go with the SonOff switches for relatively low power stuff, and re-flash the ESP8266 with custom firmware, as there is no chance I will let such a firm on my WiFi. (I would also set up a separate Wifi Network just for controlling stuff like this. Maybe I'm paranoid).Swiches like the SonOff S20 are very cheap compared to what they do, and they also have a nice enclosure for that little money.But for 30A loads that get switched often I would not call them suitable, and would use bigger relays or contactors, and probably also a power supply with extra filtering to improve reliability near switching such high loads.

author: gnuarm
author_rank: Super Contributor
timestamp: April 30, 2021, 02:26:08 am
content: Quote from: ralphrmartin on April 28, 2021, 05:23:56 pmYeah, it would seem to be simple to set times, but time actually has many confusion factors. Summer time is just one. I am looking at moving to Puerto Rico which is an hour east of where I am now. However, while we are on summer time since Puerto Rico does not do that, we are the same time. Huzzah!I think it may have been the summer time change here that whacked out my Ankuoo. Seems to be working now. Maybe it was me. I have 8 months before I deal with that again.

author: gnuarm
author_rank: Super Contributor
timestamp: April 30, 2021, 02:35:10 am
content: Quote from: Doctorandus_P on April 29, 2021, 04:51:42 pmI didn't see any SonOff that are rated for 30 amps, so yeah, a relay is required. But I don't know what you mean about "a power supply...". These devices use 120 VAC or 240VAC. What power supply???I do wish they had a selection guide rather than just pictures and names. I hate browsing web pages that are just glossy ads with minimal information content.

author: PlainName
author_rank: Super Contributor
timestamp: April 30, 2021, 12:45:47 pm
content: QuoteGot to the bottom of this page (right at the bottom) and there's a table of them all saying what they do:https://www.itead.cc/sonoff-sv.htmlI think that table is attached to all the Sonoff pages at Itead; the one I post is just a random one I dropped on.

author: gnuarm
author_rank: Super Contributor
timestamp: April 30, 2021, 02:56:33 pm
content: Quote from: dunkemhigh on April 30, 2021, 12:45:47 pmThanks, that is very useful. They have R2 versions of some devices which seem to add more software features. I wonder why they still sell the lesser versions? In the case of the Sonoff Pow the R2 version is also much smaller, so maybe the specs are not so accurate.I've ordered a couple of the S31 smart plugs to start playing with. I don't have any time to muck with this stuff at the moment, but we'll see how it goes.

author: gnuarm
author_rank: Super Contributor
timestamp: May 15, 2021, 06:10:56 am
content: I bought a couple of the Sonoff switched outlets that measure the power consumption and I am not at all impressed with the user interface. The Ankuoo interface is better and it's not all that great.I guess I'll work on installing the open source stuff.

author: james_s
author_rank: Super Contributor
timestamp: May 15, 2021, 06:31:03 am
content: I have dozens of Sonoff devices, they're quite good and have been reliable so far. I never even tried the stock firmware though so I can't comment on that, it requires their cloud backend to do anything so I opened my devices up and flashed them with Tasmota prior to even plugging them in. Tasmota is fantastic, there are several other options too.

author: james_s
author_rank: Super Contributor
timestamp: May 15, 2021, 06:35:25 am
content: Quote from: gnuarm on April 28, 2021, 03:09:26 amUse a Sonoff Basic to control a contactor, then you can control as big a load as you want, limited only by the rating of the contactor you select. Furnace contactors are relatively cheap and readily available, they're used for controlling the heating elements in electric furnaces and can be had with 240VAC coils.

author: Alti
author_rank: Frequent Contributor
timestamp: May 15, 2021, 09:48:09 am
content: Quote from: gnuarm on April 27, 2021, 06:33:59 pmThis is all fine as long as you do not trade safety for convenience. Just be aware that this thing might come on or off and on again at any time. If this leads to inconvenience and the EV is damaged by thousands of on/off commands during one night then that is ok. But if someone unaware approaches an appliance that can unexpectedly turn on by itself, make sure this is not endangering anyone first.

author: gnuarm
author_rank: Super Contributor
timestamp: May 15, 2021, 02:29:49 pm
content: Quote from: james_s on May 15, 2021, 06:35:25 amYes, that's why I was talking about a relay. Contactor is another name for a relay.My concern is the utility of the software. So I guess I'll have to play with the Tasmota software.

author: james_s
author_rank: Super Contributor
timestamp: May 15, 2021, 06:29:10 pm
content: A contactor is a specific type of relay, with large heavy duty contacts designed for repeated switching of large loads. I know from experience that the small cube relays used in the Sonoff devices do not last long if you try to use them to control higher powered loads. Especially reactive loads, they may be rated for 10A but if you look up the datasheet for a 10A relay, it's probably less than 1A switching an inductive load.

author: gnuarm
author_rank: Super Contributor
timestamp: May 15, 2021, 06:42:12 pm
content: Quote from: james_s on May 15, 2021, 06:29:10 pm"Probably"So you have not looked? The only issue with switching an inductive load is the need for snubbing. Water heaters are not very inductive and EVs are also not very inductive. A relay is a relay. They are called "contactors" out of habit much like the old timers call capacitors "condensers" and use μμF. Condenser is still the term used for the capacitor across points in auto ignitions.The term contactor is used in the power industry for high power handling relays. What is important is the spec on the relay ADDED to the Sonoff, not the relay inside the Sonoff. BTW, the relay inside the S31 is 15A, same as the rating on the electrical circuit as a whole.

author: james_s
author_rank: Super Contributor
timestamp: May 15, 2021, 10:17:26 pm
content: Quote from: gnuarm on May 15, 2021, 06:42:12 pmI did look, I investigated quite thoroughly after trying to use a Sonoff Pow to control power to my air compressor, it worked great for about a week and then burned up the relay (and melted the terminals where the wires connect) despite being rated for 16A and the compressor draws only 10A. I said "probably" because I don't remember the precise value which varies a bit from one relay to another and can't be bothered to look it up again. Snubbing does not solve the problem of inrush current, LRA on an electric motor can be 5x-10x the rated current and transformers and other inductive loads draw a significant surge as well. I bought a 30A furnace contactor on ebay for around 10 bucks and that does the job.Water heaters, yes they're as close to an ideal resistive load as you're going to find. EVs I assume are power factor corrected. Still it's worth being aware that inexpensive devices like the Sonoff switches are probably rated in Chinese amps, ie take the printed specs with a grain of salt, personally I would not expect them to hold up to more than about half the rated load long term, but used with this in mind they work really well.

author: gnuarm
author_rank: Super Contributor
timestamp: May 15, 2021, 10:45:53 pm
content: Quote from: james_s on May 15, 2021, 10:17:26 pmThere's not much in low price devices that isn't designed and made in China. I've been using an Ankuoo switch for some years now to control the times my EV charges with no signs of wear with 12 amp loads. There aren't many devices that are permitted to draw more than 12 amps from a 15 amp circuit. Most devices have to be derated to 80% of the circuit capacity.Part of the reason I want a timer to control a relay driving the load is to use it with 240V higher current loads like the water heater and a 240V connection to the EV. Charging a car on a US 120V outlet suffices for many needs, but only 95% of the time. Other times you want a faster charge so it is fully up in the morning after coming home with a low state of charge the night before. Even a 40 amp circuit at 240V will bring an EV up to full charge overnight.As to your relay problem, the start up current is not a big deal as it is over quickly. Current is a thermal issue that has to be present for some time to damage the contacts. Opening the contacts interrupts the current flow resulting in a very high kickback voltage from the motor inductance with a substantial arc across the contacts. This is very damaging and will burn out the relay contacts regardless of the rating, it just takes a bit longer. Electric motors are typically not snubbed and so the relay contacts suffer the full brunt. Add a snubber and your relays will hold up much better.

author: PlainName
author_rank: Super Contributor
timestamp: May 15, 2021, 11:10:32 pm
content: QuoteOne trick I have heard of is to put a MOSFET in parallel with the relay contacts. If the MOSFET is turned on first and switched off last, it deals with the contacts arcing whilst the relay deals with the current.

author: james_s
author_rank: Super Contributor
timestamp: May 15, 2021, 11:32:07 pm
content: Quote from: gnuarm on May 15, 2021, 10:45:53 pmThe only EV I've ever charged myself was a Tesla and it had the ability to have the charging scheduled and the current could be set to anything up to the maximum 32A supported by the included home charging cable depending on the plug adapter that was connected. Do others not have the ability to schedule or manually control charging?In my case the relay was never opened while the motor was running, the existing pressure switch on the compressor did that. What I have is a Sonoff controlling the power so I can turn it on from in the house and let the compressor charge up before I go out to the garage to use it, it's normally empty when I switch it on due to slow leaks at some connectors so the motor starts up as soon as the relay contacts close, then when I shut it off the tank is normally full and the motor has already stopped running. Like I said, these Sonoff things are fine, I have loads of them controlling various things but don't expect them to survive being used at the full rated current printed on them.

author: gnuarm
author_rank: Super Contributor
timestamp: May 16, 2021, 12:59:02 am
content: Quote from: james_s on May 15, 2021, 11:32:07 pmThe Tesla control over charging times is extremely crude and not suitable for my situation. I'm not sure why you mention the current level. My car has the ability to charge at up to 72 amps from an appropriate connector. What it can not do is charge only at the times of my off peak electric rates.QuoteI suppose they are not really capable of their rating then. The Ankuoo I use has worked fine for a couple of years now, other than it glitching the program settings eventually. Which model Sonoff did you have? They have different ratings, so they don't all use the same relay.

author: gnuarm
author_rank: Super Contributor
timestamp: May 16, 2021, 01:14:47 am
content: Quote from: dunkemhigh on May 15, 2021, 11:10:32 pmOne of the issues of charging an EV at high rates is to not overload the main feed to the house if you use truly high currents and other appliances are on at the same time. In the US 200 amp feeds to the house are common, but that can disappear when the hot water heater comes on, the stove is on, the clothes dryer is on, the furnace is on and potentially others along with a 40 or 50 amp feed to the EV. So I have thought of wiring the EV outlet with an A/B switch to allow a single circuit to be shared with another load such as a hot tub that is not essential (not that I have a hot tub, lol). I'd like this A/B switch to be controlled like one of the Sonoff switches.My original thinking in starting this thread was to use an embedded CPU with wifi to roll my own. Maybe I should check out the Tasmota software to see what it is designed to work on. I looked into some open source software once that was intended to simply control various existing devices like the Ankuoo, but trying to learn how it worked was such a chore I gave up. Very convoluted.

author: alepape
author_rank: Newbie
timestamp: September 19, 2022, 02:42:27 pm
content: Quote from: gnuarm on April 27, 2021, 06:33:59 pmwould you happen to have the protocol documented somewhere? trying to use my raspberry pi to do the same...

author: brucehoult
author_rank: Super Contributor
timestamp: September 20, 2022, 09:21:25 am
content: Quote from: alepape on September 19, 2022, 02:42:27 pmThat's gnuarm quoting *me*.I might have, but in the eight years since I last used that I've lived in eight houses or apartments in four countries.

author: brucehoult
author_rank: Super Contributor
timestamp: September 20, 2022, 09:36:16 am
content: Quote from: brucehoult on September 20, 2022, 09:21:25 amI can't immediately find my updated code to do the 433 MHz control directly, only the remote control hacking version, but I found some stuff I got ideas from:https://hoult.org/2262_datasheet.pdfhttps://hoult.org/SC2262_emulator.cppOne thing I had to do, in addition to that documentation, was trace how the remote's buttons were connected to the chip, and also I think some pins tied hi or lo to make the codes transmitted different from other similar remotes.