I just received 2 new QT PY ESP32-S2 and 2 new QT PY ESP32-S3. I have run the following tests on each board with the same problem results. I also have several QT PY SAMD M0 boards that all work perfectly with these example sketches.
I am able to successfully run the Adafruit Testbed/I2C_SCAN with the ESP32's and the STEMMA connections and addresses are detected, on the secondary I2C port.
When connected to Adafruit 7-Seg Display (https://www.adafruit.com/product/881) via STEMMA I am unable to get the Adafruit example sketch Adafruit LED Backpack Library/sevenseg to work. The display never lights up at all. I have tried to edit the example sketch with the code noted from website page https://learn.adafruit.com/adafruit-qt- ... -scan-test "Note we are using the STEMMA QT port here, that means we need to reference Wire1 for I2C communication and also add Wire1.setPins(SDA1, SCL1) in our code in setup()" but with no luck.
Same problem exists wit the ESP32's connected via STEMMA to Adafruit I2C Stemma QT Rotary Encoder Breakout with NeoPixel - STEMMA QT / Qwiic and trying to run the Adafruit example sketch Adafruit Seesaw Library/encoder. The sketch runs and is unable to find the Seesaw on the default address.
I have a sketch using both of these STEMMA devices running perfectly on my QT PY SAMD21 M0 and want to move the code to a ESP32 so I can connect with the WipperSnapper IOT. Perhaps there is another MCU choice that will work with the libraries that I am using.
Any advice please.
QT PY ESP32-S2/S3 not working with sample sketches
Moderators: adafruit_support_bill, adafruit
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
- jjjjkem
- Posts: 15
- Joined: Tue May 10, 2022 6:25 pm
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
We should be able to get you going with these QtPy's.
Can you post your modified code with the Wire1.setpins().
You will need to turn on the I2C power as well as seen in the testbed code.
https://learn.adafruit.com/adafruit-qt- ... an-3108213
Can you post your modified code with the Wire1.setpins().
You will need to turn on the I2C power as well as seen in the testbed code.
https://learn.adafruit.com/adafruit-qt- ... an-3108213
Code: Select all
#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S2)
// turn on the I2C power by setting pin to opposite of 'rest state'
pinMode(PIN_I2C_POWER, INPUT);
delay(1);
bool polarity = digitalRead(PIN_I2C_POWER);
pinMode(PIN_I2C_POWER, OUTPUT);
digitalWrite(PIN_I2C_POWER, !polarity);
#endif
- jjjjkem
- Posts: 15
- Joined: Tue May 10, 2022 6:25 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
Here is the modified code for the LED backpack/sevenseg using the ESP32-S3. It compiles without error but still does not work. Sevenseg display has a small green LED that indicates it's getting power but the sketch does not light up the display. The display works fine with other SAMD MCU's running this same test sketch.
Thank you for your help.
Thank you for your help.
Code: Select all
/***************************************************
This is a library for our I2C LED Backpacks
Designed specifically to work with the Adafruit LED 7-Segment backpacks
----> http://www.adafruit.com/products/881
----> http://www.adafruit.com/products/880
----> http://www.adafruit.com/products/879
----> http://www.adafruit.com/products/878
These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#define DEFAULT_I2C_PORT &Wire
#if defined(ARDUINO_ARCH_RP2040) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3) \
|| defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO) \
|| defined(ARDUINO_SAM_DUE)
#define SECONDARY_I2C_PORT &Wire1
#endif
Adafruit_7segment matrix = Adafruit_7segment();
void setup() {
#if defined(ARDUINO_ADAFRUIT_QTPY_ESP32S2) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3_NOPSRAM) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32S3) || \
defined(ARDUINO_ADAFRUIT_QTPY_ESP32_PICO)
// ESP32 is kinda odd in that secondary ports must be manually
// assigned their pins with setPins()!
Wire1.setPins(SDA1, SCL1);
#endif
#if defined(ARDUINO_ADAFRUIT_FEATHER_ESP32S3)
// turn on the I2C power by setting pin to opposite of 'rest state'
pinMode(PIN_I2C_POWER, INPUT);
delay(1);
bool polarity = digitalRead(PIN_I2C_POWER);
pinMode(PIN_I2C_POWER, OUTPUT);
digitalWrite(PIN_I2C_POWER, !polarity);
#endif
#ifndef __AVR_ATtiny85__
Serial.begin(9600);
Serial.println("7 Segment Backpack Test");
#endif
matrix.begin(0x70);
}
void loop() {
// try to print a number thats too long
matrix.print(10000, DEC);
matrix.writeDisplay();
delay(500);
// print a hex number
matrix.print(0xBEEF, HEX);
matrix.writeDisplay();
delay(500);
// print a floating point
matrix.print(12.34);
matrix.writeDisplay();
delay(500);
// print a string message
matrix.print("7SEG");
matrix.writeDisplay();
delay(10000);
// print with print/println
for (uint16_t counter = 0; counter < 9999; counter++) {
matrix.println(counter);
matrix.writeDisplay();
delay(10);
}
// method #2 - draw each digit
uint16_t blinkcounter = 0;
boolean drawDots = false;
for (uint16_t counter = 0; counter < 9999; counter ++) {
matrix.writeDigitNum(0, (counter / 1000), drawDots);
matrix.writeDigitNum(1, (counter / 100) % 10, drawDots);
matrix.drawColon(drawDots);
matrix.writeDigitNum(3, (counter / 10) % 10, drawDots);
matrix.writeDigitNum(4, counter % 10, drawDots);
blinkcounter+=50;
if (blinkcounter < 500) {
drawDots = false;
} else if (blinkcounter < 1000) {
drawDots = true;
} else {
blinkcounter = 0;
}
matrix.writeDisplay();
delay(10);
}
}
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
I had to wire up my Qt Py ESP32-S2 to reproduce the issue. The key is this line:
We need to tell the matrix constructor which I2C bus to use so pass it a second argument to the STEMMA I2C connector.
I re-arranged your modifications to the code for troubleshooting, but this should get you going. You might need to uncomment the PIN_I2C_POWER.
Code: Select all
matrix.begin(0x70, &Wire1);
I re-arranged your modifications to the code for troubleshooting, but this should get you going. You might need to uncomment the PIN_I2C_POWER.
Code: Select all
/***************************************************
This is a library for our I2C LED Backpacks
Designed specifically to work with the Adafruit LED 7-Segment backpacks
----> http://www.adafruit.com/products/881
----> http://www.adafruit.com/products/880
----> http://www.adafruit.com/products/879
----> http://www.adafruit.com/products/878
These displays use I2C to communicate, 2 pins are required to
interface. There are multiple selectable I2C addresses. For backpacks
with 2 Address Select pins: 0x70, 0x71, 0x72 or 0x73. For backpacks
with 3 Address Select pins: 0x70 thru 0x77
Adafruit invests time and resources providing this open source code,
please support Adafruit and open-source hardware by purchasing
products from Adafruit!
Written by Limor Fried/Ladyada for Adafruit Industries.
BSD license, all text above must be included in any redistribution
****************************************************/
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#define SECONDARY_I2C_PORT &Wire1
Adafruit_7segment matrix = Adafruit_7segment();
void setup() {
Serial.begin(115200);
Serial.println("7 Segment Backpack Test");
Wire1.setPins(SDA1, SCL1);
/* pinMode(PIN_I2C_POWER, INPUT);
delay(1);
bool polarity = digitalRead(PIN_I2C_POWER);
pinMode(PIN_I2C_POWER, OUTPUT);
digitalWrite(PIN_I2C_POWER, !polarity); */
delay(500);
matrix.begin(0x70, &Wire1);
}
void loop() {
// try to print a number thats too long
matrix.print(10000, DEC);
matrix.writeDisplay();
delay(500);
// print a hex number
matrix.print(0xBEEF, HEX);
matrix.writeDisplay();
delay(500);
// print a floating point
matrix.print(12.34);
matrix.writeDisplay();
delay(500);
// print a string message
matrix.print("7SEG");
matrix.writeDisplay();
delay(10000);
// print with print/println
for (uint16_t counter = 0; counter < 9999; counter++) {
matrix.println(counter);
matrix.writeDisplay();
delay(10);
}
// method #2 - draw each digit
uint16_t blinkcounter = 0;
boolean drawDots = false;
for (uint16_t counter = 0; counter < 9999; counter++) {
matrix.writeDigitNum(0, (counter / 1000), drawDots);
matrix.writeDigitNum(1, (counter / 100) % 10, drawDots);
matrix.drawColon(drawDots);
matrix.writeDigitNum(3, (counter / 10) % 10, drawDots);
matrix.writeDigitNum(4, counter % 10, drawDots);
blinkcounter += 50;
if (blinkcounter < 500) {
drawDots = false;
} else if (blinkcounter < 1000) {
drawDots = true;
} else {
blinkcounter = 0;
}
matrix.writeDisplay();
delay(10);
}
}
- jjjjkem
- Posts: 15
- Joined: Tue May 10, 2022 6:25 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
Thank you Scott, the changes you posted worked fine for the 7seg example sketch using the QT py ESP32-S2. I did not need to uncomment the PIN_I2C_POWER. If I do uncomment that PIN_I2C_POWER, it does not compile "Compilation error: 'PIN_I2C_POWER' was not declared in this scope".
I still am having no luck with the Adafruit seesaw Library/encoder basic example sketch. I added some of the change you made to the 7seg sketch, and it compiles, but it still does not find the seesaw on the default address. Console message is:
Looking for seesaw!
Couldn't find seesaw on default address
Here is the code edits for the seesaw that I tried.
I still am having no luck with the Adafruit seesaw Library/encoder basic example sketch. I added some of the change you made to the 7seg sketch, and it compiles, but it still does not find the seesaw on the default address. Console message is:
Looking for seesaw!
Couldn't find seesaw on default address
Here is the code edits for the seesaw that I tried.
Code: Select all
/*
* This example shows how to read from a seesaw encoder module.
* The available encoder API is:
* int32_t getEncoderPosition();
int32_t getEncoderDelta();
void enableEncoderInterrupt();
void disableEncoderInterrupt();
void setEncoderPosition(int32_t pos);
*/
#include "Adafruit_seesaw.h"
#include <seesaw_neopixel.h>
#include <Wire.h> // Enable this line if using Arduino Uno, Mega, etc.
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#define SECONDARY_I2C_PORT &Wire1
#define SS_SWITCH 24
#define SS_NEOPIX 6
#define SEESAW_ADDR 0x36
Adafruit_seesaw ss;
seesaw_NeoPixel sspixel = seesaw_NeoPixel(1, SS_NEOPIX, NEO_GRB + NEO_KHZ800);
int32_t encoder_position;
void setup() {
Serial.begin(115200);
while (!Serial) delay(10);
Wire1.setPins(SDA1, SCL1);
/* pinMode(PIN_I2C_POWER, INPUT);
delay(1);
bool polarity = digitalRead(PIN_I2C_POWER);
pinMode(PIN_I2C_POWER, OUTPUT);
digitalWrite(PIN_I2C_POWER, !polarity);*/
delay(500);
Serial.println("Looking for seesaw!");
if (! ss.begin(SEESAW_ADDR) || ! sspixel.begin(SEESAW_ADDR)) {
Serial.println("Couldn't find seesaw on default address");
while(1) delay(10);
}
Serial.println("seesaw started");
uint32_t version = ((ss.getVersion() >> 16) & 0xFFFF);
if (version != 4991){
Serial.print("Wrong firmware loaded? ");
Serial.println(version);
while(1) delay(10);
}
Serial.println("Found Product 4991");
// set not so bright!
sspixel.setBrightness(20);
sspixel.show();
// use a pin for the built in encoder switch
ss.pinMode(SS_SWITCH, INPUT_PULLUP);
// get starting position
encoder_position = ss.getEncoderPosition();
Serial.println("Turning on interrupts");
delay(10);
ss.setGPIOInterrupts((uint32_t)1 << SS_SWITCH, 1);
ss.enableEncoderInterrupt();
}
void loop() {
if (! ss.digitalRead(SS_SWITCH)) {
Serial.println("Button pressed!");
}
int32_t new_position = ss.getEncoderPosition();
// did we move arounde?
if (encoder_position != new_position) {
Serial.println(new_position); // display new position
// change the neopixel color
sspixel.setPixelColor(0, Wheel(new_position & 0xFF));
sspixel.show();
encoder_position = new_position; // and save for next round
}
// don't overwhelm serial port
delay(10);
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return sspixel.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return sspixel.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return sspixel.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
I'm Mikey not Scott.
The PIN_I2C_POWER is only necessary for specific models. It does not exist on the Qt Py ESP32-S2.
The Seesaw encoder might be the same issue that the 7-seg matrix display had. The constructor needs to know which I2C bus to use.
change this:
to this:
The PIN_I2C_POWER is only necessary for specific models. It does not exist on the Qt Py ESP32-S2.
The Seesaw encoder might be the same issue that the 7-seg matrix display had. The constructor needs to know which I2C bus to use.
change this:
Code: Select all
Adafruit_seesaw ss;
Code: Select all
Adafruit_seesaw ss(&Wire1);
- jjjjkem
- Posts: 15
- Joined: Tue May 10, 2022 6:25 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
Hi Mikey,
Thanks for the edits, but seesaw encoder sketch still did not recognize seesaw on default address. It was the neopixel part that also needed to be edited. I replaced the 2 lines as follows and the seesaw/encoder basic example sketch now works fine with the QT py ESP32-S2. I'm pretty sure the ESP32-S3 will work fine also.
// Adafruit_seesaw ss;
// seesaw_NeoPixel sspixel = seesaw_NeoPixel(1, SS_NEOPIX, NEO_GRB + NEO_KHZ800);
Adafruit_seesaw ss(&Wire1);
seesaw_NeoPixel sspixel = seesaw_NeoPixel(1, SS_NEOPIX, NEO_GRB + NEO_KHZ800,&Wire1);
Thanks again for your support.
Thanks for the edits, but seesaw encoder sketch still did not recognize seesaw on default address. It was the neopixel part that also needed to be edited. I replaced the 2 lines as follows and the seesaw/encoder basic example sketch now works fine with the QT py ESP32-S2. I'm pretty sure the ESP32-S3 will work fine also.
// Adafruit_seesaw ss;
// seesaw_NeoPixel sspixel = seesaw_NeoPixel(1, SS_NEOPIX, NEO_GRB + NEO_KHZ800);
Adafruit_seesaw ss(&Wire1);
seesaw_NeoPixel sspixel = seesaw_NeoPixel(1, SS_NEOPIX, NEO_GRB + NEO_KHZ800,&Wire1);
Thanks again for your support.
- mikeysklar
- Posts: 13936
- Joined: Mon Aug 01, 2016 8:10 pm
Re: QT PY ESP32-S2/S3 not working with sample sketches
Good find on the seesaw_NeoPixel also needing the I2C bus argument.
Agreed, this should just work with the ESP32-S3.
Agreed, this should just work with the ESP32-S3.
Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.