1
\$\begingroup\$

I have made a circuit for a pressure sensor, wherein I have connected an MPX5700 pressure sensor output to the A0 pin of an ADS1115 ADC, which is connected through an I2C interface to an Arduino Nano.

I used a device scanner code to see if the Nano could detect the ADS1115, which gave an output as detecting the ADS1115. But on trying to read the raw data output from the ADS1115 on the serial monitor, it gives 0.

I checked my connection, tried changing pins, and gave A3 pin a constant voltage of 2.5 V other than the sensor voltage output, but to no avail. The voltage is 5 V, and has not dripped at any needed point (so no scope of error thus). I have attached the schematic and a picture of my connections. Can you give me suggestions on what to do?

Connections

Schematic of my circuit

#include <Wire.h>
#include <ADS1115_WE.h>

// Initialize the ADS1115 at address 0x48
ADS1115_WE ads(0x48);  // Create an instance of the ADS1115

void setup() {
  Serial.begin(9600); // Initialize the serial communication at 9600 baud rate
  Wire.begin();
  Wire.setClock(100000);
  delay(500);  // Delay to allow serial communication to initialize
  
  Serial.println("Initializing ADS1115...");
  delay(500);  // Delay to allow serial communication to initialize
  
  // Initialize the ADS1115
  if (!ads.init()) {
    Serial.println("Failed to initialize ADS1115.");
    while (1); // Halt the program if initialization fails
  } else {
    Serial.println("ADS1115 initialized successfully.");
  }
  
  // Configure ADS1115 settings
  ads.setVoltageRange_mV(ADS1115_RANGE_4096); // Set voltage range to +/- 2.048V
  ads.setMeasureMode(ADS1115_SINGLE);  // Set single-ended measurement mode
  ads.setCompareChannels(ADS1115_COMP_3_GND); // Compare A0 to GND 
}

void loop() {
  // Read the analog value from the ADS1115 (connected to A0)
  int16_t adc0 = ads.getRawResult(); // Get raw ADC result
  
  Serial.print("ADC Value: ");
  Serial.print("Bits: ");
  
  for (int i = 15; i >= 0; i--) {
    Serial.print(bitRead(adc0, i));
  }
  
  Serial.println();
  
  // Wait for a moment before the next reading
  delay(5000);
}
\$\endgroup\$
1
  • 1
    \$\begingroup\$ The library you are using come with several examples, try the example(s) first before you are trying to customise it. \$\endgroup\$
    – hcheung
    Commented Sep 3 at 11:39

1 Answer 1

0
\$\begingroup\$

Please see the example code provided for the 'official' ADC-Library.

If you want to stay with your library, please see the example code and pay special attention to the implementation of the float readChannel(ADS1115_MUX channel){...} method.

It seems to me - i have no knowledge regarding the chip or either library - that you are missing some crucial steps like setting the multiplexer, starting the conversion, and some other initialization steps.

EDIT: To check the proper wiring of your serial communication you can also try this Who Am I code

\$\endgroup\$
2
  • \$\begingroup\$ The first link pointed to a different library than the one OP is using. \$\endgroup\$
    – hcheung
    Commented Sep 3 at 11:41
  • \$\begingroup\$ @hcheung "Please see ... the 'official' ... if you want to stay with your library ... " \$\endgroup\$ Commented Sep 3 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.