Go Down

Topic: How to power an arduino + relay without access to an power outlet (Read 276 times) previous topic - next topic

sennec

Hello fellow makers,

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.



Code: [Select]
#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(); 
  }
}




Paul_KD7HB


sennec

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).

hzrnbgy

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.

sennec

I figured. Can I somehow use the circuit of the ceiling lamp to put out 5V to the Arduino VIN?

Idahowalker

I like using these AC in DC out thingy

I won't do your homework, don't ask.

CrossRoads

Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

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

recommended?

Nick_Pyner



Paul_KD7HB

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


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

sennec

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.

Paul_KD7HB

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.
I don't see this ending well.
Paul

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.
This response is to help you get started in solving your problem, not solve it for you.
Good Luck & Have Fun!
Gil

sennec

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

Go Up