Your new topic does not fit any of the above??? Check first. Then post here. Thanks.

Moderator: igrr

User avatar
By shoelessone
#32863 Thanks again for your time/thoughts!

To be honest I think before I did something like that I'd probably use a multiplexor like the mcp23017 (which was actually my original plan).

Honest question though, is there a reason you don't recommend using the ADC pin? Given your options seem very smart, and would certainly solve my problem, it seems that simply using the ADC pin would be a possibly "easier" solution?
User avatar
By lethe
#32866
shoelessone wrote:Honest question though, is there a reason you don't recommend using the ADC pin? Given your options seem very smart, and would certainly solve my problem, it seems that simply using the ADC pin would be a possibly "easier" solution?

You can't measure capacitance with just a free running ADC.
Since F = C/V = A*s/V (see https://en.wikipedia.org/wiki/Farad), you need to know 3 parameters. The easiest way to do that, is by fixing 2 of them and measure the third.
You can do that with your ADC by charging the capacitor with a known current and measure the voltage after a known time. But since you need to switch between charging and discharging, you still need an additional digital I/O, so you won't gain anything by using the ESPs ADC.
Another method is to charge the capacitor through a known resistor (ohm = V/A, so F*ohm = s) and measure the time it takes for the capacitor to reach a certain voltage. This is what the techniques I described will do. In the single GPIO example the internal pull-up of an GPIO is not know, but it can be assumed to be constant, so you can still use it to measure changes in capacitance instead of an absolute value.
User avatar
By mrburnette
#32876
shoelessone wrote:<...>
...the GPIO0 pin so I could switch it between 3.3V for programming and a GPIO pin...



You can still use GPIO0 to activate re-programming as the pin only needs to be Grounded at reset/poweron, after the bootloader starts loading, pin 0 can be lifted from Gnd potential... when the sketch starts, the pin 0 will perform its normal function. I do this with a pushbutton some times and sometimes with a 3-pin male header and a shorting plug.

Ray
User avatar
By shoelessone
#32897 Well, again, all I can say is thank you.

I promise I'm not dense, but honestly I don't have a good "feel" for most of this stuff yet. But you've given me a lot to go on. I think your solution of using a single GPIO pin and switching betwen input/output seems nice as it's only one pin.

I know it probably seems simple to you, but I was just hoping to get away from having to do any more figuring out with the pin situation. So now I guess I just need to decide if I switch GPIO 0 with something "fancy", or if I just go straight into using a multiplexor. (I know there is also the "charlieplexing" solution but for whatever reason that doesn't appeal to me as much..).

I'm going to think about this and read a bit more and bread board the first solution. If that works well and it's not a huge pain to use the GPIO0 pin AND program with it, then I'll probably just go that rought!

Again, thanks, and any other tips/advice is much appreciated :)