GPIO expander

The GPIO expander extension board is based on the MCP23008 by Microchip. The expander uses I2C to communicate with the Picoclick (SDA = GPIO2, SCL = GPIO8). It can be used with the on board ultra low power voltage regulator or with the 3.3V output of the Picoclick, which is only present when the Picoclick is activated. By using the 3.3V output the soldering jumper J1 has to be closed and the voltage regulator has to be removed.

Soldering jumper J2 connects the interrupt signal of the MCP23008 to the extension connector in order to let the expander activate the Picoclick by firing an interrupt.

The pinout of the pinheaders is labeled on the bottom of the PCB.

Hardware

Overview

Technical drawing

  • PCB: 18mm x 18mm

  • Thickness: 1mm

  • Mounting holes: 3.2mm

  • Corner radius: 2mm

  • The pinheaders are breadboard compatible (12.7mm distance between the rows)

Schematics

Software

Hardwaretest can be found on Github.

#include <Arduino.h>
#include <WiFi.h>
#include <FastLED.h>
#include <Wire.h>
#include <Adafruit_MCP23X08.h>
#include "config.h"

Adafruit_MCP23X08 mcp;

void setup(){
  pinMode(BUTTON_PIN, INPUT);
  pinMode(ADC_ENABLE_PIN, OUTPUT);
  pinMode(ADC_PIN, INPUT);
  analogReadResolution(12);
  digitalWrite(ADC_ENABLE_PIN, HIGH);

  btStop();
  WiFi.mode(WIFI_OFF);

  FastLED.addLeds<APA102, APA102_SDI_PIN, APA102_CLK_PIN, BGR>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.setBrightness(160);
  delay(50);

  set_fastled(CRGB::Blue);

  Wire.begin(SDA_PIN, SCL_PIN);
  delay(100);

  if(!mcp.begin_I2C()){
    printf("Error.\r\n");
    set_fastled(CRGB::Red);
    delay(3000);
    esp_deep_sleep_start();
  }

  for(int i=0; i<8; i++) mcp.pinMode(i, OUTPUT);
}

unsigned long t_expander = millis() + 300;

int counter = 0;
bool dir = true;

void loop() {
  if(digitalRead(BUTTON_PIN) == 1){
    set_fastled(CRGB::Red);
    delay(500);
    esp_deep_sleep_start();
  }

  if(millis() >= t_expander + 1000){
    t_expander = millis();
    if(dir) mcp.digitalWrite(counter, 1);
    else mcp.digitalWrite(counter, 0);

    counter++;
    if(counter == 8){
      counter = 0;
      dir = !dir;
    }
  }
}

Last updated