Creating an Eddystone beacon?

  • Hi, i have sucessfully implemented an iBeacon using the 'bluetooth.set_advertisement' function with the proper manufacturer_data.

    Now I would like to create an Eddystone beacon, but I am unable to determine the proper parameters.

    Has anyone made an Eddystone beacon using a pycom module?

  • @papasmurph Great! it works! Thank you very much

  • @surly Here's a complete example of iBeacon and Eddystone-URL. I don't have an example of UID or TLD, as I didn't need those.

    In my iBeacon example, the UUID is encoded in the packet. That's the only UUID I needed (my own), but would be easy to create dynamically from a string.

    from network import Bluetooth
    import pycom
    import time
    mode = MODE_IBEACON
    def twocompl(x):
        if x < 0:
            x += 256
        return x        
    timeSleep = 1
    bluetooth = Bluetooth()
    power1m = -59
    if mode == MODE_IBEACON:
        major = 22240
        minor = 234
        data = [
            0x4c, 0x00, 0x02, 0x15, # Manufacturer data
            0xA6, 0xE3, 0xE0, 0x06, 0xBB, 0xC4, 0x4D, 0xD1, 0x9C, 0xA3, 0x3E, 0x86, 0xC4, 0x95, 0x7D, 0xF0, # UUID (CliqTags)
            (major >> 8) & 0xFF, major & 0xFF, # Major ID
            (minor >> 8) & 0xFF, minor & 0xFF, # Minor ID
            twocompl(power1m) # Power
        bluetooth.set_advertisement(name = None, manufacturer_data = bytes(data))
    elif mode == MODE_EDDYSTONEURL:
        url = ''
        uuid = [0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xaa, 0xfe, 0x00, 0x00]
        url = url.replace('http://www.', chr(0))
        url = url.replace('https://www.', chr(1))
        url = url.replace('http://', chr(2))
        url = url.replace('https://', chr(3))
        url = url.replace('.com/', chr(0))
        url = url.replace('.org/', chr(1))
        url = url.replace('.edu/', chr(2))
        url = url.replace('.net/', chr(3))
        url = url.replace('.info/', chr(4))
        url = url.replace('.biz/', chr(5))
        url = url.replace('.gov/', chr(6))
        url = url.replace('.com', chr(7))
        url = url.replace('.org', chr(8))
        url = url.replace('.edu', chr(9))
        url = url.replace('.net', chr(10))
        url = url.replace('.info', chr(11))
        url = url.replace('.biz', chr(12))
        url = url.replace('.gov', chr(13))
        data = [
            0xAA, 0xFE, # Eddystone ID
            0x10, # Eddystone-URL
            twocompl(power1m), # Power
        for c in url:
        bluetooth.set_advertisement(service_uuid = bytes(uuid), service_data = bytes(data))
    while True:

  • @papasmurph yes, sorry! I mean the Eddystone-URL is ok, but what I really need is the Eddystone-UID ( also the IBeacon version would be usefull ) !

  • @surly I can help you with Eddystone-URL, if that's interesting, but this seems to be Eddystone-UID.

  • I tried with data = bytes([0xAA, 0xFE, 0x00,
    0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99,
    0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF,
    0x00,0x00]) , but it doesn't work!

  • @b-veen You have successfully implemented an iBeacon. I'm doing the same thing but struggling with the bluetooth.set_advertisement method. Can you help? What should I put in the manufacterer_data and what in the service_data? Should I put the complete 31 bytes in the manufacturer_data and in what order...

  • @b.veen Changing the firmware is not an option for me, considering how much maintenance is still done on it. E.g. continuous Bluetooth scanning (that I need in another project) is still unstable. The UUID insertion seems "magical", as the data is only partly available in the actual packet. I have a slew of dedicated beacons as part of my main offering CliqTags (I even sell beacons, not successfully though). What I'm experimenting with is making a remotely configurable beacon. Especially changing the URL for Eddystone would be interesting, so I've made a converter to the compressed URL format used by Eddystone. What remains is essentially pushing or pulling (more likely the latter, to avoid firewall issues) the URL.

  • @papasmurph
    For my purposes I do not need TLM so I did not try to get that working.
    My solution was to change the bluetooth.setadvertisement function to include an extra option to enable/disable the TX and interval information.

    I have got the UUID working by providing the full google eddystone UID as registered on the bluetooth website. This resulted in a 'Complete 16 bit service UUD list'.

    The broadcasting of the URL is working too.

    (Since this project I have bought a couple of commercial beacons, it was fun experimenting with the PyCom though).

  • @b.veen You don't have to advertise UID as well. TLM is practical though. I got it working too, but from where did you get the UUID?

  • I actually managed to get the 16 bit UUID in the frame by using the full 128-bit ID.

    from network import Bluetooth
    b = Bluetooth()

    uuid = bytes([0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80, 0x00, 0x10, 0x00, 0x00, 0xaa, 0xfe, 0x00, 0x00])
    data = bytes([0xAA, 0xFE, 0x10, 0xF8, 0x00, ord('p'), ord('y'), ord('c'), ord('o'), ord('m'), ord('.'), ord('i'),ord('o')])
    b.set_advertisement(service_uuid=uuid, service_data=data)

    This seems to work to create an Eddystone URL frame.
    But, to be Eddystone compliant you need an UID frame too.

    The frame takes all 32 bytes, so there is no room for extra information.
    The Pycom framework unfortunately adds TX power and beacon interval information. This is hardcoded in modbt.c

    adv_data.set_scan_rsp = false;
    adv_data.include_txpower = true,
    adv_data.min_interval = 0x20;
    adv_data.max_interval = 0x40;

  • Hi everybody, I have come a little step closer to my goal.
    By using bluetooth.set_advertisement(service_data=bytes([0xAA, 0xFE,0x10,0xF8,0x00,ord('p'),ord('y'),ord('c'),ord('o'),ord('m'),ord('.'),ord('i'),ord('o')]))
    the WiPy is simulating a 'Physical Web Beacon' with the Eddystone Url

    The framedata looks like this
    2, 0x01, 0x06
    2, 0x0A, 0xEB
    5, 0x12, 0x20004000
    14 ,0x16, 0xAAFE10F8007079636F6D2E696F

    Question is: how to add the field 'Complete 16 bit service UUID list' containing the Eddystone uid (AAFE) ?
    I would expect it should be possible to add this line to the raw data above.
    0x03, 0x03, 0xAAFE

  • This post is deleted!

Log in to reply

Pycom on Twitter

Looks like your connection to Pycom Forum was lost, please wait while we try to reconnect.