Doubling amount of soil sensors using transistors?
My sensors projects are going well and I have three nodes running doing various things, connecting to an ESP8266. I hope to write more in depth about these as soon I have moved them from breadboard to some PCB, it also has direct SD card backup, web logging as well as writing to a MQTT server. Works quite good :-). After years of messing with 433mhz modules (and giving up),some other kind of transceivers (forgot), things are looking well!
But I have a question about the soil sensor setup. I use the sensor system as described in various topics: the "fork" of the typical soil moisture sensor using two analog pins which alternate while reading. Works well: I have three sensors (A0, A1), (A2, A3) and (A4,A5) on my Pro mini 3.3v. Battery sensing has moved to A7 because of the pull up resistor restriction (not available on A6,A7).
Now, I am mostly a programmer and electronics are still quite new to me. I was wondering if I could extend the amount of soil sensors easily to 6 by putting 6 transistors (2 per Analog pin pair) all to one Digital pin (Say: D0) in order to double the amount of soil sensors?
D0 - LOW: Read soil sensor 1,2,3 from A0-A5
D0 - HIGH: Read soil sensor 4,5,6 from A0-A5
Would this work? Or am I simplifying things too much from an circuit point of view? :-). And would any "standard" NPN transistor work for this?
Thanks a lot!
Michiel van der Wulp last edited by
I would use a 4067 IC for the analog voltage, and probably a second 4067 to switch the power. Then you will only need one analog line of the Arduino, and a few digital lines.
The 4067 is one of the 4000 series CMOS chips, which work with 3V to 15V power supply. It contains a 1-of-16 multiplexer of analog switches. For a smaller number of analog switches, you could use 4016 or 4066.
Michiel van der Wulp last edited by Michiel van der Wulp
Oh, I just remembered, a 4051 contains a 1-of-8 multiplexer, and is cheap.
Look also at the 4052 which contains two 1-of-4 multiplexers.
Search on ebay for: 4051 DIP
Thanks for that idea! I didn't knew these IC's existed. It looks like a good approach to me. Also good to know for other future Arduino projects.
The only thing I was wondering if the "alternating" DC would still be feasible.
I think the GND of the IC needs to alternate between two analog pins, using the pinMode INPUT_PULLUP similar as how it is now. This of course in order to prevent corrosion from happening due to all the ions flowing to one direction :).
Will still have to read more about this, I expect I am not the first one that tries to do it like this!
@Kokosnoot my experience is that alternating does not help. I have had at least 3 sensors break due to rust even with alternating.
The voltage is only on for a short time (0.5 second) so there will not be much time for electrolysis to occur.
Most corrosion happens in the part of the sensor that is just above the dirt. The dirt keeps it always wet, and the access to the oxygen in the air makes it corrode.
My solution is to protect that part with hot-melt glue. I started doing that about two months ago so it is too early to tell if it works.
Ah, I did have mixed feelings about the alternating. I also don't know what happens with ions when water moves down after watering some plants.
I did came across this page (in Dutch, but code in English) which kind of shows a very simple example of using the CD74H4067 multiplexer: http://12volt.kloppenburgweb.nl/een-garduino/.
It might be a good thing to see how it performs and come up with something alternative if really needed. I was also thinking of adding some glue to the parts exposed to air.