A library for Cayenne LPP

  • Hi all,

    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;
    • accelerometer;
    • barometer;
    • gyrometer;
    • 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)
    # 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(False, channel = 112)
    # sending the packet via the socket

    There are some other examples in the GithHub repo.

    Hope it help :)



  • @jojo

    The problem is that I have insufficient knowledge in python. I cannot write a working script that(for example) reads a DHT22 sensor and formats the data in LPP. Thats why I want a working example with a real sensor.

  • @miroslav-petrov

    Can you be a bit more specific when you say you have some difficulties using the library? Is it because you did not join the network? Or is it because you have troubles reading the data from a particular sensor?

    An example is available here for using the library with TTN. You simply need to fill you application credentials in the lines 31 and 32. Please note that this example assumes that you are using the frequency plan for Australia.

  • I have difficulties using the library. Can somebody share a working code with a real sensor(bme280, dht11/22,ds18b20 etc.)? I think many people would appreciate it!

  • @jojo said in A library for Cayenne LPP:



    Thanks for sharing this with the rest of the community, it looks very useful and very well documented!

Log in to reply

Pycom on Twitter