/*
Arduino | hardware-help
Could you doulbe check the blueprint of my first arduino project?
Ben.Ninefire — Saturday, November 29, 2025 3:26 AM
I want to make a device that can push the button on the heater of
my van (5x) to start the heating 8 a.m. and 10 p.m. if the temperature
is under 0 C degree for a month and a half while I am away.
Hardwares:
-Nano Module with CH340 Microchip
-RTC Module for Arduino and RPi with Battery
-SG90 9G Micro Servo Motor
-DS18B20 Digital Temperature Sensor TO92
*/
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Servo.h>
#include <RTClib.h>
const unsigned long ONE_SEC = 1000;
const int SERVO_PIN = A0;
const int BTN_PIN = A1;
const int LED_PIN = A2;
unsigned long prevTime = 0;
OneWire oneWire(A3);
DallasTemperature sensor(&oneWire);
RTC_DS1307 rtc;
Servo servo;
void startHeater() {
for (int count = 0; count < 5; count++) {
digitalWrite(LED_PIN, HIGH);
servo.write(0);
delay (500);
digitalWrite(LED_PIN, LOW);
servo.write(90);
delay(500);
}
}
void setup() {
Serial.begin(115200);
sensor.begin();
if (! rtc.begin()) {
Serial.println("Couldn't find RTC");
while (true) {};
}
pinMode(BTN_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
servo.attach(SERVO_PIN);
servo.write(90);
}
void loop() {
char buffer[24];
if (millis() - prevTime >= ONE_SEC) {
prevTime = millis();
DateTime now = rtc.now();
snprintf(buffer, 24, "%2d/%2d/%4d %02d:%02d:%02d",
now.day(), now.month(), now.year(),
now.hour(), now.minute(), now.second()
);
Serial.println(buffer);
sensor.requestTemperatures();
Serial.print("Temperature is: ");
Serial.print(sensor.getTempCByIndex(0));
Serial.println("°C");
Serial.println();
}
if (digitalRead(BTN_PIN) == LOW) {
startHeater();
}
}