My project Goal is "Netduino Read 9 or more Analog Sensor".
Here I'm using Netduino+, with RTC on A4 and A5. so I just have 4 left more analog pin, but I used to read 9 analog sensor continuously. So I come with 4017 and 4066 to drive Analog Reading alternately.
here my schema:
Q0 => Humidity Sensor
Q1 => Distinguish-er (not a sensor... just a voltage divider to return 2.2v )
Q2 => Temperature
Q3 => Air Pressure
Q4 => Reset if you don't attaching any more sensors.
Q5 - Q9 (we can add more sensor) but in my case I just need to use 3 sensor in a single analog pin.
whenever we trigger 4017, it will send a 3.3v logic consecutively from Q0 to Q9 (except you reset it on middle).
This is one block of 4017 and 4066 as switcher. we can trigger the 4017 clock by using a single digital pin as output port. here, every 15sec netduino trigger 4017 to switch the analog input.
if (_getDistinguisher){ Distinguisher.Read(); //read analog input while (Distinguisher.value < 2000) //millivolts { Switcher.Switch(); //trigger 4017 to switch the channel (send positive triger 50ms) Distinghuiser.Read(); Thread.Sleep(490); } if (Distinguisher.value > 2000) // if analog input reads 2v { Switcher.Channel = 0; _getDistinguisher = false; } // then reset the chanel}if (_Second % 15 == 0) //do switch every 15 sec.{ if (_timeToSwitch) { Switcher.Switch(); if (Switcher.Channel == 0 || Switcher.Channel == 4) { Switcher.Channel = 0; _getDistinguisher = true; } _timeToSwitch = false; }}else { _timeToSwitch = true; }
and we can read analog input alternately, here I use a simple code: (read 3 Analog sensor in asingle Analog Pin)
switch (Switcher.Channel) //these all Analog Read from Analog_GPIO_A0{ case 0: Distinguisher.Read(); _currentReadValue = "Ch 0: " + Distinguisher.valueToString;//to display on Lcd break; case 1: AirTemprature.Read(); AirTemprature.Collect(AirTemprature.value); _currentReadValue = "Ch 1: " + AirTemprature.valueToString; break; case 2: Humidity.Read(); HumidityContainer.Collect(Humidity.value); _currentReadValue = "Ch 2: " + Humidity.valueToString; break; case 3: AirPress.Read(); AirPressContainer.Collect(AirPress.value); _currentReadValue = "Ch 3: " + AirPress.valueToString; break; default: break; }
Here's my note:
4017 is not always start with channel 0 on the start Up. That's why I do this (keep read and switch until we got the distinguish-er.
while (Distinguisher.value < 2000) { Switcher.Switch(); //trigger 4017 to switch the channel Distinguisher.Read(); Thread.Sleep(490); }
I'm still work with the code... so I cant attach it yet (sorry)... I will attach it soon....
Cheers ^.^V