0

I am looking to use the adafruit rfm95w(https://www.adafruit.com/product/3231) on top of the adafruit huzzah esp8266(https://learn.adafruit.com/adafruit-fea ... 6/overview) and an SPI sd card breakout. I have wired it up correctly, and have it working without the rfm95w lora module, however, when i put the rfm95w featherwing on it, things break, and I get a crash on boot. specifically: ets Jan 8 2013,rst cause:2, boot mode:(3,7)

load 0x4010f000, len 1392, room 16
tail 0
chksum 0xd0
csum 0xd0
v3d128e5c
~ld
Feather LoRa RX Test!
ERROR: Failed to put device in LoRa mode.
RH_RF95_REG_01_OP_MODE: FF
LoRa radio init failed
Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info

I am thinking it is because both the SD card and the LoRa module use the same SPI pins, so I have moved the chip select of my SD card to gpio0 while the chip select of the LoRa module is on gpio2

commenting out the SD card stuff makes the LoRa stuff work just fine again. I tried to define pin 0 as an output and putting it low after i am done with the SD card, I would hope i could toggle between both the LoRa module and the SD card in the future... but I don't know if that will happen. here is a copy of my code:

// Feather9x_RX
// -*- mode: C++ -*-
// Example sketch showing how to create a simple messaging client (receiver)
// with the RH_RF95 class. RH_RF95 class does not provide for addressing or
// reliability, so you should only use RH_RF95 if you do not need the higher
// level messaging abilities.
// It is designed to work with the other example Feather9x_TX

#include <SPI.h>
#include <SD.h>
#include <RH_RF95.h>

File root;
int sd_CS = 0;

#define RFM95_CS  2    // "E"
#define RFM95_RST 16   // "D"
#define RFM95_INT 15   // "B"


// Change to 434.0 or other frequency, must match RX's freq!
#define RF95_FREQ 900.0

// Singleton instance of the radio driver
RH_RF95 rf95(RFM95_CS, RFM95_INT);

// Blinky on receipt
#define LED 13

void setup()
{
  pinMode(LED, OUTPUT);
  pinMode(RFM95_RST, OUTPUT);
  digitalWrite(RFM95_RST, HIGH);

  Serial.begin(115200);
  while (!Serial) {
    delay(1);
  }
  delay(100);


  // START SD CARD STUFF
  // Open serial communications and wait for port to open:
//  pinMode(sd_CS, OUTPUT);
//  digitalWrite(sd_CS, HIGH);
//  Serial.print("Initializing SD card...");
//  if (!SD.begin(sd_CS)) {
//    Serial.println("initialization failed!");
//    while (1);
//  }
//  Serial.println("initialization done.");
//  root = SD.open("/");
//  printDirectory(root, 0);
//  Serial.println("done!");
//  delay(10);
//  digitalWrite(sd_CS, LOW);
  // END SD CARD STUFF


  Serial.println("Feather LoRa RX Test!");
  // manual reset
  digitalWrite(RFM95_RST, LOW);
  delay(10);
  digitalWrite(RFM95_RST, HIGH);
  delay(10);

  while (!rf95.init()) {
    Serial.println("LoRa radio init failed");
    Serial.println("Uncomment '#define SERIAL_DEBUG' in RH_RF95.cpp for detailed debug info");
    while (1);
  }
  Serial.println("LoRa radio init OK!");

  // Defaults after init are 434.0MHz, modulation GFSK_Rb250Fd250, +13dbM
  if (!rf95.setFrequency(RF95_FREQ)) {
    Serial.println("setFrequency failed");
    while (1);
  }
  Serial.print("Set Freq to: "); Serial.println(RF95_FREQ);

  // Defaults after init are 434.0MHz, 13dBm, Bw = 125 kHz, Cr = 4/5, Sf = 128chips/symbol, CRC on

  // The default transmitter power is 13dBm, using PA_BOOST.
  // If you are using RFM95/96/97/98 modules which uses the PA_BOOST transmitter pin, then
  // you can set transmitter powers from 5 to 23 dBm:
  rf95.setTxPower(23, false);
}

void printDirectory(File dir, int numTabs) {
  while (true) {

    File entry =  dir.openNextFile();
    if (! entry) {
      // no more files
      break;
    }
    for (uint8_t i = 0; i < numTabs; i++) {
      Serial.print('\t');
    }
    Serial.print(entry.name());
    if (entry.isDirectory()) {
      Serial.println("/");
      printDirectory(entry, numTabs + 1);
    } else {
      // files have sizes, directories do not
      Serial.print("\t\t");
      Serial.println(entry.size(), DEC);
    }
    entry.close();
  }
}

void loop()
{
  if (rf95.available())
  {
    // Should be a message for us now
    uint8_t buf[RH_RF95_MAX_MESSAGE_LEN];
    uint8_t len = sizeof(buf);

    if (rf95.recv(buf, &len))
    {
      digitalWrite(LED, HIGH);
      RH_RF95::printBuffer("Received: ", buf, len);
      Serial.print("Got: ");
      Serial.println((char*)buf);
       Serial.print("RSSI: ");
      Serial.println(rf95.lastRssi(), DEC);

      // Send a reply
      uint8_t data[] = "And hello back to you";
      rf95.send(data, sizeof(data));
      rf95.waitPacketSent();
      Serial.println("Sent a reply");
      digitalWrite(LED, LOW);
    }
    else
    {
      Serial.println("Receive failed");
    }
  }
}

I have commented out the SD Card stuff in this snippet.

Does anyone see where I am going wrong here, do I need to add more detail to this question? Any advice would be much appreciated!

  • what SD card breakout? one with 5 V conversion? – Juraj Feb 25 at 6:02
  • yes, and I am running it through the USB (5v) pin. If i run it on the 3.3v pin it errors immediately. The sd breakout works just fine without the LoRa Radio connected. Speciffically, I have a CATALEX v1.0 MicroSD card adapter. It came from catalex.taobao.com, however the link no longer works :( – user77533 Feb 25 at 7:09
  • 1
    this adapters hold the MISO HIGH (lthe level conversion chip) so no other device can use the bus. but you have a 3.3 V MCU and a 3.3 V SD card, so you don't need logic level conversion at all. buy a simple holder or create one from a micro to normal SD card adapter. – Juraj Feb 25 at 7:45
  • i.stack.imgur.com/urotx.jpg – Juraj Feb 28 at 6:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.