SX1268Library 1.0.5
dotnet add package SX1268Library --version 1.0.5
NuGet\Install-Package SX1268Library -Version 1.0.5
<PackageReference Include="SX1268Library" Version="1.0.5" />
<PackageVersion Include="SX1268Library" Version="1.0.5" />
<PackageReference Include="SX1268Library" />
paket add SX1268Library --version 1.0.5
#r "nuget: SX1268Library, 1.0.5"
#:package SX1268Library@1.0.5
#addin nuget:?package=SX1268Library&version=1.0.5
#tool nuget:?package=SX1268Library&version=1.0.5
SX1268Library
This library simplifies control of SX1268 LoRa HAT module in C#. The library is designed and configured to run on a Raspberry Pi 4.
Usage
All samples below assume that LoRa HAT is exposed on /dev/serial0 on a Raspberry Pi 4. Please visit SX1268 Wiki for details about configuring the module for Raspberry Pi.
Below is a short snippet to send data over LoRa using Raspberry Pi 4, without modifying module configuration.
var module = SX1268.CreateRaspberryPi("/dev/serial0"); var bytes = Encoding.ASCII.GetBytes("Hello World!"); module.SendData(bytes);- Similarly, one can create an instance for Jetson by calling
SX1268.CreateJetsonOrinNano("/dev/serial0")orSX1268.CreateJetsonAlternative("/dev/serial0"), depending on how Jetson is setup.
- Similarly, one can create an instance for Jetson by calling
It is possible to modify various properties of the module on initialization, by passing a
SX1268Configurationinstance to the constructor. This method requires one to explicitly state all GPIO pins to be used (for M0 and M1 pins of SX126x module)var config = new SX1268Configuration() { AirSpeed = RATE_9K6, BufferSize = SIZE_128B, Power = POWER_22DBM }; var module = new SX1268("/dev/serial0", 22, 27, config); var bytes = Encoding.ASCII.GetBytes("Hello World!"); module.SendData(bytes);Changing module properties can also be done after the class is initialized.
var config = new SX1268Configuration() { AirSpeed = RATE_9K6, BufferSize = SIZE_128B, Power = POWER_22DBM }; var module = SX1268.CreateRaspberryPi("/dev/serial0"); var bytes = Encoding.ASCII.GetBytes("Old configuration"); // Send with the old configuration. module.SendData(bytes); // Modify some of the properties. module.SetConfiguration(config); // Send with the new configuration. bytes = Encoding.ASCII.GetBytes("New configuration"); module.SendData(bytes);To receive data from the module, one can use the
DataReceivedevent.var config = new SX1268Configuration() { AirSpeed = RATE_9K6, BufferSize = SIZE_128B, Power = POWER_22DBM }; var module = SX1268.CreateRaspberryPi("/dev/serial0"); module.DataAvailable += (sender, args) => { Console.WriteLine($"Received {args.Payload.Length} bytes: {Encoding.ASCII.GetString(args.Payload)}"); }
Credits
This project is solely based on SX126x binaries & source code package provided in SX1268 Wiki page.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- System.Device.Gpio (>= 4.1.0)
- System.IO.Ports (>= 10.0.5)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.