ESP32, ads1115, linear transducers, pressure transducer

boards: esp32 devkit V1, ads1115, pte7300, 4 5v linear transducer
I am trying to get my esp32 devkit V1 to communicate with a linear transducer and a pressure transducer.
Any help would be greatly appreciated
The wiring is easy. I plan to use a 12v to 5v buck converter.
5 v to all sensors, ground to all sensors, signal wire will go to A0,A1,A2,A3 for the linear position transducers, "ADS1115" SCL to GPIO22, SDA to GPIO21;
PTE7300 SDA to GPIO 21, SCL to GPIO22.

For each of those sensors and ESP32, getting started guides, code libraries and simple example programs are posted on the web. Find them using a web search, study them and make sure you have the required parts, and work through one at a time. When each sensor is working to your satisfaction, move on to the next.

Don't start putting the project together until all the pieces are well understood.

Finally, avoid mixing 5V logic and the 3.3V logic dictated by the ESP32, as bidirectional logic level shifters are required, and a real pain to assemble. Stick to 3.3V parts and you can avoid that problem.

You MUST NOT feed the output of a 4.5V linear transducer into a 3.3V ADC input.

Thank you for your input. From my understanding the adafruit ads1115 has a level shifter installed. This should tave the 5v and lower the voltage correct?

Adafruit has great getting started tutorials, called learning guides, for all of their advanced products. That would be a good place to begin with the ADS1115.

The ADS1115 works on --
image.
Figure-1:

You may connect 3.3V pin of ESP32 with VDD pin of ADS1115 breakout board (Fig-2). The logic level of SDA/SCL will be 3.3V which are compatible with ESP32. And the range of A0-A1 will be within 0.0V to 3.3V. There is no need of level shifter between ADS1115 and ESP32.


Figure-2:

When using any I2C devices it is good practice to use the I2C scanner example (sketch) to see what I2C devices the ESP32 is successfully connecting to. The Scanner will identify any I2C device (properly connected) by reporting the I2C address.

This is a good idea to spot the connection fault at the very earliest. I use the following scanner program:

#include<Wire.h>
byte busStatus;

void setup()
{
  Serial.begin(9600);
  Wire.begin();
  for (int i2cAddress = 0x00; i2cAddress < 0x80; i2cAddress++)
  {
    Wire.beginTransmission(i2cAddress);
    busStatus = Wire.endTransmission();
    if (busStatus == 0x00)
    {
      Serial.print("I2C Device found at address: 0x");
      Serial.println(i2cAddress, HEX);
    }
    else
    {
      Serial.print("I2C Device not found at address: 0x");
      Serial.println(i2cAddress, HEX);
    }
  }
}

void loop()
{

}

So i just watched a 90 minute video. Arduino Masterclass.
Amazing. I didnt realize in the library function, their is example sketches.

How can i get my 5v sensors to read on my esp32 then. If i only have 3.3 v.
Got it figured out.
Ill use the 5volts to power the 4 sensors, a0,a1,a2,a3 for the signal wires, scl,sda to gpio 21 & 22.

These days, almost all sensors run on 3.3V, ADS1115 and PTE7300 included. Please post a link to the linear transducer data sheet or product page.

Caution: Do not power the sensor with 5 V, as this may cause 5 V logic levels on the I/O pins. If these pins are connected to an ESP32, the over-voltage can permanently damage the ESP32, which is 3.3 V tolerant only.

I got chat gpt to write me some code.
The pressure trans info is . attached pdf at bottom
(int16, at address 0x30)
min./max. of span mapped to
±16000 bit value

I keep getting -16000 then it will randomly go to a higher number. photo attached

#include <Wire.h>
#include "PTE7300_I2C.h"

PTE7300_I2C mySensor;

void setup() {
  Serial.begin(115200);
  delay(1000);

  // Start I2C
  Wire.begin(21, 22);       // SDA, SCL for ESP32 DevKit
  Wire.setClock(10000);     // Slow clock for stability
  Wire.setTimeOut(50);

  Serial.println("Starting PTE7300 test...");

  // Disable CRC for testing
  mySensor.CRC(false);

  // Check if sensor responds
  if (mySensor.isConnected()) {
    Serial.println("Sensor connected.");
  } else {
    Serial.println("Sensor NOT detected!");
  }

  // Reset and start measurement mode
  mySensor.reset();
  delay(50);
  mySensor.start();
  delay(20);
}

void loop() {

  // Trigger single measurement
  mySensor.start();
  delay(10);

  // Read raw pressure counts
  int16_t raw = mySensor.readDSP_S();

  Serial.print("RAW COUNTS: ");
  Serial.println(raw);

  delay(1000);
}

sensata-pte7300-pressure-sensor-installation-and-communication-guideline.pdf (776.1 KB)

Print the value returned in HEX and see if the value is signed! Your negative values are actually going less each time until they turn positive. Your library may be giving a negative value when nothing is read from the sensor. See the library documentation.

I had to change from the esp32. Turns out the pressure stransducer wasnt getting good readings from the 3.3v.
I had to use 5v so i ended up using the uno r3.
I eventually want to make an app that uses bluetooth.
Any recommendations on which board to choose.

You can use the ESP32 with an I2C level shifter.

Thanks I purchased this one.
ADS1115
It only has 4 slots.
I have 5 components

I2C is a bus, you can connect any number of devices on the bus provided they have different addresses. I believe you can change the ADS1115 to four different values.

This is your sensor which has a I2C output. Why are you even using an ADS1115? Read the data sheet. The data sheet includes a typical application basic schematic. I see no reason to try and include an ADS1115 anywhere.

The data sheet even includes Arduino code and an Arduino C++ library.

Did you even read your sensor’s data sheet?

Ron

Thanks ron, yes ive read it and also implemented the code. I obviously dont have enough experience with an arduino.
This is literally my first project.
I was thinking i needed the ads1115 bc i already had 4 other sensors.
But im not using the esp32 anymore. The 3.3v that was supposed to work for the pte7300 kept returning erroneous reading.
Since ive swapped to the uno r3 5v the readings have been perfect.

Thanks paul, the 3.3 volts gave me erroneous readings. I had to swap to 5v although the sensor is supposed to be able to run on 3.3v