Arduino Nano + 2 IR proximity Sensors + 4Channel 230V Relay -> Reset problem

Hi all,

I'm having some problems with my project (hacking an integrated range hood fan with arduino for motion control).

When testing without connecting 230V to relay, it seems to work properly, but when connecting it, there is some resets while using the IR motion sensors. The motion sensors cycle speed 1-2-3 opening and closing relays, while chan4 is for lights. Max the is 2 relay channels and 2 IR sensors on.

  • Is the problem related to current requirements of the cheap Nano 5v output? (Input via 5V 1A usb)
  • Or is the problem backchannel EMF? I thought the relay VOs are separated from 5V rail?

Any advise?

Parts

Schematics

Pic of the thing

UPDATES:

I Tried that didnt help:

  • removed the 10k resistors from IR sensors
  • added 0.1uF ceramic capactors from D4 and D8 to GND

Next to try:

  • To increase ac and dc cables distance further
  • 250V VDR

Additional info:

  • With lights OFF (meaning only 1 relay channel active at time) still resets, so I don't think its current problem
  • I have pinMode INPUT for sensors, and they seem to be working correctly, should I still change to INPUT_PULLUP?

Hi,
Can you supply a copy of your schematic, so we can see how you power everything.

What are the IR sensors?

Thanks.. Tom.. :slight_smile:

adrianlee:
...(Input via 5V 1A usb)...

?

Can't push 1Amp through a Nano's USB socket. Clone or otherwise.
Or any other Arduino.

How are you powering the relay coils.
Leo..

e18-d80nk infrared proximity sensor datasheet

4-channel relay: relaydatasheet
I'm making a fritz, but all is powered from 5V rail from arduino nano

Wawa:
?

Can't push 1Amp through a Nano's USB socket. Clone or otherwise.
Or any other Arduino.

How are you powering the relay coils.
Leo..

Yes I think arduino nano has 500ma max current input fuse through usb

adrianlee:
Yes I think arduino nano has 500ma max current input fuse through usb

No, an Uno/Mega has an (auto)resetable polyfuse.
A Nano has a tiny 500mA backflow protection diode (that burns when overloaded).

Relay link is a useless sales pdf. No real info there.
And they have hidden the most important side.
Were does it say the board is mains (230AC) rated?

Post a diagram.
Leo..

Wawa:
No, an Uno/Mega has an (auto)resetable polyfuse.
A Nano has a tiny 500mA backflow protection diode (that burns when overloaded).

Relay link is a useless sales pdf. No real info there.
And they have hidden the most important side.
Were does it say the board is mains (230AC) rated?

Post a diagram.
Leo..

Here's link to fritz

First time using it, so couldn find all. unmarked wires going to relay are mains 230V, and NO output wires go to ac fan motor (chan1-3) and chan4 to a Led driver (ac to 12V)

EDIT: in the relay itself is says 250V 10A

adrianlee:
Here's link to fritz
Dropbox - File Deleted - Simplify your life

First time using it, so couldn find all. unmarked wires going to relay are mains 230V, and NO output wires go to ac fan motor (chan1-3) and chan4 to a Led driver (ac to 12V)

EDIT: in the relay itself is says 250V 10A

Sorry forget Fritzy, use a pen and paper, that way you can show what is really in your project, including pin names and component labels.
Draw and post a picture of your circuit.
Thanks.. Tom... :slight_smile:

TomGeorge:
Sorry forget Fritzy, use a pen and paper, that way you can show what is really in your project, including pin names and component labels.
Draw and post a picture of your circuit.
Thanks.. Tom... :slight_smile:

Okey, here's drawing, hope it helps drawing

Here's picture the whole thing range hood

IR sensors on the side, arduino in the right lamp container and 4 channel relay in the left

EDIT: here's link to the relay, cant find any proper datasheets: https://www.robotshop.com/en/4-channel-5v-relay-module.html

The two resistors are used in series with the pin, but should be used as pull up resistors (NPN sensor).
So connect sensor outputs directly to the Arduino pins, and connect the resistor between pin and 5volt.

Educated guess is that the relays are using 80mA each when active.
That, and the draw of the Nano and sensors (~400mA) is just withing the limit of the USB supply.
Maybe wise to connect the 5volt supply directly to the 5volt pin instead of running it via that tiny USB diode
(that diode also lowers the supply by ~0.4volt).

Interference:
Don't run the fan wires next to the low voltage wires.
You might have to use snubber circuits across the relay contacts.
A VDR/Varistor, rated for your mains voltage, could be enough.

The relays itself might be rated for your mains voltage, but the board might not be.
YOU are the judge of that.
You might have to ground any exposed ground/controls/etc. of the Nano to mains ground.
Ask a electrician if you're not sure.
Leo..

Hi,
OPs circuit;


