Arduino Uno Power issue

Hello,

I've been following this guide closely and just completed the final steps of mounting the door lock onto my door.

Everything was working properly until about 5 hours into use when the actuator stopped moving and started clicking quietly. I encountered this issue before when putting together the project and it happened because of a power issue. As of now, I have the linear actuator powered through the 5V pin of the Arduino Uno and the GND pin connected to ground of the actuator. I'm using a 9V Duracell battery to power the Arduino.

Any suggestions are greatly appreciated.

That's a classical mistake, powering the controller via Vin and then hooking up loads on the +5 volt pin. Thebinternal 5 volt controller is not a nuclear power station.
Arrange for a separate power supply to the actuator, or get a good 5 volt supply that provudes power for both the controller and the actuator.

Could you suggest a way for me to arrange for a separate power supply for the actuator? I'm kind of a noob to all of this and this is my first project, thanks.

How much current does the actuator need?

The website says that the stall current is 460mA and the standby current is 7.2mA.

I would use a power bank, those charging phones, connected to the USB of the controller. I'm pretty sure the copper stripes of the controller board will manage to output that current on the +5 volt pin.

I would use a power bank, those charging phones, connected to the USB of the controller. I'm pretty sure the copper stripes of the controller board will manage to output that current on the +5 volt pin. They supply 1 Amp or more depending on the type.

I found a 1 Amp power bank around the house and I plugged it in for now. It seems to be working for now and I'll check back in if it doesn't work. Thanks for the tip!

Using the power bank works for a couple seconds, but it seems like the power bank goes to sleep when the door lock isn't being switched on/off which subsequently turns off the Arduino. I tried several power banks and they all seem to fall asleep after a few seconds of idle time.

That is indeed correct, and a common observation made here.

The “power bank” contains a “boost” converter to step the 3.7 V of the lithium battery up to the nominal 5 V, but like all converters, it has a “quiescent” current even if there is no load on it which would slowly drain the battery, so the control circuitry turns it off if the load drops to a really low level, implying it has finished charging the phone to which it is connected.

Frankly, the article you were following is misleading in a number of aspects, like the “instructables” articles so often observed here. :cold_sweat: Obvious foolishness includes powering via the “Barrel jack”, using a “PP3” battery to do so, and powering it from batteries in the first place. Even if the “power bank” was a useful source of power, it would run out in a couple of days simply from powering the UNO so this is a party trick, not a useful project unless you use a mains power supply such as a 1 or 2.1 Amp USB “Phone charger”.

And if you did want to make this permanent, you would be using a Nano (clone) rather than a UNO.

kylekam:
Using the power bank works for a couple seconds, but it seems like the power bank goes to sleep when the door lock isn't being switched on/off which subsequently turns off the Arduino. I tried several power banks and they all seem to fall asleep after a few seconds of idle time.

That can be cured. You need a resistor connected between a digital outout and GND. A timer based turning toggling that output on and off will keep the board alive. I use it in some low current situations.

Could You show us the code? Remember to start the blink sequence with "On". Elde You get half a blink period of delay.

I chose not to use the LED version of the build because I thought it’d be annoying see those lights in the dark so I did not use the blinking code in mine. Also, I’m not sure what you mean by using a resistor and a timer based turning toggling. Could you clarify a bit please?

#include <Servo.h>

const int LINEARACTUATORPIN = 9; //Linear actuator pin
const int receiver1Pin = 2;
const int receiver2Pin = 3;

int button1State = 0;
int button2State = 0;

Servo LINEARACTUATOR;

int linearValue = 1100;
//int linearValue = 1700;

void setup() { 
  Serial.begin(9600);
  LINEARACTUATOR.attach(LINEARACTUATORPIN, 1050, 2000); // .attach(pin#, min, max)

  pinMode(receiver1Pin, INPUT); //pinMode(pin#, input/output)
  pinMode(receiver2Pin, INPUT);

  LINEARACTUATOR.writeMicroseconds(linearValue);
}

void loop() {
  int button1State = digitalRead(receiver1Pin);
  int button2State = digitalRead(receiver2Pin);


  Serial.print(button1State);
  Serial.println(button2State);
  delay(1);

  //Moves the linear actuator according to receiver value

  if(button1State == HIGH) {
    linearValue = 1100;
    LINEARACTUATOR.writeMicroseconds(linearValue);
  }

  else if(button2State == HIGH) {
    linearValue = 1700;
    LINEARACTUATOR.writeMicroseconds(linearValue);
  }
  LINEARACTUATOR.writeMicroseconds(linearValue);


}

Look at reply #9 once more. If the current consumption is below a certain limit the powerbank cuts off. You can prevent that by pulsing some little more current through a resistor "now and then". Using an automaticly running timer toggling the output with the resistor tricks the poeerbank to stay on.
I did that for an UNO project so I could ude powerbanks.

Do you know of where I could start looking to learn how to make or get one of these automatic running timers?

kylekam:
Do you know of where I could start looking to learn how to make or get one of these automatic running timers?

Yes, the BlinkWithoutDelay example sketch that ships with the IDE. Modify it to use a different interval for HIGH and LOW. Make the "on" time short and the "off" time very long.

aarg:
Yes, the BlinkWithoutDelay example sketch that ships with the IDE. Modify it to use a different interval for HIGH and LOW. Make the "on" time short and the "off" time very long.

That can be a solution but I got help from forum to create another solution based on timer registers that runs in the background.
It's bedtime. 3 AM here but I'll dig up that piece of code and present it. Just wait some 12 - 15 hours.

Railroader:
That can be a solution but I got help from forum to create another solution based on timer registers that runs in the background.
It's bedtime. 3 AM here but I'll dig up that piece of code and present it. Just wait some 12 - 15 hours.

Sure, you can. But while there are a finite number of hardware timers, there are a virtually unlimited number of software timers.

@aarg Yes, when OP feels ready for that, it's an option.

My piece of code, runs one time in setup:

void setup()
// put your setup code here, to run once:
{
//1Hz 90% dutycycle  
  pinMode(9, OUTPUT);                               // Set digital pin 9 (D9) to an output
  TCCR1A = _BV(COM1A1) | _BV(WGM11);                // Enable the PWM output OC1A on digital pins 9
  TCCR1B = _BV(WGM13) | _BV(WGM12) | _BV(CS12);     // Set fast PWM and prescaler of 256 on timer 1
  ICR1 = 62499;                                     // Set the PWM frequency to 1Hz: 16MHz/(256 * 1Hz) - 1 = 62499
  OCR1A = 6249;                                     // Set the duty-cycle to 90%: 62499 * 9 / 10 = 56249
  delay(10);//allow pwm timers to start
  digitalWrite(9, HIGH);
  digitalWrite(9, LOW);

I use 270 Ohm from D9 to GND.