This results in a safe, reliable and simple monitoring system.
On a related note, as to microcontroller choices: having done quite a bit of work with MSP430 and various NXP Kinetis chips, I am very, very tired of crappy software engineering practices, monstrous IDEs which are all a reworked version of Eclipse, bad libraries and frameworks which change direction seemingly every month. So I decided to stick with the Nordic Semiconductor chips (mostly nRF52832 and 52840 these days). Yes, they are more expensive per chip. But I don't use hundreds of them, and the savings in my time are huge: their SDKs are nice, you don't have to use their IDEs, you can stick to gcc and Makefiles, and it's overall a decent experience.
In general, while I really like the article series, I don't think the price of a microcontroller matters much in hobby usage. It's very important in commercial designs, but at home where you will never use more than 10 — who cares? It's the overall development experience that matters.
There are some little tools that make this easy: https://github.com/bemasher/rtlamr
You'll need to do a little detective work to separate yours out from the neighbors' but it's not hard.
For my house, I can also read water usage and natural gas the same way by alternating through the relevant frequencies.
Power monitoring involves converting the mains voltage to DC that is almost proportional to the mains voltage. Then you would rectify it and downsize it and get it to a voltage level that whatever power management IC you use can accept. You also need to include fuses and other safety circuitry to ensure it doesn't exceed that threshold your microcontroller can accept. For example, if my uC works based off just 5 volts, I want to make sure I downsize my 120VAC to just 2.5V but still proportional, this means, when there is a spike, my uC can take a hit upto 5 volts, but that means my actual power supply has a spike of 100%, which means I'm getting 240VAC on a 120VAC outlet (which has never happened so far).
Then, for the actual turning on or off of switches itself, I just use relays and some relay/motor coil ICs to control them. Sorry I don't remember exactly as this was a year ago and this system is lying inside my wall. So I need to remove the switchboard (and use a lens) to find out the numbers. But then, you can always google for "Power management / mains voltage IC", you can find even ready made modules on eBay.
The tricky part is component layout since you are dealing with high voltage, it can form arcs: https://www.youtube.com/watch?v=MAlyEMQxTN0
Not as powerful, but still a smaller version of those arcs. So, you want to use well rated components with decent thresholds. Eg. Don't use a low power relay, cheap capacitors, etc.
All of this is then passed on through uCs(ATTINY 85 + other uCs in the circuit) to some nrF wireless modules I bought in bulk on AliBaba through my uC
To be clear, each switchboard housing contains - a couple of relays, uCs, nRF modules, temperature and humidity sensors and some infrared sensors (I don't use them anymore). I believe they also have overvoltage protection and short circuit protection in built (because of an IC I use). It will simply turn the relay off in the event of a spike or short circuit.
BTW, AliBaba is the cheapest. Don't buy from AliExpress, it's usually plagued with dropshippers (god, I hate them so much) who just keep hefty margins off a factory somewhere that you can find on AliBaba. Other alternatives, but still under AliBaba group: 1688.com, tmall.com
If you think about it, in cloud lingo, we would call this architecture as "micro services" except that there's one big monolith which is my mains module run by an old laptop motherboard. (Sony Vaio FZ series)
This nrF module talks to a an old laptop motherboard through serial, that passes information to a REST API. This laptop motherboard is located where usually all the mains connections go in. One thing I didn't use on purpose is smart trippers/circuit breakers. Sure, they're smart, but you're relying on someone else for security while also giving away your power usage consumption data. Besides, if a circuit breaker goes off, you want to know why it happened before turning it on, so I find it pointless to make them be able to turn on automatically or from your phone when I can just walk to my mains box and turn it on myself.
The REST API is built with Phoenix/Elixir, and is hosted on Google Cloud AppEngine. I haven't had any downtime so far (yet) and is blazing fast. Like I said, I'm a Google Cloud consultant, so this is what I do for a living. You may have luck doing the same with AWS/DigitalOcean. Just use something you know well.
And don't ever get into doing devops for this kind of thing. It's more critical than you think. So, don't make choices like try to save up on the servers by running your own instance on a DO droplet for 5 bucks a month. Sure, you saved up some cash, but the devops it takes you will cost you more. More importantly, if some hacker gets in, you're doomed!
Once, when I was in my house, the lights and TV suddenly started turning on and off in the hall room. This was right after I came back from watching Insidious and it was really scary. Then I found out, it happened because there was a really fat mouse on the motherboard (don't know how it got there) walking around the jumper wires. Haha!
Hope this helps, sorry I will try to update with specifics maybe in a separate blog post here.
I'd say you need to include other safety circuitry, as well as proper PCB design, to make sure it doesn't start a fire.
If you don't know what you're doing, don't rely on random stuff from AliExpress etc to be grid safe, and don't try to make stuff that connects to the grid yourself.
If you do not know what you're doing, for stuff like this I'd go with say Fibaro Z-Wave stuff or similar devices which have built-in power monitors, and can interface with Home Assistant or similar.
[1] https://www.yoctopuce.com/EN/products/category/usb-electrica...
Having said that, you can always buy "modules" from Siemens, Honeywell, etc. Get your circuits audited by someone with more experience, in particular by an experienced electrical engineer before using it live.
Have multiple levels of fail-safe, fuses, fire retardant casings, what not. Just think of every possible worse-case scenario before you do it.
After all, electricity is no joke and can literally kill you.
MEE hobbyists, disregard.
I won't touch electrical on my house and will happily contract it out to a license+bonded electrician for the exact same reason.
That said really cool project and Kudos for tacking it, just make sure your smoke detector is working :).
Even theoretically, the only way a relay could catch fire if the coil inside overheats or if you pass very high voltages to the coil. But, with a well designed circuit, it should be fine.
I'd be curious of how do you update these devices, did you get OTA to work through an nRF24? did you need some external eeprom for that?
I'm just curious how your homeowner's insurance feels about this? That is, will they still pay out for a claim should something happen, and they determine your modifications were at fault?
Because if the adjuster or whomever does find you have such modifications - they -will- blame those.
And probably deny your claim and coverage (and probably cancel your policy).
At least that would likely be your experience if you live in the United States.
I've often thought that having such a system would be fun, but the potential downside should anything go wrong has put a damper on it (even if whatever happened was not related to your modifications - they will blame it on them, just to get out of the claim).
The only "inexpensive" way around it is to use UL listed interfaces made by a third party, then interface with those. But there, you don't usually get everything you want.
Of course at that point, the insurance company might just shift the burden on you to "So, did you have this done by a licensed electrician? Where is your inspection report?"...
- Will the board short if it happens to collect moisture, oil, dust, or lint? What if a bug is attracted to it? Will I even monitor the condition of the board?
- Will the traces and relays heat up if I accidentally draw too much current through them? Will they degrade over time?
- Is there a chance that vibration could loosen the board and make unintentional connections?
I decided I probably could never answer these questions well enough to satisfy an insurance company. It doesn't matter that I have plenty of experience with line voltage; what matters is that I am not a licensed electrician. Therefore, at home, I only experiment with low voltage and low current, delegating all line voltage to UL listed devices.
A toy, in other words. It might be good enough to get a rough idea what eats more or less and when, but it'll never match the utility power meter which is what you're paying by.
cdrc: I rewire my houses myself, because those licensed loons can't be trusted with a 12V light bulb. At least that way _I_ am sure it won't blow up or burn or whatever.
Still, inductive current measurement with the sizes of the clamps they show and typical currents they're measuring isn't accurate at all. Not even considering that voltage measuremens via a wall wart would depend on what load is currently sharing the same wiring.
This might be my bias since I design similar stuff for solar offgrid, where a percent or ten off are that much in capex divided by battery lifetime, then multiplied by battery cost. It bites.
I don't trust inductive clamps at low currents. I would never trust measuring voltage on the same line as a load.
Hall sensors or current shunts; voltage dividers - all driving MCU ADC channels via optoisolated opamps. Everything measured as near to the source as possible. Otherwise you're getting nearly worthless data.
That's actually not correct. Clamps / current transformers are totally fine.
The flip side of that is the risk of a geek installing a power monitor without permits pales in comparison to someone plugging a 1500 Watt wall heater an an ancient wall outlet.
And probably deny your claim and coverage (and probably cancel your policy)."
I'm skeptical that an insurance company will be able to determine exactly what part you used and if it was UL listed unless you yourself tell them
If it's an electrical fire and they find modifications to the electrical wiring the chances of getting the insurance money are slim. Unless those modifications are explicitly covered by the insurance.
Given the kind of exposure insurance companies have they are willing to invest a lot in fighting the payout. It's their business model.
Can you cite any firsthand account of this sort of thing happening somewhere in the US? Given the ease with which people can reach millions of people with their tale of woe/outrage the fact that such stories are not readily available on social media makes me think this is mostly urban legend.
There's no need to cite firsthand accounts, you will find this in your own insurance contract. Insurance works pretty much the same everywhere, unauthorized modifications (especially to critical systems) usually invalidate any insurance claim when they can be linked to the incident. [0] Electrical wiring, plumbing, structure of the building, safety or security systems, etc. And it makes perfect sense if you think about it.
[0] http://www.insurancequotes.org/renters/3-major-diy-mistakes-...
Here is a link to a sample Homeowner's policy: https://www.iii.org/sites/default/files/docs/pdf/HO3_sample....
Exclusion B on page 12 is probably the relevant section. It excludes loss due to "Faulty, inadequate or defective:... workmanship, re- pair, construction, renovation, remodeling,..." but also contains an "ensuing loss" exception.
Here is an article about that: https://www.irmi.com/articles/expert-commentary/ensuing-loss...
> A classic example [of an ensuing loss exception] is if faulty repair resulted in improper wiring and the improper wiring caused a fire. Almost every insurer would pay for the fire damage, but not for the repair of the improper wiring.
1) The insurance company will more often than not sue the party responsible for the faulty workmanship that triggered the incident to recover the money (I've seen this happen). In this case the owner is that party.
2) One real example is enough to show it's not a legend and you provided it yourself:
> Some courts have upheld this rather cramped reading of the exclusion, while others construe it properly and require insurers to pay for the water damage
Since it's upheld in court I find your statement that it's an urban legend pretty confusing. It's like showing a picture of the night sky to prove the Sun is a myth.
YMMV of course, you should read your own contract to see what's stipulated and how comprehensive it is, and case law in your jurisdiction to see if courts would rule in your favor. But better be safe and start from the assumption that the "urban legend" is real since courts support it. It's the kind of legend that might cost you money.
Another? Didn't we clear this one already above when your link showed courts upheld the "legend"? Are you contradicting me or the courts? Feels like you're no longer looking for any evidence, just grasping at straws.
Plenty of resources that tell you that it's perfectly possible to get no payout (depends on your contract of course)[0][1]. Or they will pay out but capped to a low figure [3]. Again, read your contract and decide what applies to you, pray there's no fineprint to screw you over.
[0] https://www.boss.info/us/consumer_warning/
> unauthorized modification of electrical wiring may void your homeowners fire insurance policy
[1] https://www.quora.com/Is-it-illegal-to-do-electrical-tasks-w...
> Most jurisdictions require a permit to be pulled for most electrical work
[3] https://www.reddit.com/r/HomeImprovement/comments/7vwe23/doe...
P.S. No, I do not know any cases where the owner was sued but I do know many cases where the insurance company payed out and then sued the company that did the faulty repairs to recover the entire payout. I also know one case where a faulty repair done by the owner caused a fire that injured the tenant - the owner was found guilty of recklessness/gross negligence (no idea about the insurance in that case).
First-party claims, absolutely. Insurers want to pay when they are liable, and they don't want to pay when they are not. Your contract defines that, and your contract is written in plain English.
Insurers aren't out to get you, and the insurance industry doesn't rely on shafting people to make money. When you purchase insurance your policy is priced according to the exposure it creates, but a lot of people mistakenly assume that the insurer's profit comes from premium payments. It often doesn't. From what I have read, insurers are generally happy to break even on premiums vs. payouts. Their profit comes from investing the float and earning a return on those investments.
Related, I think that most people don't understand how tightly regulated insurance is, and how much it can suck for an insurer to improperly deny a claim. It creates huge legal and regulatory exposure for the insurer.
Indeed they are not. They are out to maximize profit either by not paying out when possible (sometimes only if forced by the court), or by paying out and recovering the money from the party to blame for the damage (in this case also the owner). And as the links provided below show, many courts see it their way and consider that damage cause by faulty workmanship is not covered by insurance.
I've done my part, the court supporting my claim shows it's as real as it gets. If you want to support your claim that it's an urban legend all you have to do is show that this never actually happened.
https://www.robinskaplan.com/~/media/pdfs/uncrackable%20cons...
Can you point me to an instance of this actually happening? I see this warning given all the time but have to date never found an instance where someone's claim was denied for these sorts of reasons.
This isn't to say that I would discourage a hobbyist from building their home automation controls. I would strongly recommend learning about designing electronics for mains voltage (creepage and clearance, grounding strategy, fuses and other circuit protection, types of transformers and how they're built (double insulated?), capacitor voltage rating|derating, ripple current ratings, lifetime vs. temperature, etc.
You can be a hobbyist and design things well, just be thorough when it's something that can set you and everything you love on fire if you do it wrong.
How do you deal with the small number of pins? The NRF24L01+ uses SPI, which requires 4 pins. There are some guides on how to hook up an NRF with 3 pins. I think that only leaves 3 pins (besides VCC and GND)?
The ATtiny seems to be very attractive otherwise, because it works across a relatively large voltage range and does not use a lot of power.
Did you consider the ATtiny84, which has double the GPIO pins?
https://www.instructables.com/id/NRF24L01-With-ATtiny85-3-Pi...
Regardless, I find the minimalism of the ATtinies interesting too, but haven't made the plunge yet.
$3.49 is great, nice find. Hopefully now that Espressif has unveiled their fork of LLVM you (as well as myself :P) will be able to use Rust on the ESP chips soon enough.
That said, it's really confusing how much flash memory are on these. The community seems to find that they list as 64 KB, but in reality ST has been shipping the part with 128 KB without saying. I have two black pills (slightly different board, same MCU) but the one I tested only has 64 KB. :(
1: https://www.aliexpress.com/item/32839140960.html?productId=3...
Now I have up to 20 extra gpio for 0.5$ or so. This is not very hard.
My point is, can you link to a tutorial? I'm a newb, but I'm a fairly competent full-stack developer.
Derp - You're a cloud consultant, oh okay haha. I'm guessing your home ISP network is pretty reliable then? I'm stuck on con-cast so unfortunetly I have to be prepared for occasional high-packet loss/no internet situations. They're fairly rare, but I want to make sure my lights can be controlled 24/7
Do you have any blog posts showcasing your project?
>Do you have any blog posts showcasing your project?
Started writing today. Haha. I will share it on HN once done.
Maybe if we just put 10 of these mini-controllers in each home, we can cover the majority of electricity consumption, and get demand flexibility the cheap way (instead of fitting each home with an expensive smart meter).
(Obviously the cloud/app parts will have to be centralized with consumer opt-in and preferences etc..)
Have u thought about this ?
Has this approach been explored ?
great project..
BOM (Bill Of Materials) cost is rarely the limiting factor on commercial products. The selling price of most devices is usually a large multiple of the cost of components.
Power-measuring outlets do exist, Belkin has one under the WEMO brand for example. It's just that it generally makes far more sense (for the electric company) to put the meter in one spot, instead of every outlet.
You still have to have the mini-controllers communicate with the power company though, so I'm not sure what problem you'd be solving?
My other friends are spending thousands of dollars retrofitting lighting and everything when they could spend a fraction and write some code.
And learn a skill. And not have their privacy invaded. And have more money they always complain about not having enough of.
For one year, it was constant annoying discouragement. Then, once we had this party in my house and I showed it off to everyone and they finally realized its worth. To me, the privacy factor is alone worth doing this project.
It's not like that in my software life. Like databases are not as... neat to most people but everyone can appreciate something they can see and touch and control.
I've got a Google Home and LIFX bulbs, but I've also spent hundreds and hundreds of hours learning, tinkering and coding. I can do this because I'm single and am lucky enough to have a lot of free time.
If I was doing it again, I'd stick with the LIFX bulbs and use the hundreds of hours doing something that would earn me some money.
Then you can sell your hours over and over again.
I've been interested in Lora/nRF/LoraWAN for some of my low-power further range projects. I'm just curious as to how they compare to the ESP's.
Also, how do you power your projects? I'm considering buying 6+ usb bricks, but I'm skeptical of non-brand name ones, and brand name bricks are expensive. After watching BigClive though I'm sure I trust any non-brand name ones....
For powering projects, it depends - most projects I do can be plugged into a laptop or into the wall - I have a programmable light array that is the main project I do with the kids. For other portable projects, I might use 18650s, might use coin cells, might just use AAs. This is a big topic and I’ve been meaning to write this up in detail.
Thanks for the questions! Sorry it took me until now to respond.
I want to automate my blinds, which is kinda annoying as that means ~6 different, "high up" spots in high visibility areas, and obvious motors mean "high power" (compared to micro amps).
I'm really not sure how to approach this one yet...
I'm saying: the power consumtion of an LED seems minimal compared to the power consumption of the motor to move them up and down.
They have four screw terminals - two for 3VDC to control and two for 24V - 380V AC for the load. They have the CE certification.
I bolt them down inside a NEMA enclosure and use standard residential wiring techniques (buy a book or two!) to wire them to standard outlets, where I plug in the load.
The controller (Arduino etc.) is typically mounted in a small plastic box outside the NEMA enclosure with a terminal strip to attach sensors and so forth. It's powered by a wall wart.
This approach meets code and is perfectly safe. For level of competence needed - you should be capable of doing residential electrical wiring. That's a useful skill to learn.
- learn how to and design a PCB with relays or FETs or whatever, following all the best practices for it to not catch fire.
- buy off-the-shelf rail-mounted relays/contactors, then design a driving circuit that will be all low voltage.
Assembling it all on a breadboard won't cut it (as in will blow up sooner or later), that's for sure.
You might call that an upside!
>> yet, vastly more powerful
What's sorts of things can you now do with this setup?
I can do some stuff like turn on AV receivers and program them to do something automatically, like switch to movie mode if I stay in the room for 2 minutes (just an example) for example because each of my power outlet has an IR transceiver. Though I don't use them much, they have a lot of utility. The reason I don't use them much now is I upgraded my receiver and now I need to re-program the IR transceiver with the commands from the AV unit's remote.
With Google cloud, you can write your own Siri-like interface, so you can talk to any power outlets you want, which is my next milestone. Stuff like this would normally require different vendors to operate together (Eg. Nest + SIRI + Homekit) but because this is my own platform, I can do whatever I want.
Last year, I started out to digitalize my entire house with these tiny ATTINY 85 chips and with some nrF wireless chips. It has worked really well for me and I'm able to control and monitor any power port in my house as well as my mains.
The overall setup still costed less than a Nest, yet, vastly more powerful. Of course, the downside is you need to write code, have a running server to control it on the cloud. But, no problem for me as I'm a (Google Cloud) consultant and this is what I do for a living.
I use Google Cloud's IAP with AppEngine (I may switch to cloud run now, since it's cheaper tho) and I have a private REST server running that I can access from my own Android app.
The whole thing took me a year to finish, but that's because I worked on it maybe once or twice a week in the weekends and didn't focus on it much.
But, my effort has paid off and it's amazing to me that what is possible with just a dollar investment.