https://github.com/jonashoechst/ttgo-lora-sd
TTGO LoRa and SD card (working demo)
https://github.com/jonashoechst/ttgo-lora-sd
esp32 lora platformio sd-card ttgo
Last synced: 4 months ago
JSON representation
TTGO LoRa and SD card (working demo)
- Host: GitHub
- URL: https://github.com/jonashoechst/ttgo-lora-sd
- Owner: jonashoechst
- License: bsd-3-clause
- Created: 2018-12-14T14:32:00.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-14T14:36:12.000Z (almost 7 years ago)
- Last Synced: 2025-04-23T16:09:29.293Z (6 months ago)
- Topics: esp32, lora, platformio, sd-card, ttgo
- Language: C++
- Homepage:
- Size: 91.8 KB
- Stars: 9
- Watchers: 2
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
# TTGO LoRa + SD Card
The TTGO LoRa boards have some issues when using together with SD cards. Both the SX1278 and SD cards use SPI as communication bus. SPI is a protocol family can work in many different configurations.
## ESP32: Software and Hardware SPI
The ESP32 on the TTGO LoRa board has a builtin **hardware SPI** (HSPI) and can also do **virtual / software SPI** (VSPI) through emulation. Also the VSPI busses as well as the HSPI can be routed to **any** of the pins.

In the default configuration both SX1278 and the SD library uses the HSPI and thereby impede each other.
## Using multiple busses
In order to make the SX1278 and SD card working, two SPI busses need to be used. While experimenting with the board it also became obvious, that the SX1278 is error-prone on the hardware SPI, and did **not** work, when using the SD card on a VSPI.
The final solution uses the **HSPI** bus for communication with SD and a software SPI for the SX1278. It is also an option to use two seperate software SPI busses.
### SD on rerouted HSPI
```c
#define SD_CS 23
#define SD_SCK 17
#define SD_MOSI 12
#define SD_MISO 13SPIClass sd_spi(HSPI);
sd_spi.begin(SD_SCK, SD_MISO, SD_MOSI, SD_CS);if (!SD.begin(SD_CS, sd_spi))
Serial.println("SD Card: mounting failed.");
else
Serial.println("SD Card: mounted.");
```### RH95 on VSPI
```c
RHSoftwareSPI sx1278_spi;
RH_RF95 rf95(LORA_CS, LORA_IRQ, sx1278_spi);sx1278_spi.setPins(LORA_MISO, LORA_MOSI, LORA_SCK);
if (!rf95.init())
Serial.println("LoRa Radio: init failed.");
else
Serial.println("LoRa Radio: init OK!");
```