Hi to all friends
i would like to use my Arduino to read from multiple analog sensors in one analog pin.
i decide to use some pc817 optocouplers as switches (not to isolate)
From my code i will set High each pin in sequence to drive each optocoupler then take the reading and store it in array , set the digital pin low and then go to the next digital .
i have tried it with a breadboard and i think i am not getting the right readings... i am not sure if the method with the diodes at the end is the best to isolate the thermistors from each other.
has any one a better solution or part to use in the thermistors output pin ?
Are you intending to scale this up for multiple thermistors ?
For your current circuit, 4 analog pins would be enough to read the values. You could then drop the opto couplers, the 10k and 470R resistors and the IN4148 diodes. You could anyway power the top of each 100k/ thermistor divider network directly from an Arduino pin.
As it is, you have to consider the silicon diode voltage drop ( 2 times 0.7 volts) in each reading.
In my schematic just place the "problem", in my original project i am using the rest of the analog pins. A4,A5 for a i2c comunication and the other analog pins to read different type of analog sensors.
i tried to power the resistors of each thermistor directly from my digital pins but as i am having a long distance between arduino and thermistors (5m) i had a voltage drop and so i decide to use the optocouplers with a close distance 5v supply.
i dont care for very accurate readings .... i can live with +/- 5 degree of Celsius in my readings.
my problem is that as i have seen until know my readings seem to be dependent in each other (i havent time to experiment more...)
You are introducing the voltage drop of the diode and the photo-transistor into the measurement and these are not even constant.
OK, so you are using the other analog pins (notably A4 and A5 which are more important as the I²C interface). What you want is an analog multiplexer, a 74HC4051 for 8 channels or a 74HC4067 for 16 and you use your three or four Arduino outputs to select the input. Much neater.
You can get these on neat breakout boards. Seriously, just forget mucking about with optocouplers - they have more important uses.
Please do not power an Arduino with 9 V via "Vin" or the "barrel jack". It uses 5 V, you need a proper regulated 5 V supply to the "5V" pin (but must disconnect it on a UNO when plugged into the USB on a PC - a Nano is more useful and does not have this problem).
The ADC is ratiometric - you need to be connecting the NTCs to the "5V" pin - actually more practical to connect them to ground and pull-ups to the 5 V. This will also resolve some of your problems.
You need to analogRead twice whenever you switch to a new multiplexer input.
Assuming, of course, that the voltage drop is lower that the original voltage to be measured.
In this case a 1.4v drop in a 5 volt range could mean quite a reduction in the measurable temperature range.