element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Industrial Automation
  • Technologies
  • More
Industrial Automation
Blog Connect to AVNET iotconnect.io with Python IoTConnectSDK and BLE - part 4: Talk BLE to the On Semi RSL10 Sensor Kit
  • Blog
  • Forum
  • Documents
  • Quiz
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join Industrial Automation to participate - click to join for free!
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 11 May 2021 3:02 PM Date Created
  • Views 1078 views
  • Likes 7 likes
  • Comments 2 comments
  • bluepi
Related
Recommended

Connect to AVNET iotconnect.io with Python IoTConnectSDK and BLE - part 4: Talk BLE to the On Semi RSL10 Sensor Kit

Jan Cumps
Jan Cumps
11 May 2021

AVNET's iotconnect.io cloud platform is an online service that you can use to send data to, and then show it on a dashboard. In this blog series I'm learning the Python SDK and integrating BLE devices.

In this post: talk to the RSL10 sensor kit via its Bluetooth Low Energy interface.

image

Like the previous blog, the technique in this post can be used on other devices. When you use it outside the context of the Avnet portal, you can learn BLE integration from it too.

 

The Bluetooth Low Energy Python interface

 

The Avnet + On Semi example that I'm reviewing uses the bluepy Python BLE library for Linux.

It is a neat library, well maintained and supported by a group of committers.

The interface file that defines its API is btle.py.

The example imports that API:

 

from bluepy import btle

 

Before starting the BLE scan process, the example uses Linux command tools to check what BLE interfaces are available on the device:

image

 

It then uses the bluepy functionality to find the RSL10 and gets its data.

Instead of replicating the code, I'm showing examples from bluepy.

 

Scan for devices and get info:

scanner = Scanner().withDelegate(ScanDelegate())
devices = scanner.scan(10.0)

for dev in devices:
    print "Device %s (%s), RSSI=%d dB" % (dev.addr, dev.addrType, dev.rssi)
    for (adtype, desc, value) in dev.getScanData():
        print "  %s = %s" % (desc, value)

 

output (the RSL10 is 60:c0:bf:28:a3:68)

image

 

By default, the RSL10 firmware sends Eddystone TLM data, when in Environment Only mode.

 

            elif("aafe" in value and adtype == 22 and 'mybeacaddress' in globals()):             # Eddystone TLM packet (Service Data - 16-bit UUID)       
                if (mybeacaddress == dev.addr):
                    print("Eddystone Battery")

 

You can see the info in the log:

image

 

This is parsed by the sample project:

 

                    # Filter out the RSL10 beacon from other beacons                     
                    raw = value.replace("aafe", "")
                    battery = round(float((int(raw[4:6],16)*256 + int(raw[6:8],16)))/1000, 2)       # unit Volts
                    os.system('touch /home/avnet/ok')
                    batteryValue = battery

 

Let's review the battery:

 

battery = round(float((int(raw[4:6],16)*256 + int(raw[6:8],16)))/1000, 2)       # unit Volt

 

image

2.95 Volt.

image

 

When you put the RSL10 in Acceleration mode (with the custom firmware that it is running, this is done by pushing user button 1 then shaking the device), it sends more info, 128 bytes:

image

The example code also looks for that signature, and performs different logic:

 

            elif("203606dce9dcb3b7745559262ee12305" in value and adtype == 33):             # ON Semi Advertisement packet (Service Data - 128-bit UUID) - MOTION DATA (Red LED state)
                print("MotionMode")
                parsed = motion_parse(value)
                packet = {
                # ...

 

 

This is how the BLE part is implemented in the example.

The process is continuously controlled by a python thread.

There is another thread that will - independently - send the data to

 

Custom Firmware on RSL10

 

The firmware loaded on the RSL10 is custom for this evaluation. It is comparable to the out-of-box, but has support for Over The Air firmware upgrade:

image

 

The output captures I've posted in the first paragraph are the Environmental Only Mode (default when starting up, green led) and Acceleration Mode (red led) BLE captures.

 

 

The Python SDK with On Semiconductor RSL10 BLE article seriesIndustry
part 1: overview and goal
part 2: WiFi Provisioning
part 3: Adding a Module (RSL10)
part 4: Talk BLE to the On Semi RSL10 Sensor Kit
part 5: A Cloud User Experience Example
part 6: Register as a Gateway Device
part 7: Register a Gateway and Client Devices
The NODE-Red SDK article seriesIndustry
part 1: overview and goal
register a Thing and connect to IoTConnect.io cloud
part 2: create an account and log on to the portal
part 3: set up the thing and its interface in the cloud
part 4: set up Node-RED and first exchange
interact with IoTConnect.io cloud
part 5: online dashboard
part 6: rules and alerts
part 7: messages and commands from the cloud
safer connections with certificates
part 8a: safer connect with Self Signed Certificates
part 8b: safer connect with CA certificatesY
commercial and industrial scale: outsource certificate generation and programming to subcontractors and suppliers
part 9a: Outsource Certificate Signing in IIoT Supply ChainY
part 9b: IIoT supply chain and Certificates - Create Ca Root certificate, Load to IoTConnect Cloud and ValidateY
part 9c: IIoT supply chain and Certificates - Create an Intermediate CA Certificate for your SubcontractorY
part 9d: IIoT supply chain and Certificates - Subcontractor Generates a Thing Certificate for Your DeviceY
part 9e: IIoT supply chain and Certificates - Test!Y
commercial and industrial scale: Trusted Platform Module (TPM) Authentication
part 10: Trusted Platform Module (TPM) SecurityY
Infineon SLx9670 Trusted Platform Module (TPM) for IoT SecurityY
The Automate Device Provisioning and Cloud Configuration article seriesIndustry
Automatic Provisioning with REST APIY
  • Sign in to reply

Top Comments

  • fmilburn
    fmilburn over 4 years ago +1
    Thanks, I wasn’t aware of bluepy
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to fmilburn +1
    The same for me. I learned it while reviewing the example. I've been investigating it and it has been working very well. I'm new at writing Python too. I'm able to read it decently but I'm not a Python…
  • Jan Cumps
    Jan Cumps over 4 years ago in reply to fmilburn

    The same for me. I learned it while reviewing the example.

    I've been investigating it and it has been working very well.

    I'm new at writing Python too. I'm able to read it decently but I'm not a Python developer.

    Part of this exercise here is to achieve a decent level.

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • fmilburn
    fmilburn over 4 years ago

    Thanks, I wasn’t aware of bluepy

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube