I've just bought my first arduino (Nano V3.0 ATmega328) to build an automated fan system for my log burner.
It's pretty simple in what it needs - when the temperature of the log burner goes up the arduino turns the fans on, blowing air into the room, and keeps them going until the fire is out and the burner has cooled.
The problem is if there is a power cut the fans will cut off, and a chimney fire will ensue. For this I'm adding an uninterruptible power supply using a car battery and a trickle charger.
I've done my circuit diagram but I want to check that it's all OK as it's been years since doing any electronics in school!
I'm running a K type thermcouple with a MAX6675 to check the temperature (I have the thermocouple and arduino so far, I need to order the relays), and the relay and relay board to control the power.
As far as code goes I've got a pin turning on and off at the correct temperatures, and giving me readouts in the serial port so I think no problems.
#include "max6675.h"
const int threshold = 50; //Fan start temperature
int fanPin = 13; //Pin to fan relay
int thermoDO = 4;
int thermoCS = 5;
int thermoCLK = 6;
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
const int numReadings = 10;
int readings[numReadings]; // the readings from the digital input
int index = 0; // the index of the current reading
int total = 0; // the running total
int average = 0; // the average
void setup() {
Serial.begin(9600);
// use Arduino pins
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
Serial.println("MAX6675 test");
// wait for MAX chip to stabilize
delay(1000);
// initialize all the readings to 0:
for (int thisReading = 0; thisReading < numReadings; thisReading++)
readings[thisReading] = 0;
}
void loop() {
// subtract the last reading:
total= total - readings[index];
// read from the sensor:
readings[index] = (thermocouple.readCelsius());
// add the reading to the total:
total= total + readings[index];
// advance to the next position in the array:
index = index + 1;
// if we're at the end of the array...
if (index >= numReadings)
// ...wrap around to the beginning:
index = 0;
// calculate the average:
average = total / numReadings;
// send it to the computer as ASCII digits
// basic readout test, just print the current temp
Serial.print("C = ");
Serial.println(thermocouple.readCelsius());
Serial.print("Av = ");
Serial.println(average);
if (average > threshold) {
digitalWrite(fanPin, LOW);
}
else {
digitalWrite(fanPin, HIGH);
}
delay(1000);
}
The code is probably a bit dodgy as I copied and pasted the first chunk, but it seems to work fine,
I plan on adding an LCD readout and some warning LEDs later on, but for now I just want to check I'm not going to destroy anything or cause an electrical fire when I out the initial circuit together.
Many thanks! I'm looking forward to getting stuck in, with several other projects lined up for the near future.