How to use 2 SPI devices, LoRa and SD Card, on ESP32 TTGO T1 V1.3
Good moorning,
I am using these modules in order to send and save data from BME280 sensor.
TTGO T1 ESP-32 V1.3
https://es.aliexpress.com/item/4001229463219.html?src=google&albch=shopping&acnt=439-079-4345&isdl=y&slnk=&plac=&mtctp=&albbt=Google_7_shopping&aff_platform=google&aff_short_key=UneMJZVf&gclsrc=aw.ds&&albagn=888888&&ds_e_adid=487540931172&ds_e_matchtype=&ds_e_device=c&ds_e_network=u&ds_e_product_group_id=1161613595211&ds_e_product_id=es4001229463219&ds_e_product_merchant_id=105381714&ds_e_product_country=ES&ds_e_product_language=es&ds_e_product_channel=online&ds_e_product_store_id=&ds_url_v=2&ds_dest_url=https://es.aliexpress.com/item/4001229463219.html?&albcp=11896381096&albag=115883339016&isSmbAutoCall=false&needSmbHouyi=false&gclid=CjwKCAiAjp6BBhAIEiwAkO9WuvOsa0-mHfAed1LxcUORiEYGYmSEv4_Nvsd2cMWRX-EANE_Y14rTwBoC5FoQAvD_BwE
Adafruit RFM95W LoRa Radio Transceiver Breakout
https://www.adafruit.com/product/3072
BME280
https://www.aliexpress.com/i/32959552723.html?albagn=888888&&src=google&albch=search&acnt=479-062-3723&isdl=y&aff_short_key=UneMJZVf&albcp=653902457&albag=33232068455&slnk=&trgt=dsa-401928029209&plac=&crea=427719926346&netw=g&device=c&mtctp=b&memo1=&albbt=Google_7_search&aff_platform=google&gclid=CjwKCAiAjp6BBhAIEiwAkO9WuhnFHM6F–M1ItYiM1M-eKgtI6K0qsWE24r6DSnabOhFKYQWtrCBxxoCIe8QAvD_BwE&gclsrc=aw.ds
However, I need to solve a problem relate to two SPI devices on an esp32. LoRa and SD card module using SPI.
There are a number of articles out there on how to do what you want but not much with the ESP32.
https://learn.sparkfun.com/tutorials/serial-peripheral-interface-spi/all
https://cdn-learn.adafruit.com/downloads/pdf/arduino-ethernet-sd-card.pdf
https://stackoverflow.com/questions/57454066/how-to-use-2-spi-devices-lora-and-sd-card-on-esp32
However, I haven’t found a right option.
Any help in the correct direction would be appreciated.
Thanks in advance 😉
Hi Pepe.
You can use two or more SPI devices on the ESP32 on the same SPI pins as long as each module is connected to a different chip select (CS) pin.
In your board pinout, we can see that these are the pins for the SD card:
- MOSI: GPIO 15
- MISO: GPIO 2
- SCK: GPIO 14
- CS: GPIO 13
You can use those same pins to connect your LoRa transceiver module, except the CS pin that must be unique. Or you can use the VSPI pins:
- MOSI: GPIO 23
- MISO: GPIO 19
- SCK: GPIO 18
- CS: GPIO5
And finally, you also need to connect G0 (DI0 in our instructions). You can connect it to GPIO 27, for example.
You can see the pinout for your board here:
I see that you have access to the “Learn ESP32 with Arduino IDE” course. Take a look at Project 4 (Unit3) that uses SD card and LoRa. That will help you with the code.
I hope this helps.
Regards,
Sara