Go Down

Topic: Expand digital port to sensor ? (Read 130 times) previous topic - next topic

andresilva

Jan 11, 2018, 02:51 am Last Edit: Jan 11, 2018, 02:56 am by andresilva
I do not know if this is the correct place for the doubt, but I need to expand the digital ports of my Uno to connect sensors, I read something about the 74HC595 but I did not understand how I can 'create' a port on it and setar, for example, a DHT22 ... I saw only examples to blink leds but not to set a door on a sensor.
How can I expand digital ports and set them in sensor configuration?

Delta_G

You can't read your sensor with a shift register.  A shift register doesn't create more pins just like the ones on the board.  Look up what a shift register does.  The 74HC595 just has 8 outputs and that's ALL they can ever be is outputs.  There is another kind of shift register that can be treated as 8 inputs but that's all you can do with them is read whether they're high or low.  Your sensor uses the 1-wire protocol.  To get that you'll have to use one of the pins on the board. 

You could use a multiplexer to connect more than one thing and be able to choose which one the pin is connected to. 
If at first you don't succeed, up - home - sudo - enter.

Koepel

The DHT22 requires specific timing, and the libraries are written for a normal Arduino pin. Rewriting it for a pin after a shift register will be almost impossible and totally impractical. It would require two shift registers (input and output), clock and data signals, and an ugly bunch of extra code.

Why do you want to use the DHT22 sensor ? It is not accurate. The BME280 is accurate and uses I2C. You can connect a number of sensors to the I2C bus. A number of DS18B20 temperature sensors can be connected to a single digital pin.

When an Arduino Uno has not enough pins, the common way is to upgrade to a Arduino Mega 2560.

There are many ways to combine buttons and leds. Perhaps you can try to free some pins. For example with a I2C LCD display instead of a normal LCD display.

robtillaart

The DHT22 timing uses pulses shorter than 40 uSec so reading it with shift registers is indeed tricky. Maybe using hardware SPI would make it doable, it would be an academic exercise with quite some learning curve (but that can be fun too)

If you want to use a DHT22 (because they are cheap) you could consider a dedicated  328 or tiny85 that works as a (I2C) slave for a master arduino.

Or go to a MEGA which has far more pins.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

andresilva

Thank you all for the help!
I'll analyze the options for using I2C, but I found the tiny85 option interesting and I probably use it to expand the sensors.

Go Up