Welcome to the Pycom forum Forum
    • \[\[global:header.categories\]\]
    • \[\[global:header.recent\]\]
    • \[\[global:header.tags\]\]
    • \[\[global:header.popular\]\]
    • Login

    Explore Pybytes | Official Documentation | Report a Firmware Bug/Issue | GitHub

    A library for Cayenne LPP

    Scheduled Pinned Locked Moved LoPy
    cayenne lpplopyttn
    5 Posts 3 Posters 2.6k Views 4 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      jojo
      last edited by jojo

      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)
      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 :)

      Cheers,

      Johan

      1 Reply Last reply Reply Quote 4
      • sebS Offline
        seb
        last edited by

        @jojo said in A library for Cayenne LPP:

        GitHub

        Hi,

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

        1 Reply Last reply Reply Quote 0
        • M Offline
          miroslav.petrov
          last edited by

          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!

          J 1 Reply Last reply Reply Quote 0
          • J Offline
            jojo @miroslav.petrov
            last edited by jojo

            @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.

            M 1 Reply Last reply Reply Quote 0
            • M Offline
              miroslav.petrov @jojo
              last edited by

              @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.

              1 Reply Last reply Reply Quote 0

              Hello! It looks like you're interested in this conversation, but you don't have an account yet.

              Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

              With your input, this post could be even better 💗

              Register Login
              • 1 / 1
              • First post
                Last post

              Pycom on Twitter

              Pycom