Different behaviour using USB power 5V or 9v on Vin, arduino nano

Hello guys,

A little bit of background about me, I am a master 2 embedded systems student. I’m used to work with industrial MCUs, but I am fairly new to arduino. This said I have the basic knowledge to understand most of what I am doing.

Presentation of the project :

The project was rather simple, using an arduino nano, a MPR121 capacitive touch sensor from Adafruit : (Overview | Adafruit MPR121 12-Key Capacitive Touch Sensor Breakout Tutorial | Adafruit Learning System) and a 5V relay.

I am using only 4 out of the 12 MPR121 outputs, and basically the relay switches whenever you touch ALL 4 at the same time.

I self made the relay system using the sparkfun schematic : here
I replaced the transistor by one I had under my hand : BC547C

My issue :

The projects works perfectly whenever I am powering it up with the USB 5V from the computer. But whenever I am using the Vin input, with 9V 2A or 12V 2A a strange behaviour occurs :

The transistor switches since the LED connected to show the relay state lights up, but the relay doesn’t switch. You can’t hear the switching noise from the relay either.
Weirdest thing to me is that if i am powering the Vin using a 5v 2A external power supply the system works.

My understanding :

Basically I could avoid that quite easily using a voltage regulator and supplying the arduino nano Vin with 5V. Such as a LM7805C. But it wouldn’t be the most efficient way to solve this issue for a lot of reasons.

Basically the arduino nano has a built in voltage regulator outputing 5V, so to me it should be the same as powering up using the USB, and even better since my power supplies can output a bit more current. (even though the project isn’t current hungry)
You’ll find attached a schematic of the project I’ve done as well as my code.

What have I tested :

-replacing the arduino nano by a brand new one = SAME.
-checked differents nodes using the different power sources :

-USB 5V
Arduino 5V : 4V
Arduino relay_pin (D8) : 4V
-Power supply 9V 2A
Arduino 5V : 4,5V
Arduino relay_pin (D8) : 4,5V

You will find attached my code and a schematic of the project.
I wasn’t able to find an explanation on my own, if anyone has any idea on what’s going on i’d be pleased to hear it.

premier_jet_module_touch.ino (2.66 KB)

The LED is across the relay coil so the relay must be getting power when the LED is lit. What is the voltage across the relay coil when the LED lights up but the relay doesn't switch (Vin power)? What is the voltage across the relay coil when the LED is on and it DOES switch (USB power)?

You can at least be sure that the relay is not drawing more than 500 mA since, if it did, the USB power would be cut off by the polyfuse and you would have to disconnect the USB power to reset the fuse.

The voltage regulator on a Nano can deliver how many milliAmps? Does ithe regulator get hot when the relay is activated.

Possibly not the cause but the BC547 is rated at an IC of 100mA max; what is the current consumption of the relay.

OP’s schematic:
20180509_000202.jpg

According to this schematic, when the LED lights up, the relay is probably off (current from +5V, relay coil, resistor, LED, GND).

When the Arduino D8 pin is high, the BC547C is switched on, the relay activates, and the LED is switched off as current now flows through the transistor, rather than through the LED.

The 10k resistor between base and GND is not necessary (it’s a BJT, not a MOSFET, so with the base floating it’s simply off).

Gwenbino:
Weirdest thing to me is that if i am powering the Vin using a 5v 2A external power supply the system works.

I think this is the clue.

The higher voltage you put on the input of the regulator, the more power it has to dissipate when you pull some current from it, i.e. by connecting Vout to GND through a relay coil and a BJT.

Gwenbino:
Basically I could avoid that quite easily using a voltage regulator and supplying the arduino nano Vin with 5V. Such as a LM7805C. But it wouldn’t be the most efficient way to solve this issue for a lot of reasons.

Or you can feed your 9V or 12V into Vin of the nano, as well as into a separate 7805 for the relay. (Connect their grounds together.) I would say it is nice to have separate regulation for the part with microelectronics and the part with inductive spikes.

I don't know (maybe someone else can comment) but I feel like you can switch your relay with 9V or even 12V if you put a current limiting resistor (few 10s of Ohms? 2W?) in series with the coil. And that the 5V is a minimum given the coil resistance.

Thank you guys for your hints, I came back home today, so I’ll be able to answer this as soon as monday. I’ll also try to cut my “homemade relay” and plug a sparkfun module I should have laying around just to compare the behaviour.

wvmarle:
The 10k resistor between base and GND is not necessary (it’s a BJT, not a MOSFET, so with the base floating it’s simply off).

That’s a good point here. Thanks for that as well :smiley:

Jobi-Wan:
I think this is the clue.

The higher voltage you put on the input of the regulator, the more power it has to dissipate when you pull some current from it, i.e. by connecting Vout to GND through a relay coil and a BJT.

Or you can feed your 9V or 12V into Vin of the nano, as well as into a separate 7805 for the relay. (Connect their grounds together.) I would say it is nice to have separate regulation for the part with microelectronics and the part with inductive spikes.

I don’t know (maybe someone else can comment) but I feel like you can switch your relay with 9V or even 12V if you put a current limiting resistor (few 10s of Ohms? 2W?) in series with the coil. And that the 5V is a minimum given the coil resistance.

Sure i gotta check the datasheet but that’s a point to enlight as well. Thanks for the idea!

sterretje:
Possibly not the cause but the BC547 is rated at an IC of 100mA max; what is the current consumption of the relay.

I noticed that the BC is taking 100mA max and the original transistor on the sparkfun sch draws half of it as a max current. That’s as well something to check.

Anyway, this is the first time I really use this forum and …wow, thanks a lot for taking the time and actually you guys helped a lot !
I’ll keep you updated once I try anything and hopefully find the solution !

Cheers !

The problem is common and applies to most touch sensors. The thing is that with a computer the case makes a large ground for the electrodes to "react against".
If you are using a battery then you need a large foil or PCB ground around your touch sensors.

Gwenbino:
I noticed that the BC is taking 100mA max and the original transistor on the sparkfun sch draws half of it as a max current. That's as well something to check.

The 2N3904 as in the schematic can handle double the current the BC547 can.

Also the diode in that schematic is drawn in the opposite direction, and connects to 5V, while you connect to GND. In the Sparkfun case the diode will light up as you activate the relay. In your schematic it's reversed.

wvmarle:
The 2N3904 as in the schematic can handle double the current the BC547 can.

Also the diode in that schematic is drawn in the opposite direction, and connects to 5V, while you connect to GND. In the Sparkfun case the diode will light up as you activate the relay. In your schematic it's reversed.

Sure my sch got an error the LED is reverse. sorry for that, had to draw it as fast as I could then reach out to the airport ahah