• OK, so I've replaced the pins with the ones you mention--but still struggle a little 🙂!

    Setup now looks like this (only the pins has changed):

    const PIN_SCK = D18;
    const PIN_MISO = D19;
    const PIN_MOSI = D23;
    const PIN_CS = D5;        // NSS
    const PIN_RESET = D21;
    
    // Configuration
    const txConfig = {
        bandwidth: 0,
        freq: 434330000,
        power: 17,
        forcePaBoost: true,
    };
    

    And the code like this:

    // Setup
    const spi = new SPI();
    spi.setup({ sck: PIN_SCK, miso: PIN_MISO, mosi: PIN_MOSI });
    const sx = require("SX127x").connect({ spi: spi, cs: PIN_CS, rst: PIN_RESET });
    
    // HW SPI (replace the three lines above)
    // SPI2.setup({ sck: PIN_SCK, miso: PIN_MISO, mosi: PIN_MOSI });
    // const sx = require("SX127x").connect({ spi: SPI2, cs: PIN_CS, rst: PIN_RESET });
    
    // Poll DIO0 for interrupts
    setInterval(function () { sx.onIRQ(); }, 100);
    sx.setTxConfig(txConfig);
    
    // Transmit
    sx.send("Hello", function () {
        console.log("TX done");
    });
    

    I've attached two screenshots of the SCK, MOSI and MISO, and it looks like nothing is happening on the MOSI line when using HW SPI with this example--I'm sure I just missed something obvious, I hope someone can spot it 😬🙌?

    (are there restrictions to the CS/RESET pins as well perhaps? Do I need to set the I/O "mode" for some of the pins manually? Do I need to specify more parameters when using HW- as opposed to SW SPI?)


    2 Attachments

    • HW SPI.png
    • SW SPI.png
About

Avatar for rj @rj started