Pages: [1]   Go Down
Author Topic: Reading more than one sensor in one analog pin  (Read 437 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset



http://imageshack.us/photo/my-images/10/sensoresw.jpg/

Basically I wanted 2 more analag pins so I thought something like this might work. S1 and S2 are simple soil moisture sensors(nails) D1 and D2 are digital outputs from Arduino and A1 is the analog input.

So if  D1(hight) + D2(low)=  I get readings from S2 and D1(low) + D2(high) = readings from S1, right?

* I have almost zero experience with eletronics.

thanks in advance smiley
« Last Edit: December 04, 2012, 09:30:32 am by itiohs » Logged

Brisbane, Australia
Offline Offline
Edison Member
*
Karma: 33
Posts: 1121
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi

To add extra analog inputs to your Arduino you'll be wanting to use an additional chip, something like the 74HC4051 (click for datasheet) which acts like a switch box - you tell it which of the up to 8 sensors attached to it you want to read from, and it connects that physical leg with the leg that you have wired to a single analog pin on your Arduino.  There will be lots of tutorials about on how to use these and they're quite straightforward to set up and use too.
* I have almost zero experience with eletronics.
You've come to the right community to learn, in my experience smiley

There are plenty of examples of how to get started with this chip online.  Start with this one on the Arduino Playground but there are lots if you google search terms like Arduino 4051 tutorial (link to result).

Geoff

Edit: fixed some of that appalling spelling!
« Last Edit: December 04, 2012, 05:49:45 am by strykeroz » Logged

"There is no problem so bad you can't make it worse"
- retired astronaut Chris Hadfield

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33448
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here is another example of expanding the number of analogue inputs, the application is different but the principal is the same:-
http://www.thebox.myzen.co.uk/Hardware/MIDI_Footsteps.html
Logged

Lancashire, UK
Offline Offline
Edison Member
*
Karma: 9
Posts: 1991
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

With a RC circuit its possible to 'emulate' an analog input with a pure digital pin with the 'R' being made by your nail in the soil.. In simple terms you set the pin to output, set it high to charge the capacitor, switch it low and then to input and time how long it takes to discharge to the point where it registers as being a low.  The lower the resistance of what is connected to the pin, the quicker it discharges.  You'd need to use something (multimeter or an analogue pin) to determine an approximation of 'R' the (resistance of your nail through the soil) to determine a suitable value for C.  Plenty of stuff on google to work it out but heres a start : http://www.allaboutcircuits.com/vol_1/chpt_16/4.html.  The digital input will register as low when it reaches approximately 2.5 volts.  This probably appeals more if you're a cheapskate...........  smiley-wink
« Last Edit: December 04, 2012, 06:21:32 am by pluggy » Logged


Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Using an analog switch would be my choice.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

In other words, the circuit I drew wouldn't work? why? the transistors would interfere with the signal coming from the sensors?
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 604
Posts: 33448
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

In other words, the circuit I drew wouldn't work?
That's right spot on.

Quote
why?
Too much wrong to explain but transistors don't work like that. For starters there is no path or any current from the emitter, the analogue input is very high impedance it doesn't allow current to flow. The base needs a resistor in it. You can't get a voltage out of the emitter more than 0.7V lower than the base voltage. Basically it is not the way to do it.
Logged

Queens, New York
Offline Offline
Faraday Member
**
Karma: 86
Posts: 3487
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

If you want multiple sensors going into a single analog pin, you might want to try maybe a 8:1 multiplexer.

Logged

Created Libraries:
NPV2 (NewPasswordV2),  TFT_Extension, OneWireKeypad, SerialServo.
Will provide libraries if asked in PM or forum.

Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok, thank you for the advices  smiley-wink
Logged

Offline Offline
Edison Member
*
Karma: 116
Posts: 2205
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
the circuit I drew wouldn't work?

Simple: once you have applied a voltage to turn on those transistors, all you read on the analog pin is that voltage - Vbe of such transistors.

You can modify it by using a pnp to switch in / out of such devices. However, the design is highly dependent of the particular sensors.
Logged

Pages: [1]   Go Up
Jump to: