SPARKFUN LORA GATEWAY 1-CHANNEL CONNECTING TO SPI

I am working on a project that collects data, then transmits it, using LoRa, to a receiver which needs to record the data to a microSD module.

However, I can’t get the microSD to initialize. The card is connected to the SCK, MOSI, MISO pins on the SF module and the CS is attached to pin #5. I have also tried pin #4 for the CS. I am including the SD and SPI libraries in my code. I have checked the wiring and also tried 2 different microSD modules and yes there is a formatted SD card in the module.

I am at a loss as to what could be the issue. I have had success using SD modules while using other Arduino micro boards without this problem.

I could use some advice on what the issue may be? Has anyone else had difficulty using the SPI pins on the SF module?

I have continued my experimentation and I am thinking that the only SPI on the board works with the LoRa module only.

I have a program that works fine as long as the SD.begin function call is remarked out, however as soon as you un-comment the call the function call the out put to the serial port produces gibberish and continually resets and then repeats the gibberish. This over course using the SPI pins as marked on the SF board.

So I tried something different. I used pin 18 for the SCK, 19 for MISO and 23 for MOSI. I used these pins because these are the traditional SPI pins used for the ESP32-WROOM and this seems to be indicated in the SF board schematic . But a lass the exact same results are returned as using the marked pins.

Reading in the features of this SF module, the only reference to SPI is:

Hope RFM95W LoRa modem

Frequency range: 868/915 MHz

Spread factor: 6-12

SPI control interface

The only other discussion I can see concerning SPI is on the Hardware Overview page of the Hookup Guide and it says:

IO Pins

For anything other than I2C you can use the SPI lines and/or 7 GPIO pins which are all broken out to PTH pads around the board.

This implies SPI is implemented on the marked pins however I am having no success. Anyone have an idea to get them to work?

Here is some of the what I called gibberish, at least it is to me:

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)

flash read*⸮ɱ 1000

ets_main.c 371

ets Jun 8 2016 00:22:57

!⸮.⸮⸮⸮⸮0 (RTCWDT_RTC_RESQU⸮I⸮⸮⸮⸮0x33 (SPI_FAST_*M!_BOOT)

flash read*⸮⸮, 1000

ets_main.c 371 C⸮ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)

flash read err, 1000

ets_main.c 371

ets Jun 8 2016 00:&&⸮⸮SH⸮HH⸮⸮⸮0x10 (RTCWDT_*⸮}IMET),boot:0x33 (SPI_FASTe1M!}BOOT)

flash read err, 10⸮j

ets_main.c 371

ets Jun 8 2016 00:22:57

rst:0x10 (RTCWDT_RTC_RESET),boot:0x33 (SPI_FAST_FLASH_BOOT)

flash read err, 1000

ets_main.c 371

ets Jun 8 2016 00:22:57

Very disappointed in the lack of any response from anyone at SF and/or other users.

Sorry for the delay and I’m sorry to hear that you’re having a fight with gibberish. To better assist you, I’d like to get a few more details if possible.

Can you provide a list of parts you’re using for the receiving module?

Can you provide a clear photo of wiring and setup?

Have you probed the messages after they’ve been received by the LoRa module, but before sending to the SD card, using a serial print out?

Are there any other details about your operating environment you’d like to provide?

Could you compress your code in a ZIP folder and attach to this forum post?

Thank you and I apologize for the many questions. I hope to hear back soon!

I can do what you ask but I do not know how to attach the pics and/or zip file.

However I have 2 suggestions that will get us maybe to the answer quicker:

  1. Can you attached an example of code that you knows works with the SPI functions on this board. We know the LoRa uses SPI and that works fine. As soon as I try to add another SPI device the problems start. So send me some code you knows works and I will test it.

  2. I see to be able to attach pics I need to put them out on the internet first and then link. I have no internet location to do that. The same is with the code. So why don’t you send me your email address and I can send the pics t o you along with the code I am using.

If you send the code example and it works, #2 may not be necessary.

I think the bottomline here deals with how is SPI configured in the 1-ch module. I have traced back all the signals indicated by the SF schematic to the actual ESP32-WROOM and they all match. (Although I am confused as to why you used IO16/pin 27 for the “RFM_CS” rather then the “CSO_H / IO15/pin 23” which is the normal CS_H pin. I see you never brought it out of the WROOM to the module pins)

So it appears you are using the so called “H” SPI for the RFM95 communications. What are the labeled module pins, called out of the module MISO, MOSI, SCK? Are they “H” or “V”

If you provided a working example code for the SPI, as you would use if addressing a device that communicates using SPI, like a microSD, I am sure all the confusion would be resolved.

Brandon Williams,

You have not responded to my inputs after you replied, can you update me please?

I’ve tried hooking up an SD card breakout to the module several ways and I’m having issues as well. I’ve looked into the schematic and there are several pin decisions that could be the culprits. At this point, I’ve reached out to a member of our engineering team to see if I can get more information. I apologize for the inconvenience this issue may be causing.

Thank you for your time and input. Hopefully, the solution will be soon and fast. I will get back to you when I have more information.

Good news, thus far. I’ve wired up and microSD breakout to a WRL-15006 and took a dive into the libraries for the SD libraries and SPI libraries.

At first, I wasn’t able to connect to the card as you indicated as well. You were correct about pin IO16/RFM_CS. It is hardwired to the LoRa Module. For that reason, I tried skimming through the SD and SPI source files to see if there were any workarounds.

SD.begin() is defined in the source files as: ```
bool begin(uint8_t ssPin=SS, SPIClass &spi=SPI, uint32_t frequency=4000000, const char * mountpoint=“/sd”, uint8_t max_files=5);


Using SD_Test.ino that came with the SparkFun Arduino Examples for this board, I was able to successfully connect to my SD card by writing: ```
SD.begin(5) //IO5 for SD CS pin

I then got this output:

I spoke with an engineer about the gibberish you were experiencing. The best deduction was that, by default, the ESP32 outputs a particular output during/after startup. That output may be at a default baud rate and not your declared baud rate, so things could get a bit jumbled.

If you have issues beyond this point and you’re using custom code or anything of that nature, my best suggestion would be to incrementally test each code feature until something breaks.

I hope this helps and I apologize for the delays. I would also suggest that if you have comments or questions software related, then please feel free to post [GitHub issues for this product and files. That way we can improve our software in the future.](GitHub - sparkfun/ESP32_LoRa_1Ch_Gateway: ESP32+RFM95 = Single-channel LoRa WiFI Gateway (or device!))