electro_nooobbbb

Mar 1, 2023 04:31
Hi Mr hcheung, could you please check!
Feb 28, 2023 11:08
Now i would try it for attiny
Feb 28, 2023 11:07
void setup(){
Serial.begin(9600);
}

void loop() {



//REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
ADMUX |= B11000000;
//We read A1 (MUX0)
ADMUX |= B00000001;
//int sensor = analogRead(A1);
// Start AD conversion
ADCSRA |= B11000000;
// Detect end-of-conversion
while (bit_is_set(ADCSRA,ADSC));
float val = ADCL | (ADCH << 8);
val = val * 5.7; //Multiply by the inverse of the divider
Serial.println(val);


float voltage = val * analogRead(A0) / 1023;
voltage = ADCL | (ADCH << 8);
Serial.print ("voltage at A0:");
Feb 28, 2023 10:38
This code reads constant voltage
Feb 28, 2023 10:38
void loop() {
//REFS1 AND REFS0 to 1 1 -> internal 1.1V refference
ADMUX |= B11000000;
//We read A1 (MUX0)
ADMUX |= B00000001;
// Start AD conversion
ADCSRA |= B11000000;
// Detect end-of-conversion
while (bit_is_set(ADCSRA,ADSC));
float val = ADCL | (ADCH << 8);
val = val * 5.7; //Multiply by the inverse of the divider
Serial.println(val);
}
Feb 28, 2023 10:26
and i have already wrote a program that can read constant battery voltage the issue with that is, the moment i add solar code to battery code, it starts behaving abnormally.
Feb 28, 2023 10:25
int sensorValue = analogRead(A0); // Solar Panel Positive PIN connect to A0
float voltage = sensorValue * (5.0 / 1023.0); as per my research in order to read solar voltage constant voltage supply is required
Feb 28, 2023 10:21
but i dont understand what is the issue with solar panel
Feb 28, 2023 10:21
for testing purposes i connected potentiometre in place of solar panel and it works perfectly
Feb 28, 2023 10:13
tested with diode
Feb 28, 2023 10:12
Solar panel voltage:4.64
voltage at A0:0.82
Solar panel voltage:4.65
voltage at A0:0.82
Solar panel voltage:4.65
voltage at A0:0.81
Solar panel voltage:4.64
voltage at A0:0.81
Solar panel voltage:4.64
voltage at A0:0.82
Solar panel voltage:4.65
voltage at A0:0.82
Solar panel voltage:4.65
voltage at A0:0.81
Solar panel voltage:4.64
Feb 28, 2023 10:12
it does not work
Feb 28, 2023 09:19
i will give it a try
Feb 28, 2023 09:18
ok
Feb 28, 2023 09:07
where should i connect the solar? we are reading A0 from a voltage divider that's correct code is also correct but where should i connect the solar?
Feb 28, 2023 09:05
sorry?
Feb 28, 2023 09:05
sorry
Feb 28, 2023 09:05
just that
Feb 28, 2023 09:05
you tell me where do i need to connect solar panel
Feb 28, 2023 09:05
ok
Feb 28, 2023 09:03
is it ok to leave the two ends of the solar open like that?
Feb 28, 2023 09:00
I disconnected 5v from the panel. Now the +side goes to one end of voltage divider and -side goes to GND side of the divider.
Feb 28, 2023 08:59
.27
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:0.39
Solar panel voltage:2.25
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:1.10
Solar panel voltage:6.27
voltage at A0:1.10
Solar panel voltage:6.27
Feb 28, 2023 08:58
ok
Feb 28, 2023 08:54
my connections are right or wrong?
Feb 28, 2023 08:54
so what do you say
Feb 28, 2023 08:54
i am electronic engineer,i have completed my project but i am badly stuck in here.sorry
Feb 28, 2023 08:51
where do i need to connect it ?solar?
Feb 28, 2023 08:50
5v where?
Feb 28, 2023 08:50
one side to voltage divider goes to 5v and the other one two GND and to the same point i have connected solar panel.
Feb 28, 2023 08:49
yes
Feb 28, 2023 08:49
4.7k and 1k and from the mid took one pin to A0
Feb 28, 2023 08:48
no i made voltage divider
Feb 28, 2023 08:48
even if i cover the full panel, it should read 0v if full covered
Feb 28, 2023 08:47
A0:0.99
Solar panel voltage:5.65
voltage at A0:0.99
Solar panel voltage:5.65
voltage at A0:0.99
Solar panel voltage:5.67
voltage at A0:1.01
Solar panel voltage:5.74
voltage at A0:1.01
Solar panel voltage:5.77
voltage at A0:1.01
Solar panel voltage:5.76
voltage at A0:1.01
Solar panel voltage:5.76
voltage at A0:1.01
Solar panel voltage:5.76
voltage at A0:1.01
Solar panel voltage:5.76
voltage at A0:1.01
Solar panel voltage:5.75
voltage at A0:1.01
Solar panel voltage:5.76
voltage at A0:1.01
Solar panel voltage:5.74
Feb 28, 2023 08:46
the reading should increase
Feb 28, 2023 08:46
it does not change if light falls on it
Feb 28, 2023 08:46
hi
Feb 28, 2023 08:36
from new code
Feb 28, 2023 08:36
Solar panel voltage:4791482.00voltage at A0:841541.81
Solar panel voltage:4796788.00voltage at A0:841541.81
Solar panel voltage:4796788.00voltage at A0:843403.62
Solar panel voltage:4807400.50voltage at A0:843403.62
Solar panel voltage:4807400.50voltage at A0:841541.81
Solar panel voltage:4796788.00voltage at A0:839680.00
Solar panel voltage:4786176.00voltage at A0:837818.18
Solar panel voltage:4775563.50voltage at A0:837818.18
Solar panel voltage:4775563.50voltage at A0:839680.00
Solar panel voltage:4786176.00voltage at A0:839680.00
Feb 28, 2023 08:34
ok i will try the second one.
Feb 28, 2023 08:34
serial monitor readings from your first code
Feb 28, 2023 08:33
189.00
189.00
190.00
190.00
190.00
190.00
190.00
190.00
190.00
190.00
190.00
190.00
190.00
189.00
190.00
Feb 28, 2023 08:28
ok,omg only this much was needed.
Feb 28, 2023 08:24
can u see error?
Feb 28, 2023 08:24
ADMUX |= B11000000;
int sensor = analogRead(A0);
ADCSRA |= B11000000;
while(bit_is_set(ADCSRA, ADSC));
float voltage = ADCL | (ADCH << 8);
voltage = (sensor /1.1)*1024;
Serial.println (voltage);
Feb 28, 2023 08:18
Please check my schematic and code , i have posted it.
Feb 28, 2023 08:17
my solar panel is 6V, 30mA
Feb 28, 2023 08:16
Yes, i did try with 1.1v as well, it is persistently showing me 0.00V
Feb 28, 2023 08:16
ldr as i said is just used because i dont have solar panel component in my software.