-- John Longworth December 2017 -- Simple program to test the MCP23008.lua library module is working -- Uses mcp23008.lua - This file must be in the ESP8266 memory mcp = require("mcp23008") id = 0x00 -- Always 0 sda = 3 -- GPIO0 Connect to Pin 2 of MCP23008 scl = 4 -- GPIO2 Connect to Pin 1 of MCP23008 mcp.begin(id,sda,scl,i2c.SLOW) mcp.writeIODIR(0x00) -- Set all GPIO pins as outputs mcp.writeGPIO(0x33) -- Post a value to GPIO Register mcp.writeGPPU(0xff) -- Set all pull ups on pins print(mcp.readGPIO()) -- Print value of GPIO register -- Pin Connections on my board -- Pin 18 (VDD) to 3v3 -- Pin 9 (VSS) to GND -- Pin 7 (NC) to GND (Not necessary) -- Pin 1 (SCL) to ESP GPIO2 -- Pin 2 (SDA) to ESP GPIO0 -- Pin 5 (A0) to GND -- Pin 4 (A1) to GND -- Pin 3 (A2) to GND -- Pin 6 (RESET) to 3v3 -- Connect pins to be read to Gnd on Port A (pins 10 - 17)