Hi Friends,
I am having issues compiling using particle dev. It seems that in the configuration I have it in now, it doesn’t catch errors. to test this I threw a random character in my script and it still compiled. To further test it I threw a particle variable on a sensor reading and flashed the code, and no variables are exposed to the cloud. I even tried bringing i to the web ide to see if that would catch the error, and i get the dreaded OneWire error that I reference in the link below (one).
I am new to the desktop ide so take it easy on me, any insight is greatly appreciated always.
Here is my code; (look familiar from past posts : One, Two)
#include "application.h"
#include "spark-dallas-temperature/spark-dallas-temperature.h"
#include "OneWire/OneWire.h"
// Sensor initialazation
//DS1820B - water temperature
#define ONE_WIRE_BUS D2
#define TEMPERATURE_PRECISION 1
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress inWaterThermometer = { 0x28, 0xB6, 0x78, 0x5E, 0x07, 0x0, 0x0, 0x4F };
int TempHigh=100;
int TempLow=40;
double TempRead = -1;
double InTempC =0;
bool TempFlagA=true; //true - in threshold , false - out of range
int TempFlagB=0; // -1 is low ie turn the heater on, 0 is in range, 1 is high ie let some water in
void setup() {
//Water Temp sensor
sensors.begin();
sensors.setResolution(inWaterThermometer, TEMPERATURE_PRECISION);
Serial.begin(9600);
Particle.variable("temp", InTempC)
}
void loop() {
delay(5000);
sensors.requestTemperatures();
update18B20Temp(inWaterThermometer, InTempC);
TempRead = (InTempC * 9)/5 + 32;
int TempResult = TempThreshold( TempHigh, TempLow, TempRead);
//Change below
if (TempResult==0){
Serial.println("in range, no actions taken");
// Put everything to do here
}
else if(TempResult==-1){
Serial.println("Temp low, heater turned on");
// insert commands to call heater function
}
else if(TempResult==1){
Serial.println("Temp high, add more water");
//insert fucntions for adding water for limited amount of time
}
//for testing
Serial.print("Water Temp:");
Serial.print(TempRead);
Serial.println("F");
}
/*/////////////////////////END OF LOOP//////////////////////////////////////*/
//FUNCTIONS
//Water Temp
void update18B20Temp(DeviceAddress deviceAddress, double tempC)
{
tempC = sensors.getTempC(deviceAddress);
}
int TempThreshold(int hi, int low, int reading){
if((hi>=reading) && (low<=reading)){
Serial.println("In");
TempFlagA=true;
TempFlagB=0;
return TempFlagB;
}
else if(hi<reading){
Serial.println("out-hi");
TempFlagA=false;
TempFlagB=1;
return TempFlagB;
}
else if(low>reading){
Serial.println("out-low");
TempFlagA=false;
TempFlagB=-1;
return TempFlagB;
}
}