Trouble uploading program to Arduino uno with relay

Ardunino Uno is connected to 8-channel relay board and powered through plug (not USB). Cannot upload new programs when the relay is connected to a separate power supply.

I have to disconnect the separate power supply to relay (I don't have to disconnect VCC connection from Arduino to relay or the 12 volt power plug to Arduino itself when uploading with USB) in order to upload a program. Otherwise, the program just says "loading" and eventually an error message that it failed after 10 attempts.

Once new program is loaded, I reconnect power supply to the relay and able to read serial monitor from Arduino (so, there is USB connection with Arduino, I just cannot load a new program).

Any advice why this could be happening?

One related observation:
whenever I reset Arduino or initiate serial monitor, the relay makes loud clicking sound (I assume it momentarily pulls all pins LOW for some reason when I start serial monitor and this could be related?)

P.S. Overall set up - one 24v PSU. Then 2596-SDC steps it down to 5v that powers everything but Arduino (relays, I2C devices, etc.). Another 24-to-12 voltage reducer powers Arduino through the power plug. all grounds are connected.

12 volts is a lot for the Arduinos regulator to dissipate as heat as it has to loose almost 7 volts to get down to the 5 volts needed for the board.
7 to 10 is better.

61 posts and you still cannot post a picture ?
Maybe one of these links will help get you there.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

ballscrewbob:
12 volts is a lot for the Arduinos regulator to dissipate as heat as it has to loose almost 7 volts to get down to the 5 volts needed for the board.
7 to 10 is better.

61 posts and you still cannot post a picture ?
Maybe one of these links will help get you there.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Hi,

Not sure what you mean by "still cannot post a picture?" I read over the help section you sent and images cannot be inserted unless they are hosted online according to the section 9 (unless I am missing something). I just attached the image that is not hosted online. So, not sure... Maybe you mean to open account on hosting site and upload image there and then insert the link? Honestly, I am just trying to understand the comment to make my post better. Nothing else.

Regarding the Arduino power supply, the range is fairly broad and recommended is 7-12. I read on several forums that 12volts is ideal and gives the most stable supply (again, this is what i read) but I can get another regulator and try 7volts.

But do you think the issue I posted is related to arduino power supply voltage? I am getting problem uploading a new program when relay is powered by separate external power but, once uploaded, I can use the whole setup, including the serial monitor to the computer. So, the problem seems just with the upload and power that goes to relay.

thanks

Do you have a "common ground" between the relays and the Arduino ?
Maybe a schematic ?

There is definitely a help section for posting pictures without using a hosting site in the links.
I could do it for you but dont see any need when you were given the help links.

ballscrewbob:
Do you have a "common ground" between the relays and the Arduino ?
Maybe a schematic ?

Yes, Arduino and the rest of the components (all supplied with separate 5volt while Arduino is powered through 12volt) have common ground. I have 3 I2C devices, ACS715 current sensor and 8 port relay that are all powered through the same 5v and share ground with Arduino.

I get the upload error only when the 8 port relay is powered. Once I disconnect the relay from the power (but keep connected to arduino via pins and vcc) the upload happens normally. Again, there is no issue with Serial monitor, etc. Just the upload and below is the error code I am getting:

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

Sketch uses 8344 bytes (25%) of program storage space. Maximum is 32256 bytes.
Global variables use 635 bytes (31%) of dynamic memory, leaving 1413 bytes for local variables. Maximum is 2048 bytes.
An error occurred while uploading the sketch
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

here is more detailed "verbose" error message:

Arduino: 1.8.12 (Windows 10), Board: "Arduino Uno"

Sketch uses 8344 bytes (25%) of program storage space. Maximum is 32256 bytes.
Global variables use 635 bytes (31%) of dynamic memory, leaving 1413 bytes for local variables. Maximum is 2048 bytes.
C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM4 -b115200 -D -Uflash:w:C:\Users\msaka\AppData\Local\Temp\arduino_build_357409/Motor_master_joystick.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Program Files (x86)\Arduino\hardware\tools\avr/etc/avrdude.conf"

         Using Port                    : COM4
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00

avrdude done.  Thank you.

An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

P.S. (Sorry, still learning how to do schematics and what tools to use.)

ballscrewbob:
There is definitely a help section for posting pictures without using a hosting site in the links.
I could do it for you but dont see any need when you were given the help links.

Thank you, I finally found it.

mvoltin:
Yes, Arduino and the rest of the components (all supplied with separate 5volt while Arduino is powered through 12volt) have common ground. I have 3 I2C devices, ACS715 current sensor and 8 port relay that are all powered through the same 5v and share ground with Arduino.

I get the upload error only when the 8 port relay is powered. Once I disconnect the relay from the power (but keep connected to arduino via pins and vcc) the upload happens normally. Again, there is no issue with Serial monitor, etc. Just the upload and below is the error code I am getting:

The VCC required by the relay board maybe too much for the Arduino < 50mA MAX per pin !
It might be that the relay shield is drawing down the Arduino to an inoperable state.

I would certainly try removing that single connection and using a supply OTHER than Arduinos pin that you have connected to that VCC.

Hi,

Just to make sure I understand, below is the schematic of what my connection looks like. I am unable to upload a code unless I disconnect JD-VCC and ground (on the right side of the picture). And both relay and Arduino (including serial monitor connection back the the PC) work fine other than the problem with the upload.

Should I connect VCC (on relay) to JD-VCC instead of arduino's 5v pin? (so that all power goes from separate PSU and only pins are connected to Arduino?)

Have you tried connecting the left side ground on the relay module to the arduino ground? It sure sounds like something is floating.

The pic shows a missing ground to the Arduino.
So no COMMON GROUND.

blh64:
Have you tried connecting the left side ground on the relay module to the arduino ground? It sure sounds like something is floating.

Those relay boards have an optocoupler. Vcc to the anode side and cathode side to Arduino pin. Connecting to Arduino ground is not necessary (and probably not even recommended).

ballscrewbob:
I would certainly try removing that single connection and using a supply OTHER than Arduinos pin that you have connected to that VCC.

Sorry, I was talking in the specific context about the vcc recommendation you provided earlier - wanted to understand better the specific recommendation.

ballscrewbob:
The pic shows a missing ground to the Arduino.
So no COMMON GROUND.

As I mentioned earlier, there is common ground between arduino power and the power that feeds into JD-VCC. Connecting ground from arduino to the relay when using JD-VCC is not recommended.

There doesn't (or shouldn't) have to be a common ground between Arduino and relay; so also not between the power supplies.

                  PS                Relay
            +-----------+       +-----------+
            |           |       |           |
   ---------+        5V +-------+ JD        |
