I built an irrigation monitor / controller that uses LoRa (RA-02) to send pressure and other data to other devices that make up a automation framework on our farm.
I have been using EEPROM to continually save all critcal data so that whenever the system is restarted by the watch dog timer or it is manually reset, it grabs this data and continues seemlessly with its operations. This specific unit controls a centre pivot so it is quite important to continue with the current program after resets.
With the dependability of EEPROM declining with extended use I wrote the code to continually move where I save data into the EEPROM, to spread usage over the whole block, apparently 4kb worth on the MEGA.
I have one device set up elsewhere that has started reading garbage from the EEPROM after restart, I'm assuming some of the blocks have reached the limit of reading writing. This device writes pressure and other data into the EEPROM every second or so, so its heavy traffic and has been working for some months.
NOW - I'm attempting to change from writing to EEPROM to an SD logger. Problem is that the LoRa module already uses the SPI bus, so as soon as I connect the SD logger, the logger works, but LoRa stops working.
Currently the LoRa unit is connected like so:
MOSI - 51
MISO - 50
SCK - 52
CS - 10
Then I connected the SD logger to the ICSP header pins with the CS lead connected to 53.
The SD logger always works, regardless if the LoRa is connected or not. But the LoRa never works while the SD logger is powered up.
Question: Is it possible to get both working at the same time? Or is there another (better / easier) way to save fast coming data that is needed after each reboot?
I did not change the state - first time messing with SPI in this way. Which one of the two should I change, and to high or low, before or after accessing the device?
I did not change the state - first time messing with SPI in this way.
CS = "chip select".
It is essential that only one device is active at any one time. You do that by changing the appropriate CS pins on both devices, every time you switch between them. Usually the libraries do this for you.
Consult the device documentation to determine whether HIGH or LOW selects and activates the device.