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:
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
#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: 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?