Hey all,
i've encountered a weird problem with my system.
I'm controlling a lamp with the arduino relay module, together with a RTC.
From 8am-7pm i want the light to be turned on by setting the outpin pin high on the relay module.
It works great at start, but after around 8min it randomly turns the pin off, measuring 0V.
At first i thought it's because of the high power demand, so i disconnected the relay module completely and measured again.
Same story, after around 8min the voltage is 0V.
But the weird thing is, as soon as i connect it to a PC via USB, the pin stays HIGH.
What could cause this kind of issue?
The rest of the sensors/displays are working perfectly fine all the time, so i don't think this is a power drain issue.
Here's the (relevant) code.
Thanks in advance!
unsigned long currentTime;
//RTC (Real-Time-Clock)
#include <Wire.h>
#include <RTClib.h>
RTC_DS1307 rtc;
DateTime now;
//Lampe
const byte lampPin=4;
void setup() {
Serial.begin(9600);
analogReference(EXTERNAL);
pinMode(pinCS,OUTPUT);
digitalWrite(pinCS,HIGH);
pinMode(lampPin, OUTPUT);
//RTC (Real-Time-Clock)
rtc.begin();
Wire.begin();
if(!rtc.begin()){
Serial.println(F("Couldn't find RTC"));
}
if(!rtc.isrunning()){
Serial.println(F("RTC is NOT running"));
}
rtc.adjust(DateTime(F(__DATE__), F(__TIME__))); //Zeit/Datum neu justieren
void loop() {
//Lampe
if(now.hour()<19 && now.hour()>7){
digitalWrite(lampPin,HIGH);}
else{
digitalWrite(lampPin,LOW);
}
//RTC
now=rtc.now();
if(now.day()<10){ //Uhrzeit anzeigen
Serial.print("0");
}
Serial.print(now.day(), DEC);
Serial.print("/");
if(now.month()<10){
Serial.print("0");
}
Serial.print(now.month(), DEC);
Serial.print("/");
Serial.print(now.year(), DEC);
Serial.print(" ");
if(now.hour()<10){
Serial.print("0");
}
Serial.print(now.hour(),DEC);
Serial.print(":");
if(now.minute()<10){
Serial.print("0");
}
Serial.print(now.minute(),DEC);
Serial.print(":");
if(now.second()<10){
Serial.print("0");
}
Serial.print(now.second(),DEC);
Serial.println();