Arduino Nano Malfunctioning

Hello,
I am new to Arduino and trying to make a bottle filling system.
Parts that I am using:

  • Arduino Nano
  • 7 solenoid
  • Foot switch for input
  • 8 Channel Relay
  • 3 Power supplies
  • 1 for arduino
  • 1 for 24v DC Valve
  • 1 for 3 x 12V DC 1.1A Solenoid

Problem -
When everything is switched off except Arduino it is working fine(I check lights on relay) after pressing the switch but when I switch on solenoid valves or any other electrical appliance like Fan Arduino malfunction and starts taking input readings even when I don’t press the switch.

I have attached code file and wiring diagram.

Parts Using -
Jumper wires - https://www.amazon.in/gp/product/B0714GQG8Z/ref=ppx_yo_dt_b_asin_title_o01_s01?ie=UTF8&psc=1

Foot Switch - https://www.amazon.in/gp/product/B07P986T47/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

Arduino Nano - https://www.amazon.in/dp/B07C8G4N6X?ref=ppx_pop_mob_ap_share

8 Channel Relay - https://www.amazon.in/gp/product/B01IDNCCFQ/ref=ppx_yo_dt_b_asin_title_o03_s00?ie=UTF8&psc=1

Solenoid Lock - https://www.amazon.in/gp/product/B07T8L1WRJ/ref=ppx_yo_dt_b_asin_title_o02_s00?ie=UTF8&psc=1

DESIGN-min.pdf (146 KB)

Program.txt (2.32 KB)

Config.txt (484 Bytes)

when I switch on solenoid valves or any other electrical appliance like Fan Arduino malfunction and starts taking input readings even when I don't press the switch.

How is the inputs wired ?
Are they always in a known state (HIGH or LOW) or are they floating at an unknown voltage so liable to pick up external interference ?

Pullup or pulldown resistors in place ?

A Nano is not a power supply, meaning you can't power that 8-relay board through the Nano.

Remove the (green) ground wire between Nano and relay board, remove the JD-VCC jumper (for opto isolation),
and power the relay board on JD-VCC (not vcc) and ground of the relay board with a 5volt/1Amp cellphone charger.

Must add kickback diodes across all low voltage solenoids, and snubber circuits across the relay contacts for mains power devices. If you don't, then the sparking relay contacts could randomly reset the Nano.
Leo..

Wawa:
A Nano is not a power supply, meaning you can't power that 8-relay board through the Nano.

Not quite. With all relays activated, it draws about 720 mA. In general, the diode in the Nano which feeds the USB input voltage to the "5V" terminal is rated at 500 mA. The "Phone charger" you illustrate is probably rated at 1 Amp and would do the job but you are exceeding the diode rating.

Wawa:
Remove the (green) ground wire between Nano and relay board, remove the JD-VCC jumper (for opto isolation),
and power the relay board on JD-VCC (not vcc) and ground of the relay board with a 5volt/1Amp cellphone charger.

You possibly can use the same 5 V supply, but you need the connections from the power supply to run directly to the Nano ("5V" and ground terminals) and also separately from the power supply itself to "JD-VCC" and "GND" on the relay board.

Wawa:
Must add kickback diodes across all low voltage solenoids, and snubber circuits across the relay contacts for mains power devices. If you don't, then the sparking relay contacts could randomly reset the Nano.

It is most important that the wiring of the relays to the devices they control is kept quite separate from all the wiring to the Nano. You must keep power and ground wires always running together as a pair in every part of the circuit. This also includes keeping all control or signal wires together with their accompanying ground wires.

Finally, proper practice is to connect the footswitch - or any external switch - between the pin and ground. It is probably a good idea to add the 10k as a pull-up to Vcc, connected at the Nano itself, but in many cases setting pinMode to INPUT_PULLUP for this pin will work quite well.

If you were to read the forum instructions, you could put your code into the posting so we could check it out. :roll_eyes:

"PDF"s are not readily viewable on tablets and such, and cannot be embedded in web pages to be viewed directly.

#include "config.h"

void setup() {
//OUTPUT
pinMode(C02_VALVE, OUTPUT);//co2
pinMode(VACUUM_VALVE, OUTPUT);//slow_vaccum
pinMode(DRINK_VALVE, OUTPUT);//drink
pinMode(VACUUM2_VALVE, OUTPUT);//fast_vacuum
pinMode(BOTTLE_LOCK, OUTPUT);//drink
pinMode(MACHINE_LOCK, OUTPUT);//top
//INPUT
pinMode(SWITCH, INPUT);
Serial.begin(9600);
}

int buttonPushCounter = 0; // counter for the number of button presses
int buttonState = 0; // current state of the button
int lastButtonState = 0; // previous state of the button

void loop() {
// read the pushbutton input pin:
buttonState = digitalRead(SWITCH);
// compare the buttonState to its previous state
if (buttonState != lastButtonState) {
// if the state has changed, increment the counter
if (buttonState == HIGH) {
// if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
}
// Delay a little bit to avoid bouncing
delay(100);
}
// save the current state as the last state, for next time through the loop
lastButtonState = buttonState;

if (buttonState == HIGH) {
if (buttonPushCounter == 1) {
Serial.println("MACHINE LOCK ON");
digitalWrite(MACHINE_LOCK,HIGH);
delay(10000);
}
}

if (buttonState == HIGH) {
if (buttonPushCounter == 2) {
Serial.println("MACHINE LOCK OFF");
digitalWrite(MACHINE_LOCK,LOW);
Serial.println("FILLING ON");
digitalWrite(C02_VALVE,HIGH);//Co2 open
delay(TIME1);
digitalWrite(C02_VALVE,LOW);//Co2 close
digitalWrite(VACUUM2_VALVE,HIGH);//CO2 FLUSH OUT open
delay(TIME2);
digitalWrite(VACUUM2_VALVE,LOW);//CO2 FLUSH OUT open
digitalWrite(C02_VALVE,HIGH);//Co2 open
delay(TIME3);
digitalWrite(C02_VALVE,LOW);//Co2 close
digitalWrite(DRINK_VALVE,HIGH);//Drink open
digitalWrite(VACUUM_VALVE,HIGH);//Vaccum open
delay(TIME4);
digitalWrite(DRINK_VALVE,LOW);//Vaccum close
digitalWrite(VACUUM_VALVE,LOW);//Drink close
Serial.println("FILLING OFF");
}
}
if (buttonState == HIGH) {
if (buttonPushCounter == 3) {
digitalWrite(VACUUM2_VALVE,HIGH);//Drink close
digitalWrite(BOTTLE_LOCK,HIGH);
delay(2000);
digitalWrite(VACUUM2_VALVE,LOW);//Drink close
delay(30000);
buttonPushCounter = 0;
}
}
}

If you were to read the forum instructions, you could put your code into the posting properly so we could check it out. :roll_eyes: