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

Arduino Mega and UNO-Based NFC/RFID Reader with SD Card Data Logging

View and Edit Project In Cirkit DesignerImage of Arduino Mega and UNO-Based NFC/RFID Reader with SD Card Data Logging

Circuit Documentation

Summary

This circuit involves two microcontrollers, an Arduino Mega 2560 and an Arduino UNO, interfaced with an SD module and an NFC/RFID reader PN532. The Arduino Mega 2560 is primarily responsible for reading analog values from various sensors, while the Arduino UNO handles communication with the NFC/RFID reader. The SD module is used for data storage.

Component List

Arduino Mega 2560

Arduino UNO

NFC/RFID Reader PN532

SD Module

Wiring Details

Arduino Mega 2560

Arduino UNO

NFC/RFID Reader PN532

SD Module

Documented Code

Arduino Mega 2560 Code

#include <Wire.h>
#include <Adafruit_ADS1X15.h>

// Create an ADS1115 object
Adafruit_ADS1115 ads;  // Use default constructor

void setup() {
  Serial.begin(9600);
  
  // Initialize the ADS1115 module
  if (!ads.begin(0x48)) {  // Pass the I2C address here
    Serial.println("Failed to initialize ADS1115.");
    while (1);
  }
  
  Serial.println("ADS1115 initialized.");
}

void loop() {
  // Read analog values from the MQ sensors
  int16_t adc0 = ads.readADC_SingleEnded(0);  // MQ-2 on A0
  int16_t adc1 = ads.readADC_SingleEnded(1);  // MQ-3 on A1
  int16_t adc2 = ads.readADC_SingleEnded(2);  // MQ-7 on A2
  int16_t adc3 = ads.readADC_SingleEnded(3);  // MQ-135 on A3
  
  // Convert ADC values to voltage (optional, for reference)
  float voltage0 = adc0 * 0.1875 / 1000;  // ADS1115 16-bit, ±6.144V range, 0.1875mV per bit
  float voltage1 = voltage0;  // Same for other channels
  float voltage2 = voltage0;
  float voltage3 = voltage0;

  // Print ADC values and voltage to the Serial Monitor
  Serial.print("MQ-2 (A0) ADC: "); Serial.print(adc0);
  Serial.print(", Voltage: "); Serial.print(voltage0); Serial.println(" V");

  Serial.print("MQ-3 (A1) ADC: "); Serial.print(adc1);
  Serial.print(", Voltage: "); Serial.print(voltage1); Serial.println(" V");

  Serial.print("MQ-7 (A2) ADC: "); Serial.print(adc2);
  Serial.print(", Voltage: "); Serial.print(voltage2); Serial.println(" V");

  Serial.print("MQ-135 (A3) ADC: "); Serial.print(adc3);
  Serial.print(", Voltage: "); Serial.print(voltage3); Serial.println(" V");

  // Add delay for readability
  delay(1000);
}

Arduino UNO Code

void setup() {
  // put your setup code here, to run once:

}

void loop() {
  // put your main code here, to run repeatedly:

}

This documentation provides a comprehensive overview of the circuit, including a summary, detailed component list, wiring details, and documented code for the microcontrollers.