Skip to content
  • MySensors
  • OpenHardware.io
  • Categories
  • Recent
  • Tags
  • Popular
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo
  1. Home
  2. Development
  3. Check if (and which) SPI devices is connected (NRF24L01 and SX1278 LoRa modules)

Check if (and which) SPI devices is connected (NRF24L01 and SX1278 LoRa modules)

Scheduled Pinned Locked Moved Development
3 Posts 3 Posters 58 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ROUGEXIIIR Offline
    ROUGEXIIIR Offline
    ROUGEXIII
    wrote on last edited by
    #1

    Hi,

    I Have a small arduino atmega 328p based sensor board.
    I want too be able to choose which wireless board (NRF24L01 or SX1278) I hard connect to it without reprogramming it, it may be fast and useful for my distance tests.

    I actually use those libraries separately with success :

    • #include <nRF24L01.h> // git clone https://github.com/nRF24
    • #include <LoRa.h> // git clone https://github.com/sandeepmistry/arduino-LoRa.git

    The problem is that if I use one library with the matching chip disconnected, when I will initialise it, my atmega will freeze (get stuck and do nothing).
    So I wonder how to check if a SPI module is physically connected and how recognize which one it is so I could initialise the corresponding library or simply go to deep sleep.

    How could I easily do this SPI check?

    Thanks for reading, sorry for my poor English level :/

    1 Reply Last reply
    1
    • refh hrefR Offline
      refh hrefR Offline
      refh href
      wrote on last edited by
      #2

      Has any other individual thought about utilizing FM/RBDS/RDS for correspondence? I have a task I've been taking a shot at where I have to transmit a smidgen of information in addition to I have to transmit and get voice. I think utilizing the FM band for the voice comm and RBDS/RDS for the information may be perfect however I haven't gotten around to prototyping it yet and I haven't found any reports of individuals who may have attempted it. I notice it is certainly not on this rundown.

      1 Reply Last reply
      0
      • N Offline
        N Offline
        niclas
        wrote on last edited by
        #3

        Well.. The quick answer I guess would be Yes, it is possible. But I imagine you would need to know a little bit about how the different components work. I also use the LoRa library from Sandeep Mistry and if you take a look at the code that initializes the card you find the following:

          // check version
          uint8_t version = readRegister(REG_VERSION);
          if (version != 0x12) {
            return 0;
          }
        

        Which is using the function readRegister:

        uint8_t LoRaClass::readRegister(uint8_t address)
        {
          return singleTransfer(address & 0x7f, 0x00);
        }
        

        Which is using the function singleTransfer:

        uint8_t LoRaClass::singleTransfer(uint8_t address, uint8_t value)
        {
          uint8_t response;
        
          digitalWrite(_ss, LOW);
        
          _spi->beginTransaction(_spiSettings);
          _spi->transfer(address);
          response = _spi->transfer(value);
          _spi->endTransaction();
        
          digitalWrite(_ss, HIGH);
        
          return response;
        }
        

        Which is using pretty simple SPI commands. So perhaps you could do the same and select the LoRa library if the version is 0x12 or else select the nRF library.

        I don't know if there is enough space on the 328p to load both the libraries? And if you want to use the mysensors library it would be more complicated i suppose..

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        12

        Online

        11.7k

        Users

        11.2k

        Topics

        113.1k

        Posts


        Copyright 2025 TBD   |   Forum Guidelines   |   Privacy Policy   |   Terms of Service
        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • MySensors
        • OpenHardware.io
        • Categories
        • Recent
        • Tags
        • Popular