Skip to main content
added 275 characters in body
Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

You use pins

#define BME_SCK 12 //Connected SCL to IO12
#define BME_MISO 15 //Connected SDO to IO15
#define BME_MOSI 13 //Connected SDA to IO13
#define BME_CS 14 //Connected CS to IO14

for software SPI, but the esp32 can use any set of pins for hardware SPI.

And your set of pins are even the dedicated mux pins for SPI2 (they have the direct connection without mux). But they are in different mapping then your software SPI.

SPI2:
SCLK    14  
MISO    12  
MOSI    13
SS      15

Source: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_master.html

SPI2 is the default SPI used by the ESP32 Arduino SPI library, so the Adafruit library should have no problem to use hardware SPI with the SPI library.

Adafruit_BME680 bme(BME_CS); // use hardware SPI

and wire the sensor to SPI2 pins according to their function

You use pins

#define BME_SCK 12 //Connected SCL to IO12
#define BME_MISO 15 //Connected SDO to IO15
#define BME_MOSI 13 //Connected SDA to IO13
#define BME_CS 14 //Connected CS to IO14

for software SPI, but the esp32 can use any set of pins for hardware SPI.

And your set of pins are even the dedicated mux pins for SPI2 (they have the direct connection without mux). But they are in different mapping then your software SPI.

SPI2:
SCLK    14  
MISO    12  
MOSI    13
SS      15

Source: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_master.html

You use pins

#define BME_SCK 12 //Connected SCL to IO12
#define BME_MISO 15 //Connected SDO to IO15
#define BME_MOSI 13 //Connected SDA to IO13
#define BME_CS 14 //Connected CS to IO14

for software SPI, but the esp32 can use any set of pins for hardware SPI.

And your set of pins are even the dedicated mux pins for SPI2 (they have the direct connection without mux). But they are in different mapping then your software SPI.

SPI2:
SCLK    14  
MISO    12  
MOSI    13
SS      15

Source: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_master.html

SPI2 is the default SPI used by the ESP32 Arduino SPI library, so the Adafruit library should have no problem to use hardware SPI with the SPI library.

Adafruit_BME680 bme(BME_CS); // use hardware SPI

and wire the sensor to SPI2 pins according to their function

Source Link
Juraj
  • 18.3k
  • 4
  • 32
  • 50

You use pins

#define BME_SCK 12 //Connected SCL to IO12
#define BME_MISO 15 //Connected SDO to IO15
#define BME_MOSI 13 //Connected SDA to IO13
#define BME_CS 14 //Connected CS to IO14

for software SPI, but the esp32 can use any set of pins for hardware SPI.

And your set of pins are even the dedicated mux pins for SPI2 (they have the direct connection without mux). But they are in different mapping then your software SPI.

SPI2:
SCLK    14  
MISO    12  
MOSI    13
SS      15

Source: https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/peripherals/spi_master.html