Built-in project · Arduino Uno R3

Peltier cooler with a MOSFET module on an Arduino Uno

An Uno runs a TEC1-12706 Peltier module flat out for a minute through a D4184 MOSFET module on pin 9, then holds it at 60 % with PWM, off a 12 V battery. The whole build, an Arduino Uno and 3 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Intermediate About 25 minutes to build and run. Runs in your browser. Free, and no account needed.

The parts retail for about $35. On Mokxi they're free.

The circuit runs here once the page has loaded.

What you'll learn

  • A MOSFET module switches loads the Uno cannot
  • Thermoelectric cooling and why the hot side matters
  • PWM for power control
  • Timing with millis() instead of delay
  • Difficulty: Intermediate
  • Time: About 25 minutes
  • Board: Arduino Uno R3
  • Parts: 4

How it works

A TEC1-12706 Peltier module moves heat from one face to the other, so one face goes cold and the other hot. It draws a lot of current, so the Uno cannot drive it. Pin 9 goes to the TRIG input of a D4184 MOSFET module, which switches the 12 V battery to the Peltier.

The sketch first runs flat out, analogWrite(9, 255), for 60 seconds to pull the cold face down. After that it drops to a duty of 153, which is 60 percent, and prints a message.

The Uno has no way to read the cold face's temperature, so you watch the module's own readout instead. The cold face is only as cold as the heat sink on the hot face allows.

Parts list

4 parts, plus the jumper wires. They retail for about $35; on Mokxi they're free.

Wiring table

Every connection, pin by pin, read from the circuit itself. Each row joins the pin on the left to the pin on the right, by a jumper wire or a breadboard strip.

Part and pinConnects to
D4184 dual MOSFET switch module pin GNDArduino Uno R3 pin GND
D4184 dual MOSFET switch module pin TRIGArduino Uno R3 pin 9
Battery: AA, coin cell, LiPo pin V+D4184 dual MOSFET switch module pin VIN+
Battery: AA, coin cell, LiPo pin V-D4184 dual MOSFET switch module pin VIN-
Peltier module, TEC1-12706 pin +D4184 dual MOSFET switch module pin OUT+
Peltier module, TEC1-12706 pin -D4184 dual MOSFET switch module pin OUT-

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// Peltier cooler: an Uno runs a TEC1-12706 flat out for a minute to pull the
// cold face down, then holds it at 60 % with PWM on pin 9 through a D4184
// MOSFET module, off a 12 V battery.
//
//   9       the D4184 module's TRIG, and the Uno's GND to the module's GND
//   12 V    the battery into VIN+ and VIN-, the Peltier's red lead on OUT+
//           and its black lead on OUT-
//
// At 12 V the module draws about 6 A from a cold start and still about 4.5 A
// once it is cold, so it needs a MOSFET that is fully on from a 5 V pin (the
// D4184's AOD4184A is) and a supply that gives 6 A: a lead-acid battery or a
// 12 V 10 A adapter, not a USB port.
//
// The printed face of the module goes cold, the other face hot, and the cold
// face is only as cold as the heat sink on the hot face is good. Turn the
// heatsink setting up to 5 K/W (a bare plate) and see what happens.
//
// PWM works because the module's faces cannot heat and cool 490 times a
// second, but it is the least efficient way to run one: the heat it burns
// goes as the square of the current, so 60 % by PWM pumps less heat than
// 60 % of the voltage would. Real coolers use a buck converter.
//
// The sketch cannot read the cold face's temperature: no sensor in the
// simulator feels another part's heat. Watch the module's own readout.

const int MOSFET_PIN = 9;  // a PWM pin
const unsigned long PULL_DOWN_MS = 60000;
const int HOLD_DUTY = 153;  // 60 % of 255

bool holding = false;

void setup() {
  pinMode(MOSFET_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("Peltier cooler: full power for a minute");
  analogWrite(MOSFET_PIN, 255);
}

void loop() {
  if (!holding && millis() >= PULL_DOWN_MS) {
    holding = true;
    analogWrite(MOSFET_PIN, HOLD_DUTY);
    Serial.println("holding at 60 %");
  }
  delay(100);
}

Code walkthrough

The key functions of the sketch, and what each one does.

setup sketch.ino

Makes pin 9 an output, starts serial at 9600 baud and prints a message. Then it writes 255 with analogWrite, which is full power, so the cooler starts pulling down right away.

void setup() {
  pinMode(MOSFET_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("Peltier cooler: full power for a minute");
  analogWrite(MOSFET_PIN, 255);
}

loop sketch.ino

Checks the clock every 100 ms. Once millis() reaches PULL_DOWN_MS (60000) and it has not done so yet, it sets holding, drops the output to HOLD_DUTY (153, 60 percent) and prints "holding at 60 %". Nothing else changes after that.

void loop() {
  if (!holding && millis() >= PULL_DOWN_MS) {
    holding = true;
    analogWrite(MOSFET_PIN, HOLD_DUTY);
    Serial.println("holding at 60 %");
  }
  delay(100);
}

Troubleshooting

The usual mistakes with this circuit, and the fix for each.

  • The cold face barely cools This project
    The hot face needs a good heat sink. A bare plate setting leaves it too hot to cool anything.
  • The module never switches on This project
    Pin 9 goes to TRIG and the Uno's GND must join the module's GND. The battery needs VIN+ and VIN-.
  • The load never turns on, or it is only dim. D4184 dual MOSFET switch module
    Check the load's own supply is wired to the screw terminals and the control pin gets 3.3 V or 5 V. Join the grounds of the controller and the load supply together.
  • Parts get hot or wires melt at high current. D4184 dual MOSFET switch module
    The board can carry high current only with thick wire and good connections. Keep the load supply within the module's rated voltage, and use a flyback diode across motors and other coils.
  • The battery is wired backwards, or the voltage is too low or too high for the circuit. A fresh AA is about 1.5 V, a LiPo is 3.7 V nominal and 4.2 V full. Battery: AA
    Match the plus and minus marks. Check the voltage your parts need. Two AAs make 3 V, four make 6 V. Never feed a LiPo to a 3.3 V chip directly at 4.2 V.
  • The circuit resets or browns out when a motor or servo starts. A battery has internal resistance, so the voltage sags under load. Battery: AA
    Use a fresh pack with enough current rating. Add a 100 uF or larger capacitor near the load. Power motors from their own pack and join the grounds.
  • Neither side gets cold, or both get hot. Peltier module
    Put a good heat sink and fan on the hot face. Without heat removal, the whole module warms up. Use thermal paste and keep the cold side insulated.
  • The module or power supply overheats. Peltier module
    The TEC1-12706 draws up to 6 A at 12 V, so use a supply rated for it and switch it with a MOSFET. Never exceed about 15.4 V, and do not run it with no heat sink.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.