Arduino nano reset button

Hey, I am Binkal and I am using arduino nano for to build automatic water dispenser. but the reset button is not resetting the code. on several clicks it responds. I have no idea why. could you help me with this. can i somehow reset the code from arduino IDE 2.3.2?

Secondly, I am using the following code to use the setup as water dispenser and strangely only either water sensor is working or the water pump. i am using 12v power source, 1000mA. here is the code that i am using:

#define PUMP_PIN 3  // Relay for pump is connected to Arduino's Digital Pin 3
#define FLOW_CALIBRATION_FACTOR 7.5  // Calibration factor for flow sensor

volatile int flowPulses;  // Measures flow sensor pulses
float totalVolume = 0;  // Total volume of water dispensed

// Interrupt function
void flow () {
  flowPulses++;
}

void setup() {
  pinMode(FLOW_SENSOR_PIN, INPUT);
  pinMode(PUMP_PIN, OUTPUT);
  digitalWrite(PUMP_PIN, HIGH);  // Ensure pump is on
  attachInterrupt(digitalPinToInterrupt(FLOW_SENSOR_PIN), flow, RISING);  // Configuring interrupt
  Serial.begin(9600);
}

void loop() {
  flowPulses = 0;
  sei();  // Starts the interrupt
  delay(1000);  // Wait 1 second
  cli();  // Stop the interrupt
  
  // Calculate flow rate in L/min
  float flowRateLPM = (flowPulses / FLOW_CALIBRATION_FACTOR);

  // Add the amount of water flowed in this second to the total volume
  totalVolume += flowRateLPM / 60;  // Convert L/min to L/sec

  Serial.print("Flow rate: ");
  Serial.print(flowRateLPM);
  Serial.println(" L/min");

  Serial.print("Total volume: ");
  Serial.print(totalVolume);
  Serial.println(" L");

  // Control the pump based on total volume
  if (totalVolume >= 0.5) {  // If total volume is more than or equal to 0.5 L
    digitalWrite(PUMP_PIN, LOW);  // Turn off pump
  }
}```
. the connections are as follows: 
**Connecting the Flow Sensor to Arduino Nano:**
VCC/+: Connected the VCC or + pin of the flow sensor to the 5V pin of the Arduino. (red wire)

GND/-: Connected the GND or - pin of the flow sensor to the GND pin of the Arduino.(Black wire)

Signal/Out: Connected the Signal or Out pin of the flow sensor to a digital pin of the Arduino, say D2. (Yellow wire)

**Connecting the Relay to Arduino Nano and Pump:**

VCC: Connected the VCC pin of the relay to the 5V pin of the Arduino. (red wire)

GND: Connected the GND pin of the relay to the GND pin of the Arduino. .(Black wire)

IN: Connect the IN pin of the relay to a digital pin of the Arduino, say D3. (Yellow wire)

NO (Normally Open): Connected the NO pin of the relay to one terminal of the pump.

COM lCommon Terminal: Connected the common terminal of the relay to the positive terminal of your power supply.

Material used: arduino nano, 5v water pump, Seeed Studio G1/2-inch Water Flow Sensor, SRD-05VDC-SL-C 10A 28VDC relay.

could you please help me find the problem and make this system run. i will be really grateful for your help. hoping to hear from you soon.

You should never post in the Uncategorised section.
It says so in the description of the section. Therefore I have moved your post here.

You might want to look at this How to get the best out of this forum before you proceed any further.

We also need to see a schematic to help you with this problem because the code alone doesn't tell the full story. A wiring list doesn't cut it in electronics.

Why do you want to reset the board in the first place? That sounds like badly designed software.

Is your nano a clone? It could be the switches are sub standard.

curious software design….

Why are you using the reset button for anything ?

What behavior do you see that makes you reach this conclusion?

A RESET is automatically issued to a Nano once you open the Serial monitor.

However:

That's a very odd decision indeed and I wouldn't consider it a good design choice.
Don't rely on the reset button for normal functioning of the circuit.

Please show a schematic of your setup. The written-out version of your connections is difficult to read and more ambiguous than a proper schematic. Please also post some good photos of the physical setup as built.

No, that's not a good approach. One problem with this is that you're disabling interrupts for the remainder of the loop, which AFAIK does not even happen, so the sei() and cli() are superfluous to begin with. Moreover, there will probably be still interrupts occurring after your cli().

If you only want to periodically compute output values to the Serial monitor, it's best to use something based on millis(). Save a millis() timestamp into a variable every time the calculation/output is being done, and in the loop look if 1000ms have passed since the last timestamp. If so, do the calculation/output again and save a new timestamp.

thank you Mike for your quick response. I will keep your suggestion in mind when posting on forum. No, i bought it from official webstore of the arduino. the list of stores was sent to me by arduino customer care. please find the image of the circuit diagram attached.


I meant the reset button of arduino nano. i thought maybe the mini usb cable was causing this trouble so i used a new cable today and for now it worked.

OK, I can't see anything that is 12V on that schematic.
Also it looks odd connecting one side of the relay coil to a relay contact pin. I wonder if this is a mistake in your schematic or if you actually have done this?

@rsmls, error was showing in upload even when the reset button is pressed on arduino nano. and tx light was keep blinking.

sorry that is 12v power supply. my bad.

i made mistake in the schematic writing. I wrote 5v instead of 12V


here is the corrected circuit diagram.

this is the power supply unit I am using

I'm sorry, I don't know what this means. Could you rewrite this in your native language and then run it through Google translate to convert it to English? It may help me to understand what you're saying.

The schematic doesn't make much sense, especially the wiring of the relay. Are you using a bare relay, or a relay module with logic inputs?

Can you please post the photos of the setup that I asked before? This is generally easier than asking lots of follow-up questions.

Your diagram is still wrong 12v Batt and a 5v Motor.
GND should be BLACK.
RED is POSITIVE.
One side of your Relay is not connected.



relay connection: Gnd: red, I/O: yellow, VCC: red.

And earlier I meant that after pressing reset button and then when i was trying to upload new code, the error1 was showing

thank you for your suggestion about colors of wire. could you also ellaborate on 5v pump and 12v battery.

OK, what is "the error1"? Can you reproduce the error and post it, please?

Your third photo shows the Arduino is not powered. Am I correct in assuming it's normally powered through the computer's USB port?

I see you have two Nano's on that breadboard. Have you tried both of them? Do both produce the same problems related to the Rst button?

Can you please clearly answer this question I asked, but that does not appear to be fully answered yet:

I.e. what problem does your sketch/code produce when you try using the Reset button? How come you believe the Reset button does not work? Is it only the code upload problem, or something else, too?

The 5V Motor will burn if you put 12V on it.

Sketch uses 4228 bytes (13%) of program storage space. Maximum is 30720 bytes.
Global variables use 246 bytes (12%) of dynamic memory, leaving 1802 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\.\COM5": Access is denied.

Failed uploading: uploading error: exit status 1

this is the error message. for the reset button assumption, since it was not uploading the new code, even after pressing the reset button, lead me to this assumption.

yes i tried both arduino boards and yes arduino is powered through the computer's USB port.

That’s quite important…

This can mean either of two things, usually:
1: The COM port is being used by something else. E.g. an external terminal/monitor app.
2: The board is disconnected and the COM port is not available.
You can verify which it is by going into Device Manager and checking whether the selected COM port is indeed listed there.

In case the COM port does not show up in the device manager, this can be due to many issues, including a bad USB cable, or excess power draw or a short circuit on the 5V line coming from the USB, resulting in the USB port being disabled (temporarily) by the computer.

There's no logical/direct/physical relationship between this problem and the reset button on a Nano.