On this page
LoRa
Note: The code snippets in this article are intended for Mita version 1a1ed7881e2220895ec60ce4f657972538c43195 and XDK-Workbench versions 3.4.0 and higher.
LoRa is a low-power network for IoT. Since bandwidth is usually extremely limited you should only send small messages infrequently. In this implementation there are two ways to send data: either raw bytes or CayenneLPP messages, a serializable predefined format.
Receiving messages is currently not supported.
Example
setup lora: LoRa {
region = EU;
loraAppKey = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
loraAppEui = [0,0,0,0,0,0,0,0];
var r = raw(0, Unconfirmed);
var c = cayenne(1, Confirmed);
}
every 1 hour {
let data = new array(1);
data[0] = CayennePayload.Accelerometer(
accelerometer.x_axis.read() as int16,
accelerometer.y_axis.read() as int16,
accelerometer.z_axis.read() as int16
);
lora.c.write(data);
}
every 10 minutes {
let data: array = [0xCA, 0xFE];
lora.r.write(data);
}
Configuration
Signals
Cayenne Messages
The following CayenneLPP messages are supported via a sum type:
alt CayennePayload {
DigitalInput: uint8
| DigitalOutput: uint8
| AnalogInput: int16
| AnalogOutput: int16
| IlluminanceSensor: uint16
| PresenceSensor: uint8
| TemperatureSensor: int16
| HumiditySensor: uint8
| Accelerometer: int16, int16, int16
| Barometer: uint16
| Gyrometer: int16, int16, int16
| GpsLocation: {Latitude: int32, Longitude: int32, Altitude: int32}
}
Constructing them works like in the example above or as described in the documentation of sum types. For example to create a GPS location message type CayennePayload.GpsLocation(Latitude=lat, Altitude=alt, Longitude=lon)
.
Further information about integration into Cayenne can be read here.