@b_rubble Here is a sample script using the ADS7818 with SPI:
# Drive the ADS7818 ADC using SPI
# Connections:
# xxPy | ADS7818
# -----|-------
# P10 | CLK
# P11 | CONV
# P14 | DATA
#
from machine import SPI, Pin
from ubinascii import hexlify
spi = SPI(0, SPI.MASTER, baudrate=4000000, polarity=1, phase=1, bits=16)
buf = bytearray(2)
vref = 2.493 # measured at the ADS7818
while True:
# start a conversion and get the result back
spi.write_readinto(b"\xe0\x00", buf)
# extract the raw ADC value and derive Voltage
value = ((buf[0] << 8) | buf[1]) & 0xfff
volt = 2.0 * vref * value / 4096
print(hexlify(buf), value, volt)
res= input("Next: ")
if res == "q":
break
The conversion and reading back is done within the single spi.write_readinto() call. It is then easy to embed that in a small class.
Note: Since the ADS7818 runs at 5V, insert a resistor of 3.3k to 10k into the data line back into the ESP32 to limit the current into the ESD diodes.