Reading multiple strain gauges with CD74HC4067 multiplexer

Hi everyone!

I have a project where my goal is to read as many strain gauges as I can (more the better) for sectional force data on a beam. My current setup involves a singular strain gauge (for easy testing, more to be added once singular is working) whose leads are fed into two separate CD74HC4067 multiplexers. This is done as I need both leads of each strain gauge to be fed into further circuitry simultaneously and I was unable to find any 16 to 2 multiplexer (current one is 16 to 1). The output of these multiplexers is meant to feed into a singular Wheatstone bridge and then into an HX711 which interfaces with the Arduino for data collection. My schematic below shows my complete setup and I have also attached my code below.

I have already made sure that my code works to read a singular strain gauge without the multiplexers, but when added, I cannot get any readings. From what I can tell, the multiplexer chosen cannot output data though its SIG pin unless its connected directly to the Arduino and set as high. This is an issue for me as I require multiple strain gauges to be read all while using a singular Wheatstone bridge and HX711. I thought it would be possible to use the s0-s3 pins to choose which channel is being passed through onto the SIG pin and have it be fed into the Wheatstone bridge sort of like a 16 channel switch. Is this possible to do with my current hardware? Have I made any mistakes within my code? Are there better more 'switch' like breakout boards that can suit my project?

Any help is much appreciated!

Code:

#include "HX711.h"
float scale_reading;

// HX711 Data and CLK pins
const int LOADCELL_DOUT_PIN = 6;
const int LOADCELL_SCK_PIN = 7;

// Pins for the first 16-channel multiplexer
const int muxS0_1 = A1;
const int muxS1_1 = A2;
const int muxS2_1 = A3;
const int muxS3_1 = A4;

// Pins for the second 16-channel multiplexer
const int muxS0_2 = 2;
const int muxS1_2 = 3;
const int muxS2_2 = 4;
const int muxS3_2 = 5;

// Functions to select channel to read off of the mux
int SetMuxChannel_1(byte channel){
  digitalWrite(muxS0_1, bitRead(channel, 0));
  digitalWrite(muxS1_1, bitRead(channel, 0));
  digitalWrite(muxS2_1, bitRead(channel, 0));
  digitalWrite(muxS3_1, bitRead(channel, 0));
}

int SetMuxChannel_2(byte channel){
  digitalWrite(muxS0_2, bitRead(channel, 0));
  digitalWrite(muxS1_2, bitRead(channel, 0));
  digitalWrite(muxS2_2, bitRead(channel, 0));
  digitalWrite(muxS3_2, bitRead(channel, 0));
}

// Creating instance of load cell
HX711 scale;

void setup() {
  
  // Beginning Serial monitor for output
  Serial.begin(9600);

  // Beginning Scale
  scale.begin(LOADCELL_DOUT_PIN, LOADCELL_SCK_PIN);

  // Initializing multiplexer control pins
  pinMode(muxS0_1, OUTPUT);
  pinMode(muxS1_1, OUTPUT);
  pinMode(muxS2_1, OUTPUT);
  pinMode(muxS3_1, OUTPUT);

  pinMode(muxS0_2, OUTPUT);
  pinMode(muxS1_2, OUTPUT);
  pinMode(muxS2_2, OUTPUT);
  pinMode(muxS3_2, OUTPUT);
}

