Using LoPy/LO1/WiPy as iBeacon

  • Re: WiPy as an iBeacon

    I have successfully got my LoPY/LO1 based device to behave as an iBeacon:

               self._bluetooth = Bluetooth()
                # make the mfg data block incorporating our uuid/major/minor numbers
                mfghex = ubinascii.unhexlify("{}{}{:04x}{:04x}{:02x}".format("4C000215", self._uuid, self._major, self._minor, self._txPower))
                self._bluetooth.set_advertisement(name='CC1', manufacturer_data=mfghex)
                self._bluetooth.set_advertisement_params(adv_int_min=self._intervalMS, adv_int_max=self._intervalMS*2,
                        own_addr_type=Bluetooth.ADV_BLE_ADDR_TYPE_PUBLIC, channel_map=Bluetooth.ADV_CHNL_ALL)
                  self._bluetooth.tx_power(Bluetooth.TX_PWR_ADV, OutputIBeacon.mapTxPower(self._txPower))

    Couple of issues if anyone can help:

    • the beaconning interval seems to be stuck on 44ms, despite setting values from 100 to 300 for the adv_int_min/max params
    • if the ESP32 is put into light sleep (machine.sleep()) then the beaconning stops... hence it seems difficult to get a reasonable battery life while also beaconning?


  • @Brian-Wyld AFAIK, the ESP32 does not support advertising in sleep modes, so battery-powered beacons (or peripherals waiting for a central to connect to them) are not quite viable, especially given the time and power cost of a wake up.

    Not sure if anything has changed in that respect in more recent iterations of the ESP32 (not used in the Pycom devices anyway), but you'll probably have to consider alternate platforms if that's a requirement for you.

Log in to reply

Pycom on Twitter