ESP32 QT-PY Stemma QT, Adafruit libraries are incorrect

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
mariobro_3
 
Posts: 7
Joined: Wed Jan 04, 2023 3:51 pm

ESP32 QT-PY Stemma QT, Adafruit libraries are incorrect

Post by mariobro_3 »

There seems to be issues with &Wire1 being implemented properly in all of the libraries I have used thus far:
Adafruit_TestBed.h
Adafruit_NeoKey_1x4.h
seesaw_neopixel.h

Im sure there are others.
The basic example of I2C_Scan under AdaFruit Testbed does not work, i have no serial output.
I modified Adafruit_TestBed.h on this line :

Code: Select all

 TwoWire *theWire = &Wire1;    ///< The I2C port used in scanning
Then I modified the scanning example to the following, adding an extra 3 second delay because this board is slow to get serial messages out initially it seems :

Code: Select all

#include <Adafruit_TestBed.h>
extern Adafruit_TestBed TB;

#define DEFAULT_I2C_PORT &Wire1

void setup() {
  Serial.begin(115200);
  Serial.println("Adafruit I2C Scanner");
  Wire1.setPins(SDA1, SCL1);
}

void loop() {
  delay(3000); // wait 3 seconds
  Serial.println("");
  Serial.println("");

  Serial.print("Default port (Wire1) ");
  TB.theWire = DEFAULT_I2C_PORT;
  TB.printI2CBusScan();

  delay(3000); // wait 3 seconds
}
I though that all this time I must have faulty stuff or something because my Wemos D1 mini is doing everything I want it to, but the ESP32-S2 QT PY wont work at all. I have 48 boards sitting on my desk waiting to deploy, and I went with the Stemma QT stuff out of convenience.

Please review the libraries, I would prefer not use micropython. My project is very simple, I have made the neokey 1x4 work with micropython, but im using arduino IDE inseatd. Its what I'm familiar with and have a ton of working code in C++...

Just getting Arduino OTA working with the ESP32-S2 was hard enough, not getting the purple blink of death took me a week.

User avatar
mariobro_3
 
Posts: 7
Joined: Wed Jan 04, 2023 3:51 pm

Re: ESP32 QT-PY Stemma QT, Adafruit libraries are incorrect

Post by mariobro_3 »

I followed this: viewtopic.php?f=19&t=188164, copy and pasted the latest library to be sure and I have no idea whats wrong. Using my modified I2C scan posted above my serial output is:

Code: Select all

11:03:32.099 -> 
11:03:32.099 -> 
11:03:32.099 -> Default port (Wire1) I2C scan: 0x30, 
11:03:38.135 -> 
11:03:38.135 -> 
11:03:38.135 -> Default port (Wire1) I2C scan: 0x30, 
11:03:44.143 -> 
11:03:44.143 -> 
11:03:44.143 -> Default port (Wire1) I2C scan: 0x30,
IT SEES IT BUT IT DOES NOT WORK!
Here is my modified neokey basic program:

Code: Select all

#include "Adafruit_NeoKey_1x4.h"
#include "seesaw_neopixel.h"

Adafruit_NeoKey_1x4 neokey(0x30, &Wire1);  // Create the NeoKey object

void setup() {
  Serial.begin(115200);
  Wire1.setPins(SDA1, SCL1);
  while (! Serial) delay(1000);
   
  if (! neokey.begin(0x30)) {     // begin with I2C address, default is 0x30
    Serial.println("Could not start NeoKey, check wiring?");
    while(1) delay(10);
  }
  
  Serial.println("NeoKey started!");

  // Pulse all the LEDs on to show we're working
  for (uint16_t i=0; i<neokey.pixels.numPixels(); i++) {
    neokey.pixels.setPixelColor(i, 0x808080); // make each LED white
    neokey.pixels.show();
    delay(50);
  }
  for (uint16_t i=0; i<neokey.pixels.numPixels(); i++) {
    neokey.pixels.setPixelColor(i, 0x000000);
    neokey.pixels.show();
    delay(50);
  }
}

void loop() {
  uint8_t buttons = neokey.read();

  // Check each button, if pressed, light the matching neopixel
  
  if (buttons & (1<<0)) {
    Serial.println("Button A");
    neokey.pixels.setPixelColor(0, 0xFF0000); // red
  } else {
    neokey.pixels.setPixelColor(0, 0);
  }

  if (buttons & (1<<1)) {
    Serial.println("Button B");
    neokey.pixels.setPixelColor(1, 0xFFFF00); // yellow
  } else {
    neokey.pixels.setPixelColor(1, 0);
  }
  
  if (buttons & (1<<2)) {
    Serial.println("Button C");
    neokey.pixels.setPixelColor(2, 0x00FF00); // green
  } else {
    neokey.pixels.setPixelColor(2, 0);
  }

  if (buttons & (1<<3)) {
    Serial.println("Button D");
    neokey.pixels.setPixelColor(3, 0x00FFFF); // blue
  } else {
    neokey.pixels.setPixelColor(3, 0);
  }  

  neokey.pixels.show();
  
  delay(1000);    // don't print too fast
}



/******************************************/

// Input a value 0 to 255 to get a color value.
// The colors are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  if(WheelPos < 85) {
   return seesaw_NeoPixel::Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  } else if(WheelPos < 170) {
   WheelPos -= 85;
   return seesaw_NeoPixel::Color(255 - WheelPos * 3, 0, WheelPos * 3);
  } else {
   WheelPos -= 170;
   return seesaw_NeoPixel::Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  return 0;
}

User avatar
adafruit_support_carter
 
Posts: 29159
Joined: Tue Nov 29, 2016 2:45 pm

Re: ESP32 QT-PY Stemma QT, Adafruit libraries are incorrect

Post by adafruit_support_carter »

There are numerous similarly named "ESP32" boards. Just to be sure, you have one of these?
https://www.adafruit.com/product/5395

The TestBed scanner should take care of any platform specific setup and should not require any modifications. If you connect the NeoKey and run the unaltered scanner sketch:
https://learn.adafruit.com/scanning-i2c ... ng-testbed
what output do you get in the Serial Monitor?

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”