Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Smart Fuel Dispenser with RFID and Keypad using Arduino Mega and ESP32

View and Edit Project In Cirkit DesignerImage of Smart Fuel Dispenser with RFID and Keypad using Arduino Mega and ESP32

Circuit Documentation

Summary

This circuit is designed to create a smart petrol dispensing system. It utilizes an Arduino Mega 2560 microcontroller to interface with various components including an ESP32, a 16x2 I2C LCD, a 5V relay, an RFID-RC522 module, and a 4x4 keypad. The system reads RFID cards to authorize transactions, displays information on an LCD, and controls a relay to simulate fuel dispensing.

Component List

  1. ESP32 (30 pin)

    • Description: A powerful microcontroller with Wi-Fi and Bluetooth capabilities.
    • Pins: EN, VP, VN, D34, D35, D32, D33, D25, D26, D27, D14, D12, D13, GND, Vin, D23, D22, TX0, RX0, D21, D19, D18, D5, TX2, RX2, D4, D2, D15, 3V3
  2. 9V Battery

    • Description: Provides power to the circuit.
    • Pins: -, +
  3. Arduino Mega 2560

    • Description: A microcontroller board based on the ATmega2560.
    • Pins: IOREF, RESET, 3V3, 5V, GND, VIN, A0-A15, D21/SCL, D20/SDA, D19/RX1, D18/TX1, D17 PWM/RX2, D16 PWM/TX2, D15/RX3, D14/TX3, D0 RX0, D1 TX0, D2 PWM, D3 PWM, D4 PWM, D5 PWM, D6 PWM, D7 PWM, D8 PWM, D9 PWM, D10 PWM, D11 PWM, D12 PWM, D13 PWM, AREF, SDA, SCL, D52, D50, D48, D46, D44, D42, D40, D38, D36, D34, D32, D30, D28, D26, D24, D22, D53, D51, D49, D47, D45, D43, D41, D39, D37, D35, D33, D31, D29, D27, D25, D23
  4. 16x2 I2C LCD

    • Description: A 16x2 character LCD display with I2C interface.
    • Pins: GND, VCC, SDA, SCL
  5. 5V Relay

    • Description: A relay module that can be controlled by a microcontroller to switch high voltage devices.
    • Pins: Normally Open, Common terminal, Normally Closed, In, GND, VCC
  6. RFID-RC522

    • Description: An RFID reader module.
    • Pins: VCC (3.3V), RST, GND, IRQ, MISO, MOSI, SCK, SDA
  7. 4x4 Keypad (Simulator)

    • Description: A 4x4 matrix keypad for user input.
    • Pins: R1, C4, R2, C2, R3, R4, C1, C3

Wiring Details

ESP32 (30 pin)

9V Battery

Arduino Mega 2560

16x2 I2C LCD

5V Relay

RFID-RC522

4x4 Keypad (Simulator)

Documented Code

#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Keypad.h>

// RFID Module Pins
#define RST_PIN 9
#define SS_PIN 53

// Relay Pin
#define RELAY_PIN 7

// Create RFID instance
MFRC522 rfid(SS_PIN, RST_PIN);

// Create LCD instance
LiquidCrystal_I2C lcd(0x27, 16, 2);

// Keypad setup
const byte ROWS = 4;
const byte COLS = 4;
char keys[ROWS][COLS] = {
    {'1', '2', '3', 'A'},
    {'4', '5', '6', 'B'},
    {'7', '8', '9', 'C'},
    {'*', '0', '#', 'D'}
};
byte rowPins[ROWS] = {30, 31, 32, 33};
byte colPins[COLS] = {34, 35, 36, 37};
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);

void setup() {
    // Serial Monitor for Debugging
    Serial.begin(9600);
    
    // RFID initialization
    SPI.begin();
    rfid.PCD_Init();

    // LCD initialization
    lcd.begin(16,2);
    lcd.backlight();
    lcd.print("Smart Petrol");

    // Relay setup
    pinMode(RELAY_PIN, OUTPUT);
    digitalWrite(RELAY_PIN, LOW);

    delay(2000);
    lcd.clear();
}

void loop() {
    // Check for RFID card
    if (rfid.PICC_IsNewCardPresent() && rfid.PICC_ReadCardSerial()) {
        String cardID = "";
        for (byte i = 0; i < rfid.uid.size; i++) {
            cardID += String(rfid.uid.uidByte[i],