Arduino MKR WiFi 1010 - Control Heating Element
Learn to safely control 12V heating elements with your Arduino MKR WiFi 1010! This fundamental tutorial teaches relay-based heater switching—essential for temperature regulation systems, DIY incubators, and thermal projects.
You can switch a heating element with a relay or with a MOSFET module. The relay has only two states for the heater: fully ON or fully OFF. The MOSFET module gives you those two states, plus every heat level in between. It is also silent, and its contacts do not wear out when the heater is switched very often. You will learn both ways here.
What You'll Learn:
- Safe relay-based control of high-power heating elements
- A second way with a MOSFET module, which can also set the heat level (power) with PWM
- Proper electrical isolation between Arduino and heater circuits
- Programming timed heating cycles
- Foundation for thermostat and temperature control systems
Applications:
- DIY incubators: Egg hatching, bacterial cultures
- Reptile terrariums: Temperature-regulated habitats
- 3D printer heated beds: Build surface temperature control
- Food warming: Slow cooker automation, sous vide projects
- Chemical processes: Temperature-controlled reactions
- Greenhouse heating: Frost protection systems

WARNING
CRITICAL SAFETY WARNING
Heating elements pose serious safety risks:
- Burn hazard: Surface temperatures exceed 80°C (176°F)—severe burns possible
- Fire risk: Improper installation or failures can ignite nearby materials
- Electrical shock: 12V is generally safe, but wiring errors can be dangerous
- Thermal runaway: Without temperature feedback, heaters can overheat catastrophically
Safety Requirements:
- Never leave unattended: Always supervise heating element operation
- Use thermal cutoffs: Add temperature-sensing shutoff (future tutorial)
- Fire-resistant mounting: Secure to metal or ceramic surfaces only
- Ventilation: Ensure adequate airflow and heat dissipation
- Testing: Initially test with power supply disconnected, then in controlled environment
- Know your limits: If unsure about electrical safety, consult an expert
We are not responsible for injuries, fires, or property damage. Proceed only if you fully understand electrical and thermal hazards.
Tutorial Scope: This guide covers basic ON/OFF control. For intelligent temperature regulation with sensor feedback, see our Heating System with Temperature Control tutorial.
Hardware Preparation
Or you can buy the following kits:
| 1 | × | DIYables Sensor Kit (18 sensors/displays) |
Additionally, some of these links are for products from our own brand, DIYables .
Overview of Heating Elements
Heating elements are resistive devices that convert electrical energy into thermal energy. Understanding their characteristics ensures safe, effective integration.
Pinout and Electrical Characteristics

