Skip to content

Commit 8188ba3

Browse files
committed
Update user manual content: add libs links and Lora example
1 parent feb4900 commit 8188ba3

File tree

1 file changed

+81
-4
lines changed
  • content/hardware/09.kits/maker/nesso-n1/tutorials/user-manual

1 file changed

+81
-4
lines changed

content/hardware/09.kits/maker/nesso-n1/tutorials/user-manual/content.md

Lines changed: 81 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ The Nesso N1 features a 1.14-inch IPS color touchscreen with a resolution of 135
293293
- **Display Controller**: ST7789, controlled via SPI.
294294
- **Touch Controller**: FT6336U, controlled via I2C.
295295

296-
The display can be programmed using the **M5GFX** library, which can be installed using the Arduino IDE Library Manager.
296+
The display can be programmed using the [**M5GFX**](https://github.com/m5stack/M5GFX) library, which can be installed using the Arduino IDE Library Manager.
297297

298298
Here is an example to display touch input as text on the screen:
299299

@@ -369,17 +369,27 @@ The LoRa® module is controlled via SPI and several dedicated pins on both the E
369369
| `LORA_ANTENNA_SWITCH` | | E0.P6 | LoRa® RF Antenna Switch Control |
370370
| `LORA_ENABLE` | | E0.P7 | LoRa® Module Reset/Enable |
371371

372-
Here is a simple example to send a LoRa® packet using the [RadioLib](https://github.com/jgromes/RadioLib) library:
372+
#### LoRa® Transmitter Example
373+
374+
Here is a simple example to send a "Hello World!" packet every five seconds using [RadioLib](https://github.com/jgromes/RadioLib) library.
373375

374376
```arduino
375377
#include <RadioLib.h>
376378
377-
// Create an SX1262 radio object
378-
SX1262 radio = new Module(LORA_CS, LORA_IRQ, LORA_ENABLE, LORA_BUSY);
379+
// Initialize the radio module, passing RADIOLIB_NC for the reset pin.
380+
// The reset will be handled manually.
381+
SX1262 radio = new Module(LORA_CS, LORA_IRQ, RADIOLIB_NC, LORA_BUSY);
379382
380383
void setup() {
381384
Serial.begin(115200);
382385
386+
// Manually reset the LoRa module using the expander pin for reliability.
387+
pinMode(LORA_ENABLE, OUTPUT);
388+
digitalWrite(LORA_ENABLE, LOW);
389+
delay(10);
390+
digitalWrite(LORA_ENABLE, HIGH);
391+
delay(10);
392+
383393
// Initialize the LoRa® module
384394
// Frequency: 915.0 MHz
385395
int state = radio.begin(915.0);
@@ -407,6 +417,73 @@ void loop() {
407417
}
408418
```
409419

420+
421+
#### LoRa® Receiver Example
422+
423+
This example listens for packets and prints them to the Serial Monitor. It uses a simple polling method where the main loop waits until a packet is received. Upload this code to a second Nesso N1 to receive messages from the transmitter.
424+
425+
```arduino
426+
#include <RadioLib.h>
427+
428+
// Initialize the radio module, passing RADIOLIB_NC for the reset pin.
429+
SX1262 radio = new Module(LORA_CS, LORA_IRQ, RADIOLIB_NC, LORA_BUSY);
430+
431+
void setup() {
432+
Serial.begin(115200);
433+
434+
// Manually reset the LoRa module.
435+
pinMode(LORA_ENABLE, OUTPUT);
436+
digitalWrite(LORA_ENABLE, LOW);
437+
delay(10);
438+
digitalWrite(LORA_ENABLE, HIGH);
439+
delay(10);
440+
441+
// Initialize the LoRa® module.
442+
int state = radio.begin(915.0);
443+
if (state != RADIOLIB_ERR_NONE) {
444+
Serial.print(F("failed, code "));
445+
Serial.println(state);
446+
while (true);
447+
}
448+
449+
// Start listening for LoRa packets.
450+
Serial.print(F("[SX1262] Starting to listen... "));
451+
state = radio.startReceive();
452+
if (state != RADIOLIB_ERR_NONE) {
453+
Serial.print(F("failed, code "));
454+
Serial.println(state);
455+
while (true);
456+
}
457+
}
458+
459+
void loop() {
460+
// Check if a packet is available.
461+
int state = radio.readData(str);
462+
463+
if (state == RADIOLIB_ERR_NONE) {
464+
// Packet was received successfully.
465+
Serial.print(F("[SX1262] Received packet: "));
466+
Serial.println(str);
467+
468+
// Print packet statistics.
469+
Serial.print(F("[SX1262] RSSI: "));
470+
Serial.print(radio.getRSSI());
471+
Serial.print(F(" dBm, SNR: "));
472+
Serial.print(radio.getSNR());
473+
Serial.println(F(" dB"));
474+
475+
} else if (state == RADIOLIB_ERR_CRC_MISMATCH) {
476+
Serial.println(F("[SX1262] CRC error!"));
477+
} else if (state != RADIOLIB_ERR_RX_TIMEOUT) {
478+
// Some other error occurred. Timeout is expected and ignored.
479+
Serial.print(F("[SX1262] Failed, code "));
480+
Serial.println(state);
481+
}
482+
}
483+
```
484+
485+
***Please note: because the `LORA_ENABLE` pin is on an I/O expander, it cannot be passed directly to the RadioLib library constructor. The library must be initialized with the reset pin set to `RADIOLIB_NC` and is best practice to perform a manual reset in setup.***
486+
410487
## Onboard Sensors & Peripherals
411488

412489
### 6-Axis IMU

0 commit comments

Comments
 (0)