I recently moved all of my sketches and libraries to a different computer. This code used to compile, and now it won't, so I'm guessing I have a missing library or something, but I can't find it. The error message doesn't mention a missing library so??? Can anyone help?
Hardware is a SparkFun wifi IR blaster with an ESP8266 processor.
//#include <WiFi.h>
//extern "C" {
// #include "freertos/FreeRTOS.h"
// #include "freertos/timers.h"
//}
#include <ESP8266WiFi.h>
#include <Ticker.h>
#include <AsyncMqttClient.h>
// code from fujitsu ac control
#include <Arduino.h>
#include <IRremoteESP8266.h>
#include <IRsend.h>
#include <ir_Fujitsu.h>
#define WIFI_SSID "runningdog"
#define WIFI_PASSWORD "n,bUs692>Hq"
#define MQTT_HOST IPAddress(192, 168, 1, 72)
#define MQTT_PORT 1883
// Create objects to handle MQTT client
AsyncMqttClient mqttClient;
//TimerHandle_t mqttReconnectTimer;
//TimerHandle_t wifiReconnectTimer;
Ticker wifiReconnectTimer;
const int tempSet = 20; //wall unit temperature setpoint
const int ac_mode = 1; //wall unit mode, 1 = cool, 2 = heat
void connectToWifi() {
Serial.println("Connecting to Wi-Fi...");
WiFi.begin("ssid", "password");
}
void connectToMqtt() {
Serial.println("Connecting to MQTT...");
mqttClient.connect();
}
void WiFiEvent(WiFiEvent_t event) {
Serial.printf("[WiFi-event] event: %d\n", event);
switch (event) {
case SYSTEM_EVENT_STA_GOT_IP:
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
connectToMqtt();
break;
case SYSTEM_EVENT_STA_DISCONNECTED:
Serial.println("WiFi lost connection");
xTimerStop(mqttReconnectTimer, 0); // ensure we don't reconnect to MQTT while reconnecting to Wi-Fi
xTimerStart(wifiReconnectTimer, 0);
break;
}
}
// Add more topics that want your ESP32 to be subscribed to
void onMqttConnect(bool sessionPresent) {
Serial.println("Connected to MQTT.");
Serial.print("Session present: ");
Serial.println(sessionPresent);
// ESP32 subscribed to hvac/lr_AC_setpoint;
uint16_t packetIdSub = mqttClient.subscribe("hvac/br_AC_setpoint", 0);
uint16_t packetIdSub1 = mqttClient.subscribe("hvac/br_AC_mode", 0);
Serial.print("Subscribing at QoS 0, packetId: ");
Serial.println(packetIdSub);
Serial.println(packetIdSub1);
}
void onMqttDisconnect(AsyncMqttClientDisconnectReason reason) {
Serial.println("Disconnected from MQTT.");
if (WiFi.isConnected()) {
xTimerStart(mqttReconnectTimer, 0);
}
}
void onMqttSubscribe(uint16_t packetId, uint8_t qos) {
Serial.println("Subscribe acknowledged.");
Serial.print(" packetId: ");
Serial.println(packetId);
Serial.print(" qos: ");
Serial.println(qos);
}
void onMqttUnsubscribe(uint16_t packetId) {
Serial.println("Unsubscribe acknowledged.");
Serial.print(" packetId: ");
Serial.println(packetId);
}
// You can modify this function to handle what happens when you receive a certain message in a specific topic
void onMqttMessage(char* topic, char* payload, AsyncMqttClientMessageProperties properties, size_t len, size_t index, size_t total) {
String messageTemp;
for (int i = 0; i < len; i++) {
//Serial.print((char)payload[i]);
messageTemp += (char)payload[i];
}
if (topic == "hvac/br_AC_setpoint" ) {
tempSet = stoi(messageTemp);
ac.setTemp(tempSet);
}
if (topic == "hvac/br_AC_mode") {
ac_mode = stoi(messageTemp);
if (ac_mode = 1) {
ac.setMode(kFujitsuAcModeCool);
}
if (ac_mode = 2) {
ac.setMode(kFujitsuAcModeHeat);
}
}
}
// Now send the IR signal.
Serial.println("Sending IR command to A/C ...");
#if SEND_FUJITSU_AC
ac.send();
#else // SEND_FUJITSU_AC
Serial.println("Can't send because SEND_FUJITSU_AC has been disabled.");
#endif // SEND_FUJITSU_AC
printState();
}
void printState() {
// Display the settings.
Serial.println("Fujitsu A/C remote is in the following state:");
Serial.printf(" %s\n", ac.toString().c_str());
// Display the encoded IR sequence.
unsigned char* ir_code = ac.getRaw();
Serial.print("IR Code: 0x");
for (uint8_t i = 0; i < ac.getStateLength(); i++)
Serial.printf("%02X", ir_code[i]);
Serial.println();
}
void setup() {
ac.begin();
Serial.begin(115200);
delay(200);
mqttReconnectTimer = xTimerCreate("mqttTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast<TimerCallbackFunction_t>(connectToMqtt));
wifiReconnectTimer = xTimerCreate("wifiTimer", pdMS_TO_TICKS(2000), pdFALSE, (void*)0, reinterpret_cast<TimerCallbackFunction_t>(connectToWifi));
WiFi.onEvent(WiFiEvent);
mqttClient.onConnect(onMqttConnect);
mqttClient.onDisconnect(onMqttDisconnect);
mqttClient.onSubscribe(onMqttSubscribe);
mqttClient.onUnsubscribe(onMqttUnsubscribe);
mqttClient.onMessage(onMqttMessage);
mqttClient.setServer(MQTT_HOST, MQTT_PORT);
connectToWifi();
// Set up what we want to send. See ir_Fujitsu.cpp for all the options.
Serial.println("Default state of the remote.");
printState();
Serial.println("Setting desired state for A/C.");
// See `fujitsu_ac_remote_model_t` in `ir_Fujitsu.h` for a list of models.
ac.setModel(ARRAH2E);
ac.setSwing(kFujitsuAcSwingOff);
ac.setMode(kFujitsuAcModeCool);
ac.setFanSpeed(kFujitsuAcFanHigh);
ac.setTemp(24); // 24C
ac.setCmd(kFujitsuAcCmdTurnOn);
}
void loop() {
// Now send the IR signal.
Serial.println("Sending IR command to A/C ...");
#if SEND_FUJITSU_AC
ac.send();
#else // SEND_FUJITSU_AC
Serial.println("Can't send because SEND_FUJITSU_AC has been disabled.");
#endif // SEND_FUJITSU_AC
printState();
delay(5000);
}
I attached the many error messages in an attachment.
Many thanks,
Dennis
error_messages.txt (3.06 KB)