Skip to content

Instantly share code, notes, and snippets.

@tekkies
Last active December 28, 2021 20:23
Show Gist options
  • Save tekkies/d7027a0f9893dee60d8dd8028673833a to your computer and use it in GitHub Desktop.
Save tekkies/d7027a0f9893dee60d8dd8028673833a to your computer and use it in GitHub Desktop.
NodeMCU LIS3DSH Accelerometer Lua Test
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment