Relay is
Relay is an electrical switch that is controlled by an electrical signal. It is used for:
Control high voltage electrical devices (e.g. fans, 220V bulbs) with electrical signals from Arduino (5V).
This allows the Arduino to safely control high-current devices (since the Arduino cannot directly supply high current).
Relay Module is available in various types such as 1 Channel, 2 Channel, 4 Channel depending on the number of devices to be controlled.
Specifications of Relay 5V Module
list
details
Control pressure (Input)
5V DC (from Arduino)
Load voltage (Output)
Up to ~250V AC or 30V DC
Maximum load current
10A
Number of channels (Channel)
1, 2, 4 (select according to the number of devices to be controlled)
Logic Control
Active LOW (some models)
There is an optocoupler.
Some models have a circuit breaker to isolate the electrical circuit (safer).
Output legs (3 legs)
NO (Normally Open), NC (Normally Closed), COM (Common)
Using Relay with Arduino
Wiring (Example 1 Channel):
Relay Pin
Arduino Pin
VCC
5V
GND
GND
IN1
D7 (or as required)
The IN1 leg is used to turn the relay on/off.
If it is 2/4 Channel, there will be IN2, IN3, IN4 added.
Example of connecting electrical equipment to a house:
Warning: You should have knowledge of 220V electricity and be very careful.
Use an extension cord or an electrician if you are not sure.
Connection:
COM → Connect to AC power (input line)
NO → Connect to the device you want to turn on/off (light, fan).
When Arduino sends a signal → Relay closes the circuit → Power goes to the device.
Code example:
int relayPin = 7;
void setup() { pinMode(relayPin, OUTPUT); }
void loop() {
digitalWrite(relayPin, LOW); // Open relay (some models LOW means open)
delay(3000); // leave open for 3 seconds
digitalWrite(relayPin, HIGH); // close relay
delay(3000); // wait another 3 seconds }
If your relay is Active HIGH, switch LOW and HIGH.
What can it be used with?
Turn on/off 220V light bulbs
Water pump control
Order to turn on the fan/electrical appliance
Make a Smart Home System
The Arduino UNO R4 WiFi combines the processing power and exciting new peripherals of the RA4M1 microcontroller from Renesas with the wireless connectivity power of the ESP32-S3 from Espressif. On top of this, the UNO R4 WiFi offers an on-board 12x8 LED matrix, Qwiic connector, VRTC, and OFF pin, covering all potential needs makers will have for their next project.
With the UNO R4 WiFi, you can easily upgrade your project and add wireless connectivity to expand the reach of your current setup. If this is your first project, this board has everything you need to spark your creativity.
Hardware compatibility with UNO form factor: The UNO R4 WiFi maintains the same form factor, pinout, and 5 V operating voltage as its predecessor, the UNO R3, ensuring a seamless transition for existing shields and projects.
Expanded memory and faster clock: The UNO R4 WiFi boasts increased memory and a faster clock speed, enabling more precise calculations and effortless handling of complex projects.
Extra on-board peripherals: The UNO R4 WiFi introduces a range of on-board peripherals, including a 12-bit DAC, CAN BUS, and OP AMP, providing expanded capabilities and design flexibility.
Extended 24 V tolerance: The UNO R4 WiFi supports a wider input voltage range, allowing seamless integration with motors, LED strips, and other actuators using a single power source.
HID support: With built-in HID support, the UNO R4 WiFi can simulate a mouse or keyboard when connected to a computer via USB, making it easy to send keystrokes and mouse movements.
Wi-Fi® and Bluetooth®: The UNO R4 WiFi hosts an ESP32-S3 module, enabling makers to add wireless connectivity to their projects. Combined with the Arduino IoT Cloud, makers can monitor and control their projects remotely.
Qwiic connector: The UNO R4 WiFi features a Qwiic I2C connector, allowing easy connection to nodes from the extensive Qwiic ecosystem. Adapter cables also enable compatibility with sensors and actuators based on other connectors.
Support for battery-powered RTC: The UNO R4 WiFi includes additional pins, including an "OFF" pin to turn off the board and a "VRTC" pin to keep the internal Real-Time Clock powered and running.
LED matrix: The UNO R4 WiFi incorporates a bright 12x8 red LED matrix, ideal for creative projects with animations or plotting sensor data, eliminating the need for additional hardware.
Diagnostics for runtime errors: The UNO R4 WiFi includes an error-catching mechanism that detects runtime crashes and provides detailed explanations and hints about the code line causing the crash.
MC-38 Normally Closed <Normally Closed principle is together, the signal is on, with the wired host use can not be used alone>
MC-38 is normally closed: the magnet is close to the conduction, the magnet is away from the circuit breaker.
MC-38A is normally open: the magnet is close to the closed (disconnected), the magnet is away from the open circuit
Action distance: 18mm ± 6mm
Lifetime: 1,000,000 times Switching output: often closed (together with the conductive) Open type, suitable for non-ferrous doors or windows Surface mountin
It is used for directional control, similar to that used in video games, by providing an analog output using two potentiometers to read the position of the joystick.
Working voltage : DC 5 V Static current : 3 mA Working temperature : 0 ~ + 70 Output way : GPIO Induction Angle : Less than 15 Detection range : 2 cm to 4 m Detecting precision : 0.3 cm + 1% Sensor size : Approx. 45.1 x 20 x 14.5mm
NodeMCU ESP8266
NodeMCU is a microcontroller board developed using the ESP8266 chip from Espressif, which is notable for:
Built-in Wi-Fi connectivity
cheap price
Easy to use with Arduino IDE
Suitable for IoT (Internet of Things) such as controlling devices via the Internet, sending sensor data to the web, making a smart home.
The name "NodeMCU" stands for "Node MicroController Unit" and was originally written in Lua, but is now more commonly written in C/C++ via the Arduino IDE.
NodeMCU ESP8266 Specifications
list
details
Main chip
ESP8266 (ESP-12E or ESP-12F)
CPU speed
80 MHz (Overclockable up to 160 MHz)
Memory (Flash)
4MB
SRAM (RAM)
64KB
Wi-Fi
802.11 b/g/n (2.4GHz), supports both STA and AP
Working pressure
3.3V (but USB can use 5V because it has a built-in converter)
USB port
Use CH340 or CP2102 chip (for programming via USB)
Number of GPIOs
11 legs (some legs have special functions such as PWM, ADC, I2C, SPI)
ADC leg
1 leg (reads analog values 0–1V)
Digital leg pressure
3.3V (If using with 5V, a voltage divider resistor is required)
3. Using NodeMCU ESP8266
Highlights:
Built-in Wi-Fi connectivity (no separate module required)
You can load the code via USB.
Works with the web, phones, and online databases.
Supports writing with Arduino IDE or PlatformIO
Popular usage examples:
✅ Control light bulbs via Wi-Fi
✅Write a built-in web server, control it via a web browser.
✅ Send sensor data (DHT11, MQ-2, Soil) to Firebase / ThingSpeak
✅ Make a node to send data via Wi-Fi to a server or MQTT.
✅ Create a notification system via LINE Notify or Telegram.
Code sample: Open a simple web server
include <ESP8266WiFi.h>
const char* ssid = "YOUR_WIFI_NAME";
const char* password = "YOUR_WIFI_PASSWORD";
WiFiServer server(80);
void setup() {
Serial.begin(115200);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..."); }
Serial.println("Connected: ");
Serial.println(WiFi.localIP());
server.begin();
}
void loop() {
WiFiClient client = server.available();
if (client) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.println("<h1>Hello from NodeMCU!</h1>");
delay(1000);
}
}
Soil Moisture Sensor is a popular device in Smart Farm projects or automatic watering systems. It works with Arduino easily, is cheap, and is suitable for learning and experimenting.
Soil Moisture Sensor
Soil moisture sensor is a sensor that detects the moisture level in the soil by measuring the conductivity between the probe legs (similar to measuring the resistance of soil).
Dry soil → low conductivity → low value obtained
Moist soil → High conductivity → High obtained value
Sensors often come with a conversion module that provides both analog and digital pins.
Soil Moisture Sensor Specifications
list
details
Supply voltage
3.3V – 5V
Current used
About 10mA
Output signal
Analog (A0) and Digital (D0)
Detection range
General soil moisture levels
structure
2 probe legs (ground plug), signal converter board has a threshold adjustment potentiometer
The Digital Output will give a HIGH or LOW value according to the threshold we set.
Using with Arduino
Wiring:
Soil Sensor Pin
Arduino Pin
VCC
5V
GND
GND
A0 (Analog)
A0
D0 (Digital)
D2 (if used)
Analog code example:
------------------------------------------------------------------------------
int sensorPin = A0;
void setup() { Serial.begin(9600); }
void loop() { int value = analogRead(sensorPin); Serial.print("Soil moisture : "); Serial.println(value);
delay(1000); }
----------------------------------------------------------------------------------------------
The value returned by analogRead() will be between 0–1023.
High value = dry soil
Low value = moist soil
Digital code example:
----------------------------------------------------------------------
int sensorDigital = 2;
void setup() { pinMode(sensorDigital, INPUT); Serial.begin(9600); }
void loop() { int value = digitalRead(sensorDigital);
if (value == LOW) { Serial.println("Moist soil"); } else { Serial.println("Dry soil"); }
delay(1000); }
Additional tips:
Do not leave the sensor plugged into the ground for a long time (rust may occur).
Use the relay together with a water pump or electric valve to automatically water plants.
If you want more accuracy, try using a capacitive soil moisture sensor instead of the regular one (it is more durable and does not rust).
The MQ-2 sensor is a very popular gas sensor for use with Arduino and other microcontroller boards, and is ideal for home gas or smoke detection projects, such as gas leak alarms.
MQ-2 is
The MQ-2 is a gas sensor that can detect many types of gases such as:
LPG (cooking gas)
Butane gas
Propane gas
Methane gas (CH₄)
Hydrogen gas (H₂)
Smoke
alcohol
Inside the sensor is a heating coil and a SnO₂ (tin dioxide) gas detector, whose resistance changes in the presence of gas in the air, allowing it to be converted to an electrical signal.
MQ-2 specifications
list
details
Supply voltage
5V DC
Electrical power
About 800mW
Signal type
Analog and digital (depending on module)
Warm-up time
About 20 seconds to 2 minutes
Detectable gases
LPG, Methane, Alcohol, Propane, Hydrogen, Smoke
Detection range
Approximately 300 - 10,000 ppm
Number of legs
4 legs (VCC, GND, AOUT, DOUT)
AOUT (Analog Out) – Analog signal indicating gas level. DOUT (Digital Out) – Digital signal (1 or 0) when gas level exceeds set point.
Using MQ-2 with Arduino
Wiring:
MQ-2 Pin
Arduino Pin
VCC
5V
GND
GND
AOUT
A0 (Analog)
DOUT
D2 (Digital) (if used)
Some MQ-2 modules have a potentiometer (adjuster) to set the threshold level on DOUT.
Example code for use in Analog:
int mq2Pin = A0;
void setup() { Serial.begin(9600); }
void loop() { int gasLevel = analogRead(mq2Pin); Serial.print("gasLevel: "); Serial.println(gasLevel); delay(1000); }
Example of code for Digital usage:
int mq2Digital = 2;
void setup() { pinMode(mq2Digital, INPUT); Serial.begin(9600); }
void loop() { int gasDetected = digitalRead(mq2Digital);
if (gasDetected == LOW) { Serial.println("gas detect!"); } else { Serial.println("Safe"); }
delay(1000); }
The DHT11 sensor is one of the most popular sensors for measuring temperature and humidity, especially in Arduino projects because it is easy to use, cheap, and readily available.
What is DHT11?
DHT11 is a sensor that measures temperature and relative humidity in the air. This sensor has a capacitive humidity sensor and a thermistor temperature sensor inside, which outputs digital data, making it very easy to connect to Arduino.
DHT11 specifications
list
details
Humidity measurement range
20–90% RH (±5% RH)
Temperature measurement range
0–50°C (±2°C)
Supply voltage
3.3V – 5.5V
Output signal
Single-wire digital
Read Rate
1 time/second (1Hz)
Number of legs
3 legs (VCC, GND, Data) or 4 legs (if it is a module but actually uses 3 legs)
Using DHT11 with Arduino
Wiring:
DHT11
Arduino
VCC
5V
GND
GND
DATA
Digital Pin (eg. D2)
Some models have a pull-up resistor (about 10KΩ) already attached to the module. If it is a bare sensor, you may need to connect your own resistance.
Arduino code example:
Requires DHT library, which can be installed via Library Manager.
define DHTPIN 2 // The pin connected to the DHT11's Data #define DHTTYPE DHT11 // The type of sensor
DHT dht(DHTPIN, DHTTYPE); void setup() { Serial.begin(9600); dht.begin(); }
void loop() { float h = dht.readHumidity(); float t = dht.readTemperature();
if (isnan(h) || isnan(t)) { Serial.println("Read failed!"); return; }
Serial.print("Humidity: "); Serial.print(h); Serial.print(" %\t"); Serial.print("Temperature: "); Serial.print(t); Serial.println(" *C"); delay(2000); // wait 2 seconds }
Specification
2.4G NRF24L01 Wireless Transceiver/Receive Module NRF24L01 2.4GHz wireless data transmission module
NRF24L01 is a work in the 2.4-2.5GHz worldwide ISM band single-chip transceiver, wireless transceiver, including: the frequency generator the enhanced SchockBurstTM mode controller power amplifier crystal amplifier modulator demodulator output power channel selection and protocol set by the SPI interface to set a very low current consumption, lower current consumption mode 12.3mA Power-down mode and standby mode when in transmit mode emission power 6dBm when current consumption is 9.0mA acceptance model.
Ball to open ISM band maximum 0dBm transmit power, license-exempt use. The open 100 meters!
Support six channels of data reception
(1) low operating voltage: 1.9 ~~ 3.6V low-voltage
(2) high-rate: 2Mbps, air transmission time is very short, greatly reducing the wireless transmission of collision phenomena (software settings 1Mbps or 2Mbps air transmission rate)
Multi-frequency points: 125 frequency points, to meet the multi-point communications and frequency hopping communications needs
4 ultra-compact: built-in 2.4GHz antenna compact 15x29mm (including antenna)
(5) Low power consumption: when in answer mode communication, fast air transmission and start-up time greatly reduces the current consumption.
Low application cost: NRF24L01 integrates all RF protocol high-speed signal processing section, such as: automatically resend lost packets and automatically generate an acknowledge signal, etc. the nRF24L01 The SPI interface can take advantage of the microcontroller hardware SPI port or microcontroller I / O port to simulate the internal FIFO can be used with a variety of low-speed microprocessor interface, easy to use low-cost microcontroller. 7 facilitate the development: the link layer is fully integrated in the module, very easy to develop. Automatic retransmission function, automatic detection and retransmission of lost packets, the retransmission time and the number of retransmission can be software-controlled automatic storage is not received the packet of the response signal auto-answer, after the receipt of a valid data, the module automatically sends the reply fixed frequency detection signals without any additional programming Carrier Detect - built-in hardware CRC error detection and point-to-multipoint communication address control packet transmission error counter and carrier detection can be used for frequency hopping set can also set up six to receive the channel address, can have a choice of open receive channel standard the pin Dip2.54MM spacing interfaces for embedded applications.
UNO R3 ATMega328P USB Compatible Development Board is a microcontroller board based on the ATmega328. It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analogue inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller; Simply connect it to a computer with a USB cable or power it with a AC-to-DC adapter or battery to get started. This upgraded model is completely compatible with original Arduino UNO.
Microcontroller
ATmega328
Operating Voltage
5V
Input Voltage (recommended)
7-12V
Input Voltage (limits)
6-20V
Digital I/O Pins
14 (of which 6 provide PWM output)
Analog Input Pins
6
DC Current per I/O Pin
40 mA
DC Current for 3.3V Pin
50 mA
Flash Memory
32 KB ( ATmega328 ) of which 0.5 KB used by bootloader
SRAM
2 KB ( ATmega328 )
EEPROM
1 KB ( ATmega328 )
Clock Speed
16 MHz