Heating elements feature two wire terminals:
- Positive (+) pin (red wire):
- Connects to positive terminal of 12V DC power supply
- Polarity usually doesn't matter for resistive heaters, but follow manufacturer markings
- Negative (-) pin (black wire):
- Connects to ground (GND) terminal of 12V power supply
- Completes circuit for current flow
- Voltage rating: Typically 12V DC (this tutorial), but also available in 5V, 24V, 110V AC
- Power consumption: 10-50W common for small elements (higher = more heat)
- Current draw: Calculate using P = V × I (e.g., 24W at 12V = 2A current)
- Temperature range: Can reach 80-200°C depending on design
- Current = Power ÷ Voltage = 24W ÷ 12V = 2A
- Your power supply must provide at least 2A continuous current
- Your relay must be rated for at least 2A switching current
- Voltage mismatch: Heating elements require 12V; Arduino pins output only 3.3V
- Current demand: Elements draw 1-5A; Arduino pins supply maximum 15mA (333× insufficient!)
- Isolation: Keeps high-power heater circuit separate from sensitive Arduino logic
- Arduino sends 3.3V LOW signal → Relay opens → Heater OFF (no power flow)
- Arduino sends 3.3V HIGH signal → Relay closes → Heater ON (12V applied, heat generated)
- Relay pinout and internal mechanics
- How electromagnetic coils control switch contacts
- Wiring diagrams for various configurations
- Programming relay control logic
- Choosing appropriate relay ratings
Key Specifications (check your element's datasheet):
Example Calculation:
If your heating element is rated 12V, 24W:
How Heating Element Control Works
Operating Principle: When voltage is applied across the heating element's resistance, current flows, generating heat (Joule heating effect). More current = more heat.
Control Method: ON/OFF switching via relay
Why Relay is Essential:
Direct connection would instantly destroy your Arduino and likely damage the heating element.
The Relay Solution:
The relay acts as an electrically-isolated switch, allowing low-power Arduino signals to control high-power heater operation safely.
Relay Prerequisite: Not familiar with relays? Study our comprehensive Arduino MKR WiFi 1010 - Relay tutorial. It covers:
Master those concepts, then apply them here for heating element control!
MOSFET Prerequisite: Planning to use the MOSFET module instead? Read the Arduino MKR WiFi 1010 - MOSFET Module tutorial to see how the module is built and how to pick between AOD4184, LR7843 and FR120N.
Heating Element: Relay vs MOSFET Module
| Relay | MOSFET Module | |
|---|---|---|
| Heat control | ON or OFF only | ON, OFF, and heat level (power) by PWM |
| Sound | a click at every switch | silent |
| Switching time | milliseconds (slow) | very fast |
| Wear | contacts burn and wear when switched often | no moving parts, no wear |
| Supply type | works with AC or DC | works with DC only |
| Minimum supply | none (within the relay rating) | about 6V, because the gate needs it |
| Isolation | coil is apart from the contacts | PC817 optocoupler |
| Best for | AC heaters, simple ON/OFF | 12V DC heaters, power control, frequent switching |
A thermostat project switches the heater many times every hour. That wears out relay contacts, so the MOSFET module is a good fit for a 12V heating element. Keep the relay for a heater that runs on AC mains. Also check the current: the FR120N handles only about 2A without a heatsink, so a 24W heater (2A at 12V) is better with the AOD4184 or LR7843.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Arduino MKR WiFi 1010 Code
This code repeatedly turns the heating element on for five seconds and then off for five seconds.
Detailed Instructions
New to Arduino MKR WiFi 1010? Complete our Getting Started with Arduino MKR WiFi 1010 tutorial first to set up your development environment.
- Connect the components to the Arduino MKR WiFi 1010 board as depicted in the diagram
- Plug your Arduino MKR WiFi 1010 into your computer's USB port
- Launch the Arduino IDE on your computer
- Select the Arduino MKR WiFi 1010 board and its COM port
- Copy the code provided above and paste it into the Arduino software.
- Click the Upload button to compile and send the code to your Arduino MKR WiFi 1010 board.
- Look at the temperature of the heating element.
WARNING
Be careful. It can burn you and your home. This is very serious, and we want you to be safe. If you are not 100% sure about what you are doing, please do not touch anything. Ask someone who understands. We are not responsible for your safety.
Code Explanation
The Arduino MKR WiFi 1010 code above has an explanation for each line. Please read the comments in the code!
Arduino MKR WiFi 1010 Code - Set Heat Level with MOSFET Module
In this part, a MOSFET module switches the heating element instead of the relay. The MKR sends a PWM signal, so the heater gets only part of its power when you want less heat.
Wiring Diagram

This image is created using Fritzing. Click to enlarge image
Connections:
- MKR pin 6 → module PWM pin
- MKR GND → module GND pin
- 12V adapter + and heater red wire (+) → module + terminal (they share it)
- Heater black wire (−) → module LOAD terminal
- 12V adapter − → module − terminal
A heating element is only a resistor, not a coil, so no flyback diode is needed.
Code
What happens: the heater gets full power for 2 seconds, then no power for 2 seconds. After that, the power climbs from 10% to 100% in steps, then goes back down. A heater warms up and cools down slowly, so you feel the change only after some time, not at each step.
Detailed Instructions
- Prepare the MKR board and the Arduino IDE like in the relay Quick Steps above.
- Build the circuit from the MOSFET wiring diagram. Mount the heater on a safe, fire-resistant surface.
- Upload the code above to the Arduino MKR WiFi 1010.
- Connect the 12V adapter.
- Open the Serial Monitor (9600 baud) to see the power level.
WARNING
The heater still gets hot with the MOSFET module. Do not touch it, and never leave it running alone.
Tip: Use the MOSFET module only for DC heaters with a supply of about 6V or higher. For an AC heater, use the relay.