In both cases I have the relay being connected GND to GND, Vin to a digitalpin with output high and the control signal connected to a different digitalpin. This worked with just the relay being attached but when other electronics are attached those parts aren't powered and the relay stops working.
I suspect that the relay is exceeding the max current draw but I am confused as to why it would work with just the nano on its own. I would probably have to have a separate power source to power the coil on the relay but I wanted to try and avoid that if possible. Is there another route I could go?
D13 and D10 are set to output and high in code. Without relay attach LCD and sensor work fine it’s when the IN pins on relay are attached to D8 or D9 but just Vcc and Gnd attached works fine.
LCD has a bunch more pins attached to make it work but that’s the entire circuit.
Relay coils can pull a lot of current compared to the amount an Arduino digital pin can provide. You might do better powering the relay board from Arduino 5V instead.
Even that may not be sufficient, it's not uncommon to need separate power for the coils - that's why so many relay modules have a jumper to allow you to separate the digital logic from the supply that powers the relay.
Why a relay? Could you use mosfets? These require far less current to actuate them. Almost nothing, in fact. But the devices being switched on must need DC power no more than about 50~60V and you must choose the right MOSFET, and you may also need to use a diode to protect the whole circuit from the reverse polarity spike when your sketch turns the current off.
Arduino Nano tech sheet states 40 mA per pin limit. SONGLE relay coil is 0.45W which is V*I, V is 5v, I comes to 90 mA. And you operate 2 relays? You are taking more than 4 times the limit from IO pin. Maybe you damaged your Nano already, maybe not, but it won’t probably take long before it burns out.
You mean 120 or 240 VAC? If so, I agree, stick to relays. But don't use the term "line voltage" because it is ambiguous. The 5V line from an Arduino has, unsurprisingly, a line voltage of 5V DC, for example.
also those relay modules have option to be powered from separate power source, you should connect them directly to output of the converter and leave Nano alone
Wow okay yeah I see now, I was searching for that pin on the pin outs earlier this month for this project but somehow didn't see it.
Yeah that was my backup plan I had a feeling the Arduino didn't supple enough current but when I looked at videos and designs for using a relay with an Arduino it looked like you could just connect them and it'd be fine. For instance: Humidity Control with an Arduino - YouTube, and other circuit schematics when googling.
Okay, I figured out a solution. The 5v pin draws current directly from the power source powering the Arduino and can thus output a much higher current than any of the digital out pins so no separate power source is needed. I am just using the 5v pin to power everything.