though having a background in system and network programming, I've not massively dived into electronics prior to this project - so please bear with me.
I'm working on a very simple home automation project - just WiFi controlled lamps for now. I've hooked up MKR WiFI 1010 boards + relays to all lamps in my flat. Wherever possible, the Arduino boards are powered via USB connected to an outlet next to the one that is powering the corresponding lamp.
My ceiling lights however do not have any outlets nearby, obviously. Which is why I am powering their boards via battery (3,7V 1200mAh). Problem: They're being drained within less than a day/two days at max (even when the relay is on idle/open 100% of the time). Relay is draining 30 mA (according to it's technical documentation). Adding the native consumption of the Arduino on top of that, I really don't see how I'd power the entire circuit for an extended period of time, even using way bigger batteries.
So I guess my question is: how to I power these things? Does a something like a parellel relay exist, that can control the circuit (230V AC) of the lamp while also using that exact same ciruit to provide a lower voltage to power the Arduino - instead of having the Arduino power the relay?
Arduino code used on all of my boards below.
#include <WiFiNINA.h>
#define RELAY_PIN 14
WiFiServer server(30000);
int connect()
{
return WiFi.begin();
}
void setup()
{
int status = WL_IDLE_STATUS;
while (status != WL_CONNECTED)
{
status = connect();;
delay(5);
}
server.begin();
pinMode(LED_BUILTIN, OUTPUT);
pinMode(RELAY_PIN, OUTPUT);
WiFi.lowPowerMode();
}
void loop()
{
int status = WiFi.status();
while(status != WL_CONNECTED)
{
status = connect();
delay(5);
}
if(WiFiClient client = server.available())
{
if(client.connected())
{
if(client.available())
{
if(client.read() == 0x01) // lamp on
{
digitalWrite(RELAY_PIN, HIGH);
}
else // lamp off
{
digitalWrite(RELAY_PIN, LOW);
}
}
}
client.stop();
}
}
Thank you very much. I'll order a couple of those to reduce the power consumption.
The battery is however drained way too quick even without the relay draining any power at all.
According to this official arduino guide the board in "WiFI sleep mode" still consumes about 30mA, so - using a 2000mAh battery, I could still only power the board for about 60 hours (optimistically).
Unfortunately, WIFI wasn't designed for low power use. And since your Arduino is a server (waiting for connection), you can't really put the WIFI module in deep sleep, or you won't be able to connect to it to do your IoT thing.
I would add a 2nd junction box with AC outlet next your existing junction box, and then plug in USB power adapters there.
Probably should have an electrician wire them up for you.
sennec:
I actually don't have a single junction box on my ceiling. Just two isolated wires with bare ends.
Couldn't I split the output into multiple (just like a connector strip does) and then use one of these things that Idahowalker
recommended?
Do you own the house? Did you wire up the ceiling lights? You cannot have any mains junction without a proper junction box to control the possible heat and fire created by the wire connections.
Paul
Paul_KD7HB:
Do you own the house? Did you wire up the ceiling lights? You cannot have any mains junction without a proper junction box to control the possible heat and fire created by the wire connections.
Paul
I dont own it. And technically .. it's kinda just a light bulb dangling from the ceiling right now.
I'll probably attach a proper junction box with two sockets and just use one for the lamp and one for the Arduino.
sennec:
I dont own it. And technically .. it's kinda just a light bulb dangling from the ceiling right now.
I'll probably attach a proper junction box with two sockets and just use one for the lamp and one for the Arduino.
Get a Leviton 1403 Two Outlet Socket Adapter, any color you want, remove the bulb, screw the bulb into it then screw that adapter into the socket. Now plug your Arduino into the socket adapter. That solution would work in the US, but I have a feeling your from another country with a different wiring structure. The way you describe it reminds me of the Knob and Tube wiring from years past. Not sure if that adapter is available to you but it will give you an idea of a simple, safe and cheap solution.
gilshultz:
Get a Leviton 1403 Two Outlet Socket Adapter, any color you want, remove the bulb, screw the bulb into it then screw that adapter into the socket. Now plug your Arduino into the socket adapter. That solution would work in the US, but I have a feeling your from another country with a different wiring structure. The way you describe it reminds me of the Knob and Tube wiring from years past. Not sure if that adapter is available to you but it will give you an idea of a simple, safe and cheap solution.
Thats actually precisely the kind of component that I've been looking for. And they're available in the EU. Thank you
You may well be right, but I thought the whole point was to turn the lights on - to the point even that the problem is when they are on....
I wasn't being too serious but, assuming that running a power device off a light circuit is as frowned upon everywhere as it is here, particularly in a renta, a PV charger beats the hell out of calling the electrician and is almost certainly cheaper.
Nick_Pyner:
You may well be right, but I thought the whole point was to turn the lights on - to the point even that the problem is when they are on....
I wasn't being too serious but, assuming that running a power device off a light circuit is as frowned upon everywhere as it is here, particularly in a renta, a PV charger beats the hell out of calling the electrician and is almost certainly cheaper.
The MKR WIFI 1010 board drains way too much energy to run off battery power, even in WiFi.lowPower mode while not doing anything.
Considering that disabling WiFi entirely would kinda defeat the entire purpose of the board, it seems safe to say that it's not exactly supposed to be battery fed in a real world scenario - apparently it'll always need a proper power line to run for an extended period of time without interruption.
Whats wrong with feeding it from the light circuit?