#Adafruit QT Py ESP32-S3 WiFi Dev Board Support
1 messages · Page 1 of 1 (latest)
Which I2C port? The stemma QT connector is a different port than the SDA and SCL pins on the boiard.
I based my script off of one of the DPS310 examples, so maybe I need to change which i2c it looks at? Not entirely sure how. I am using the on-board i2c port.
i2c = board.STEMMA_I2C()
How can I specify what i2c it uses via the Adafruit_DPS310 lib? I'm using the arduino IDE. I can't find an option to pass in the I2C to use?
https://learn.adafruit.com/adafruit-qt-py-esp32-s3/pinouts#stemma-qt-connector-3119704
The STEMMA QT connector IO pins in Arduino are 40 (SCL1) and 41 (SDA1) and are available on Wire1
The example here https://learn.adafruit.com/adafruit-qt-py-esp32-s3/i2c-scan-test#perform-an-i2c-scan-3108213
has this code:
#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
a rather involved discussion: https://forums.adafruit.com/viewtopic.php?p=944253
Great, I'll give that a go now. Thanks!
🤔 I uploaded the code, but am not getting anything on the serial monitor. I tried the QT Py blink example yesterday and it was printing serial just fine.
I've had to put the board into manual bootloader, every time I want to update the code, because the built-in upload via the Arduino IDE causes it to fail the upload.
We spent hours in the projects channel debugging this. It's a bug with the esp library. Either way, manually uploading seems to successfully get the code onto the board. Though now it is having issues either executing the code, or writing to serial. All rather frustrating TBH.
i'd say get the minimal example that shows the problem. can continue debugging here. I have not looked in the projects channel
I think part of what is confusing me here is how there are certain global variables that are imported in when I #include a .h file. For instance, the use of #include <Wire.h> allows #define WIRE Wire1 and looks like Wire1.setPins(SDA1, SCL1) also works? SDA1 and SCL1 being constant defined?
I am trying to take this example script and adapt it to use the Wire1 i2c instead of the default. https://learn.adafruit.com/adafruit-dps310-precision-barometric-pressure-sensor/arduino#example-code-3054891
I found the original code for the lib I am trying to use - https://github.com/adafruit/Adafruit_DPS310/blob/master/Adafruit_DPS310.cpp#L67 and it shows that the second argument is TwoWire *wire and the header file shows it as TwoWire *wire = &Wire
What does this mean exactly?
I tried this locally, and this works:
...
Serial.begin(115200);
while (!Serial) delay(10);
Wire1.setPins(SDA1, SCL1); /////////// NEW*************
Serial.println("DPS310");
if (! dps.begin_I2C(DPS310_I2CADDR_DEFAULT, &Wire1)) { // Can pass in I2C address here NEW*************
//if (! dps.begin_SPI(DPS310_CS)) { // If you want to use SPI
Serial.println("Failed to find DPS");
while (1) yield();
}
Serial.println("DPS OK!");
...
There are two I2C objects available, Wire and Wire1. I am using Wire1. Interesting, substituting Wire for Wire1 above does not work, maybe because of some pre-initialization of WIre.
but I'm not sure about this
Thanks, I will try this
What does the * and & mean next to Wire? I am not sure what that means in C++ (I think in C# it's called a pointer, but not sure if that's the same in C++)
yes that's syntax related to pointers. In C++ it's somewhat more complicated, but basically it represents the whole Wire1 object or just the address of the Wire1 object. It is worth reading a C++ intro if you want more info
Ok that worked!!
Key parts
#include <Adafruit_DPS310.h>
#include <Wire.h> // <--
#define WIRE Wire1 // <--
Adafruit_DPS310 dps;
void setup() {
Serial.begin(115200);
while (!Serial) delay(10);
Wire1.setPins(SDA1, SCL1); // <--
Serial.println("DPS310");
if (! dps.begin_I2C(0x77, &Wire1)) { // <--
Serial.println("Failed to find DPS");
while (1) yield();
}
}
Not sure if the first two changes actually matter or not. I actually tried passing in Wire1 originally but got that syntax error. I guess all I had to do was throw & on the front to get it to work?
You don't need these:
#include <Wire.h> // <--
#define WIRE Wire1 // <--
the include is already done by the other include, and WIRE (all caps) is not used, so you don't need it
I guess all I had to do was throw & on the front to get it to work?
yes, not syntax error, but type-matching error
Gotcha. Thanks for your help!