0

Data read issue with ADS1115 and ESP32 from bridge sensor
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Data read issue with ADS1115 and ESP32 from bridge sensor

by Oribe on Fri May 13, 2022 4:35 am

Hello,
I am currently working on a project with the goal of getting data from a bridge sensor and logging the data on a SD card.
The materials i am currently using is:
ESP32 HUZZAH Feather as the brain of the system(https://www.adafruit.com/product/3405)
microSD card reader to log data (https://www.adafruit.com/product/254)
Ads1115 to get data from the bridge sensor(https://www.adafruit.com/product/1085)
MT3608 to power the sensor(https://www.az-delivery.de/en/products/ ... up-modul-1)
LM317 to power the sensor(https://protosupplies.com/product/lm317 ... or-module/)


The bridge sensor needs 10V to work so i use the MT3608 to boost the 3V from the sensor into a 10V and i use the LM317 to make sure i don't go over this voltage.
I am using the differential mode of the ADS1115 to get data from the bridge sensor.
The ESP32 is powered by a lithium battery 3.7V.
The ESP32 is used to power all the others components using it's 3V pin.
Here is my circuit:
Circuit1.jpg
Circuit1.jpg (584.56 KiB) Viewed 229 times



Here is the code i am using in order to see the data from the ADS1115 on the serial port and log it :
Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_ADS1X15.h>
#include "FS.h"
#include "SD.h"
#include "SPI.h"

#define RATE_ADS1115_860SPS (0x00E0) ///< 860 samples per second
#define RATE_ADS1115_64SPS (0x0060)  ///< 64 samples per second
#define RATE_ADS1115_475SPS (0x00C0) ///< 475 samples per second



 Adafruit_ADS1115 ads;  /* Use this for the 16-bit version */
String entete = "temps;data\n";
String filename;
String tabdata[10];
String vdata ="";
File file;

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Hello!");

  Serial.println("Getting differential reading from AIN0 (P) and AIN1 (N)");
  Serial.println("ADC Range: +/- 0.256V (1 bit = 3mV/ADS1015, 0.1875mV/ADS1115)");

  // The ADC input range (or gain) can be changed via the following
  // functions, but be careful never to exceed VDD +0.3V max, or to
  // exceed the upper and lower limits if you adjust the input range!
  // Setting these values incorrectly may destroy your ADC!
  //                                                                ADS1015  ADS1115
  //                                                                -------  -------
  // ads.setGain(GAIN_TWOTHIRDS);  // 2/3x gain +/- 6.144V  1 bit = 3mV      0.1875mV (default)
  // ads.setGain(GAIN_ONE);        // 1x gain   +/- 4.096V  1 bit = 2mV      0.125mV
  // ads.setGain(GAIN_TWO);        // 2x gain   +/- 2.048V  1 bit = 1mV      0.0625mV
  // ads.setGain(GAIN_FOUR);       // 4x gain   +/- 1.024V  1 bit = 0.5mV    0.03125mV
  // ads.setGain(GAIN_EIGHT);      // 8x gain   +/- 0.512V  1 bit = 0.25mV   0.015625mV
   ads.setGain(GAIN_SIXTEEN);    // 16x gain  +/- 0.256V  1 bit = 0.125mV  0.0078125mV
   ads.setDataRate(RATE_ADS1115_860SPS);

  if(!SD.begin()){//Checking if the SD card is inserted or not
      Serial.println("Card Mount Failed");
      return;
  }
//to name the file on which we will save the data
  int count = 0;
      while(true){
        filename = "/LOGGER"+String(count)+".CSV";
        count++;
        if (SD.exists(filename)) continue;
        writeFile(SD, filename.c_str(), entete.c_str());
        break;
      }
  if (!ads.begin()) {//Checking if the ADS is properly wired
    Serial.println("Failed to initialize ADS.");
    while (1);
  }
 
 }

void loop(void)
{
  int16_t results;
 
  /* Be sure to update this value based on the IC and the gain settings! */

  float multiplier = 0.0078125F; /* ADS1115  @ +/- 6.144V gain (16-bit results) */
 
 
     uint32_t m = millis();

     results = ads.readADC_Differential_1_3();
     vdata = String(m)+";"+String(results * multiplier,5);
   
 
  Serial.println(vdata);
  file = SD.open(filename, FILE_APPEND);
  file.println(vdata);
  file.close();
 
 
 

  //delay(10);
}


void appendFile(fs::FS &fs, const char * path, const char * message){
    //Serial.printf("Appending to file: %s\n", path);

    File file = fs.open(path, FILE_APPEND);
    if(!file){
        Serial.println("Failed to open file for appending");
        return;
    }
    if(file.print(message)){
       // Serial.println("Message appended");
    } else {
        Serial.println("Append failed");
    }
    file.close();
}
void readFile(fs::FS &fs, const char * path){
    Serial.printf("Reading file: %s\n", path);

    File file = fs.open(path);
    if(!file){
        Serial.println("Failed to open file for reading");
        return;
    }

    Serial.print("Read from file: ");
    while(file.available()){
        Serial.write(file.read());
    }
    file.close();
}

void writeFile(fs::FS &fs, const char * path, const char * message){
    Serial.printf("Writing file: %s\n", path);

    File file = fs.open(path, FILE_WRITE);
    if(!file){
        Serial.println("Failed to open file for writing");
        return;
    }
    if(file.print(message)){
        Serial.println("File written");
    } else {
        Serial.println("Write failed");
    }
    file.close();
}



The problem i have is i am supposed to see the signal vary on the ADS1115 but it doesn't change however when i plug the sensor to the voltmeter i get the correct signal.
I also tried powering the Bridge sensor directly from the battery while still using that same battery to power the ESP32 and the other component the difference being the bridge sensor was no longer power on the 3V pin but by a wire connected on the battery and ESP32 was still powering everything else from that 3V pin.

Afterwards when i tried using a battery only to power the bridge sensor and powering the ESP32 with it's own battery i got the correct signal both on the voltmeter and the ADS1115.
Here is the circuit with the battery:
Circuit2.jpg
Circuit2.jpg (585.88 KiB) Viewed 229 times


My goal is to have only one power source just like in circuit1.
I would like to know why the circuit1 doesn't but the circuit2 works?

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Sun May 15, 2022 5:18 pm

A 3.3V-to-10V boost converter will put a huge intermittent load on its power source.

In the circuit where the boost converter takes power from the Feather's 3V output, the boost circuit probably overpowered the voltage regulator on the Feather, producing unstable voltage on both sides of the connection.

The circuit where the boost converter takes power from a LiPo has two major advantages: first, the LiPo can meet the boost converter's instantaneous current needs, and second, the boost converter isn't injecting huge amounts of noise back into the microcontroller.

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Mon May 16, 2022 5:18 am

Thanks you for your answer.
If i understand correctly your answer circuit1 don't work because the ESP32 cannot handle the needs of my boost converter and for that reason there is a noise input from the boost converter to the ESP32 but in circuit2 this problem is solved because the battery can handle the needs of my boost converter so there is no or less noise input into my ESP32.
So, I would like to know if there is a way to make my project work with only one battery?
Because my goal is to pack everything in a box and having two batteries makes it difficult to monitor and charge them.

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Mon May 16, 2022 9:50 pm

Power the boost converter directly from the battery, and add a 100uF capacitor between the feather's 3V and GND pins.

The LiPo will be able to power the boost converter without causing too much voltage noise, and the Feather's voltage regulator will keep most of the remaining noise from reaaching the ESP32. The capacitor will provide even more voltage stability for the ESP32.

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Tue May 17, 2022 4:33 am

Thanks for your answer.
If i understand correctly i should be doing this:
Circuit3.jpg
Circuit3.jpg (627.1 KiB) Viewed 174 times

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Tue May 17, 2022 10:16 am

I tried circuit3 but i still get don't get the correct signal even on my voltmeter.
I would like to know what should i do in order for the circuit to work ?

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Tue May 17, 2022 4:11 pm

Post a photo showing your actual hardware and we'll take a look. 800x600 images usually work best.

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Wed May 18, 2022 4:54 am

Here is the photo you asked for :
real_circuit3.jpg
real_circuit3.jpg (253.19 KiB) Viewed 157 times

The SD module is different because i didn't have the one in the fritzing circuit near me at the time.

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Sun May 22, 2022 12:30 pm

adafruit_support_mike wrote:Post a photo showing your actual hardware and we'll take a look. 800x600 images usually work best.

Hello Sir,
I would like to know if you had question about the picture i posted so i can answer them.

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Sun May 22, 2022 6:45 pm

Sorry for the delay.

I can't see much detail in the the photo, and the voltage being measured by the ADC seems to come in through a cable whose other end is out of the frame.

Where are you measuring the signal the ADC should read, and what value do you get from the ADC?

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Mon May 23, 2022 4:17 am

Hello Sir,
I am measuring the signal on the green and white cable on the photo.
real_circuit3_wire.jpg
real_circuit3_wire.jpg (171.63 KiB) Viewed 129 times

On the photo i am using the ADS1115 to measure the signal. On this ADS1115 I soldered a terminal block which i am using to put my voltmeter on it to see and compare the value with the one the ADS1115 get.

The sensor i am using has a rated ouput of 2mv/V (20mV).
So i did two test with a weight of 11.8kg :
- two battery (one power the ESP32,the ADS1115, the sd module and the other one power the sensor)
- one battery power all the system

Here is a datalog from the ADS1115 get when i use 2 battery :
Data_11,8kg_good_data.CSV
(10.14 KiB) Downloaded 1 time

The correct value for this test is 0.473 mV there is a 0.20mv difference on the ADS1115 and the voltmeter but i can correct this by doing a calibration.

Here is a datalog from the ADS1115 when i use 1 battery :
Data_11,8kg_bad_data2.CSV
(7.51 KiB) Downloaded 1 time

The value are higher than the previous value for this weigth but i only get these values when the ADS1115 is wired.
When i do the the same test with only my voltmeter that mean when the ADS1115 is not powered i get the same value as the first test on my voltmeter.

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Wed May 25, 2022 3:19 am

Hello Sir,
The boost converter i have chosen is causing too much difficulties for this project so i am not going to use it. I would like know if you have any idea or reference of components that would help me to boost the 3V from the ESP32 to 10V without the instability.

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Wed May 25, 2022 4:10 pm

We don't have any 10V devices, and you'll probably have a hard time finding a 3.3V-to-10V converter that doesn't generate a lot of noise. The physics of boost converters demands a heavy, choppy current load.

You might find it easier to work the other direction: use a 3S 11.1V LiPo and reduce the voltage to 10V and 3.3V. It's easier to find efficient step-down converters with smooth output than to find step-up converters with quiet input.

https://www.adafruit.com/product/4711

The math works more in your favor too: a 3.3V-to-10V step-up converter has to draw at least 300mA from the battery for every 100mA of output it produces, where a 10V-to-3.3V step-down converter draws at least 100mA from the battery for every 300mA of output.

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by Oribe on Thu Jun 02, 2022 8:49 am

Hello sir,
Thanks you for your answer.
In the case of powering the ESP32 with a 3S 11.1V LiPo i found a couple of devices that could work.

https://www.adafruit.com/product/4683

https://www.amazon.fr/ARCELI-AMS1117-3- ... C89&sr=8-5

https://www.amazon.fr/DollaTek-MP1584EN ... C80&sr=8-6

But my sensor require a stable voltage of 10V to work correctly and i didn't find any step-down converters that could achieve that voltage for this configuration.
All the step-down converters i found need at least 2V to work properly and a 3S LiPo battery will go down to 11.1V which is less than that.

https://www.amazon.com/MP1584EN-DC-DC-C ... B01MQGMOKI

Do you have any idea how i can achieve a stable voltage of 10V with a 3S LiPo battery?

Oribe
 
Posts: 14
Joined: Thu May 12, 2022 7:53 am

Re: Data read issue with ADS1115 and ESP32 from bridge sens

by adafruit_support_mike on Thu Jun 02, 2022 4:56 pm

The ‘2V of headroom’ value is reasonable for older linear voltage regulators. Newer designs, called ‘low dropout’ linear regulators can run with as little as 200mV of headroom at low current levels.

Buck converters (step-down switching regulators) usually dont have any headroom requirement. They just get more efficient as the input voltage approaches the output voltage.

Here’s a page from Digikey of 10V linear regulators with dropout voltages of 1V or less:

https://www.digikey.com/en/products/fil ... fC5MXDQBoA

adafruit_support_mike
 
Posts: 64793
Joined: Thu Feb 11, 2010 2:51 pm

Please be positive and constructive with your questions and comments.