I use an Arduino Nano input pin in order to read a certain value during the setup.
This pin is connected to a 2 state switch, which delivers VCC or GND via 1K resistor to the IO port.
The value is read during the setup routine, and remains "don't care" afterwards.
During setup the pin is set to INPUT.
Since it is a battery operated project. I wonder if there is a away to define the IO port after that read operation, so it will consume the minimum possible leakage power.
Or if there is another idea how to read this one out of 2 states during setup time.
Yes,
pinMode(yourPin, INPUT);
If the pin is an input, and is either VCC or GND, just leave it as input.
If your concerned about 'pin leakage' what as a comparison is the active (or sleep) current of the nano ?
Is that really necessary? Why such a complex circuit?
Thanks, however, this is the current definition.
If this remains during the runtime of the project. it will keep consuming power through the input port. Not much, I know.
My question is: is there any other way, except from INPUT or OUTPUT (which is a bad choice, I know), that will prevent from this small leakage power?
You don't seem to know. This really is false, the current amounts to nano Amperes. If it is some result of your switch circuit, you should of course post a schematic.
It looks simple to me: just a switch and a resistor. Do you have a better idea how to read one out of two states?
As much as that ?
You could use a SPST switch, one side to ground, the other to the input pin, read it with INPUT_PULLUP enabled.
Have you not done a survey of how switches are connected in other projects and tutorials?
I have bad experience with the internal pullup resistors. Easy to damage, especially in the ESP32 I am using too. So I prefer external resistor.
So, with an external resistor... no difference. It will draw current if it is active though. Is this a toggle switch that can remain active? Is that your problem?
Please respect the forum guidelines and post a diagram of your switch circuit.
You were directed to the forum guide in your last thread, I suggest you go back and read it again if you doubt that it is necessary.
You could connect the external pullup resistor to another pin, put that pin in output mode, output a HIGH to supply the pullup voltage, then afterwards output a LOW and return to input mode. If leakage is that big of a concern, a 1K pullup seems like a very low value.
Personally I don't see much chance of damaging the internal pullup once the switch is wired, if someone is going through your device randomly shorting wiring the internal pullup resistors are one of the last things I would be worried about.
There are two states with 2 pins switch as you suggested:
When the switch is at OFF, the pull up will deliver HIGH value to the input pin, and the only power consumed will be the leakage power of the pin. This is low indeed.
When the switch is ON, there will be a continuous power leakage through the resistor to GND. I guess I will go with that with a higher resistor.
The described circuit will probably work. I don't want to commit an opinion to a verbal description alone, though. If it's a double throw switch, resistor on the common to input, other poles to ground and Vcc, leaving it set to INPUT will not consume any significant current, even in standby or sleep modes.
I've
- asked you repeatedly for a diagram
- explained numerous times why you should
You are ignoring me.
So I am adding you to my permanent ignore list.
I know how to fix your circuit. But you didn't want to cooperate. So you'll just have to guess. Bye. I made it so I won't ever see your replies again.
The Nano is a very poor choice for low power operation, unless you have modified the board.
Indeed so.
I agree, yet I will not modify the board. My next target is to with ESP32 in order to add wireless, at this stage I will draw schematics, build the prototype and see the battery life behavior with the Nano.
I may also do a version with ATtiny, if I could reduce the needed IO.
Thank you!
The average ESP32 will be a lot worse than an Nano.
I apologize I missed that request. of course, simple diagram is better than many words.
The header is for testing. or put a switch out of the pcb.
I just noticed I have two mistakes:
1- GND net is not really connected.
2- The power in is 5V, so it should be connected to the +5V, not to the VIN.
Both corrected.
