spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_HIGH, 8, 255)
spi.transaction(1, 0, 0, 8, 0x80 + 0x0f,0,0,8)
read = spi.get_miso(1,0,8,1)
print("Who_AM_I register (expect 3f): " .. string.format("%x", read))
Output should be Who_AM_I register (expect 3f): 3f
This tests that the LIS3DSH is detected on the port when wired
NodeMCU | NodeMCU | LIS3DSH |
---|---|---|
HSPI CLK | D5 | SCL |
HSPI MISO | D6 | SDO |
HSPI MOSI | D7 | SDI |
HSPI /CS | D8 | CS |