Project working when connected via USB to PC but not by 12V on DC IN or 5V USB

Hi everyone.

Hopefully someone might have some ideas for me to try as I have gone through pretty much everything I can think of.
I am having an issue where my Duinotech Mega with LCD module and Temperature/humidity sensor work well together when connected to either my laptop or desktop PC by USB, but won’t work when connected to either a 12V power supply connected to the barrel connector or a 5V 2.1A USB power supply connected to the USB B connection.
As far as I can tell in all cases the display is working fine as it shows the temp and humidity when powered by PC, then shows 0.00C for temp and “nAn” for humidity when powered by other sources as per the program is tell it to do.
If I delete pretty much everything to do with the display in the program and leave the DHT sensor programming in, set up to switch the backlight on and off at a temp of 25c then the backlight switches, indicating the sensor is working on it’s own with the LCD module still physically connected but not programmed.
I also have some other modules hanging off the Mega, which I will note all the pins below in case it helps, but I have pretty much disconnected them all at one point or another with no difference in operation.

LCD keypad shield:
Bit0 - D4
Bit1 - D5
Bit2 - D6
Bit3 - D7
RS - D8
E - D9
Backlight - D10
keypad - A0
3.3v - N/C
5V - 5V
Gnd - GND
Reset - Reset

Temp/Humid sensor: Humidity and Temperature Sensor Module | Freetronics
Sense - D16
5V - 5V

Ethernet module: ENC28J60 chip (unfortunately can’t find any datasheets on this one)
SI - D11
SO - D12
SCK - D13
CS - D14
VCC - 3.3V
Reset - Reset

8 channel relay module: Arduino Compatible 8 Channel Relay Board | Jaycar Electronics
12V - linked off diode output from barrel connector +
1 - D22
2 - D23
3 - D24
4 - D25
5 - D26
6 - D27
7 - D28
8 - D29
] - Jumper linking these two pins

RTC module: Arduino Compatible Real Time Clock Module | Jaycar Electronics
Battery Voltage - A1
VCC - 5V
SCL - SCL(JP6 Pin 1 - same header as D8-13)
SDA - SDA (JP6 Pin 2 - as above, same header as D8-13)

As mentioned earlier, everything works fine on USB from PC, just not via a USB power supply or 12v plugpack. Once they are programmed, the RTC, relay board and LCD/keypad modules all work fine via USB, I just haven’t gotten around to the ethernet programming yet.

Attached is the code I was using tonight to just test the DHT sensor with the LCD with no luck.

Sorry about the long post. Any help is appreciated.
Fire away with any questions.

DHTLCD_TEST.ino (9.26 KB)

Sorry, I forgot to also mention about the bootup speed. On USB power or 12V plugpack the mega seems to start up really quick. When it's connected to the PC it takes a few more seconds to start up, but at least it works after that. I don't know if that helps any more or not, but it's just an observation of it's operation in each state.

Maybe the usb and 12v supplies are not capable of delivering the currnet needed to run that lot.

Measure ALL 5V and 3.3V voltage connections when powered by PC usb. Then repeat for when powered from usb power supply and 12v battery. If the voltages are lower then it is a current issue.

I should have mentioned that in my original post. Running from PC the 3.3V rail is pretty well bang on, same when running from USB power. The 5V rail at all pins and modules is measuring at 4.58-4.61V. When connected to my USB power supply the 5V rail is measuring slightly higher at 4.68-4.7 volts. The LEDs on all modules are brighter when on USB power rather than running from the PC USB, which makes me think it's not a power supply limitation.

Maybe you can get a spare arduino (of the same kind) and power it with your 12V DC supply. And do some simple things with it .... such as running a LED blink program for testing. And then followed by connecting a single sensor to the arduino, and see if it behaves properly --- with that 12 V DC supply. And keep building up from that. You might be able to trace the issue that way.

Or, if possible, measure the DC supply voltage with an oscilloscope, to see if it's stable ---- like ... no nasty oscillations etc.

