Arduino UNO and ADS1115-Based Current Monitoring System with Toggle and Push Switches
View and Edit Project In Cirkit Designer
Circuit Documentation
Summary
This document provides a detailed overview of a circuit that includes an Arduino UNO, an ADS1115 ADC, an ACS712 current sensor, a potentiometer, toggle switches, a push button, and a power supply. The circuit is designed to read current values, potentiometer settings, and switch states, and then send this data to a serial monitor for further processing.
Component List
ADS1115
- Description: 16-bit Analog-to-Digital Converter (ADC)
- Pins: VDD, GND, SCL, SDA, ADDR, ALRT, A0, A1, A2, A3
Toggle Switch
- Description: Simple on/off switch
- Pins: Vcc, Sig, Gnd
Arduino UNO
- Description: Microcontroller board based on the ATmega328P
- Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
ACS712 Current Sensor 5A 20A 30A
- Description: Current sensor module
- Pins: 1, 2, GND, OUT, VCC
Potentiometer
- Description: Variable resistor
- Pins: GND, Output, VCC
2Pin Push Switch
- Description: Simple push button switch
- Pins: Input +, Output +
POWER SUPPLY 5V 5AMP
- Description: Power supply unit
- Pins: 220V Positive Pole (AC), 220V Negative Pole (AC), GND, GND (DC), 12V-24V Output (DC)
Wiring Details
ADS1115
- VDD connected to 5V of Arduino UNO
- GND connected to:
- GND of Arduino UNO
- Input + of 2Pin Push Switch
- GND of ACS712 Current Sensor
- Sig of Toggle Switch 1
- Sig of Toggle Switch 2
- GND of Potentiometer
- SCL connected to A5 of Arduino UNO
- SDA connected to A4 of Arduino UNO
- A0 connected to OUT of ACS712 Current Sensor
- A1 connected to Output of Potentiometer
Toggle Switch 1
- Vcc connected to D6 of Arduino UNO
- Sig connected to GND of Arduino UNO
- Gnd connected to D5 of Arduino UNO
Toggle Switch 2
- Vcc connected to D4 of Arduino UNO
- Sig connected to GND of Arduino UNO
- Gnd connected to D3 of Arduino UNO
Arduino UNO
- 5V connected to VDD of ADS1115
- GND connected to:
- GND of ADS1115
- Input + of 2Pin Push Switch
- GND of ACS712 Current Sensor
- Sig of Toggle Switch 1
- Sig of Toggle Switch 2
- GND of Potentiometer
- A5 connected to SCL of ADS1115
- A4 connected to SDA of ADS1115
- A1 connected to Output of Potentiometer
- D7 connected to Output + of 2Pin Push Switch
- D6 connected to Vcc of Toggle Switch 1
- D5 connected to Gnd of Toggle Switch 1
- D4 connected to Vcc of Toggle Switch 2
- D3 connected to Gnd of Toggle Switch 2
ACS712 Current Sensor
- 1 connected to 220V Negative Pole (AC) of POWER SUPPLY 5V 5AMP
- 2 connected to 220V Positive Pole (AC) of POWER SUPPLY 5V 5AMP
- GND connected to GND of Arduino UNO
- OUT connected to A0 of ADS1115
- VCC connected to 5V of Arduino UNO
Potentiometer
- GND connected to GND of Arduino UNO
- Output connected to A1 of ADS1115
- VCC connected to 5V of Arduino UNO
2Pin Push Switch
- Input + connected to GND of Arduino UNO
- Output + connected to D7 of Arduino UNO
POWER SUPPLY 5V 5AMP
- 220V Positive Pole (AC) connected to 2 of ACS712 Current Sensor
- 220V Negative Pole (AC) connected to 1 of ACS712 Current Sensor
Code Documentation
#include <Adafruit_ADS1X15.h>
#include <Wire.h>
Adafruit_ADS1115 ads; // Create an instance of the ADS1115
// Pin Definitions
const int potPin = A1; // Pin for potentiometer
const int toggleSwitch1Pin = 3; // Pin for toggle switch 1 (corrected)
const int toggleSwitch2Pin = 4; // Pin for toggle switch 2 (corrected)
const int pushSwitchPin = 7; // Pin for push button (corrected)
// Variables to store values
int toggleSwitch1State = 0; // Variable for toggle switch 1 state
int toggleSwitch2State = 0; // Variable for toggle switch 2 state
int pushSwitchState = 0; // Variable for push button state
float currentSetting = 0; // Variable for potentiometer value
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // Start Serial communication for debugging
ads.begin(); // Initialize the ADS1115 ADC
// Configure pins for switches
pinMode(toggleSwitch1Pin, INPUT); // Set toggle switch 1 pin as input
pinMode(toggleSwitch2Pin, INPUT); // Set toggle switch 2 pin as input
pinMode(pushSwitchPin, INPUT_PULLUP); // Set push button pin as input with internal pull-up
}
void loop() {
// put your main code here, to run repeatedly:
// Read the current from ACS712 via ADS1115
int16_t rawADC = ads.readADC_SingleEnded(0); // Read from A0 of ADS1115
float voltage = rawADC * (4.096 / 32767.0); // Convert raw ADC value to voltage
float current = (voltage - 2.5) / 0.185; // Convert voltage to current based on ACS712 (adjust based on your model)
// Read the potentiometer value
currentSetting = analogRead(potPin); // Read potentiometer value from A1
float knobValue = map(currentSetting, 0, 1023, 0, 100); // Map to 0-100 range (adjust as needed)
// Read the toggle switch states
toggleSwitch1State = digitalRead(toggleSwitch1Pin); // Read toggle switch 1 state
toggleSwitch2State = digitalRead(toggleSwitch2Pin); // Read toggle switch 2 state
// Read the push button state
pushSwitchState = digitalRead(pushSwitchPin); // Read push button state (LOW when pressed)
// Send data to Serial for your custom software
Serial.print("Current: ");
Serial.print(current, 3); // Print current in Amps
Serial.print(" A, Knob Value: ");
Serial.print(knobValue); // Print potentiometer value as a percentage
Serial.print(" %, Toggle Switch 1: ");
Serial.print(toggleSwitch1State == HIGH ? "OFF" : "ON"); // Print toggle switch 1 state
Serial.print(", Toggle Switch 2: ");
Serial.print(toggleSwitch2State == HIGH ? "OFF" : "ON"); // Print toggle switch 2 state
Serial.print(", Push Button: ");
Serial.println(pushSwitchState == HIGH ? "Released" : "Pressed"); // Print push button state
// Add a small delay to avoid spamming Serial
delay(500); // Adjust the delay as needed
}
This code initializes the ADS1115 ADC, reads current values from the ACS712 current sensor, potentiometer values, and switch states, and then sends this data to the serial monitor for further processing.