Makerfabs / Lora-Soil-Moisture-Sensor

Lora Soil Moisture Sensor
53 stars 23 forks source link

ESP32 [SX1278] Initializing ... failed, code -2 #8

Open mconlow opened 2 years ago

mconlow commented 2 years ago

Hi,

I'm trying to get the ESP32 receiver to work with the Lora Soil Moisture Sensor. I have RadioLib 4.6.0, though it doesn't specify anywhere exactly what version I should use. I'm in the U.S.

The relevant part of my code is:

//SX1278 radio = new Module(LORA_CS, DIO0, LORA_RST, DIO1);
// SX1278 radio = new Module(LORA_CS, DIO0, LORA_RST, DIO1, SPI, SPISettings());  //433Mhz
SX1276 radio = new Module(LORA_CS, DIO0, LORA_RST, DIO1, SPI, SPISettings()); //868Mhz or 915Mhz

// or using RadioShield
// https://github.com/jgromes/RadioShield
//SX1278 radio = RadioShield.ModuleA;

void setup()
{
    Serial.begin(115200);

    // initialize SX1278 with default settings
    Serial.print(F("[SX1278] Initializing ... "));
    SPI.begin(SPI_SCK, SPI_MISO, SPI_MOSI);
    int state = radio.begin(FREQUENCY, BANDWIDTH, SPREADING_FACTOR, CODING_RATE, SX127X_SYNC_WORD, OUTPUT_POWER, PREAMBLE_LEN, GAIN);
    //int state = radio.begin();
    if (state == ERR_NONE)
    {
        Serial.println(F("success!"));
    }
    else
    {
        Serial.print(F("failed, code "));
        Serial.println(state);
        while (true)
            ;
    }

I've also tried the first line SX1278 radio = new Module(LORA_CS, DIO0, LORA_RST, DIO1); instead of the third line. In each case I get [SX1278] Initializing ... failed, code -2

Thanks