On the SOS code I was getting 1 blink which told me hard fault.
Be forewarned I suck at writing code and working to improve, there is a lot that still needs to be done here.
Many parts of the code that I was getting SOS out of have been copied from the example for the AHT20
Below is the code that I experienced the hard fault on. I have removed all the code associated with “AHT20” and have been able to get the board to run code with no surprise issues. When it first happened it went into SOS and it was completely locked up. I had to put it in safe mode, then it would startup, run part of the code and hit SOS and reboot. I do not know where in the code it was hitting the problem, my level of frustration that evening was at 11 and I decided it was better to remove what was causing me an issue rather than troubleshoot it and come up with a solution.
Since the “Adafruit_AHTX0” library is not in the Partible online repository I removed the dependencies entry. I still can not get it to build. I may try that AHT20 library again to see if there was something else that was causing me issues.
#include "LiquidCrystal_I2C_Spark.h"
#include "AnalogSmoother.h"
#include "Arduino.h"
#include "Debounce.h"
#include <Wire.h>
#include <SparkFun_Qwiic_Humidity_AHT20.h>
AHT20 humiditySensor;
// DOOR SWITCHES
const int door_sw = 8;
// int door_sw = 0;
// Water level LOWLOW Water level LOW
const int water_low_sw = 7;
// int water_low_sw = 0;
const int water_LOWLOW_sw = 6;
// int water_LOWLOW_sw = 0;
// water_level = ("GOOD", "LOW", "BAD")
// Air Pressure sensor input
AnalogSmoother gas_pressure(A0, 10);
LiquidCrystal_I2C *lcd;
int lastSecond = 0;
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
void setup()
{
pinMode(door_sw, INPUT_PULLDOWN);
pinMode(water_low_sw, INPUT_PULLDOWN);
pinMode(water_LOWLOW_sw, INPUT_PULLDOWN);
Serial.begin(115200);
lcd->println("SHOWER TRAILER 0000");
lcd->setCursor(0,1);
Wire.begin();
//Check if the AHT20 will acknowledge
if (humiditySensor.begin() == false)
{
Serial.println("AHT20 not detected. Please check wiring. Freezing.");
while (1);
}
Serial.println("AHT20 acknowledged.");
lcd = new LiquidCrystal_I2C(0x3f, 20, 4);
lcd->init();
lcd->backlight();
lcd->clear();
}
void loop()
{
//If a new measurement is available
if (humiditySensor.available() == true)
{
//Get the new temperature and humidity value
float temperature = humiditySensor.getTemperature();
float humidity = humiditySensor.getHumidity();
//Print the results
Serial.print("Temperature: ");
Serial.print(temperature, 2);
Serial.print(" C\t");
Serial.print("Humidity: ");
Serial.print(humidity, 2);
Serial.print("% RH");
Serial.println();
delay(5000);
}
}
This is the code I have been currently working out of. When I added the include statement I was able to select the Adafruit_AHT0.h file from the dropdown as I started typing it in.
/* SHOWER TRAILER MONITOR
* Monitor door position, water level low and LOWLOW switches
* Monitor temperature via I2C sendor and gas bottle pressure via analog input
* Send information to cloud 2 times a day at 0400, 1200
* Board to sleep mode between transmissions turning off LCD and cellular. Will wake on door switch or wake button
* When board has been woken up it is to stay awake for 20 minutes, transmit status when woken up and prior to returning to sleep.
*/
#include "AnalogSmoother.h"
#include "Arduino.h"
#include "Debounce.h"
#include <Wire.h>
#include "Adafruit_LiquidCrystal.h"
#include "Adafruit_AHTX0.h"
// WAKE BUTTON
const int wake_sw = 4;
// DOOR SWITCHES
const int door_sw = 8;
// int door_sw = 0;
// Water level LOWLOW Water level LOW
const int water_low_sw = 5;
// int water_low_sw = 0;
const int water_LOWLOW_sw = 6;
// int water_LOWLOW_sw = 0;
// water_level = ("GOOD", "LOW", "BAD")
// Air Pressure sensor input
// AnalogSmoother gas_pressure(A0, 10);
int led = D7;
// int temperature();
LiquidCrystal lcd(0x3f);
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
void setup()
{
pinMode(door_sw, INPUT_PULLDOWN);
pinMode(water_low_sw, INPUT_PULLDOWN);
pinMode(water_LOWLOW_sw, INPUT_PULLDOWN);
pinMode(led, OUTPUT);
Serial.begin(115200);
Serial.print("no idea");
Wire.begin();
lcd.begin(20, 4);
lcd.print("WTF");
}
void loop()
{
// int gas_pressure = analogRead(A0);
Serial.println("SHOWER TRAILER 0000");
Serial.println("TEMP:100");
Serial.println((digitalRead(wake_sw)));
Serial.println((digitalRead(water_low_sw)));
Serial.println((digitalRead(water_LOWLOW_sw)));
Serial.println((digitalRead(door_sw)));
Serial.println((analogRead(A0)));
digitalWrite(led, HIGH);
delay(5000);
digitalWrite(led, LOW);
delay(1000);
Serial.println();
delay(5000);
}