I'm playing around with the SX127x library in a large project, and have some problems using the HW SPI with the SX127x module.
I've boiled an example down based on the example code.
This works (soft SPI):
// Pins
const PIN_SCK = D5;
const PIN_MISO = D18;
const PIN_MOSI = D23;
const PIN_CS = D19; // NSS
const PIN_RESET = D21;
// Configuration
const txConfig = {
bandwidth: 0,
freq: 434330000,
power: 17,
forcePaBoost: true,
};
// Setup
const spi = new SPI();
spi.setup({ sck: PIN_SCK, miso: PIN_MISO, mosi: PIN_MOSI });
var sx = require("SX127x").connect({ spi: spi, cs: PIN_CS, rst: PIN_RESET });
// Poll DIO0 for interrupts
setInterval(function () { sx.onIRQ(); }, 100);
sx.setTxConfig(txConfig);
// This one uses an interval, to show that it works continuously
setInterval(() => {
sx.send("Hello", function () {
console.log("TX done");
});
}, 500);
But this doesn't (HW SPI, same txConfig, same pins):
// Setup
SPI1.setup({ sck: PIN_SCK, miso: PIN_MISO, mosi: PIN_MOSI });
var sx = require("SX127x").connect({ spi: SPI1, cs: PIN_CS, rst: PIN_RESET });
// Poll DIO0 for interrupts
setInterval(function () { sx.onIRQ(); }, 100);
sx.setTxConfig(txConfig);
// This one is just "locked" in a state of constant transmission (see screen capture)
sx.send("Hello", function () {
console.log("TX done");
});
My LoRa module is the AI Thinker RA-02.
Anyone have an idea as to why 🙂?
I've attached examples of the captured radio outputs, but I think I've boiled it down to the HW SPI being off in some way, and not setting the radio up properly to begin with.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Hey 👋,
I'm playing around with the SX127x library in a large project, and have some problems using the HW SPI with the SX127x module.
I've boiled an example down based on the example code.
This works (soft SPI):
But this doesn't (HW SPI, same
txConfig
, same pins):My LoRa module is the AI Thinker RA-02.
Anyone have an idea as to why 🙂?
I've attached examples of the captured radio outputs, but I think I've boiled it down to the HW SPI being off in some way, and not setting the radio up properly to begin with.
2 Attachments