Arduino Mega 2560-Based Temperature-Controlled Valve, Pump, and Fan System with SD Card Logging
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This circuit is designed to control a valve, pump, and fan based on temperature readings from multiple thermocouple amplifiers. The temperature data is logged to an SD card. Additionally, a current sensor is used to monitor the current and control the relays. The circuit is managed by an Arduino Mega 2560 microcontroller.
Component List
Valve
- Pins: GND, DCIN
- Description: Controls the flow of a fluid or gas.
1 Channel Relay 5V
- Pins: VCC, GND, IN, NC, COM, NO
- Description: Used to control high voltage devices with a low voltage signal.
120V Outlet
- Pins: AC Neutral, AC Hot, GND
- Description: Standard electrical outlet for 120V AC devices.
Pump
- Pins: in, -VE, ground
- Description: Used to move fluids.
Power Supply
- Pins: +, -, GND
- Description: Provides power to the circuit.
Current Sensor 5A
- Pins: 1, 2, GND, OUT, VCC
- Description: Measures the current flowing through the circuit.
Adafruit Thermocouple Amplifier MAX31855
- Pins: VIN, +3V3, THERMO-, GND, DO, THERMO+, CS, CLK
- Description: Amplifies the signal from a thermocouple for temperature measurement.
Arduino Mega 2560
- Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D0-D53, SDA, SCL, AREF
- Description: Microcontroller used to control the circuit.
Adafruit MicroSD card breakout board
- Pins: VCC, +3V3, GND, CLK, DO, DI, CS, CD
- Description: Used to log data to an SD card.
Fan
- Pins: +ve, grnd, -ve
- Description: Used for cooling purposes.
AC
- Pins: +ve, grnd, -ve
- Description: Air conditioning unit.
18650 Li-Ion Battery
- Pins: Positive, Negative
- Description: Rechargeable lithium-ion battery.
Wiring Details
Valve
- GND: Connected to Power Supply (-)
- DCIN: Connected to 1 Channel Relay 5V (NO)
1 Channel Relay 5V
- VCC: Connected to Arduino Mega 2560 (5V)
- GND: Connected to common ground
- IN:
- Relay 1: Connected to Arduino Mega 2560 (D36)
- Relay 2: Connected to Arduino Mega 2560 (D37)
- Relay 3: Connected to Arduino Mega 2560 (D38)
- NC: Not connected
- COM:
- Relay 1: Connected to Power Supply (+)
- Relay 2: Connected to 120V Outlet (AC Hot)
- Relay 3: Connected to 120V Outlet (AC Hot)
- NO:
- Relay 1: Connected to Valve (DCIN)
- Relay 2: Connected to Pump (in)
- Relay 3: Connected to Fan (+ve)
120V Outlet
- AC Neutral:
- Outlet 1: Connected to Pump (-VE)
- Outlet 2: Connected to Fan (-ve)
- Outlet 3: Connected to AC (grnd)
- AC Hot:
- Outlet 1: Connected to 1 Channel Relay 5V (COM)
- Outlet 2: Connected to 1 Channel Relay 5V (COM)
- Outlet 3: Connected to AC (+ve)
- GND:
- Outlet 1: Connected to Pump (ground)
- Outlet 2: Connected to Fan (grnd)
- Outlet 3: Connected to AC (-ve)
Pump
- in: Connected to 1 Channel Relay 5V (NO)
- -VE: Connected to 120V Outlet (AC Neutral)
- ground: Connected to 120V Outlet (GND)
Power Supply
- +: Connected to 1 Channel Relay 5V (COM)
- -: Connected to Valve (GND)
- GND: Common ground
Current Sensor 5A
- 1: Connected to 1 Channel Relay 5V (NO)
- 2: Connected to 120V Outlet (AC Neutral)
- GND: Common ground
- OUT: Connected to Arduino Mega 2560 (D2 PWM)
- VCC: Connected to Arduino Mega 2560 (5V)
Adafruit Thermocouple Amplifier MAX31855
- VIN: Connected to Arduino Mega 2560 (5V)
- +3V3: Not connected
- THERMO-: Not connected
- GND: Common ground
- DO: Connected to Arduino Mega 2560 (D50)
- THERMO+: Not connected
- CS:
- Thermocouple 1: Connected to Arduino Mega 2560 (D22)
- Thermocouple 2: Connected to Arduino Mega 2560 (D23)
- Thermocouple 3: Connected to Arduino Mega 2560 (D24)
- Thermocouple 4: Connected to Arduino Mega 2560 (D25)
- Thermocouple 5: Connected to Arduino Mega 2560 (D26)
- Thermocouple 6: Connected to Arduino Mega 2560 (D27)
- Thermocouple 7: Connected to Arduino Mega 2560 (D28)
- CLK: Connected to Arduino Mega 2560 (D52)
Arduino Mega 2560
- 5V: Connected to various components requiring 5V
- GND: Common ground
- D2 PWM: Connected to Current Sensor 5A (OUT)
- D22-D28: Connected to Adafruit Thermocouple Amplifier MAX31855 (CS)
- D36-D38: Connected to 1 Channel Relay 5V (IN)
- D50: Connected to Adafruit Thermocouple Amplifier MAX31855 (DO)
- D52: Connected to Adafruit Thermocouple Amplifier MAX31855 (CLK)
- D53: Connected to Adafruit MicroSD card breakout board (CS)
Adafruit MicroSD card breakout board
- VCC: Connected to Arduino Mega 2560 (5V)
- +3V3: Not connected
- GND: Common ground
- CLK: Connected to Arduino Mega 2560 (D52)
- DO: Connected to Arduino Mega 2560 (D50)
- DI: Connected to Arduino Mega 2560 (D51)
- CS: Connected to Arduino Mega 2560 (D53)
- CD: Not connected
Fan
- +ve: Connected to 1 Channel Relay 5V (NO)
- grnd: Connected to 120V Outlet (GND)
- -ve: Connected to 120V Outlet (AC Neutral)
AC
- +ve: Connected to 120V Outlet (AC Hot)
- grnd: Connected to 120V Outlet (AC Neutral)
- -ve: Connected to 120V Outlet (GND)
18650 Li-Ion Battery
- Positive: Connected to 45 (+ve)
- Negative: Connected to 45 (-ve)
Code Documentation
/*
* Arduino Sketch for controlling a valve, pump, and fan based on temperature
* readings from multiple thermocouple amplifiers. The temperature data is
* logged to an SD card. The current sensor is also read and used to control
* the relays.
*/
#include <SPI.h>
#include <SD.h>
#include <Adafruit_MAX31855.h>
// Pin definitions
#define RELAY1_PIN 36
#define RELAY2_PIN 37
#define RELAY3_PIN 38
#define CURRENT_SENSOR_PIN 2
#define SD_CS_PIN 53
// Thermocouple amplifier pins
#define THERMO_CS1 22
#define THERMO_CS2 23
#define THERMO_CS3 24
#define THERMO_CS4 25
#define THERMO_CS5 26
#define THERMO_CS6 27
#define THERMO_CS7 28
// Create thermocouple objects
Adafruit_MAX31855 thermocouple1(THERMO_CS1);
Adafruit_MAX31855 thermocouple2(THERMO_CS2);
Adafruit_MAX31855 thermocouple3(THERMO_CS3);
Adafruit_MAX31855 thermocouple4(THERMO_CS4);
Adafruit_MAX31855 thermocouple5(THERMO_CS5);