system
December 17, 2014, 2:25pm
1
Hi,
i recently bought a new arduino nano and I'd like to measure current and voltage of a photovoltaik power plant and the state of charge of a battery.
This is my program code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11 , 10, 7, 6, 5, 4);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
}
void loop() {
//Photovoltaik
int sensorValue = analogRead(A1);
float voltage = sensorValue 4 (4.5/ 1024.0 );
int sensorValue2 = analogRead (A2);
float current = (sensorValue2-511.0)0.64 ( 20.0 / 512.0);
float power= voltage*current;
delay(500);
lcd.print( "P=");
lcd.print(power);
lcd.print(" Watt");
lcd.setCursor(0,2);
//Batterie
int sensorValue3 = analogRead(A0);
float voltage2 = sensorValue3 * 4 * (4.5 / 1024.0 );
float percentage = voltage2 * 100 / 12.853;
lcd.print("Ladestand:");
lcd.print(percentage) ;
lcd.print("%");
lcd.setCursor(15,1);
}
Unfortunately it does not work. I programmed it in parts and each of them is working. But when i merged my parts it did not work.
Do you have any ideas?
Thanks for the help,
Merve
In what way does it "not work"?
I would expect to see the LCD cursor position being set BEFORE the output is started, not after it is done.
You may want to display Voltage and Current as well as Power since a bad connection for either of those could cause Power to be wrong.
lcd.setCursor(15,1);
That is a very strange place to move the cursor to on a 16 by 2 LCD.
system
December 18, 2014, 12:12pm
4
Ok, so i set the cursor to another place in the programm.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11 , 10, 7, 6, 5, 4);
void setup() {
Serial.begin(9600);
lcd.begin(16,2);
}
void loop() {
//Photovoltaik
int sensorValue = analogRead(A1);
float voltage = sensorValue 4 (4.5/ 1024.0 );
int sensorValue2 = analogRead (A2);
float current = (sensorValue2-511.0)0.64 ( 20.0 / 512.0);
float power= voltage*current;
delay(500);
lcd.setCursor(0,0);
lcd.print( "P=");
lcd.print(current);
lcd.print(" Watt");
//Batterie
int sensorValue3 = analogRead(A0);
float voltage2 = sensorValue3 * 4 * (4.5 / 1024.0 );
float percentage = voltage2 * 100 / 12.853;
lcd.setCursor(0,1);
lcd.print("Ladestand:");
lcd.print(percentage) ;
lcd.print("%");
}
The current measurement is working.
But the voltage measurement is still not working.
Our loop is not working too. I have to upload the programm everytime i change my input signal og my power supply. It's simply not updating the new voltage....
Thanks for your help,
Merve
But the voltage measurement is still not working.
What do you mean by this ? Do you see a value, if so what is it ? How are your analogue inputs wired ?
Hi,
Can you please post a copy of your sketch, using code tags?
Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png or pdf?
Thanks..Tom.......
system
December 18, 2014, 1:13pm
7
It shows the value 0,00.
The batterys stand for the power supply. And the current also comes from the power supply.
I attached my circiut.
Best Regards,
Merve
system
December 18, 2014, 1:33pm
8
Now it is working it was a problem with the power supply
thanks for your help!!
Merve