Git Product home page Git Product logo

ttgo-lora-sd's Introduction

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.

TTGO LoRa Pinout

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

#define SD_CS 23
#define SD_SCK 17
#define SD_MOSI 12
#define SD_MISO 13

SPIClass 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

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!");

ttgo-lora-sd's People

Contributors

jonashoechst avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.