Connecting a 4.5V sensor to ESP32

Hello

I am trying to connect a 0.5v-4.5v pressure transducer to blynk via esp32
I am aware i am above the 3.3v but i found info that said the board may handle it.

HYDAC | HDA 4748-H with HSI sensor recognition

I had the code working on UNO with serial monitor, now it wont work on esp32
the sensor has only three wires at the moment:
output - GPIO 34
12vdc in
ground

It appears blynk is connecting via BLE
I am getting nothing on the serial monitor, i fear the excess voltage may be too much to read?

#define BLYNK_PRINT Serial

#define BLYNK_USE_DIRECT_CONNECT

#include <BlynkSimpleEsp32_BLE.h>
#include <BLEDevice.h>
#include <BLEServer.h>

BlynkTimer timer; // Create a Timer object called "timer"!

const int VOL_PIN = 34;

char auth[] = "removed";

void setup()
{
  // Debug console
  Serial.begin(9600);

  Serial.println("Waiting for connections...");

  Blynk.setDeviceName("Blynk");

  Blynk.begin(auth);
}

void myTimerEvent()
{
  int value;
  float volt;
  float BAR;
  float PSI;
  float KPA;

  value = analogRead( VOL_PIN );

  volt = value * 4.5 / 4095.0;

  BAR = value * 16 / 4095.0;
  PSI = value * 235.2 / 4095.0;
  KPA = BAR * 100;


  Serial.print( " Value: " );
  Serial.println( value );

  Serial.print( "  Volt: " );
  Serial.println( volt );

  Serial.print( "  BAR: " );
  Serial.println( BAR );

  Serial.print( "  PSI: " );
  Serial.println( PSI );

  Serial.print( "  KPA: " );
  Serial.println( KPA );

  delay( 200 );
}
void loop()
{
  Blynk.run();
  timer.run(); // BlynkTimer is working...
}

If that’s the problem a simple voltage divider with a few resistors should fix the problem. Google voltage divider and test with a multi meter to make sure you get close to the max voltage. Also note that the analog values on a 32 are different than a esp8266.

If you have fried you analog connector you could try a different pin. If I error not the 32 has 3 converters.

You may want to use a different ADC for the following reason. If you read to the end of the post there is a conflict with ADC1 and WIFI.

Thanks for that, i ordered an ADC
I may try this if it doesn’t work

Your esp has 3 ADCs already built in…

1 Like