Hello there I have some serious temperature issues in abasement im living in Im trying tu use my Arduino to control my environment .I have no experience in coding can you please help me with combining theses to codes together .I’m trying to have Relay 1 (channel 1 )turn on for 8 seconds and Off for 10 minutes continuously and Relay 2 ( channel 2) temperature controlled to turn on and off at a certain temperature.I found thses two examples on the Arduino IDE and they both indivully do what I need so can I just combine them.
Code 1
/*
RelayExample.ino
*/
#include <Easyuino.h> // Include the library in order to the compiler know you want Easyuino library
using Easyuino::Relay; // Necessary in order to use Relay
int arduinoPin = 6; // Arduino pin that controls the relay
Relay relay(arduinoPin); // Create the Relay object that exposes the API to use
void setup() {
Code 2
/********************************
name: 5V relay module and DHT 11/22/21 humidity and temperature sensor module
function: This program shows how the temperature and humidity sensor turns on
devices or power sockets connected to 5V relay module
email: info.acoptex@gmail.com
web: http://acoptex.com
********************************/
#include <DHT.h> // include library
const int relayPin = 8;
const int DHTPIN = A0;
// Uncomment whatever type you're using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302), AM2321
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
DHT dht(DHTPIN, DHTTYPE);// Initialize DHT sensor
/********************************/
void setup() {
Serial.begin(9600);
pinMode(relayPin, OUTPUT);
dht.begin();
}
void loop()
{
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds 'old' (its a very slow sensor)
float h = dht.readHumidity();
// Read temperature as Celsius (the default)
float t = dht.readTemperature();
// Read temperature as Fahrenheit (isFahrenheit = true)
float f = dht.readTemperature(true);
// Check if any reads failed and exit early (to try again).
if (isnan(h) || isnan(t) || isnan(f)) {
Serial.println("Failed to read from DHT sensor!");
return;
}
Serial.print("Temperature = ");
Serial.print(t);
Serial.print(" *C ");
Serial.print("Temperature = ");
Serial.print(f);
Serial.print(" *F ");
Serial.print("Humidity = ");
Serial.print(h);
Serial.print(" %\t ");
Serial.println();
if (h >= 66) { // you can change humidity value here - h>=66 to your preffered number
digitalWrite(relayPin, LOW);
}
else {
digitalWrite(relayPin, HIGH);
}
if (t >= 25) {// you can change temperature value here - t>= 30 to your preferred number or change from Celsius to Fahrenheit readings
digitalWrite(relayPin, LOW);
}
else {
digitalWrite(relayPin, HIGH);
}
delay(1000);// 1 second delay between measurements
}