Smart outlets are actually plug-in outlets. You plug them into a wall outlet or a power strip, and have your own outlet to plug into with the device you want to automate. You are neither gaining nor losing any outlets in the process.
I bought an affordable set of those recently. I got them at a regular price of about 26 EUR, so they didn't cost much.
After reading a short manual included in a package, I got an understanding of what they do and what they are capable of. In short, they are operated by a remote controller. They come without any setup, so you can switch them on and off manually bry pressing the single button they have on them. Before being able to operate them remotely, you have to setup them to any of the groups A, B or C. Every switch could belong to one, two or even all three of the groups. To add an outlet to the group, long press the button (3-6 seconds), than release, if the LED is blinking, press the appropriate button on the remote controller, and that makes the outlet member of the group on whose button you clicked on the remote controller. If you want to clear the setup of the outlet, press the same button longer than 6 seconds, and then release it. And this is all you need to know about using the outlets. With remote it functions well.
But if you want to operate smart outlets without a remote controller you will need some hacking. One is to hack into a remote controller, destructive and dirty approach. Second is to sniff the communication between remote controller and outlets and reproduce it, which is a way better solution. To try this solution you need a RF 433MHz transmitter and receiver pair, and I bought the most common one I could find. Both have VCC, GND and DATA pins (receiver has two DATA pins but you use only one), it transmits and receives signal present or not, binary code. You control it with the digital output or read it from digital input.
For sniffing onto communication between remote controller and the outlets, I used the Arduino with a receiver, and the code found in this github project. This software works great and I got my codes in no time.
# | ON | OFF |
---|---|---|
A | 3158956 | 3985788 |
4128620 | 3743276 | |
B | 4020981 | 3533717 |
4174053 | 3811541 | |
C | 3886478 | 3564062 |
3253950 | 3671902 |
With all this under control, an idea of having smarter smart charger project comes into existence.
This smarter version of the older project solves one big problem of its design. Bluetooth sometimes hangs and without restart connection can't be reastablished. And without that connection smart charging can not function.
Hardware is simple and affordable. All this project needs is:
Software is written in Visual Studio 2022 Community Edition, using Xamarin.
Although the source code is available on the github, just a basic explanation and APK for download, for those who want to use it.
Application expects running Raspberry Pi from the project above.
The two sliders defining the upper and lower limits of battery charge level operating range dominates the form.
The lower value means that the charger will always be ON when the battery level is less than that value.
The upper value means that the charger will always be OFF when the battery level is greater than that value.
Third slider is a ping interval in minutes. It defines how often does the phone reports its status to the server.
Ping timeout occurs when there is no status received by the server in 2.5 ping intervals..
Commands to switch the charger on or off are going via server. Upon click on the button appropriate command is set to the server, and server executes it by sending correct RF code.
Foreground Service is started on first run. It is a special type of service in Android, that can survive for a longer time.
Android system is notorious for silently killing background services when it senses a lack of memory or other resources.
But foreground service has to maintain notification in the notification area of your phone, as long as it is active.
Service periodically checks (every Ping interval set above) the battery level and reports it to the server.