Increase microcontroller sensor inputs (digital) + outputs

Hi I have a version of the esp8266 with 1 analog pin, TX and RX pins. I'm looking to attach a temperature sensor (Grove - I2C High Accuracy Temperature Sensor - MCP9808), humidity, and a few others in addition to controlling a logic-level MOSFET for LED control.

What would I use for this? Would a multiplexer like the CD74HC4067 or the MCP23017 - i2c 16 Input/Output Port Expander work?

Basically, I need to both expand serial/digital input and still have at least 1 output control.

Well that is on the I2C bus and you can have up to 127 devices on that using no extra pins.

For suitable devices yes. The 4067 where you have analogue outputs on your sensor and the 23017 on the I2C bus when you want extra digital input / output.


How would I connect to the I2C bus on this device if I have a gpio, tx & rx pin?

You need to disclose your big secret.

Just what "version of the ESP8266" actually is this? You can generally allocate the I²C bus to any two GPIO pins.

1 Like

its a version used in the 4d systems gen4-IOD display. Gpio 16 and rx/tx are the only pins available.

You do not need to delete posts - just edit them!

If you do not need to use TX and RX for serial communications, you can use them as the I²C interface. They only become TX and RX if and when you program them to be that in your code.

1 Like

I don't think the first reply was actually to you so that's why I redid it.

Ok I see thanks, would the CD74HC4067 multiplexer be able to do both sensor data inputs and control the mosfet?

Well, (analog) multiplexers are not appropriate to control outputs as when you switch to a different device, the one from which you switched away is now connected to nothing, so is no longer under control at all.

1 Like

Oh I see, what do you recommend I do?

Stick to i2c devices if you can. The mcp23017 will control your MOSFET for example, but if you don't need 16 digital pins, there is mcp23008 or pcf8574. For humidity, sht21 or similar. If you need more analog inputs, consider ads1115.

1 Like

I only need 3-5 sensor inputs. Will the mcp23008 or pcf8574 be able to do analog/digital input and control the MOSFET? Also, what's the difference between the 2, I can't really find much of comparison online? Thanks

Digital yes, analogue no.
mosfet control only needs a digital output.

Not much of a difference in terms of simple I/O but the former has more options like being able to generate an output when any on of a definable group of inputs change. And other such niceties,

1 Like

Ok great, so I'll stick to digital sensors. Looks like the mcp23008 is the way to go then. Thanks!

Given your level of experience, I would ask, on this fotum topic, about any sensor before you buy, analog or digital.

Pcf8574 is often cheaper and I doubt you will find any use for the mcp23008's few extra features.


Here's one to start with:

1 Like

Sounds good, the mcp23008 is harder to find/more expensive as well. Thanks.

Thanks for the help, I've been using Arduino for years but never ventured into this realm until now.

No it is cheaper

As opposed to

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.