Loading Items

About This Project

Here is a tutorial on how to connect the Pycom to the Nordic Developer app nRF Connect. This tutorial will be using nRF Connect to send Hex color code values to the Pycom via Bluetooth*NOTE* A computer, and an Android/apple device are required
Request Access

Project Info


  • Programming
  • Pycom
  • Qt.io
  • Overall

Meet The Makers

Join Team
  • xjoexripx
    • User:xjoexripx
    • Rank:Master
    • Projects:31
    • Joined:2016
    • From:US
  • alexswym
    • User:alexswym
    • Rank:Master Apprentice
    • Projects:14
    • Joined:2017
  • James
    • User:James
    • Rank:Master
    • Projects:30
    • Joined:2016
    • From:US
    Interests: Systems Architect. Love making robots and systems with moving parts.
    • nec
    • More than a year ago
    Hi, thaks for your project, please do more examples (pycom) ble and wifi. Send some datas like humidity and heat (dht22 or other sensors)

.Connecting to the Pycom

Pycom Hello World

Pycom Hello World

  • 2085
  • Makes: 0
  • Watchers: 0
  • Rating:
  • Difficulty:
  • User:xjoexripx
  • Rank:Master
  • Projects:31
  • Joined:2016
  • From:US
  • User:James
  • Rank:Master
  • Projects:30
  • Joined:2016
  • From:US
Interests: Systems Architect. Love making robots and systems with moving parts.
  • User:Riley.Purvis
  • Rank:Master Apprentice
  • Projects:12
  • Joined:2017
  • From:US
  • User:alexswym
  • Rank:Master Apprentice
  • Projects:14
  • Joined:2017
  • Status:Work In Progress
  • Published:October 19, 2017
  • Est. Time:0 Hours
Overview: In this project we will be lighting the rgb led on the pycom different colors.

.Coding the Pycom

The Pycom will host the Bluetooth, as well as accept hexadecimal values in the form of color code.
When the Pycom receives a valid color code value, you will notice the LED change to the desired color.

Keep in note that the Pycom's LED isnt as accurate the brighter the color.

Copy the following code into Atom
from network import Bluetooth
import pycom
import struct
import binascii
bluetooth = Bluetooth()
bluetooth.set_advertisement(name='SWYM_Pycom', service_uuid=b'1234567890123456')
color = 0
barray = b'\x00\x7f\x00'

def conn_cb (bt_o):
    events = bt_o.events()
    if events & Bluetooth.CLIENT_CONNECTED:
        print("Pycom is connected")

    elif events & Bluetooth.CLIENT_DISCONNECTED:
        print("Pycom is disconnected")

bluetooth.callback(trigger=Bluetooth.CLIENT_CONNECTED | Bluetooth.CLIENT_DISCONNECTED, handler=conn_cb)


srv1 = bluetooth.service(uuid=b'1234567890123456', isprimary=True)
chr1 = srv1.characteristic(uuid=b'ab34567890123456', value=5)

def char1_cb_handler(chr):
    events = chr.events()
    if  events & Bluetooth.CHAR_WRITE_EVENT:
         print("Write request with value = {}".format(chr.value()))
         barray = binascii.hexlify(chr.value())
         color = hex(int(barray,16) + int ("0x00",16))
         color = int(color)
    elif events & Bluetooth.CHAR_READ_EVENT:
        print("Read request with value = {}".format(chr.value()))
         print("An error has occured")

char1_cb = chr1.callback(trigger=Bluetooth.CHAR_WRITE_EVENT | Bluetooth.CHAR_READ_EVENT, handler=char1_cb_handler)

Once the code is copied into Atom, and the Pycom is properly connected, run the code.

.Testing the Pycom

You can test your code by either checking your Bluetooth for "SWYM_Pycom"
NOTE: The Pycom runs Low Power Bluetooth, which most devices cannot connect to. If you try connecting to SWYM_Pycom, most devices will result in a failure to connect.

When the code has properly uploaded, you can also notice that the Pycom's LED will change to the blinding color shown below.

You have now properly coded the Pycom to host Bluetooth.

.Connecting to the Pycom

Next we will be installing the app nRF Connect by Nordic Sensors to connect to the Pycom, and change its colors via bluetooth connection.
Once you have installed nRF Connect on your device, open it and you should be greeted by a screen similar to below

The app will show you a list of all the nearby devices you can connect to, and the SWYM_Pycom is the connection we are going to connect to. Note that SWYM_Pycom will not show up if the Pycom is already connected to a device. So make sure that the Pycom is not currently paired.
Once you have connected to the Pycom, you will notice that your Pycom turns a purplish color. This is to notify you of anytime the Pycom is actively connected.
Once your device is properly connected, your Pycom will look like so

You should also see on your device that you now have an "unknown access" listed under SWYM_Pycom's Client. Click the unknown service and more options will be available

Now click the up-arrow next to "Unknown Characteristic". A pop-up window will appear, where you can place the 6 hex-digit value corresponding to the color code, like such. When you have the desired value, click "send"

You will now notice that your Pycom's LED changes color accordingly.

You have now successfully sent data to the Pycom over Bluetooth!

There are no project files yet.

Qty   Item Where to Find Est. Cost More Info
1 Pycom WiPy 2.0 Item Number: C1015

Pycom WiPy 2.0

Item #: C1015

Powerful CPU, BLE and sta