Unkown issue with project

Hello guys! I recently completed one of my larger “retard” projects, A hot tub fueled by an oil burner, controlled with an arduino and i even made an app for my android communicating with bluetooth.

The arduino specs:

12V Transformer powering the arduino (Capable of very much current, so can not be a problem)

1xArduino nano

1xRelay module with four relays (Using only three, one for burner, one for circulation pumnp and one for lights)

2x MAX6675 temperature sensors

1x HC-05 bluetooth module

So my issue:

When we were going to test it all out, i set the temperature to 37 and everything was seemingly smooth, the arduino controlled the tub and it was heating for maybe three hours straight, but when the temperature was little below wanted, the arduino completely freaked out, flimmering with the relays in very fast intervals, which actually seemed like it was rebooting over and over again. At first i reconed it was overheated so i unplugged it for maybe 15 minutes and then started it again. Then it worked for maybe one minute and then it started flimmering again.

I really do not have a clue why this is, I noticed that the relay lights seemed kind of weak when it flimmered, like it didn’t have enough power, so i tried turning of the lights to lighten the load with at least one relay but did not do the trick either.

Does anyone have any clue what this could be about? I have also tried changing every component except the bluetooth module with no luck, i have soldered every connection so i dont think a loose connection is the problem. I doubt that the device could be overloaded even if that is possible since I have something like 5 second delays in my code.

Like this project is now i do not have an external powersource for my modules, i just run them from the 5V output pin on my arduino board, could something like this be the problem? But then again it is strange that it worked well for a couple of hours before starting to give me trouble.

Many thanks for any thoughts on this, I believe I’m soon going nuts if i don’t find the issue.

#include <SoftwareSerial.h>// import the serial library
#include <max6675.h>
#include <Time.h>

int RXD = 2;
int TXD = 3;
int cirkRelay = 4;
int heatRelay = 5;
int overTempCS = 11;
int tempSck = 8;
int tempSo = 9 ;
int retTempCS=10;
int lightRelay = 12;

bool circulate = false;
bool heat = false;

bool circulateTimer = false; // Used to override circulation in case of cold winter

bool lights = false;
bool debug = false;

SoftwareSerial bTooth(RXD, TXD); // RX, TX
MAX6675 ovTemp(tempSck, overTempCS, tempSo);
MAX6675 retTemp(tempSck, retTempCS, tempSo);

int cirkTimeLimit = 5;

int returnTemp = 0;
int overTemp = 0;

int retTempLimit = 15;
int overTempLimit = retTempLimit+10;

int heatTime = 0;
int cirkTime = 0;

int tempDelta = 0;
int cirkDelta = 0;

int retNoSignalTimes = 0;
int heatNoSignalTimes = 0;

void readBluetooth()
{
  if(bTooth.available())
  {
      char message[100]= {'\0'};
      int counter =0;
      while (bTooth.available() > 0) {
        message[counter%100] = bTooth.read();
        counter++;
      }
    if(strcmp(message,"STATUS;") == 0)
    {
      char str[60] = {'\0'};
      int h=0,c=0,l=0;
      if(heat) {
        h = 1;
      }
      if(circulate) {
        c = 1;
      }
      if(lights) {
        l = 1;
      }
      sprintf(str, "TEMP:%d;HEATTEMP:%d;HEATING:%d;CIRCULATING:%d;LIGHTS:%d;TEMP:%d;", returnTemp,overTemp,h,c,l,returnTemp);
      bTooth.println(str);
  
    }
    else if(strcmp(message,"LIGHT;") == 0)
    {
      lights = !lights;
      if(lights)
        bTooth.println("LIGHTS:1;");
      else
        bTooth.println("LIGHTS:0;");
    }
    else if(strcmp(message,"HEAT;") == 0)
    {
        bTooth.println("Heating Test;");
        digitalWrite(heatRelay, LOW);
        delay(60*1000);
    }
    else if(strcmp(message,"CIRCULATE;") == 0)
    {
        bTooth.println("Heating Test;");
        digitalWrite(cirkRelay, LOW);
        delay(60*1000);
    }
    else if(strcmp(message,"DEBUG;") == 0)
    {
        debug = !debug;
        if(debug) {
          bTooth.println("DEBUG MODE;");
        } else {
          bTooth.println("DEBUG MODE CANCELLED;");
        }
    }
    else if(strncmp(message,"setTemp",7) == 0)
    {
      char temp[3] = {'\0'};
      temp[0] = message[8];
      temp[1] = message[9];
      temp[2] = '\0';
  
      int newTemp = atoi(temp);
      if(newTemp < 40 && newTemp >5)
      {
        heatTime = 0;
        char str[40] = {'\0'};
        sprintf(str, "New Temperature is:%d;", newTemp);
        bTooth.println(str);
        retTempLimit = newTemp;
        overTempLimit = retTempLimit+10;
        //Serial.println(str);
      }
    }
    else if(strncmp(message,"setCirkTime",7) == 0)
    {
      char timer[2] = {};
      timer[0] = message[8];
  
      int newTime = atoi(timer);
      if(newTime < 10 && newTime >1)
      {
        char str[80];
        sprintf(str, "New Cirk Time is:%d;", newTime);
        bTooth.println(str);
        cirkTimeLimit = newTime;
      }
    }

  }
}


