Example Code for Arduino-Read Data Using UART
This project demonstrates how to read the voltage value of channel 1 from the Gravity: 0-10V 15-bit High Precision Dual Channel ADC Module using UART communication with an Arduino UNO controller. Users will learn how to wire the module via UART, install the required library, and use sample code to obtain voltage data.
Hardware Preparation
- DFRduino UNO Controller x1
- DFR1184 Gravity:2-Channel 15bit 0-10V ADC Module x1
Software Preparation
- Arduino IDE Click to download Arduino IDE
- Download and install DFRobot_ADS1115 Library.
Wiring Diagram

Other Preparation Work
- Connect the module to the UNO controller according to the wiring diagram above. You can also use an expansion board for easier prototype construction.
- Switch the sensor's selection switch to the UART side.
- Download and install the DFRobot_ADS1115 Library.
- Note: Switch off the power when switching the toggle switch.
Sample Code
#include <DFRobot_ADS1115_0_10V.h>
#include <SoftwareSerial.h>
SoftwareSerial mySerial1(4, 5);
DFRobot_ADS1115_UART ads1115(&mySerial1);
void setup() {
Serial.begin(9600);
while (!ads1115.begin()) {
Serial.println("Error, check connection!");
delay(1000);
}
}
void loop() {
double data;
const unsigned char channel = 1;
data = ads1115.getValue(channel);
Serial.print("channel:");
Serial.print(channel);
Serial.print(" adValue:");
Serial.print(data);
Serial.println("mv");
delay(1000);
}
Result
Open the serial monitor of the Arduino IDE, adjust the baud rate to 9600, and observe the serial print results to get the voltage value input from channel 1.
Switch off the power when switching the toggle switch.**
Was this article helpful?
