Strange values from ubidots

I am making a fermentation controller which reads temperatures from dallas sensors and then turns on or off a chiller to maintain temperature control. the temperature values and set vaules are uploaded to ubidots for display. set temperatures are also controlled via ubidots

all works except every few minutes I get a value of -197 deg f. The graph shows this activity.

I have tried changing the resistor 4.7k to one that offers a bit less resistance
I have simplified the wiring removing all connectors so has a direct soldered connections and the solder joints are good.

if I set max and min values in ubidots it if fine but I want to know why I an getting bad values.
if I remove min max from the set variables they eventually will change to -39???.

any ideas? is it ubidots? have others had this problem?

thanks steve

here is my code

// This #include statement was automatically added by the Particle IDE.
#include <Ubidots.h>

// This #include statement was automatically added by the Particle IDE.
#include "spark-dallas-temperature.h"

// This #include statement was automatically added by the Particle IDE.
#include <OneWire.h>

// This #include statement was automatically added by the Particle IDE.
#include <flashee-eeprom.h>

//#pragma SPARK_NO_PREPROCESSOR


#define TOKEN "A1E-5jwFy81e8SllpBzA3PY5vET9MbhXhi"  // Put here your Ubidots TOKEN

Ubidots ubidots(TOKEN);




// data line to pin 2
#define ONE_WIRE_BUS 2
//#define ONE_WIRE_BUS2 1
//const int relay11h = 0;
const int relay11c = 3;
//const int relay12h = 1;
const int relay12c = 4;
//const int relay13h = 7;
const int relay13c = 5;
const int chiller = 6;

int SetTempLow[16];
int SetTempHigh[16];
float ActualTemp[16];
char incoming[41];
String teststring;
int deviceID = 0;
double FermTemp[4];


// setup onewire to communicate with any OW device
OneWire oneWire(ONE_WIRE_BUS);

// pass OW reference to Dallas temp
DallasTemperature sensors(&oneWire);

// array for addresses
DeviceAddress ThermoOne,ThermoTwo,ThermoThree,ThermoFour,ThermoFive,ThermoSix,ThermoSeven,ThermoEight;


void setup() 
{
  Serial.begin(4800);
  
  
  

  pinMode(relay11c, OUTPUT);
 
  pinMode(relay12c, OUTPUT);

  pinMode(relay13c, OUTPUT);
  pinMode(chiller, OUTPUT);

  
  digitalWrite(relay11c, LOW);

  digitalWrite(relay12c, LOW);
 
  digitalWrite(relay13c, LOW);
  digitalWrite(chiller, LOW);
  



// start the library
sensors.begin();

// locate the devises on the bus
delay(10);
sensors.getAddress(ThermoOne, 0);
delay(10);
sensors.getAddress(ThermoTwo, 1);
delay(10);
sensors.getAddress(ThermoThree, 2);
delay(10);
sensors.getAddress(ThermoFour, 3);



eepromRead();

}


// function to print a device address
void loop()
{
     SetTempHigh[1] = ubidots.getValue("5a7b04177625422027b409fc");
     SetTempHigh[2] = ubidots.getValue("5a7b04187625422027b40a10");
     SetTempHigh[3] = ubidots.getValue("5a7b04177625422027b409e2");
  ubidots.add("Fermenter1", ActualTemp[1]);
  ubidots.add("Fermenter2", ActualTemp[2]);
  ubidots.add("Fermenter3", ActualTemp[3]);
  ubidots.add("Fermenter4", ActualTemp[4]);
  ubidots.add("set1", SetTempHigh[1]);
  ubidots.add("set2", SetTempHigh[2]);
  ubidots.add("set3", SetTempHigh[3]);
  
  eepromWrite();

   // ubidots.add("address3", addresses[3]);
 
    ubidots.sendAll();

 sensors.requestTemperatures();
 
 
 // print device information
 deviceID = 1;
 printTemperature(ThermoOne);
 delay(10);
 deviceID = 2;
 printTemperature(ThermoTwo);
 delay(10);
 deviceID = 3;
 printTemperature(ThermoThree);
 delay(10);
 deviceID = 4;
 printTemperature(ThermoFour);
 
 relays();
 delay(5000);
}



// function to print the temp for a device
 
 void printTemperature (DeviceAddress deviceAddress)
{
    
  float tempC = sensors.getTempC(deviceAddress);    
  delay(10);
  ActualTemp[deviceID]= DallasTemperature::toFahrenheit(tempC);
  
}

void relays()
{
  
  

  if (ActualTemp[1] > SetTempHigh[1]) {
    digitalWrite(relay11c, HIGH);
  }
  else
  {
    digitalWrite(relay11c, LOW);
  }

  if (ActualTemp[2] > SetTempHigh[2]) {
    digitalWrite(relay12c, HIGH);
  }
  else
  {
    digitalWrite(relay12c, LOW);
  }

  if (ActualTemp[3] > SetTempHigh[3]) {
    digitalWrite(relay13c, HIGH);
  }
  else
  {
    digitalWrite(relay13c, LOW);
  }

  if (ActualTemp[1] > SetTempHigh[1]) {
    digitalWrite(chiller, HIGH);
    return;
  }

  if (ActualTemp[2] > SetTempHigh[2]) {
    digitalWrite(chiller, HIGH);
    return;
  }

  if (ActualTemp[3] > SetTempHigh[3]) {
    digitalWrite(chiller, HIGH);
    return;
  }
  else {
    digitalWrite(chiller, LOW);
  }

}

void eepromWrite()
{
     // write setTemps to eephrom
  int temp[10];
  temp[1] = int (SetTempHigh[1]);
  temp[2] = int(SetTempHigh[2]);
  temp[3] = int (SetTempHigh[3]);
  temp[4] = int(SetTempHigh[4]);
  temp[5] = int(SetTempHigh[5]);
  for (int i = 0; i < 20; i++){
  EEPROM.write(i, temp[i]);
   }
}

void eepromRead()
{
// read setpoints from eeprom


   int value[20];
    int i;
    for (int i = 0; i < 20; i++){value[i] = EEPROM.read(i);}
  SetTempHigh[1] = value[1];
  SetTempHigh[2] = value[2];
  SetTempHigh[3] = value[3];
  SetTempHigh[4] = value[4];
  SetTempHigh[5] = value[5];
}

It looks as though the ‘erratic’ values are coming from your device, rather than from ubidots, no?
Try implementing a running average to compare your values to, and if they deviate by too much, discard the value and measure a new one. That should filter out any erratic spikes.

thats easy enough to do but before I do that i would like to nail down why?

Yes my first thought is that it is hardware but I have changed photons, sensors, simplified the wiring.

The thing leads me to non-hardware is that the set values change too. if you look at the code I have disconnected the eeprom reads and writes which is the only thing that has any ability to change set points.

thanks steve

I’m not using the spark-dallas-temperature library but DS18B20 (which also supports other dallas sensors, despite the name) and also does CRC checking (no idea if the other does).
And with the CRC check and some minimal sanity checks in application firmware my devices never publish wrong readings.
So even when erronous readings happen to turn up, some subsequent read will eventually provide a good one to publish.

BTW, I do recall seeing this code in some other thread where the use of arrays and loops - along with transitioning to DS18B20 too - was suggested but obviously not taken up on. Hence I stopped following the rest of the code as soon I realised that.

1 Like

I am ready to transition to DS12B20. I was lazy… hoping to not rewrite. you have convinced me. I will review your previous recommendations thanks steve

1 Like