I am not sure where to start. I have planned to create a door angle measurement system by placing a flex sensor on the door hinge and using an ESP32 microcontroller to collect data. However, I am new to this and I am confused about where to begin and what I need to take into consideration. Could you please provide me with some guidance on how to get started?
Does the flex sensor come with a data sheet (link?) and Arduino sample code?
Hello Yes .
and this is the code i am using i got it from online
// Define the analog input pin for the flex sensor
const int FLEX_PIN = 34;
// Define the calibration values (you will need to measure these)
const float CALIB_0_DEG = 0.0; // voltage reading at 0 degrees
const float CALIB_90_DEG = 3.3; // voltage reading at 90 degrees
// Define the reference angle (you will need to measure this)
const float REF_ANGLE = 0.0; // angle when the door is closed
void setup() {
// Initialize serial communication
Serial.begin(9600);
}
void loop() {
// Read the voltage output from the flex sensor
float voltage = analogRead(FLEX_PIN) * 3.3 / 4095.0;
// Calculate the voltage difference relative to the reference angle
float voltage_diff = voltage - CALIB_0_DEG;
// Convert the voltage difference to an angle measurement
float angle = (voltage_diff * 90.0) / (CALIB_90_DEG - CALIB_0_DEG);
// Subtract the reference angle to get the angle relative to the reference position
angle -= REF_ANGLE;
// Print the angle to the serial monitor
Serial.print("Angle: ");
Serial.print(angle);
Serial.println(" degrees");
// Wait a short time before taking another reading
delay(100);
}
Fine ![]()
Next you have to find a door and mounting place for the sensor field test. Also build or get an amplifier as outlined in the data sheet, for mount directly at the sensor. Then you are ready to run the test program.
warning DO NOT CREATE TOPICS IN THIS CATEGORY warning
Please move your topic!