Hello,
I've downloaded the new Arduino IDE for the Digispark and am starting my first project. Currently I've been developing the code for my Arduino UNO, since I'm still 6xx on in the shipping order. The relay controls an electrical radiator type heater. The temp sensor is mounted inside a thermowell surrounded in 5 gallons of beer. The goal here is to keep the beer at a constant (or close) desired temp. Where I brew can get down to 50F if no heater is there. I like to think of this as an overly geeky thermostat. A raspberry pi will receive the data from serial and log it for review later.
hardware: DS18B20 temp sensor, Fotek SSR-10DA
I'm currently running into size restrictions though...
Is there a way to get this down to size to fit on the Digispark?
I currently hit 6,402 bytes (of a 6,010 byte maximum).
Here is the code.
#include
#include
#define RELAY_PIN 3
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress insideThermometer;
void setup(void)
{
pinMode(RELAY_PIN, OUTPUT);
Serial.begin(9600); // open serial
sensors.begin();
sensors.getAddress(insideThermometer, 0);
sensors.setResolution(insideThermometer, 9);
}
float getTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
return (DallasTemperature::toFahrenheit(tempC)); // Converts tempC to Fahrenheit
}
void loop(void)
{
sensors.requestTemperatures();
float target = 70;
float temp = getTemperature(insideThermometer);
if(temp >= target){
digitalWrite(RELAY_PIN, LOW);
Serial.println("Heater Off");
}
else if(temp < target){
digitalWrite(RELAY_PIN, HIGH);
Serial.println("Heater On");
}
Serial.println(temp);
delay(6000);
}
Any Suggestions? lighter libraries? I'd prefur to keep using the DS18B20 since I have a boat load of them and no others on hand.