'MCP3464 Micropython

I want to read the result of a conversion of the MCP 3464 with a ESP32 I can read registers and write registers. But when I want to read the result of conversion the result is always the same : b'\x00\x00'

from machine import Pin, SPI, SoftSPI
from time import sleep_ms

sck = Pin(18, Pin.OUT)
mosi = Pin(23, Pin.OUT)
miso = Pin(19, Pin.IN)
cs = Pin(17, Pin.OUT)

cs.value(1)
spi = SoftSPI(baudrate=400000, polarity=0, phase=0, sck=sck, mosi=mosi, miso=miso)
spi.init()


def lecture():
    #lecture
    cs.value(0)
    spi.write(b'\x41')
    val = spi.read(2)
    print(val)
    cs.value(1)

lecture()

This is the configuration of the different registers when I do a read

CONFIG0 : b'\xc0'
CONFIG1 : b'\x0c'
CONFIG2 : b'\x8b'
CONFIG3 : b'\x00'
IRQ : b'ss' 

when I read the value with an oscilloscaop I found : 01110011

MUX : b'\x01'
SCAN : b'\x00\x00\x00'
TIMER : b'\x00\x00\x00'
OFFSETCALL : b'\x00\x00\x00'
GAINCAL : b'\x80\x00\x00'
RESERVED : b'\x90\x00\x00'
RESERVED : b'PPP'
LOCK : b'\xa5'
RESERVED : b'\x00\x0b'
CRCCFG : b'\x00\x00'


Solution 1:[1]

Have you considered using the ESP32 Hardware.SPI bus that supports much faster transmission rates ? especially as you are using the optimal pins for use with the ESP32 Hardware SPI bus 2.

In addition, depending on the sensor, it usually takes some time for the sensor to read, convert, and return the requested data on the SPI bus. The datasheet should tell you the minimum required timing, but for initial debugging start with an ample delay of time.sleep_ms(100) or similar.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jos Verlinde