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];
}