Hi,
i want to control the AC of my university for a project. I’m using an arduino uno wifi.
My code works great without blynk. When i use blynk i can see via a camera that my leds blink but the AC doesn’t respond. Any thoughts?
#include <BlynkSimpleWifiLink.h>
#include <IRLibSendBase.h> //We need the base code
#include <IRLib_HashRaw.h> //Only use raw sender
#include <TimeLib.h>
#include <Time.h>
#include <TimeAlarms.h>
IRsendRaw irsend;
char auth[] = "xxxx...";
.
char ssid[] = "cs-wireless";
char pass[] = "";
const int sensorPin = A3;
float temperature;
const float baselineTemp = 10.0;
const float baselineTemp2 = 15.0;
const long interval = 60000;
unsigned long previousMillis = 0;
unsigned long time;
unsigned long previousTime = 0;
const PROGMEM unsigned int rawOnAuto24[200] = {4309, 4480, 491, 1600, 512, 555, 512, 1600, 512, 1621, 512, 533, 512, 555, 512, 1600, 533, 555, 533, 533, 512, 1643, 512, 533, 512, 576, 512, 1600, 512, 1643, 512, 533, 533, 1621, 512, 555, 512, 555, 512, 533, 512, 1643, 512, 1621, 512, 1643, 533, 1621, 512, 1621, 512, 1621, 512, 1600, 512, 1643, 512, 555, 512, 555, 512, 533, 512, 555, 512, 533, 512, 555, 512, 1600, 512, 576, 512, 533, 512, 1643, 512, 533, 512, 555, 512, 533, 512, 1643, 512, 533, 512, 1621, 512, 1600, 512, 576, 512, 1600, 512, 1621, 512, 1621, 512, 5205, 4288, 4480, 512, 1621, 512, 555, 512, 1600, 512, 1621, 512, 533, 512, 555, 533, 1600, 512, 555, 512, 533, 512, 1621, 533, 533, 512, 555, 512, 1600, 512, 1621, 533, 533, 512, 1643, 533, 512, 555, 512, 512, 533, 533, 1621, 533, 1621, 533, 1600, 512, 1643, 533, 1600, 512, 1643, 533, 1621, 533, 1600, 533, 555, 533, 533, 533, 533, 533, 555, 533, 512, 512, 555, 533, 1579, 533, 555, 512, 512, 533, 1621, 533, 512, 533, 555, 533, 533, 512, 1600, 533, 512, 533, 1621, 533, 1579, 533, 533, 533, 1579, 533, 1621, 533, 1621, 533};
const PROGMEM unsigned int rawOnAuto25[200] = {4352, 4395, 576, 1536, 576, 512, 576, 1536, 576, 1579, 576, 491, 555, 512, 576, 1557, 576, 512, 576, 469, 576, 1579, 576, 469, 555, 512, 555, 1557, 555, 1600, 555, 512, 576, 1557, 555, 491, 555, 512, 555, 491, 555, 1600, 555, 1557, 555, 1600, 555, 1600, 555, 1579, 555, 1600, 555, 1557, 555, 1600, 555, 491, 555, 512, 555, 491, 555, 512, 555, 491, 555, 1600, 555, 1579, 555, 533, 555, 491, 555, 1600, 555, 512, 533, 533, 555, 491, 555, 533, 555, 512, 555, 1600, 555, 1579, 555, 533, 555, 1579, 555, 1600, 555, 1579, 555, 5184, 4352, 4416, 555, 1579, 555, 533, 555, 1579, 555, 1600, 555, 491, 555, 533, 555, 1579, 555, 533, 533, 512, 555, 1600, 555, 491, 555, 533, 555, 1579, 555, 1600, 555, 512, 555, 1600, 555, 491, 576, 491, 555, 512, 533, 1600, 555, 1600, 555, 1579, 555, 1600, 555, 1579, 533, 1600, 555, 1600, 533, 1579, 533, 533, 533, 512, 533, 512, 533, 533, 533, 512, 533, 1600, 533, 1600, 533, 512, 555, 512, 533, 1600, 533, 512, 533, 533, 533, 512, 533, 533, 533, 512, 533, 1600, 533, 1579, 555, 533, 533, 1579, 533, 1621, 533, 1600, 533};
const PROGMEM unsigned int rawOff[200] = {4245, 4501, 512, 1621, 512, 576, 512, 1621, 491, 1643, 512, 555, 512, 576, 512, 1621, 512, 576, 512, 533, 491, 1621, 533, 533, 512, 555, 491, 1621, 512, 1621, 512, 555, 512, 1643, 491, 555, 512, 1643, 512, 1621, 512, 1621, 512, 1621, 512, 555, 491, 1643, 512, 1600, 512, 1621, 512, 555, 512, 555, 512, 533, 512, 555, 512, 1600, 512, 576, 512, 533, 512, 1643, 512, 1600, 512, 1621, 512, 533, 512, 555, 512, 533, 512, 555, 512, 533, 512, 555, 533, 533, 512, 555, 512, 1621, 512, 1643, 512, 1600, 512, 1621, 512, 1600, 512, 5205, 4309, 4459, 512, 1621, 512, 555, 512, 1621, 512, 1621, 512, 533, 512, 555, 512, 1621, 512, 576, 512, 533, 533, 1621, 512, 555, 512, 555, 512, 1600, 512, 1621, 512, 533, 512, 1643, 512, 533, 533, 1600, 512, 1643, 512, 1621, 512, 1643, 512, 533, 512, 1643, 512, 1621, 512, 1643, 512, 576, 512, 533, 512, 533, 512, 576, 512, 1621, 512, 555, 512, 533, 512, 1621, 512, 1621, 512, 1600, 512, 576, 491, 555, 512, 533, 512, 555, 512, 533, 512, 576, 512, 512, 533, 555, 512, 1600, 512, 1643, 512, 1621, 512, 1643, 491, 1643, 512, 1398078};
BlynkTimer timer;
void myTimerEvent()
{
Blynk.virtualWrite(V5, temperature);
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
timer.setInterval(15000L, myTimerEvent);
}
BLYNK_WRITE(V1) {
int rawOnAuto24 = param.asInt();
if (rawOnAuto24 == 1) {
irsend.send(rawOnAuto24, 200, 36);
Serial.println("Anoikse to klimatistiko!!");
}
else {
irsend.send(rawOff, 200, 36);
Serial.println("Ekleise to klimatistiko!!");
}
}
BLYNK_WRITE(V2) {
unsigned long currentMillis = millis();
int rawOnAuto24 = param.asInt();
if (temperature > baselineTemp) {
if ((unsigned long)(currentMillis - previousMillis) >= interval) {
previousMillis = currentMillis; //apo8hkeuei thn teleutaia fora pou stal8hke shma
irsend.send(rawOnAuto24, 200, 36);
Serial.println("mphke 1");
}
}
if (temperature < baselineTemp2) {
irsend.send(rawOff, 200, 36);
Serial.println("mphke 2");
}
}
void loop()
{
unsigned long currentMillis = millis();
int sensorVal = analogRead(sensorPin);
Serial.print("Sensor Value: ");
Serial.print(sensorVal);
float voltage = sensorVal * 5.0 / 1024.0;
//voltage /= 1024.0;
Serial.print(", Volts: ");
Serial.print(voltage);
temperature = (voltage - 0.5) * 10.0;
Serial.print(", Temperature: ");
Serial.println(temperature);
Blynk.run();
timer.run(); // Initiates BlynkTimer
}