A library for Cayenne LPP
Recently I had to do a few projects using LoPy boards, The Things Network and its Cayenne Integration to quickly build some dashboard.
In order to use the integration, the packets send by the LoPy should use the in the Low Power Payload format.
To facilitate that, I made a simple library and thought I would share it with you since it could be useful to someone else. It is available on GitHub.
The type of sensors compatible with this library are:
- digital input/output;
- analog input/output;
- luminosity (or illuminance) sensor;
- presence sensor;
- temperature sensor;
- humidity sensor;
- and gps.
Here is a small example of how it works, assuming that the network join has already been done:
import socket # importing the module import cayenneLPP # create a LoRa socket s = socket.socket(socket.AF_LORA, socket.SOCK_RAW) s.setsockopt(socket.SOL_LORA, socket.SO_DR, 0) s.setblocking(True) # creating Cayenne LPP packet lpp = cayenneLPP.CayenneLPP(size = 100, sock = s) # adding 2 digital outputs, the first one uses the default channel lpp.add_digital_input(True) lpp.add_digital_input(False, channel = 112) # sending the packet via the socket lpp.send()
There are some other examples in the GithHub repo.
Hope it help :)
Thanks for sharing this with the rest of the community, it looks very useful and very well documented!