I have a Redboard connected to an alphanumeric display, single relay, and TMP117, all through qwiic. I am running the below code and, while the system works, it locks up after a period of time. When it does, I power off then back on and it resets. It doesn’t lock up at a consistent temperature or after a consistent period of time. The only thing that’s consistent is it always locks up with the relay off. I am powering the board with a barrel connector from a power supply at 12V. Any idea how I can eliminate the lock ups?
#include <Wire.h>
#include <SparkFun_TMP117.h>
TMP117 sensor;
#include <SparkFun_Alphanumeric_Display.h>
HT16K33 display;
#include "SparkFun_Qwiic_Relay.h"
#define RELAY_ADDR 0x18
Qwiic_Relay relay(RELAY_ADDR);
void setup()
{
Wire.begin();
Serial.begin(115200);
Wire.setClock(400000);
if (sensor.begin() == true)
{
Serial.println("Sensor - GO");
}
else
{
Serial.println("Sensor - FAULT");
while (1);
}
if (display.begin() == false)
{
Serial.println("Display - FAULT");
while (1);
}
Serial.println("Display - GO");
if(!relay.begin())
Serial.println("Relay - FAULT");
else
Serial.println("Relay - GO");
}
void loop()
{
if (sensor.dataReady() == true)
{
float tempC = sensor.readTempC();
float tempF = sensor.readTempF();
Serial.println(tempF);
String DispF = String(tempF, 2);
display.print(DispF);
if (tempF <= 56.001) relay.turnRelayOn();
else relay.turnRelayOff();
delay(100000);
}
}