Arduino Nano 33 IoT - Control Pump

This guide shows you how to use the Arduino Nano 33 IoT board to control a pump. You can also use this guide to create your own aquarium, cocktail maker, coffee machine, or watering system.

Arduino Nano 33 IoT Pump

Hardware Preparation

1×Arduino Nano 33 IoT
1×Micro USB Cable
1×Relay
1×12V Pump
1×Vinyl Tube
1×12V Power Adapter
1×Breadboard
1×Jumper Wires
1×Optionally, DC Power Jack
1×Recommended: Screw Terminal Expansion Board for Arduino Nano
1×Recommended: Breakout Expansion Board for Arduino Nano
1×Recommended: Power Splitter for Arduino Nano

Or you can buy the following sensor kits:

1×DIYables Sensor Kit (30 sensors/displays)
1×DIYables Sensor Kit (18 sensors/displays)
Disclosure: Some of the links provided in this section are Amazon affiliate links. We may receive a commission for any purchases made through these links at no additional cost to you.
Additionally, some of these links are for products from our own brand, DIYables .

Overview of 12V Pump

Pump Pinout

Arduino Nano 33 IoT Pump Pinout
image source: diyables.io

A pump that runs on 12 volts has two wires:

  • Black wire (-): Attach this wire to the negative terminal of your 12V DC power supply.
  • Red wire (+): Attach this wire to the positive terminal of your 12V DC power supply.

How to Control Pump using Arduino Nano 33 IoT

If you connect a 12V power supply to a pump, the pump will run. You can control the pump with code using the Arduino Nano 33 IoT. To do this, you need to use a relay between the pump and the Arduino board. There is a detailed tutorial about using a relay. The guide explains the hardware connections, how it works, how to wire it to the Arduino Nano 33 IoT, and shows example code. Learn more in the Arduino Nano 33 IoT - Relay tutorial.

Wiring Diagram between Arduino Nano 33 IoT, Relay and Pump

The wiring diagram between Arduino Nano and 33 IoT Pump

This image is created using Fritzing. Click to enlarge image

Arduino Nano 33 IoT - Pump Code

The code below turns the pump on and off every 4 seconds.

/* * This Arduino Nano 33 IoT code was developed by newbiely.com * * This Arduino Nano 33 IoT code is made available for public use without any restriction * * For comprehensive instructions and wiring diagrams, please visit: * https://newbiely.com/tutorials/arduino-nano-iot/arduino-nano-33-iot-controls-pump */ #define RELAY_PIN 2 // The Arduino Nano 33 IoT pin connected to the pump the via the relay // The setup function runs once on reset or power-up void setup() { // initialize digital pin as an output. pinMode(RELAY_PIN, OUTPUT); } // The loop function repeats indefinitely void loop() { digitalWrite(RELAY_PIN, HIGH); // turn on pump 4 seconds delay(4000); digitalWrite(RELAY_PIN, LOW); // turn off pump 4 seconds delay(4000); }

Detailed Instructions

If you are new to the Arduino Nano 33 IoT, be sure to check out our Getting Started with Arduino Nano 33 IoT tutorial. Then, follow these steps:

  • Connect the components to the Arduino Nano 33 IoT board as depicted in the diagram.
  • Use a USB cable to connect the Arduino Nano 33 IoT board to your computer.
  • Launch the Arduino IDE on your computer.
  • Select the Arduino Nano 33 IoT board and choose its corresponding COM port.
  • Copy the above code and paste it into the Arduino IDE.
  • Compile and upload the code to the Arduino Nano 33 IoT board by clicking the Upload button in the Arduino IDE.
  • Check the pump’s status.

Line-by-line Code Explanation

The Arduino Nano 33 IoT code above explains each line. Please read the comments in the code!

Video Tutorial

※ OUR MESSAGES

  • As freelancers, We are AVAILABLE for HIRE. See how to outsource your project to us
  • Please feel free to share the link of this tutorial. However, Please do not use our content on any other websites. We invested a lot of effort and time to create the content, please respect our work!