@@ -65,7 +65,6 @@ uint8_t BME280::begin()
6565{
6666 // Check the settings structure values to determine how to setup the device
6767 uint8_t dataToWrite = 0 ; // Temporary variable
68-
6968 switch (settings.commInterface )
7069 {
7170
@@ -76,6 +75,14 @@ uint8_t BME280::begin()
7675 case SPI_MODE:
7776 // start the SPI library:
7877 SPI.begin ();
78+ #ifdef ARDUINO_ARCH_ESP32
79+ SPI.setFrequency (1000000 );
80+ // Data is read and written MSb first.
81+ SPI.setBitOrder (SPI_MSBFIRST);
82+ // Like the standard arduino/teensy comment below, mode0 seems wrong according to standards
83+ // but conforms to the timing diagrams when used for the ESP32
84+ SPI.setDataMode (SPI_MODE0);
85+ #else
7986 // Maximum SPI frequency is 10MHz, could divide by 2 here:
8087 SPI.setClockDivider (SPI_CLOCK_DIV32);
8188 // Data is read and written MSb first.
@@ -85,6 +92,7 @@ uint8_t BME280::begin()
8592 // This was SPI_MODE3 for RedBoard, but I had to change to
8693 // MODE0 for Teensy 3.1 operation
8794 SPI.setDataMode (SPI_MODE3);
95+ #endif
8896 // initalize the data ready and chip select pins:
8997 pinMode (settings.chipSelectPin , OUTPUT);
9098 digitalWrite (settings.chipSelectPin , HIGH);
0 commit comments