Code examples and extended information
In the Waspmote Development section you can find complete examples:
Example:
#include <WaspSX1272.h>
#include <WaspFrame.h>
// variable to show the flag from some functions
int e;
void setup()
{
// Init USB port
USB.ON();
USB.println(F("SX1272 module TX in LoRa, complete example"));
// Init SX1272 module
sx1272.ON();
// Select frequency channel
e = sx1272.setChannel(CH_11_868);
USB.print("Setting Channel: state ");
USB.println(e);
// Select implicit (off) or explicit (on) header mode
e = sx1272.setHeaderON();
USB.print("Setting Header ON: state ");
USB.println(e);
// Select mode (mode 1 is the better reach one)
e = sx1272.setMode(1);
USB.print("Setting Mode 1: state ");
USB.println(e);
// select CRC on or off
e = sx1272.setCRC_ON();
USB.print("Setting CRC on: state ");
USB.println(e);
// Select output power (Max, High or Low)
e = sx1272.setPower('H');
USB.print("Setting Power: state ");
USB.println(e);
// Select the node address value
e = sx1272.setNodeAddress(6);
USB.print("Setting Node Address: state ");
USB.println(e);
delay(1000);
USB.println(F("Configuration finished"));
}
void loop()
{
// Creating frame to send
frame.createFrame(ASCII,"WASP_PRO");
// Adding sensor battery
frame.addSensor(SENSOR_BAT, (uint8_t) PWR.getBatteryLevel());
// Printing frame via USB
frame.showFrame();
// Sending packet with timeout protection
sx1272.sendPacketTimeout(5, frame.buffer, frame.length);
delay(1000);
}
Last updated