Check if (and which) SPI devices is connected (NRF24L01 and SX1278 LoRa modules)
-
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
-
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.
-
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..