Analog Multiplexer CD74HC4067 = 16 analog input for $1

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
User avatar
hilo90mhz
Normal user
Posts: 11
Joined: 29 Mar 2016, 21:21
Location: Hilo, Hawaii
Contact:

Analog Multiplexer CD74HC4067 = 16 analog input for $1

#1 Post by hilo90mhz » 22 Aug 2016, 01:53

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 4344 times

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

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

#2 Post by groovy » 10 Nov 2016, 08:01

Did you get any further with this? It's exactly what I'm looking for to read multiple moisture sensors.

Martinus

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

#3 Post by Martinus » 10 Nov 2016, 15:00

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.

groovy
Normal user
Posts: 39
Joined: 14 Oct 2016, 11:32
Location: Chemnitz, Germany

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

#4 Post by groovy » 10 Nov 2016, 17:44

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).

User avatar
hilo90mhz
Normal user
Posts: 11
Joined: 29 Mar 2016, 21:21
Location: Hilo, Hawaii
Contact:

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

#5 Post by hilo90mhz » 11 Nov 2016, 08:01

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.

User avatar
redskinhu
Normal user
Posts: 4
Joined: 09 Apr 2018, 23:37

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

#6 Post by redskinhu » 10 Apr 2018, 00:30

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.

Post Reply

Who is online

Users browsing this forum: No registered users and 15 guests