Example Code for Arduino-Measure Voltage

Measure Voltage by Arduino

Hardware Preparation

Software Preparation

Wiring Diagram

MCP3424 wiring diagram

Other Preparation Work

  1. Adjust voltage of Regulated Power to 0-2.085V, and then power on.
  2. Install Arduino MCP3424 library, see Install Arduino MCP3424 library
  3. Open Arduino IDE

Sample Code

 /* MCP 3424 version 1.2 example sketch OneShotConversion
 Written by B@tto
 Contact : [email protected]

 In this example, one conversion per second is performed on channel 1 and 16 bits resolution.
 A new conversion has to be initiated by the user
 */


 #include <Wire.h>
 #include <MCP3424.h>

 MCP3424 MCP(0x68);   // Declaration of MCP3424 with Address of I2C

 long Voltage;

 void setup(){

   Serial.begin(9600);
   MCP.Configuration(1,16,0,1); // Channel 1, 16 bits resolution, one-shot mode, amplifier gain = 1

 }

 void loop(){

   MCP.NewConversion();    // New conversion is initiated

   Voltage=MCP.Measure();  // Measure, note that the library waits for a complete conversion

   Serial.print("Voltage = ");
   Serial.print(Voltage);
   Serial.println("uV");  // unit: microVolt

   delay (1000);

 }

Result

  • Open Arduino serial monitor, the voltage will be displayed.

Was this article helpful?

TOP