Page 1 of 1

MCP23017 question

Posted: 02 Mar 2019, 19:50
by Sasch600xt
Hello all :)

may i have a probably dumb question but i cant find the answere.

i need to send out 4 analog values from ESP (0-3.3V / 0-255)

I have a MCP23017 connected to ESP.
Can i do it with a MCP ?
And if yes, how would the syntax look like ?
If NO, is there a way to get 4 analog output pins working with ESP (like a "analog output port expander") ?

See ? Dumb question :)

Thanks for help :)
Sascha

Re: MCP23017 question

Posted: 02 Mar 2019, 19:59
by budman1758
Methinks the best way is to use an ADS1115 A-D Converter chip. MCP23017 is only for on,off or pulse stuff.

No such thing as a dumb question. Nobody falls out of their mama knowing everything. :mrgreen:

Re: MCP23017 question

Posted: 02 Mar 2019, 20:30
by HomeJCL
ADS is an AD.

In this case the question is for an DA output stage.

I am also interested if anybody has the answer.

Re: MCP23017 question

Posted: 02 Mar 2019, 20:58
by budman1758
What is the source of these values? How does the ESP get the values in the first place?

Re: MCP23017 question

Posted: 02 Mar 2019, 21:37
by Sasch600xt
i want to send MQTT Messages to the ESP.

like:

http://192.168.123.45/control?cmd=ANALOG_OUT,1,255
http://192.168.123.45/control?cmd=ANALOG_OUT,2,127
http://192.168.123.45/control?cmd=ANALOG_OUT,3,0
http://192.168.123.45/control?cmd=ANALOG_OUT,4,200

this sends the value to a 4ch dimmer (0-3.3volt expected)

So lets google for a ADS1115 A-D Converter chip :)
Is there a plugin already for ESP Easy ?

Thank you all for your Help :)
Sascha

Re: MCP23017 question

Posted: 02 Mar 2019, 21:51
by budman1758
Not sure you need the ADS1115 here as I am still a bit confused as to what the ESP is actually doing here. You say you want to send these analog values TO the ESP. I assume they then go out to a dimmer of some sort?

Maybe a picture or a diagram or schematic would be helpful.

Re: MCP23017 question

Posted: 02 Mar 2019, 22:06
by Sasch600xt
http command ---> ESP Easy -----> 4 times analog 0-3.3Volt out ------> 4 CH Dimmer

I see the ADS1115 is for analog INPUT, but i need to have analog OUTPUT.

Re: MCP23017 question

Posted: 02 Mar 2019, 22:28
by budman1758
I think what you need to do is convert PWM output to a voltage.
See this for inspiration.
https://www.instructables.com/id/Analog ... o-Voltage/

Re: MCP23017 question

Posted: 02 Mar 2019, 22:50
by Sasch600xt
Perfect !!!

Re: MCP23017 question

Posted: 02 Mar 2019, 23:05
by Sasch600xt
Now another question :)

i dont understand in doku:
MCPPulse,<pin>,<value>,<duration> 1,0 Pulse control on MCP23017 output pins (duration in mS, MILLIseconds)

so how would a http command look like for MCP port 1 with a pwm of 127 ( i assume value can be from 0-255) ?

Thank you so much
Sascha

Re: MCP23017 question

Posted: 03 Mar 2019, 00:57
by budman1758
I'm not sure the MCP23017 supports PWM. That's a question for the devs. Some of the native ESP GPIO support PWM. Might be easier to use those.

Or a dedicated PWM output chip module.

Re: MCP23017 question

Posted: 03 Mar 2019, 09:12
by Sasch600xt
i have a PCA9685 here and i will try one of those :)

Re: MCP23017 question

Posted: 03 Mar 2019, 10:47
by Sasch600xt
i do not get a signal out of the PCA9685 ?

It shows up after "scan for i2C device".

So i try:
http://192.168.123.45/control?cmd=PCAPWM,1,4095

and get:
{
"log": ": PWM 1",
"plugin": 22,
"pin": 1,
"mode": "PWM",
"state": -1
}

any ideas ?
Thank you for your help

Re: MCP23017 question

Posted: 03 Mar 2019, 22:00
by kimot
You can use this motor PWM like DA converter for convert digi to analog via i2c:
https://www.letscontrolit.com/wiki/inde ... 2#Hardware

So by TB 6612

Re: MCP23017 question

Posted: 04 Mar 2019, 19:50
by Sasch600xt
yes, but i have already a PCA9685 and there is a plugin for in ESP Easy.
plus budman showed a very good and very small solution to get a analog signal out of a pwm signal.

the only question right now is why does the PCA9685 not work ?
i must do something wrong here.

Thanks for help
Sascha