Hello,
I am designing a solar battery charger where the load of the battery is used to power the arduino nano amongst other loads.
I have connected my battery to the Vin pin of the Arduino nano to be able to temporarily power my arduino in periods of low sunlight since the charging chip i am using has a "load sharing" attribute which prioritizes the larger source (ie the solar panel over the battery). My issue however arises during times of poor solar exposure and dependence on the battery as a source for the arduino.
I noticed that the arduino does not function as expected and i was wondering whether the issue comes with the fact that im operating the nano at below 5 V causing it to malfunction or whether there was an issue in the way that I have coded my board.
PS: The enable pin is triggered to turn on/off a regulators enable pin to restrict the amount of charge being dispersed out of the regulator during periods of prolonged idleness.
Here is the code:
int buttonpin = 4;
int buttonstate = 0;
int ledpin=6;
int enable_pin=5;
boolean enableState = false;
boolean LEDState = false;
long buttonTimer = 0;
long longPressTime = 1000;
boolean buttonActive = false;
boolean longPressActive = false;
void setup()
{
pinMode(ledpin, OUTPUT);
pinMode(enable_pin, OUTPUT); // sets the digital pin 4 as output
pinMode(buttonpin,INPUT); //sets the digital pin 9 as input
}
void loop() {
buttonstate = digitalRead(buttonpin);
if (buttonstate == HIGH)
{
if (buttonActive == false)
{
buttonActive = true;
buttonTimer = millis();
}
if ((millis() - buttonTimer > longPressTime) && (longPressActive == false))
{
longPressActive = true;
enableState = !enableState;
digitalWrite(enable_pin, true);
}
}
else
{
if (buttonActive == true)
{
if (longPressActive == true)
{
longPressActive = false;
}
else
{
LEDState = !LEDState;
digitalWrite(ledpin, LEDState);
}
buttonActive = false;
}
}
}
The regulators fixed 5 V output was not connected to the Vin or 5 V pin of the nano since my method to turn the enable pin on/off to save power would not work due to the turning off of the incoming power to the arduino once the enable pin is triggered.
I have also attached a schematic of my configuration below
Any help would be greatly appreciated,
Thank you!