Hey everyone, this is my first time posting here. I'm having some trouble reading pressure sensors with my 16 channel multiplexer and Arduino nano. Right now, the S0 to S3 pins, Sig, EN, GND, and VCC on the mux is connected to D2-D5, A0, GND, GND, and 5V on the Nano. And then I have the sensors connected over a 39kOhm voltage divider to the mux channels. I've used this set up before with the sensors connected to the analog Arduino nano pins, trying to add more sensors so wanted to use a multiplexer. Currently I have two sensors connected, with the other 14 going to gnd. However, when I use serial monitor to read the values from the sensors, all of them read 1023 (in reference to the 5V the divider is connected to) and do not change when I press the sensors. I feel like this has to be a hardware or wiring issue? Should I just go ahead and solder 14 others and then see if it makes a difference?
I don't think soldering the rest of the sensors will make any difference.
You need to post a schematic and your code, otherwise you are just preventing us from helping you.
Please read the forum guide in the sticky post first.
Ok. Here is my code and a schematic:
#include <Wire.h> // I2C communication library used by PCA9685
#include <Adafruit_PWMServoDriver.h> // Adafruit library controlling PCA9685 PWM driver
Adafruit_PWMServoDriver pwm = Adafruit_PWMServoDriver(); // I2C address for PCA9685
// PRESSURE SENSOR SETUP
const int muxPins[] = {2, 3, 4, 5}; // S0-S3 digital pins on mux
const int muxSignalPin = A0; // SIG common output pin on mux
// INITIALIZE COMMUNICATION
void setup() {
Serial.begin(9600);
for (int i = 0; i < 4; i++) pinMode(muxPins[i], OUTPUT); // Set mux pins as output
}
// READ PRESSURE: Read sensor, convert to force value
float readPressure(int channel) {
for (int i = 0; i < 4; i++){
digitalWrite(muxPins[i], (channel >> i) & 1); // Convert channel number to binary for pins
}
delayMicroseconds(5);
int fsrValue = analogRead(muxSignalPin); // fsr = Force Sensitive Resistor
float voltage = fsrValue * (5.00 / 1023.00);
float resistance = (39 * voltage) / (5.00 - voltage); // 39kΩ resistor
float force = 70.927 * pow(resistance, -0.758); // Nonspecific calibration
return force;
}
void loop() {
static unsigned long lastPrintTime = 0;
if (millis() - lastPrintTime >= 100) {
printPressureReadings();
lastPrintTime = millis();
}
}
void printPressureReadings() {
for (int j = 0; j < 16; j++) {
float force = readPressure(j);
Serial.print("FSR");
Serial.print(j + 1);
Serial.print(": ");
Serial.println(force);
}
}
Yes, it's a wiring error. That circuit will read 1023.
Your sensor must have 2 terminals. Your wiring diagram (not a schematic, by the way) shows only one.
One of those terminals should go to the multiplexer input. The other should go to ground.
Hmm still doesn't work.
Your wiring is, we have to assume, still wrong.
Yes, this is what I had initially thought was the issue. I'm assuming you aren't sure what the reason is either? Do you have any ideas on how to determine it?
See post #4.
I did see post #4. I mentioned earlier that connecting one terminal to ground and the other to the mux gives the same issue. Just wondering if you had any other ideas.
What pressure sensor? Post link to datasheet or brand name and full exact part number of sensor.
It's the RP-S5-ST Force Sensitive Resistor. It's this one on Amazon: Amazon.com: 2PCS RP-S5-ST Thin Film Pressure Sensor High Sensitivity Force Sensitive Resistor 10G to 1Kg for Measurement Testing and Arduino : Industrial & Scientific
No, you didn't mention that, you said
but didn't say what you had changed, or if the readings changed at all.
We still have only your wiring diagram from post #3 to look at, and that's wrong as you know.
Is the reading still 1023? What does your wiring diagram look like now?
What is the sensor's resistance with 1kg of force applied?