Also ----- indicate the power handling specifications of this 12V DC power supply. What's the rated current for it?

Also show the connections of everything in a diagram. You mentioned everything works when you're using computer USB power ...... but you don't show how you power your 12V relay module ---- with a 12 V DC supply? In other words ----- make sure to show adequate details.

I suggest a wiring diagram showing where the PC, USB and 12 V would be connected.

And, I assume "banged on" means good. If so is the 5V line "banged on" when unit is connected to 12V?

I have a guess on what might be happening but its only a guess given the limited info.

If you are supplying the 5V to the Mega board and taking 5V off the boards 5V pins. The internal 12V --> 5V regulator is likely not able to supply the current you need for your setup.

Thanks for the replies. I started drawing a diagram of everything last night but it ended up really messy. The 3.3 volt pins all measure 3.3-3.32 volts at the mega pins and at the modules that have the 3.3v wires to them, regardless of what power supply is being used (12v, PC USB, USB power supply). I have stopped testing with the 12 volt supply on the barrel connector using the board regulator as the poor thing was burning up trying to pass enough current for all the modules. While using the 12v in though the 5v rail was just under 5v, but higher than when it’s powered from the PC USB. My relay board was fed 12volts from the reverse polarity protection diode on the 12v input. This is currently not operational now, but i’m not too worried about this at this stage. I can power this separately once I sort out the sensor/lcd issue. I have gone to testing between the PC USB, which works, and the USB power supply, which looks to be supplying more than enough current for everything as it’s running a slightly higher 5v rail on the mega as well as all the modules, plus everything works fine when supplied from the lower current PC USB connection.

All of the modules are fed from either 5 or 3.3v pins off the mega board. Saying this though, from a schematic of these boards it looks like the USB power pretty much goes straight to these pins. Regardless, again it runs from the lower current supply my PC is giving it from the same connector.

As suggested, I will find my old scope if I can see if there is anything messy on the USB supply lines. It’s really the only thing I can think of unless these boards interact with the USB chips in the PC in some way that allows it to have both the lcd and temp modules talking at the same time when connected?

I couldn’t find my PC Scope, but I did run a battery bank of 5 volts into the USB input and still had no luck. I doubt it’s anything like a power supply ripple or dirty power causing the issue when even a battery bank still gives the same results.
Attached is a wiring diagram showing all of the modules and where I have them wired.
This one has got me stumped as to why it won’t work. My only other guess is that the Duinotech Mega isn’t as good as the Arduino version and it requires clocking from the PC USB or something.

Wiring diagram.pdf (144 KB)

Does anyone have any other ideas on what could be causing these issues? I am about to try another one of these Duinotech Mega's, plus I have a stepdown DC-DC converter to take the 12v in to 5V to power all the modules. I will be very surprised though if this is a power related issue as I have tried running it all off batteries that have more capacity to run it than even the USB ports on my PC. My least favourable option is to run this project without the display, as I will be incredibly frustrated to not work out the issue, but also I won't have a display for the humidity, temperature and RTC for my application.

Well, this one's got me stuffed. I have swapped Mega boards as well as run from different power supplies and batteries and I continually get the same result. I also ran through the main project, as well as the LCD and DHT libraries and commented out anything with reference to the serial port, in case that was causing issues when not connected to the USB port on the PC and again, no difference.

This is the time when you should start from stage 1 again. Get 1 sensor only. Unhook all the other items from the board. And use your 12V DC power supply. And the first step will be to start testing that sensor ------ get something happening with that sensor only with the arduino. Get proper readings happening first. And then slowly build up from that. One step at a time.

wally01: Plus I have a stepdown DC-DC converter to take the 12v in to 5V to power all the modules.

Are the negative terminals of the 12V and the 5V supplies connected together electrically? Or not electrically connected together? The wiring diagram didn't show a DC-DC converter.

If you have 'other' power supplies, then see whether the negative terminals of those power supplies are connected together, and see whether those negative terminals are also electrically connected to the 'GND' pins of the arduino.