Power Issue - Working on power bank but not on mains power

Hello,

I was wondering if anyone could help as I am very new to Arduino.

I have built set up to control x2 relay switches. The code has compiled and is running as it should, triggering relays correctly when running from a power bank via USB or from laptop.

As soon as I plug it into I wall usb socket or power using the power supply via the DC barrel/jack then the set up doesn't work correctly. It is like its running through the code to quickly not stopping to listen for commands but then plug it back into the powerbank via usb and its working correctly again.

The Powerbank is 5V 3A - Works
USB via laptop - Works
USB Wall Chargers 3A/ 2A / 1A - All don't work
12V 13A DC Barrel/Jack - Doesn't Work
9V 3A DC Barrel/Jack - Doesn't Work
7V 2A DC Barrel/Jack - Doesn't Work

I feel like I have tried everything I can think of and I'm stumped. Any help or advice would be greatly received as I have read so many forums and had no luck yet.

Many Thanks in advance
Katie

const int intervelometer = 2;
int RELAY_PIN4 = 7; //to turn on and off first light/mains power
int RELAY_PIN1 = 6; //to turn on and off second light/mains power


void setup() {
  // put your setup code here, to run once:
  pinMode (intervelometer, INPUT);
  pinMode (RELAY_PIN4, OUTPUT); // first light/mains power
  pinMode (RELAY_PIN1, OUTPUT); // second light/mains power
}

void loop() {
  // put your main code here, to run repeatedly:
int intervelometerState = digitalRead(intervelometer); // read new state

  if (intervelometerState == LOW) {
    Serial.println("The intervelometer is being pressed");
    
    digitalWrite(RELAY_PIN4, LOW); // turn off first light/mains power on relay
    delay (1000); //2 Seconds delay
    digitalWrite(RELAY_PIN1, HIGH); // turn on second light/mains power on relay
    delay (3000); //3 Seconds delay
    
    digitalWrite (RELAY_PIN1, LOW); //Turn second light/mains power off
    delay (1000); //1 Second delay
    digitalWrite (RELAY_PIN4, HIGH); //Turn first light/mains power on
  }
  else
  if (intervelometerState == HIGH) {
    Serial.println("The intervelometer is unpressed");
    
    digitalWrite(RELAY_PIN4, HIGH);  // first light remains on
    digitalWrite(RELAY_PIN1, LOW); // second light reamins off
  }
}





Hard to say, USB can provide a lot more current than the barrel jack, so my first guess would be a lack of power. However, if a USB wall charger doesn't work, it's a mystery.

Need more details on your setup.

Hi Wildbill, thank you for responding :slight_smile: What details can I add that could help? Images, code? Il look into how to correctly add these to my post

We need a decent ( hand drawn) circuit diagram ( schematic) of how you are connecting up this stuff

Yup, code, images, schematic as @hammy mentioned.

Can you run an Arduino from one of these wall USB devices without anything attached to it?

@wildbill & @hammy

I hope I have uploaded my code and image correctly to my post and it helps clarify a few things. From my basic understanding the intervalometer should act no differently to having a button installed, however it is being powered via the 3V on the Arduino.

Arduino runs and powers just relay switches too quickly. I have tried swapping relays out too. All behaves fine on USB powered via powerbank and laptop.

The common theme seems to be mains. The power block and laptop are insulated from it, if only to a degree in the case of the computer.

I suspect that the situation will change if the ssrs are replaced by indicator leds.

The solid state relays have indicator LEDs on the so can see whats going on but I am stumped. Can you spot anything wrong with my coding or schematic?
Many thanks

How much 3.3V current does the intervalometer draw?

I am unsure. How would I go about testing this? Normally it would be powered via CR2025 coin battery when not being powered via the arduino but i wanted to have it powered via the arduino so it never ran out of battery as it triggers the system.

There are no published specs? But it it runs from a coin cell it can't be very much...

I strongly suggest posting detailed close up photos of all the equipment and wiring.

So I have just tried powering the intervelometer via a coin battery instead of the arduino with the arduino powered via my laptop and it made the situation worse as so far I have not had issues powering via the laptop. Plug the intervelometer power back into 3v and ground on the arduino and no issues.

Does this mean it could be a grounding issue somewhere in my circuit causing issues?

Don't even think of it! Do not use the "barrel jack" or "Vin" for any real project!

Ok, thanks for the tip. May I ask why?

I am really trying to power the arduino via usb mains but not having any luck on anything other than a power bank or laptop power. Any ideas what may be causing this?
Thanks for helping

I guess we're not really thinking the same way. I'm looking for some authoritative information about the actual current draw. I assumed you had some reason to be confident about powering it that way. Instead of guesswork, can you provide some link to the device and/or its specifications?

Also, where are the images? We really need to see what you've got there!

Sorry, just thought I'd try it see if it made a difference. I can't find the manual for the exact intervelometer but similar models draw 27mA.

I have added images to my edited original post along with the schematic and code.

Yeah, don't do that. Leave your original posts alone, just post in new messages please.

I really don't like the idea of running the high voltage wires right next to the Arduino.

Please explain? Everything is secured and separate so no danger of accidentally contacting with each other.

At the moment. I spotted that and also had qualms. All high voltage wires should be on the HV side of the SSRs.

It's not just a safety thing, there is also EMI to think about.