Tom.. :slight_smile:

Hi,
You don't need the 10K on the inputs D4 and D8, connect the sensor output directly to the inputs.
At the moment they will be adding to the high impedance input and so may be picking mains switching noise up from the relays.
Place a 0.1uF capacitor from each of the inputs to gnd, to bypass any noise.

Thanks.. Tom.. :

If you remove the 10k resistors,
then you also must use internal pull up on the pins with pinMode.
Assuming you have NPN-type sensors.

pinMode (sensorPin1, INPUT_PULLUP); // use internal pull up resistors

Adding the caps might be a good idea.
Leo..

Hi,
Those resistors were not acting as pullups in that circuit.

Spec sheet is a bit lacking when it says NPN output, normally high!!!

This one is a bit more explanatory, Yes will need to turn pullups ON.

Tom... :slight_smile:
(I found a site that shows the "pullup" resistor as they call it in series with the sensor output, which is contrary to the information table they post in the schematic.)

SHT-015d.pdf (175 KB)

Confusing statements in industrial datasheets.

An NPN output is always LOW.
It's only "normally HIGH", and "active LOW" if you connect a load to it.

But I assume you already knew that Tom.
Leo..

Wawa:
Confusing statements in industrial datasheets.

You have got to be joking "industrial datasheets" :o :o :o :o

Tom.... :slight_smile:

Wawa:
The two resistors are used in series with the pin, but should be used as pull up resistors (NPN sensor).
So connect sensor outputs directly to the Arduino pins, and connect the resistor between pin and 5volt.

Educated guess is that the relays are using 80mA each when active.
That, and the draw of the Nano and sensors (~400mA) is just withing the limit of the USB supply.
Maybe wise to connect the 5volt supply directly to the 5volt pin instead of running it via that tiny USB diode
(that diode also lowers the supply by ~0.4volt).

Interference:
Don't run the fan wires next to the low voltage wires.
You might have to use snubber circuits across the relay contacts.
A VDR/Varistor, rated for your mains voltage, could be enough.

The relays itself might be rated for your mains voltage, but the board might not be.
YOU are the judge of that.
You might have to ground any exposed ground/controls/etc. of the Nano to mains ground.
Ask a electrician if you're not sure.
Leo..

Thanks for all the responses, much appreciated.

I Tried that didnt help:

  • removed the 10k resistors from IR sensors
  • added 0.1uF ceramic capactors from D4 and D8 to GND

Additional info:

  • With lights OFF (meaning only 1 relay channel active at time) still resets, so I don't think its current problem
  • I have pinMode INPUT for sensors, and they seem to be working correctly, should I still change to INPUT_PULLUP?

UPDATE:

  • I removed the relay, reattached the connection and it seems to work without resetting at least while out of the enclosure. I also reattached 10k resistor and this time between D4&D8 and 5V rail
    Arduino monitor shows that sometimes (although rare now) it records millis() handOnSensorTime timestamp a bit wrong for ir sensors but that could be maybe a reflection problem than hardware.
    -> will put back in for more testing...
    UPDATE2:
    Again resetting problems;
  • Can the metal enclosure cause problems? Arduino -> Relay wires are 20cm long jumpers that go through metal "canal"
  • Does it affect that usb power supply and AC mains are connected to same outlet via outlet splitter? Can these cause interference?
    Outlet
    Arduino in enclosure
    UPDATE3:
  • I plugged some extension cable(1m) between power supply and arduino usb cable(50cm) and that seems keep resets away for now
  • I'll keep testing why IR sensors register times for swipe motion wrong.
    Test A : reduce proximity sensors to minimum -> RESULTS: Still errors reading swipe direction, probably close range hand reflection
    Test B : set proximity sensors to max -> RESULTS: Too much reflection e.g. from opposite wall
    Test C . take of sensors and test with angle to see if the problem is really a reflection problem -> RESULTS: 0 erros of reading swipe direction

Final test: Put sensors back and use zip tie to pull them together from back to create an angle to reduce reflection errors- > RESULTS: not enough angle, they need more space or some kind of filter system

As always, time to fix design flaws with software. Any experience with switching between sensors?
I'm first just trying by just reading every other loop left and every other right

UPDATE4:

Problem A - Arduino resets randomly using IR sensors and relays at the same time
Fixed by (active?) usb extension cable. Probably by reducing noice from the relays AC mains that was plugged in the same outlet using splitter (does anyone agree/disagree?)

Prolem B - IR sensors proximity crossed readtimes not consistent
Fixed by switching reading between sensors
UPDATE5:

Interesting update, using oven below (turning the dial to switch between programs), IR sensors registers a swipe right and turns the fan on! :O( That only happens when powered from laptop usb though)

Anyway,I modified code to only detect fast swipe or hand on sensor so it's not reading direction of swipe anymore.