So I’m using ESP8266 to control my air conditioner, it worked with the old Blynk version, tried migrating but encountered the following problem, the ESP8266 does connect to the WiFi, but doesn’t connect to the cloud, this is my code:
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <BlynkSimpleEsp8266.h>
#define BLYNK_TEMPLATE_ID "TMPLCjaYMdOj"
#define BLYNK_DEVICE_NAME "ESP8266AC"
#define BLYNK_PRINT Serial
const uint16_t IrPin = 12; // ESP32 GPIO pin to use. Recommended: (D4).
unsigned long last_button_time = 0;
char auth[] = "";
char ssid[] = "";
//char pass[] = "";
char pass[] = "";
IRsend irsend(IrPin); // Set the GPIO to be used to sending the message.
uint8_t samsungState[kSamsungAcStateLength] = {
0x02, 0x92, 0x0F, 0x00, 0x00, 0x00, 0xF0,
0x01, 0xE2, 0xFE, 0x71, 0x40, 0x11, 0xF0
};
#include "DHT.h"
#define DHTPIN 2 // Digital pin connected to the DHT sensor
#define DHTTYPE DHT11 // DHT 11
// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
DHT dht(DHTPIN, DHTTYPE);
void setup() {
Serial.begin(115200);
irsend.begin();
dht.begin();
Blynk.begin(auth, ssid, pass);
}
void loop() {
Blynk.run();
long time = millis();
if (time > 2000) {
int humidity = dht.readHumidity();
float tempC = dht.readTemperature();
if (isnan(humidity) || isnan(tempC)) {
Serial.println(F("Failed to read from DHT sensor!"));
return;
}
float heatIndex = dht.computeHeatIndex(tempC, humidity, false);
Blynk.virtualWrite(V1, tempC);
Blynk.virtualWrite(V2, humidity);
Blynk.virtualWrite(V0, heatIndex);
}
}
BLYNK_WRITE(V3) {
int pinValue = param.asInt();
if (pinValue == 1) irsend.sendRaw(powerOn, sizeof(powerOn) / sizeof(powerOn[0]), 38); // Send a raw data capture at 38kHz.
}
BLYNK_WRITE(V4) {
irsend.sendRaw(up, sizeof(up) / sizeof(up[0]), 38); // Send a raw data capture at 38kHz.
Serial.println("up");
}
BLYNK_WRITE(V5) {
irsend.sendRaw(down, sizeof(down) / sizeof(down[0]), 38); // Send a raw data capture at 38kHz.
Serial.println("down");
}
How can I fix it?
Thanks.