I have a piezoelectric sensor disk. I’m looking to take a output from this by using ESP32 microcontroller. But when I connect the sensor with microcontroller at GPIO 34, it gives only the positive peaks. But I need negative peaks also (i.e., I need to take a waveform as like in a oscilloscope).
Connections made like:
Sensor +ve – GPIO34
Sensor -ve – Ground
Here is my code to convert the digital readings that are readed from analogRead function into analog values.
void setup() {
pinMode(34, INPUT);
Serial.begin(9600);
}
void loop() {
int sensorValue = analogRead(34);
float analogValue = sensorValue * (255.0 / 1023.0); // Convert the sensor value to analog value (8-bit)
Serial.println(analogValue);
delay(10);
}
My ESP32 has 12bit ADC and I’m working with Arduino IDE. Your solutions are most welcome.
GnanaBarathi SP is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.