Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SX1262 Sleep #740

Closed
lvplummer opened this issue May 2, 2023 · 15 comments
Closed

SX1262 Sleep #740

lvplummer opened this issue May 2, 2023 · 15 comments
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)

Comments

@lvplummer
Copy link

My board is very simple - Arduino UNO chip and crystal with no regulator or serial interrace - battery powered. I made two changes to your transmit example without interrupts: pin assignments to match my board and serial baud rate changed to 115200.

I turned on debug and compiled your blocking SX1262 transmit example. Here are the results from that:

18:03:36.088 -> [SX1262] Initializing ... Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:
18:03:36.088 -> 0000320 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 | SX1261 V2D 2D02.
18:03:36.088 ->
18:03:36.088 -> M SX126x
18:03:36.088 -> Symbol length: 4719 ms
18:03:36.136 -> Symbol length: 4719 ms
18:03:36.136 -> Symbol length: 4719 ms
18:03:36.136 -> success!
18:03:36.136 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:03:36.278 -> success!
18:03:36.278 -> [SX1262] Datarate: 567.64 bps
18:03:37.273 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:03:37.462 -> success!
18:03:37.462 -> [SX1262] Datarate: 567.64 bps
18:03:38.455 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:03:38.643 -> success!
18:03:38.643 -> [SX1262] Datarate: 567.64 bps
18:03:39.633 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:03:39.822 -> success!
18:03:39.822 -> [SX1262] Datarate: 567.64 bps
18:03:40.811 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:03:40.999 -> success!

I then inserted a radio.sleep() just before the one second delay.

} else {
// some other error occurred
Serial.print(F("failed, code "));
Serial.println(state);

}

radio.sleep();
// wait for a second before transmitting again
delay(1000);
}

Here are the results of that:

18:09:34.496 -> [SX1262] Initializing ... Found SX126x: RADIOLIB_SX126X_REG_VERSION_STRING:
18:09:34.496 -> 0000320 53 58 31 32 36 31 20 56 32 44 20 32 44 30 32 00 | SX1261 V2D 2D02.
18:09:34.496 ->
18:09:34.496 -> M SX126x
18:09:34.496 -> Symbol length: 4719 ms
18:09:34.544 -> Symbol length: 4719 ms
18:09:34.544 -> Symbol length: 4719 ms
18:09:34.544 -> success!
18:09:34.544 -> [SX1262] Transmitting packet ... Timeout in -8704 us
18:09:34.686 -> success!
18:09:34.686 -> [SX1262] Datarate: 567.70 bps
18:09:35.711 -> [SX1262] Transmitting packet ... Timed out waiting for GPIO pin, is it connected?
18:09:36.714 -> failed, code -705
18:09:37.708 -> [SX1262] Transmitting packet ... Timed out waiting for GPIO pin, is it connected?
18:09:38.694 -> failed, code -705
18:09:39.723 -> [SX1262] Transmitting packet ... Timed out waiting for GPIO pin, is it connected?
18:09:40.703 -> failed, code -705

The first transmission before the first sleep works correctly. Subsequent transmission fail.

@jgromes
Copy link
Owner

jgromes commented May 2, 2023

Thanks for the report, I was able to find this one quickly. There was a bug in waking up the SX126x device after it was put to sleep (the Arduino just timed out waiting for the BUSY signal to go low, which is not going to happen when the device is sleeping). I added a check to make sure that it will wakeup. Tested on Uno + SX1268, thanks for reporting!

@jgromes jgromes closed this as completed May 2, 2023
@jgromes jgromes added bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented) labels May 2, 2023
@lvplummer
Copy link
Author

lvplummer commented May 2, 2023 via email

@lvplummer
Copy link
Author

lvplummer commented May 2, 2023 via email

@jgromes
Copy link
Owner

jgromes commented May 2, 2023

I see - that's caused by the timeout while waiting for BUSY, which is one second.

I added additional parameter to the standby() method, so if the one second waiting time is critical for you, you can wakeup the module immediately like this:

radio.sleep();
// radio sleeping here
(...)

// OK, time to wake up
radio.standby(RADIOLIB_SX126X_STANDBY_RC, true);

// radio in standby, transmit
radio.transmit(...)

@lvplummer
Copy link
Author

lvplummer commented May 2, 2023 via email

@lvplummer
Copy link
Author

lvplummer commented May 2, 2023 via email

@jgromes
Copy link
Owner

jgromes commented May 3, 2023

That's interesting, couple of thoughts:

  1. Is there any difference between the SX126x module that works and the others? I'm guessing the rest of the hardware (the MCU, power etc.) is the same for all three.
  2. Could you run the module that does not work with both DEBUG and VERBOSE enabled?

@lvplummer
Copy link
Author

lvplummer commented May 3, 2023 via email

@jgromes
Copy link
Owner

jgromes commented May 3, 2023

OK, let me know if the issue pops up again, I'd like to get to the bottom of this.

@lvplummer
Copy link
Author

lvplummer commented May 3, 2023 via email

@lvplummer
Copy link
Author

lvplummer commented May 3, 2023 via email

@lvplummer
Copy link
Author

lvplummer commented May 3, 2023 via email

@lvplummer
Copy link
Author

lvplummer commented May 4, 2023 via email

@jgromes
Copy link
Owner

jgromes commented May 4, 2023

the CPU was running at about 4 MHz instead of 16 MHz

Thanks for letting me know - to be honest, I'm rather surprised it was working at all at that frequency, because the default SPI frequency is 2 MHz.

@lvplummer
Copy link
Author

lvplummer commented May 4, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working resolved Issue was resolved (e.g. bug fixed, or feature implemented)
Projects
None yet
Development

No branches or pull requests

2 participants