Initially asked for confirmation of the actual LORA pins and how to connect to an Arduino.
Got confirmation as to the correct connections to a MEGA. Also confirmed that actual SPI connections are not required as the pins: int pin_cs = 41; int pin_dio0 = 0; int pin_nrst = 33;
int pin_dio1 = 34, are the SPI connections. Issue is with MEGA pin 0 is the RX UART so when a devcie is connected to that pin it overrides the USB programming port.
The other issue is where is the documentation that explains error codes? I am getting error code -2, and error code -16.
Can you share what LoRa module you are using? Is there a library that you are using to that is giving you these error codes or does this happen when compiling the code?
This is the board I wanted as that is why I ordered it.
The first enquiry I had was to try to find an actual connection diagram, there are many other sensor and lora tutorials that include an actual physical wiring diagram from the device to the Arduino. I have not been able to find one.
I have studied the RadioLib github at length and cannot find to the incorrect SPI bus connections.
Thanks for responding, will assist in any other way.
It’s the use of MEGA pin 0 that is the issue, not the SPX1276 pin_DI0. The other confusion is that the SPX1276 pins are labelled as: D0, D1, D2 etc, not DI0, DI1, etc.
Another MEGA pin could be used but will the correct signalling be applied from that other pin? There must be some technical reason for initially using MEGA pin 0?
If you could share some images of your current setup and the code you are currently running we can dive deeper into the problem.
If you look at the schematic for this board the pins on the E19-915M30S module are named DI0, DI1, etc. These line up with pins D0, D1, and onwards, so there is no need to worry about this.
And last question, where did you get the pinout you are following to connect the Mega to the LoRa breakout?
There is no technical difference between Mega pin 0 and the other digital pins. Some Mega pins do have a technical difference, in whether or not they support PWM and exactly which PWM frequencies can be used. I don’t think PWM is relevant in this case, and anyway pin 0 isn’t a PWM pin. Pin 0 is actually a poor choice but perhaps the original configuration used when this sketch was implemented forced that choice for some reason. If you aren’t using other pins for other purposes then go ahead and test it out with any other pin - it won’t hurt to try.
There is a difference between Pin 0 and other MEGA digital pins. It is the RX pin for the UART 0. So if the sketch is using that pin to do something it will matter.
I tried changing to MEGA pin 2, physical wiring change, and altered the line in the sketch:
int pin_di0 = 2; // was 0
No difference to the operation, still returned an error:
Yes - the comment should have been “There is no technical difference between ATMega2560 pin 0 and the other digital pins”. In other words there is no technical reason for choosing this pin.
However, in the Arduino Mega development board the ATMega2560 pin 0 is wired to the ATMega16U2 used for the USB interface, which is why it is a poor choice in this application and why you should try the sketch using any other digital pin. Pin 2 is fine for this choice. If that didn’t solve the problem then either pin 0 was not the cause or there was a good reason for using pin 0, even though there is no technical difference.
The original configuration would likely work just fine with Pin 0 if the sketch did not create a Serial object, which is quite possible with the Mega because it has multiple hardware UARTs. So the other change is to check if Serial is being used and if it is then either remove it or change it to Serial1 and debug through that port instead of the USB connection. If that doesn’t work then I would conclude that Pin 0 is not the problem and you can continue debugging with whatever configuration is most convenient. Leaving the code exactly as provided and using an alternative debugging console would be my preference.
Further to this forum topic: I have the SPX1276 working using a MEGA board. My issue was that I had the SDO and SDI pins on the SPX swapped around when connected to the SPI connections on the MEGA.
The SDO pin goes to MEGA pin 50, which is labelled as MISO, and the SDI pin goes to MEGA pin 51, which is labelled as MOSI.
Regarding the issue with the sketch suggesting MEGA pin 0, disconnecting this pin before uploading the sketch, and then reconnecting it after loading the sketch also caused the SPX to work. Another option is to just use another MEGA pin other than 0, (I used D2), and included the pin numbers in the sketch on line:
SX1276 radio = new Module(pin_cs, pin_dio0, pin_nrst, pin_dio1);
just replace the pin_cs with the actual MEGA pin number that is suggested in the sketch: 41.
Do the same with the other pins in the brackets; pin_di0 becomes 2.
With the transmitter working the next step is to configure and code the receiver.