I have an Arduino sketch in which I receive data from a DHT22 sensor. If the temperature is higher than 22, a LED lights on and then is turned off after one second. Also, if the humidity is over 40, another LED turns on, and off after 1 second. At the moment, the arduino is connected to the laptop. I would need to connect a solar panel to the arduino, to see the leds turning on and off when the board isn't connected to the computer.
I have a solar panel which has an internal battery of 3.7V.
How could I connect the solar panel to the project?
I am also attaching the project code:
#define DHTPIN 3 // Analog Pin sensor is connected to
#include "DHT.h"
#define DHTTYPE DHT22
DHT dht(DHTPIN, DHTTYPE);
int incomingByte; // a variable to read incoming serial data into
void setup() {
Serial.begin(9600);
dht.begin();
pinMode(4, OUTPUT);
delay(500); //Delay to let system boot
}
void loop() {
read_temp_umid();
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(4, HIGH);
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(4, LOW);
}
}
}
void read_temp_umid()
{
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
if(humidity >40 ) {
digitalWrite(4, HIGH);
delay(1000);
digitalWrite(4, LOW); //turn LED LOW AFTER 1s
// turn the ledPin ON
} else {
digitalWrite(4, LOW);
// turn the ledPin OFF
}
if(temperature >22 ) {
digitalWrite(2, HIGH);
delay(1000);//turn LED LOW AFTER 1s
digitalWrite(2, LOW);
// turn the ledPin ON
} else {
digitalWrite(2, LOW);
// turn the ledPin OFF
}
String message = "temperatura ";
String toprint = message + temperature +";" ;
Serial.print(temperature);
String message2 ="umiditate ";
String toprint2 = message2 + humidity + ";";
Serial.print(humidity);
delay(1000);//read every second
}
Assuming you have a self contained device that can charge the battery and you have a 3.7V output (what power is available) ? then you need a boost converter to bring that up to 5V so that you can power your Arduino.
You need a lot more electronics: this 18650 Li-Ion cells don't like to be discharged under about 3V.. If you don't take precautions to discharge them further you will waste your battery very soon.
then a Li-Ion can be charged to about 4.2V. As a solarpanel is a currentsource you can get higher voltages. Maybe even enough to charge 2 of those 18650's in series.. which gives you a voltage of 6-8.4V.. This can be connected direct to the powerinput of the Arduino Uno.
definitely needs a boost converter and a link to the device would be useful.
for example, we don't know if you can charge at the same time you power something?
the solar panel is from a set of christmas leds; I connected it to the arduino board and it just lights up the "ON" led from the arduino board. Is it possible to power the arduino and to test the functionality of the board with this solar panel? Or else, how could I connect an additional 1.5V battery?
At a minimum the solar cell should be connected to a TP4056. Use a diode on the + side to prevent current backflow during nighttime use, into the solar cell and damaging the solar cell. Out of the TP4056 you'll need a boot converter to make 5V.
The TP4056 works great between 5 and 8 volts. I put 6V, when I tried this, worked well.
Such a set up will run the battery for about 4 months and then you'll need to replace the battery.
If you want to do it right, that's a different story.