i have a nrf52840 dk
i need to connect the flex sensor to the board and know the resistance value while bending
how to do it?
and what code should i dump
i have a nrf52840 dk
i need to connect the flex sensor to the board and know the resistance value while bending
how to do it?
and what code should i dump
Hi,
I do not have any experience with flex sensors, but I found these lines on SparkFun that enlightened me a bit on what this is and how it can be measured:
"Left flat, these sensors will look like a 30kΩ resistor. As it bends, the resistance between the two terminals will increase to as much as 70kΩ at a 90° angle. By combining the flex sensor with a static resistor to create a voltage divider, you can produce a variable voltage that can be read by a microcontroller's analog-to-digital converter."
You can find a SAADC example in our SDK that can be used to read the analog input from the voltage divider.
Best regards,
Jørgen
Hi,
I do not have any experience with flex sensors, but I found these lines on SparkFun that enlightened me a bit on what this is and how it can be measured:
"Left flat, these sensors will look like a 30kΩ resistor. As it bends, the resistance between the two terminals will increase to as much as 70kΩ at a 90° angle. By combining the flex sensor with a static resistor to create a voltage divider, you can produce a variable voltage that can be read by a microcontroller's analog-to-digital converter."
You can find a SAADC example in our SDK that can be used to read the analog input from the voltage divider.
Best regards,
Jørgen
i had got the adc values from saadc example
but now i want the resistance value of the bending
below is the arduino code for resistance from the flex sensor
can you suggest me how to what to modify in the saadc example to get the resistance value
on the terminal.
const int FLEX_PIN = A0; // Pin connected to voltage divider output // Measure the voltage at 5V and the actual resistance of your // 47k resistor, and enter them below: const float VCC = 4.98; // Measured voltage of Ardunio 5V line const float R_DIV = 47500.0; // Measured resistance of 3.3k resistor // Upload the code, then try to adjust these values to more // accurately calculate bend degree. const float STRAIGHT_RESISTANCE = 37300.0; // resistance when straight const float BEND_RESISTANCE = 90000.0; // resistance at 90 deg void setup() { Serial.begin(9600); pinMode(FLEX_PIN, INPUT); } void loop() { // Read the ADC, and calculate voltage and resistance from it int flexADC = analogRead(FLEX_PIN); float flexV = flexADC * VCC / 1023.0; float flexR = R_DIV * (VCC / flexV - 1.0); Serial.println("Resistance: " + String(flexR) + " ohms"); // Use the calculated resistance to estimate the sensor's // bend angle: float angle = map(flexR, STRAIGHT_RESISTANCE, BEND_RESISTANCE, 0, 90.0); Serial.println("Bend: " + String(angle) + " degrees"); Serial.println(); delay(500); }
Without studying this too much, I think that if you use VDD/4 as the reference for the SAADC, GAIN setting of 1/4, and a 10-bit resolution, you should be able to use these lines pretty much without modification to get the resistance:
float flexV = flexADC * VCC / 1023.0; float flexR = R_DIV * (VCC / flexV - 1.0);