You will need to use aN external ADC then your good to go. Not expensive and can use the i2c or spi bus. It's up to u.
Internally the esp866 only has 1 ADC. The other option is an external multiplexer to the one built in
I do have a MUX, but my problem is getting accurate readings from it and it says all unused pins have to be connected. connected to what?
Whats the part number of the MUX, or provide a link
CD74HC4067
Not sure where it says that but the part looks like it should work with no issues. The Enable and address lines should all be connected to something but the analog lines should n0t matter
Do you have a schematic. I assume your aware the ESP8266 ADC is only 0-1V MAX, not 0 - 3v3 right.
a schematic will help here as I don't see why you would be getting an issue with what your describing
Unused pins need to be connected to avoid having "noise" signals potentially affect any adjacent pins. As far as I know, this definitely applies for all types of pins, as an "undefined" input could cause noise to be generated. I suggest you determine the type of pin (e.g. is it control, or an analog input) and connect it accordingly to either Vcc (supply) or Ground as appropriate to ensure the part functions correctly as intended. Note that digital multiplexer ICs are not intended to pass analog signals, so probably an analog switch is a better solution.
- Gough
I didn't notice you said you were using a CD74HC4067. Probably need to check what your supply voltage to the CD74HC4067 is, as if you supply it with 5V, then the 3.3v logic from the ESP won't be recognized by the multiplexer. Best to supply it with 3.3v at the most.
Inputs S0, S1, S2, S3 are digital select lines to select any one of the 15 inputs. If you want just three inputs, then I suggest you use Y0, Y1 and Y2 as the inputs, and that maps to codes 0000, 0001, 0010. With that knowledge, you can safely connect S3 and S2 to ground, as we don't need them, but S0 and S1 need to be connected to GPIOs from your board and driven with either 00, 01, 10.
Input /E is an enable signal which is logically inverted (hence the bar). To enable the multiplexer, tie this pin to ground as well.
The inputs other than Y0-Y2 which are used for the accelerometer can be tied to ground as well, or to high. It really doesn't matter, but I'd prefer you didn't leave them floating.
Output Z needs to go to your ADC.
I hope you realize that the multiplexer is really only a switch that lets you select the input one at a time - you won't be able to read all inputs "simultaneously".
Also, as mentioned by Robert Peter Oakes, you should probably check whether the output from your accelerometer is compatible with the ADC input on the ESP on a voltage level basis, otherwise there could be damage.
- Gough
Yes I agree that the unused pins should be terminated somehow but it was not saying this in the data sheet.
Also in this case as the ADC in question has an upper limit of only 1V I would suggest connecting unused MUX inputs to 0... NOT VCC, as a mistake in programming will result in excessive volts applied to the ADC input.
Yes I agree that the unused pins should be terminated somehow but it was not saying this in the data sheet.
Also in this case as the ADC in question has an upper limit of only 1V I would suggest connecting unused MUX inputs to 0... NOT VCC, as a mistake in programming will result in excessive volts applied to the ADC input.