220V        |           |    +--+ 5V        |
   ---------+       GND +----|--+ GND       |
            |           |    |  |   ctrl    |
            +-----------+    |  +-----+-----+
                             |        |
                             |        +---------+
                             |                  |
                             |                  |
                  PS         |     Arduino      |
            +-----------+    |  +-----------+   |
            |           |    |  |           |   |
   ---------+        5V +----+--+ 5V        |   |
220V        |           |       |       pin +---+
   ---------+       GND +-------+ GND       |
            |           |       |           |
            +-----------+       +-----------+

Hi. This is DC system running on 24 volt batteries with couple 24-12 and 24-5 voltage reducers. From everything i read, grounds should be connected for all circuits and, even if i wanted to, i could not keep the relay and Arduino grounds separate unless i put relay on a separate battery of its own.

Please let me know if this is what you meant.

It's indeed what I meant; not sure if it will help seeing that you have basically seperated the powers.

I think it's time that you show a complete drawing how everything is exactly connected; including the (unknown) devices that you control through the relays.

Thank you. Just spent over 3 hours (literally) exploring different software (online and downloadable) to create a diagram and gave up in frustration. Everything seems to lack capacity and flexibility of what i am trying to diagram.

Not having any formal background in this is probably a big issue.

Do you have any recommendation on what software to use for drawing a circuit? Thank you.

Just use pencil and paper. Take a photo, resize it so it's a 100kB or 200kB or so and attach it here.