2

We are doing a project and have to use around 25 temperature sensors. Is there a way to shift through them on one Arduino similar to using a shift-register?

It is a set of analog sensors in a fridge.

  • 1
    Think about using a pair of 16-channel multiplexers. Sparkfun have a board that might be suitable. – sempaiscuba Sep 27 '17 at 12:50
  • 4
    What kind of sensors? analog, digital, ...? How far are the sensors? 1mm from each other, 10cm, 2km, ...? – frarugi87 Sep 27 '17 at 13:07
  • 1
    @sempaiscuba, why not flesh out that comment and add it as an answer. – sa_leinad Sep 27 '17 at 15:17
  • sorry for not being specific enough. it is a set of analog sensors in a fridge. – Orome Sep 28 '17 at 8:59
  • 1
    @sempaiscuba thanks for the answer. we will probably go with that. – Orome Sep 28 '17 at 9:00
4

As I mentioned in the comments, one way to do this is to use a multiplexer.

You haven't said which temperature sensors you are planning to use, so I'll illustrate this example using the TMP36 Analogue temperature sensor.

Now, if you were using just one of these, the connection would be trivial:

Single TMP36 sensor

But you want more sensors than available pins. That's where the multiplexer comes in.

I'm going to illustrate this using 16 sensors and the Sparkfun 16-channel multiplexer breakout board which is based on the 74HC4067 multiplexer. For 25 sensors, you could use a 32-channel multiplexer (like the Analogue Devices ADG732, for example), or just combine two 16-channel multiplexers (which is probably cheaper, but requires a little more care in the wiring).

[If your soldering skills are OK, I wouldn't even bother with the Sparkfun breakout board myself. It's pretty simple to connect something like this on protoboard, or make your own PCB.]

The 16 sensors are connected to pins Y0 - Y15 on the 74HC4067 (pins C0 - C15 on the Sparkfun board). Take care to note which sensor is connected to which pin!

With 16 inputs, we need 4 bits to address them. The address pins are labelled S0 - S3. The Sparkfun datasheet for their breakout board includes a Truth Table mapping the addresses to the inputs:

Truth table

The input from the selected device becomes the output from the multiplexer (pin Z on the 74HC4067; the SIG pin on the Sparkfun breakout board).

The diagram below shows one way of connecting 16 TMP36 analogue temperature sensors to an Arduino Nano using the Sparkfun breakout board:

Nano multiplexer

Note the mapping chosen for the address pins:

  • D5 -> S0
  • D4 -> S1
  • D3 -> S2
  • D2 -> S3

This makes the drawing layout simpler, but may not be the most intuitive mapping when you come to write your code. My advice is to assign meaningful labels to the pin-mappings in your code, and document that decision with comments! (I'm sure that I'm probably preaching to the choir here, but this may help someone reading this in the future to avoid some of the pitfalls.)

Now, you cycle through a loop:

while true {
    increment the address to be written to pins D5-D2 (note the order)
    read the input on A0
    <do whatever you need to do with the temperature reading>
}

And Robert is the male relative of your choice.

4

Have you looked at OneWire temperature sensors? You connect them to a bus IC and the bus IC to your Mcu. This allows you to multiplex many sensors.

You can also forego the master bus IC and just bit bang using a GPIO pin. The Arduino OneWire library uses this approach.

You can learn a lot about from this one wire sensors tutorial.

2

Another way to do this is with a series of actual shift registers (74HC595 or similar, daisy-chained.)

The shift register outputs drive a transistor. Each transistor has its collector connected to the temperature sensor, and the emitters are all collected into a single Arduino input. Depending on the number you shift into the shift register, you can pick any of the temperature sensors you want to query.

Simplified schematic

The LED in this simplified schematic actually represents the Arduino input pin. Shift a 2 into the register to query T1; 4 to query T2; 8 to query T3, and so on.

2

If you are using analog sensors, consider using the CD4051B analog multiplexer (link to data sheet). It's great for expanding analog I/O pins.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.