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
}
I am also attaching the connections to the board:
The dht22 sensor is connected to the port 3 on arduino, while the LEDS to the 2 and 4 ports. I attached the VCC cable on the 3.3V of the Arduino.



