Currently, I am starting a project that involves measuring size variations using a strain gauge and a Wheatstone bridge, where three resistors are known and one is unknown, the latter being the strain gauge. The Arduino provides a 5V voltage to the circuit as a whole. I am using two 1000-ohm resistors and one 220-ohm resistor. My problem lies in how to measure the resistance of the strain gauge using the Arduino. My current code measures the voltage in the middle of the circuit, but I am having trouble finding a way to use this measurement to determine the resistance value and then infer the size variations. Can someone help me? Below is my code.
// Arduino code to compute the tension between the points of a Wheatstone bridge
// Define the pins for reading the voltage from the Wheatstone bridge
const int pinA0 = A0; // Pin for point B
const int pinA1 = A1; // Pin for point D
// Define the pin for powering the Wheatstone bridge
const int powerPin = 8; // Pin 8 is used to provide 5V to the Wheatstone bridge
void setup() {
// Initialize Serial Monitor for communication
Serial.begin(9600);
// Set pin 8 as an output to supply 5V to the Wheatstone bridge
pinMode(powerPin, OUTPUT);
digitalWrite(powerPin, HIGH); // Provide 5V to the Wheatstone bridge
}
void loop() {
// Read the analog values from the Wheatstone bridge points
int valueA0 = analogRead(pinA0); // Reading voltage at point B (A0)
int valueA1 = analogRead(pinA1); // Reading voltage at point D (A1)
// Convert the analog readings to voltage (Arduino's ADC range is from 0 to 1023, corresponding to 0 to 5V)
float voltageA0 = valueA0 * (5.0 / 1023.0);
float voltageA1 = valueA1 * (5.0 / 1023.0);
// Calculate the differential voltage (tension) between points B and D
float voltageDifference = voltageA0 - voltageA1;
// Print the results to the Serial Monitor
Serial.print("Voltage at A0 (Point B): ");
Serial.print(voltageA0, 4); // Display voltage with 4 decimal places
Serial.print(" V\t");
Serial.print("Voltage at A1 (Point D): ");
Serial.print(voltageA1, 4); // Display voltage with 4 decimal places
Serial.print(" V\t");
Serial.print("Differential Voltage (Tension): ");
Serial.print(voltageDifference, 4); // Display the voltage difference with 4 decimal places
Serial.println(" V");
// Wait for 1 second before the next measurement
delay(1000);
}