Page 1 of 1

Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 22 Aug 2016, 01:53
by hilo90mhz
I am wondering if anyone has already written a library to use this analog MUX chip? Or would be willing to write one since it seems like such a cheap way to get 16x analog inputs :) I may get to writing my own eventually but don't have the time currently..

As far as I can tell you would just need 4x digital inputs

The bare chip is $.86 at digikey: http://www.digikey.com/product-detail/e ... -ND/376978

Or about $1 for complete module from Aliexpress:
http://www.aliexpress.com/item/Free-shi ... 60062.html
Smart-Electronics-CD74HC4067.jpg
Smart-Electronics-CD74HC4067.jpg (115.1 KiB) Viewed 7692 times

Re: Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 10 Nov 2016, 08:01
by groovy
Did you get any further with this? It's exactly what I'm looking for to read multiple moisture sensors.

Re: Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 10 Nov 2016, 15:00
by Martinus
groovy wrote:Did you get any further with this? It's exactly what I'm looking for to read multiple moisture sensors.
How many sensors do you want to connect? Have you considered PCF8591 or ADS1115? They are convenient I2C solutions.

Re: Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 10 Nov 2016, 17:44
by groovy
Thanks, Martinus. I will have a look at these. I'm about to connect 5 to 10 moisture sensors for my plants at the balcony. Will this work? I read, that there is a possibility to add more than one (using different I2C addresses).

Re: Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 11 Nov 2016, 08:01
by hilo90mhz
No I never developed a library for it if that what you're asking, the hardware should work... Honestly I am now waiting till the ESP32 is supported - it has 16 channels of 12BIT ADC converter.. not to mention these other specs:

There are 36 GPIO pins, which can be assigned to all sorts of peripheral duties, including:

Analog-to-Digital Converter (ADC) – Up to 16 channels of 12-bit SAR ADC’s. The ADC range can be set, in firmware, to either 0-1V, 0-1.4V, 0-2V, or 0-4V – no more weird 0-1V ADC!
Digital-to-Analog Converter (DAC) – Two 8-bit DAC’s to produce true analog voltages
Pulse-Width Modulation (PWM) – Up to 16 channels of PWM-capable pins for dimming LEDs or controlling motors
Touch Sensor – 10 GPIOs feature capacitive sensing; make a 10-key buttonpad!
UART - Two UART interfaces, one is used to load code serially. They feature flow control, and support IrDA too!
I2C, SPI, I2S – There are two I2C and four SPI interfaces to hook up all sorts of sensors and peripherals, plus two I2S interfaces if you want to add sound to your project.

IF you need support for more analog inputs right now the https://github.com/ESP8266nu/ESPEasySlaves MiniProExtender code gives you an easy way to get 6 additional analog inputs without having to edit the ESPeasy core code at all, you just use the miniproextender plugin to access the arduino mini pro analog IO through I2C. I adapted this and had the arduino mini pro doing some computations on the analog data and spitting out formatted values to the ESPEasy core and it didnt know the difference.

Re: Analog Multiplexer CD74HC4067 = 16 analog input for $1

Posted: 10 Apr 2018, 00:30
by redskinhu
Hello

I would like read the mux legs every minutes, digital values are present. I created rule for read the the mux legs, but it is not working properly.

Code: Select all

On Clock#Time do
	gpio,13,0
	gpio,32,0
	gpio,33,0
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C00,[SIG#Output]
	gpio,32,1
	gpio,33,0
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C01,[SIG#Output]
	gpio,32,0
	gpio,33,1
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C02,[SIG#Output]
	gpio,32,1
	gpio,33,1
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C03,[SIG#Output]
	gpio,32,0
	gpio,33,0
	gpio,34,1
	gpio,35,0
	publish home/%sysname%/C04,[SIG#Output]
	gpio,32,1
	gpio,33,0
	gpio,34,1
	gpio,35,0
	publish home/%sysname%/C05,[SIG#Output]
	gpio,32,0
	gpio,33,1
	gpio,34,1
	gpio,35,0
	publish home/%sysname%/C06,[SIG#Output]
	gpio,32,1
	gpio,33,1
	gpio,34,1
	gpio,35,0
	publish home/%sysname%/C07,[SIG#Output]
	gpio,32,0`
	gpio,33,0
	gpio,34,0
	gpio,35,1
	publish home/%sysname%/C08,[SIG#Output]
	gpio,32,1
	gpio,33,0
	gpio,34,0
	gpio,35,1
	publish home/%sysname%/C09,[SIG#Output]
	gpio,32,0
	gpio,33,1
	gpio,34,0
	gpio,35,1
	publish home/%sysname%/C10,[SIG#Output]
	gpio,32,1
	gpio,33,1
	gpio,34,0
	gpio,35,1
	publish home/%sysname%/C11,[SIG#Output]
	gpio,32,0
	gpio,33,0
	gpio,34,1
	gpio,35,1
	publish home/%sysname%/C12,[SIG#Output]
	gpio,32,1
	gpio,33,0
	gpio,34,1
	gpio,35,1
	publish home/%sysname%/C13,[SIG#Output]
	gpio,32,0
	gpio,33,1
	gpio,34,1
	gpio,35,1
	publish home/%sysname%/C14,[SIG#Output]
	gpio,32,1
	gpio,33,1
	gpio,34,1
	gpio,35,1
	publish home/%sysname%/C15,[SIG#Output]
	gpio,13,1
Endon
The [SIG#Output] is a switch device. GPIO13 is enable/disable the mux (it not necessary i think). GPIO32-35 address pin of the mux.

This rule is muxing the pins and succesfully pulish to the MQTT server but the values are not changing. It publises the switch device last value. I tested the switch output, it is get the muxed leg value but doesn't change the switch state. I thought maybe the reading too fast and the switch can't follow the muxed value (or my theory is faulty which is higly possible :) ).

And I tested with this rule:

Code: Select all

On Clock#Time do
	gpio,32,0
	gpio,33,0
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C00,[SIG#Output]
	timerSet,1,3
Endon

On Rules#Timer=1 do
	gpio,32,1
	gpio,33,0
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C01,[SIG#Output]
	timerSet,2,3
Endon

On Rules#Timer=2 do
	gpio,32,0
	gpio,33,1
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C02,[SIG#Output]
	timerSet,3,3
Endon

On Rules#Timer=3 do
	gpio,32,1
	gpio,33,1
	gpio,34,0
	gpio,35,0
	publish home/%sysname%/C03,[SIG#Output]
Endon
And this rule is behaving like the original. It looks my theory is false.... I think i need to find the another way to get the muxed output value.

I tried to use an analog pin too (ex: ADC#Value) but it sends the last ADC value like a switch device.

Any idea?

Maybe somebody can hack the _P180_Mux.ino on the plugin playground? I tied but that is too high for me or the documentation is weak....

I don't want to use any other I2C mux. The challenge is to use this. (I bought 3 pcs) :-)

Thanks for advance.