void loop() {

  SetMuxChannel_1(0);
  SetMuxChannel_2(0);

  scale_reading = scale.read();
  Serial.print("HX711 reading:");
  Serial.println(scale_reading);
  
}```

What does happen?

Maybe you need to connect the EN pins of the multiplexers.

Connecting strain gauges through multiplexers has been discussed several times before on this forum, so try using the forum search.

Why are you not using the same Arduino pins to control both multiplexers in parallel?

I remember other posters having problems with the inconsistent 'on' resistance of the 4067 switches, which is I think about 50ohm.

VCC of that (hopefully) Sparkfun HX711 board needs a 5volt supply.
VDD is correctly connected to 3.3volt.

I would suggest many HX711 boards, one for each strain gauge, and the HX711-multi library. But unsure what you mean with "further circuitry".
Leo..

No it is not.

The HC4067 does not have a zero resistance.
Each MUX can add up to 160 ohms (320 ohms total) to the bridge circuit and probably throw it way out of balance making measurements impossible.

1 Like

Would it be possible for me to measure the resistance and try new resistors within the Wheatstone bridge based on that? Also the other issue I’m worried about is if the SIG pin needs connections with the arduino or if I can connect directly to a Wheatstone bridge.

Sure but the resistance is not stable, will vary with the applied voltage and will vary a little from channel to channel. The resistance you measure with an ohmmeter may not be the same as the resistance when used in you circuit.

Depending on the resistances of your bridge the small variations may not make a difference.

It wold be easier to make the resistor opposite the strain gauge variable and adjust the bridge output until it reads zero (nulls) rather than try to read the 4067 resistance

Also the other issue I’m worried about is if the SIG pin needs connections with the arduino or if I can connect directly to a Wheatstone bridge..

It would be connected as you show in your schematic

I’m unsure what you mean by make it opposite.

And lastly are there any other breakout boards that would suit this situation?

Not that I am aware of but I have not searched for one

The E- on the Hx711 module is the same as ground, so you don't need the second 4067, you can connect one of the strain gauge wires for all the gauges to ground.

You could use the MUX at the outputs of the Wheatstone bridges (one half-bridge for each strain gauge). That's how the HX711 does it for it's two channels.

So one fixed half-bridge with top to E+ and bottom to E- with tap to A-
And "sig" of the mux to A+
Then 16 voltage/sensor dividers, powered by E+ and E-, with tap to the 16 mux inputs.
You only need one fixed half-bridge and one mux for 16 strain gauges.
Try to draw that. so we can check.

There are chips like the HX711 for multiple Wheatstone bridges. The ADS1234 does four.
Leo..

1 Like

Simple way of switching the mux.
Leo..

const byte controlPin[] {A1, A2, A3, A4}; // control pins s0-s3

void setup() {
  for (byte i = 0; i < 4; i++) pinMode(controlPin[i], OUTPUT);
}

void loop() {
  for (byte i = 0; i < 16; i++) { // 16 channels
    for (byte s = 0; s < 4; s++) digitalWrite (controlPin[s], bitRead(i, s)); // 4 control pins
    // read HX711 here
    // scale_reading[i] = scale.read();
  }
}

The 4067 /E enable pin is active low, so you should connect it to ground.

a7

Unfortunately I don't quite understand the setup you're suggesting, could you possibly expand on it or attach a very rough sketch of it?

I feel as if with what you're suggesting I still may run into the same issue where the SIG pin would need to be connected to the Arduino and cannot be used to pass through a signal to the Wheatstone bridge.

Why do you need to pass the sig pin also to the Arduino (asked in post#3).

One thing I havn't thought about is the load on E+, which basically depends on the resistance value of the (unspecified) sensor and the number of sensors.
Leo..

No. The SIG pin is one side of the multiplexer and the C0..C15 are the other side.

You can think of these as independent of the other signals and the power supply, more or less.

You need to supply power, have a common ground, enable the multiplexer and supply the address, all by wiring or by logic values supplied by the Arduinomboard.

a7

This won't work for the final setup as size is a big issue. I need to make it as small as possible, hence using multiplexers to ensure a singular wheatstone bridge and hx711 for all strain gauges.

I've checked over everything you've mentioned and I still can't get the strain gauge signal to go through.

I realized that the MKR 1010 is not outputting 5v that are needed for the MUX so I switched to an uno. With this I recreated the original wiring setup as shown in the schematic but this time wired the EN pin of the MUX to ground (also tried 5V). Unfortunately I still do not get an appropriate output (only getting 8, 388, 607).

I've also tried measuring the resistance/voltage and it varies so much that I can't tell if the appropriate channel is coming through the MUX.

The MKR1010 is a 3.3volt-logic board. Therefore you must power the mux from 3.3volt.
S0-S3 won't work properly if you don't.

This is not a problem, because the mux in my diagram is switching 2.15volt signals.
Because the excitation voltage (E+) of the Wheatstone bridge is ~4.3volt.

I see now that you have been trying to switch 5volt with your initial circuit (wrong).
A mux can't switch voltages outside it's common-mode range.

You should of course use a Sparkfun HX711 board, not a common one. Only Sparkfun boards have two supply pins. One for logic (VDD, 3.3volt) and one for excitation voltage (VCC, 5volt).
Don't know the MKR1010, but the 5volt pin (pin14) should have 5volt available when on USB supply.

Can you tell us the resistor value of your sensor, and the values (and types) of the fixed resistors.
Getting the bridge balanced is critical for this to work.
Leo..

See post #6 #8 and #9

TBH I can't tell what you are doing. Post a complete schematic and a working sketch and talk about what works and doesn't. Add this here, change that there is too fraught - you may have made mistakes relating the changes, we would might make mistakes implementing them in our copies of your device.

You should not need to try things that are straight out of the data sheet. /E needs to be logic low, the easiest way to accomplish this is to wire it to ground.

I infer even if you didn't imply from your remarks that someone has suggested using multiple multiplexers. One should switch 16 to 1 like a giant rotary switch and allow a signal to go either way from a can to SIG.

You will need a common ground. You will need to supply power to the multiplexer chip/module. You will need to connect the address lines to Arduino outputs. /E will need to be logic low, ground.

Perhaps you should play with some example code that uses the multiplexer for more pedestrian purposes, just to convince yourself that it is working, some code you know works is in front of you and that you understand how the code and chip/module function together.

Separate are issues around whether this can be made to work. At all. Several ideas beyond the original have been suggested and look like they are worth thinking about and trying.

But not until you have no zero any questions about the mux itself.

a7