void setOutput()
{
  if(heat) {
    digitalWrite(heatRelay, LOW);
    
    if(debug) {
      bTooth.println("DEBUG:Heating;");
    }
  } else {
    digitalWrite(heatRelay, HIGH);
    if(debug) {
      bTooth.println("DEBUG:Not Heating;");
    }
  }
  delay(200);   //Delays to test that i am not doing things too fast --> Didnt seem to work
  if (circulate || circulateTimer) {
    digitalWrite(cirkRelay, LOW);
    if(debug) {
      bTooth.println("DEBUG:Circulating;");
    }
  } else {
    digitalWrite(cirkRelay, HIGH);
    if(debug) {
      bTooth.println("DEBUG:Not Circulating;");
    }
  }
  delay(200);
  if(lights) {
    digitalWrite(lightRelay, LOW);
  } else {
    digitalWrite(lightRelay, HIGH);
  }
  delay(200);
}

void setupOutput()
{
  bool retNoSignal = false;
  bool heatNoSignal = false;
  
    if(returnTemp < 2) {
      retNoSignalTimes++;
      if(debug) {
        bTooth.println("DEBUG:No signal return ");
        bTooth.println(retNoSignalTimes);
        bTooth.println(";");
        bTooth.println("DEBUG:Given temp ");
        bTooth.println(overTemp);
        bTooth.println(";");
      }
    } else {
      retNoSignalTimes = 0;
    }
    if(overTemp < 2) {
      heatNoSignalTimes++;
      if(debug) {
        bTooth.println("DEBUG:No signal heating ");
        bTooth.println(retNoSignalTimes);
        bTooth.println(";");
        bTooth.println("DEBUG:Given temp ");
        bTooth.println(overTemp);
        bTooth.println(";");
      }
    } else {
      heatNoSignalTimes = 0;
    }
    if(retNoSignalTimes > 20) {
      retNoSignal = true;   // If connection lost entirely to sensor too long, shut everything down
    }
    if(heatNoSignalTimes > 20) {
      heatNoSignal = true;
    }

    int newTime = millis()/1000;

    if(returnTemp + tempDelta < retTempLimit)
    {
      tempDelta = 0;
      heat = true;
    }
    else {

      tempDelta = 1;
      heat = false;
    }
    
    if(overTemp+cirkDelta > overTempLimit)
    {
      cirkDelta = 3;
      circulate = true;
    } else {
      cirkDelta = 0;
      circulate = false;
    }
    if(heatNoSignal || overTemp > 60)
    {
      heat = false;
      if(overTemp > 60) {
        circulate = true;
      }
    }
    if(retNoSignal || returnTemp > 40)
    {
        heat = false;
        circulate = false;
    }

    if((newTime-cirkTime) > cirkTimeLimit*60)
    {
      circulateTimer = true;
    }
    else
    {
      circulateTimer = false;
    }
    if((newTime-cirkTime) > cirkTimeLimit*60+30)
    {
      cirkTime = millis()/1000;
    }

}

void setup() {
  //Serial.begin(9600);
  delay(100);
  bTooth.begin(9600);
  bTooth.println("CONNECTED;");
  pinMode(cirkRelay,OUTPUT);
  pinMode(heatRelay,OUTPUT);
  pinMode(lightRelay,OUTPUT);
  delay(1000);
}

void loop() {
    delay(200);
    returnTemp = (int) retTemp.readCelsius();
    delay(500);
    overTemp = (int) ovTemp.readCelsius();
    readBluetooth();
    setupOutput();
    setOutput();
    delay(1000);
    }

Plan to be asked for a schematic (can be hand drawn) of how you have everything hooked up. And for your complete code.

Please read "How to use this forum" so you can post your code properly.

Did it wiffle before or after the flimmering?

It started to wiffle when the two spurving bearings went out of alignment with the panametric fan.

avr_fred:
It started to wiffle when the two spurving bearings went out of alignment with the panametric fan.

I saw a retroencabulator fail once. It was not pretty.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Your 12V transformer, is it a complete DC supply or have to made it with rectifier and filter caps and regulator?

What does the DC voltage measure at the output of the power supply?

A picture of your project will help us as well, to see your component layout.

Thanks… Tom… :slight_smile:
PS Don’t forget a schematic please.

Meanwhile ...Do you have any hysterisis on your set points - without this it could oscillate on/off near to the set temp . Have a couple of degrees difference between on and heater off .

Another point is safety . Humans are very sensitive to electric shock in water . I would not use anything that is connected to the mains supply ( even via a commercial power supply ), for this , it tends to spoil the party when everyone is electrocuted.

hammy:
Meanwhile ...Do you have any hysterisis on your set points - without this it could oscillate on/off near to the set temp . Have a couple of degrees difference between on and heater off .

Another point is safety . Humans are very sensitive to electric shock in water . I would not use anything that is connected to the mains supply ( even via a commercial power supply ), for this , it tends to spoil the party when everyone is electrocuted.

Yea I have thought about both, on the first point i have a temperature "delta" which should do the trick. On the second point I think it should be safe, since everything that is connected to electricity is grounded and I also have an RCCB on the main power supply so I think it should be safe.

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html

Your 12V transformer, is it a complete DC supply or have to made it with rectifier and filter caps and regulator?

What does the DC voltage measure at the output of the power supply?

A picture of your project will help us as well, to see your component layout.

Thanks.. Tom... :slight_smile:
PS Don't forget a schematic please.

Yeah really sorry about that, fixed it now! It's a complete DC supply, I can check out the voltage tomorrow and see if anything is unusual.

Hi,
Please do not go editing old posts in reply to later requests, it makes the flow of the thread very confusing.
You should have just posted a new post with the information.

The OPs schematic.

Thans.. Tom.. :slight_smile:

Hi,
What are you switching at the bottom of your schematic, a bits been cut off.


A picture of you project will help too.

Thanks.. Tom.. :slight_smile: