This code I have been using for my dry box for 3D printer filament has stopped working on a different ESP8266 module. I used this code on a previous ESP8266 module (I purchased a pack of three on amazon) and then I accidentally blew something on the original module. So I just switched it out after updating some code and now the code doesn't seem to work. Here is the code I have been using:
#include <Adafruit_AHTX0.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Adafruit_AHTX0 aht;
Adafruit_SSD1306 display(128, 64, &Wire, -1); // Declare and initialize the display object
uint32_t delayMS = 100;
const int PETG_TEMP = 65;
const int HEAT_FAN_RELAY = 13;
const int EXIT_FAN_RELAY = 15;
const int HEATER_RELAY = 12;
void setup() {
Serial.begin(115200);
// if (!aht.begin()) {
// Serial.println("Could not find AHT? Check wiring");
// while (1) delay(10);
// }
// Serial.println("AHT10 or AHT20 found");
display.begin(SSD1306_SWITCHCAPVCC, 0x3C); // Initialize the display
pinMode(HEAT_FAN_RELAY, OUTPUT);
pinMode(EXIT_FAN_RELAY, OUTPUT);
pinMode(HEATER_RELAY, OUTPUT);
}
void displayTempHumid() {
delay(delayMS);
sensors_event_t humidity, temperature;
aht.getEvent(&humidity, &temperature);
float temp = temperature.temperature;
float humid = humidity.relative_humidity;
Serial.print("Temperature: ");
Serial.print(temp);
Serial.println("°C");
Serial.print("Humidity: ");
Serial.print(humid);
Serial.println("%");
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
display.setTextSize(1);
display.setCursor(0, 0);
display.print("Temperature: ");
display.setCursor(0, 10);
display.setTextSize(2);
display.print(temp);
display.print(" C");
display.setCursor(0, 30);
display.setTextSize(1);
display.print("Humidity: ");
display.setCursor(0, 40);
display.setTextSize(2);
display.print(humid);
display.print(" %");
display.display();
digitalWrite(HEAT_FAN_RELAY, HIGH);
digitalWrite(EXIT_FAN_RELAY, HIGH);
digitalWrite(HEATER_RELAY, temp < PETG_TEMP ? HIGH : LOW);
if (temp <= PETG_TEMP * 0.95) {
digitalWrite(HEAT_FAN_RELAY, HIGH);
digitalWrite(EXIT_FAN_RELAY, LOW);
Serial.println("Heater = On, Heat Fan = On, Exit fan = Off");
} else if (temp < PETG_TEMP) {
digitalWrite(EXIT_FAN_RELAY, HIGH);
Serial.println("Heater = ON, Fans = ON");
} else {
Serial.println("Heater = Off, Fans = On");
}
}
void loop() {
displayTempHumid();
}
I have the if statement at the beginning of void setup() to ensure my temperature and humidity sensor is connected. If its not, it will get into that loop and print out that it didn't detect the sensor. However, this print line never shows in the serial monitor. Here is the error when I keep that if statement commented out:
--------------- CUT HERE FOR EXCEPTION DECODER ---------------
11:13:13.596 ->
11:13:13.596 -> ets Jan 8 2013,rst cause:2, boot mode:(3,6)
11:13:13.596 ->
11:13:13.596 -> load 0x4010f000, len 3424, room 16
11:13:13.596 -> tail 0
11:13:13.596 -> chksum 0x2e
11:13:13.596 -> load 0x3fff20b8, len 40, room 8
11:13:13.628 -> tail 0
11:13:13.628 -> chksum 0x2b
11:13:13.628 -> csum 0x2b
11:13:13.628 -> v00045d40
11:13:13.628 -> ~ld
11:13:13.698 -> ���e�N�|er��n|�$��$ #�����r�d�N��o�l`��s�p��$e��
Let me know if you require anymore from me to diagnose the issue. Thanks!