I am using an arduino Uno v3 to monitor my pool level. I am using an analog water level sensor and feeding into A0, 5v and ground.
I am using a 9v solar panel to charge a 4.2 ion lithium battery using a 5V 1A Micro USB 18650 Lithium Battery TP4056 DW01A Charger Board Module and powers the arduino and a ESP8266 WiFi Shield. When the sun goes down the battery takes over the power. Because of the configuration I have to power the Arduino from the battery/solar panel using the Vin port. Normal operations is about 20ma except when the sensor is used every 1/2 hr. then it is around 40ma. The WiFi Shield uses 200ma but I am hoping to only use it every 1/2 hr. also. We'll see.
The Arduino then send a signal to an encoder and through a RF antenna to a receiving antenna and decoder to flip a locking relay.
WHAT I WOULD LIKE TO DO...is monitor the battery level every half hr and post it also to ThingSpeak. That way I could see if the battery is being charged and how much and how much it is discharging. I could also see when the battery starts to charge less and discharge faster indicating that the battery needs to be changed.
I have looked at various tutorials on getting the battery power but I don't know if they pertain to this situation.
I am already using A0 so can I use A1? (Sorry I am brand new to Arduino programing, I have done some IOS development but).
Since I am using a solar panel to charge the battery/run the Arduino etc.and then using the battery at night do I use the battery as the source and forget the Vin.
Do I use two resisters to split the charge on the battery anyway and then just go into A1.
Then instead of printing to LCD just print to ThingSpeak?
The problem I'm having I what code do I use. Pointers?
Using A0 for what? You can use ALL the analog pins at the same time, as long as you take care when switching analog pins (typically, this just means discarding the first reading from the new pin).
Since I am using a solar panel to charge the battery/run the Arduino etc.and then using the battery at night do I use the battery as the source and forget the Vin.
I don't understand this question. How are you connecting the battery/solar panel to the Arduino?
Do I use two resisters to split the charge on the battery anyway and then just go into A1.
What you need to do is post a schematic showing how you are charging the battery. That the battery is being charged has nothing to do with it powering the Arduino/being measured by the Arduino.
Then instead of printing to LCD just print to ThingSpeak?
if you look at the image I posted you can see my wiring diagram.
A0 is being used for the liquid level sensor input.
if I connect the resisters to the battery what happens when it is being charged during the day and the solar panel is powering the Arduino, etc.
If I connect the resisters to the Vin part of the time it will be measuring the Solar panel input of 5v.
This is why I'm not sure which to monitor the battery or the Vin input.
Also not sure what code to use to find out the voltage.
Would I use something like this to read the battery level.
void loop()
{
printVolts();
}
void printVolts()
{
int sensorValue2 = analogRead(A1); //read the A1 pin value
float voltage = sensorValue * (5.00 / 1023.00) * 2; //convert the value to a true voltage.
if (voltage < 6.50) //set the voltage considered low battery here
{
WiFi write to ThingSpeak(voltage); Not sure how to do this as I haven't connect WiFi Shield yet.
}
}
Would I use something like this to read the battery level.
I wouldn't. The function name implies that it will always print some voltage value, when that is not what the function actually does.
reportLowVoltageCondition() would be a better name, as far as I'm concerned, because it is then quite obvious what the function will do.
What is a "voltage upchanger" and why is it connected to the Arduino? The whole battery charger circuit is irrelevant to the Arduino. You are charging/discharging a 4.2V battery, so not voltage divider is needed between the battery and the Arduino.
Something to keep in mind. The output value from the analogRead() function is a scaled value, between 0 and 1023, of the reference voltage. If you are reading the voltage of the same battery that is powering the Arduino, the voltage reading will always be 1023, since the Vin pin and the analog pin are connected to the same voltage source.
I thought the Arduino needed 5v to function so I installed a board that ups the 4.2 volts to 5 volts. If I don't need it I will remove it.
the charging unit charges the battery at the same time it powers the Arduino and WiFi Shield. When the battery become almost charged it goes to trickle. When the solar panel doesn't provide enough power then it switches to the battery. So where would I put the two resister to feed the A1?