🎁📬❄️📦Adafruit Holiday Shipping Deadlines 2019: Please place all UPS 2 Day orders by 11am Monday, December 16 📦❄️📬🎁
0

Help! Circuit Playground Bluefruit
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Help! Circuit Playground Bluefruit

by Daisyyy on Mon Dec 02, 2019 6:47 pm

Hi,
I'm trying to test the example code of Playground Bluetooth Plotter (https://learn.adafruit.com/adafruit-cir ... th-plotter)

The board I'm using: Circuit Playground Bluefruit - Bluetooth Low Energy
And I downloaded the Adafruit Bluefruit LE Connect App.

I want to use ble so I download the latest library from https://github.com/adafruit/Adafruit_Ci ... E/releases

I run the example code:
Code: Select all | TOGGLE FULL SIZE
# CircuitPython Bluefruit LE Connect Plotter Example

import board
import analogio
import adafruit_thermistor
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

from adafruit_bluefruit_connect.packet import Packet

ble = BLERadio()
uart_server = UARTService()
advertisement = ProvideServicesAdvertisement(uart_server)

thermistor = adafruit_thermistor.Thermistor(board.TEMPERATURE, 10000, 10000, 25, 3950)
light = analogio.AnalogIn(board.LIGHT)


def scale(value):
    """Scale the light sensor values from 0-65535 (AnalogIn range)
    to 0-50 (arbitrarily chosen to plot well with temperature)"""
    return value / 65535 * 50


while True:
    # Advertise when not connected.
    ble.start_advertising(advertisement)
    while not ble.connected:
        pass
    ble.stop_advertising()

    while ble.connected:
        print(scale(light.value), thermistor.temperature)
        uart_server.write('{},{}\n'.format(scale(light.value), thermistor.temperature))
def mod(i):

    return i % NUM_PIXELS

while True:
    # Advertise when not connected.
    uart_server.start_advertising()
    while not uart_server.connected:
        pass

    while uart_server.connected:
        packet = Packet.from_stream(uart_server)
        if isinstance(packet, ColorPacket):
            print(packet.color)
            np[next_pixel] = packet.color
            np[mod(next_pixel + 1)] = (0, 0, 0)
        next_pixel = (next_pixel + 1) % NUM_PIXELS

And I got this error:
Traceback (most recent call last):
File "main.py", line 13, in <module>
File "adafruit_ble/services/nordic.py", line 57, in __init__
File "adafruit_ble/services/__init__.py", line 52, in __init__
TypeError: cannot create 'Service' instances

Can anyone tell me what's wrong and how to solve it?

Daisyyy
 
Posts: 4
Joined: Mon Dec 02, 2019 6:22 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Mon Dec 02, 2019 8:34 pm

Delete the CIRCUITPY/lib/adafruit_ble directory you copied from extracting adafruit-circuitpython-ble-py-3.0.0.zip. Contains *.py files.
Copy adafruit_ble after extracting the latest Bundle Version 5.x from https://circuitpython.org/libraries to CIRCUITPY/lib instead.
Contains compressed *.mpy files.

In the Bluefruit app on my Android cellphone I connected to an address that says Uart Capable.
Then selected plotter and pointed a flashlight at CPB board to see a change in light values on the plot.
Temperature and light values can be seen scrolling by in REPL window of MU.
Plotter on MU shows no activity.
Plotter on cellphone Bluefruit app is active.

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by Daisyyy on Mon Dec 02, 2019 10:14 pm

Thanks for replying.

I actually tried that and I just tried it again.

Currently I have these libraries: adafruit_ble, adafruit_bluefruit_connect, and adafruit_thermistor.mpy.

Got the same error message:

main.py output:
Traceback (most recent call last):
File "main.py", line 13, in <module>
File "adafruit_ble/services/nordic.py", line 57, in __init__
File "adafruit_ble/services/__init__.py", line 52, in __init__
TypeError: cannot create 'Service' instances

Any other ideas?

Daisyyy
 
Posts: 4
Joined: Mon Dec 02, 2019 6:22 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Tue Dec 03, 2019 12:48 am

I just tried your program in my setup. Surprisingly even though it contains many errors in the second while True loop it actually ran and yields a plot of temperature and light values on my cellphone. Run check in MU on your code.py
The neopixels part in the second while loop does not work. I did not think you could have two while loops in code.py.

See this post https://forums.adafruit.com/viewtopic.php?f=60&t=159181
You have to delete the adafruit_ble directory before copying the one from the Bundle 5.x.
Look in the CIRCUITPY/lib/adafruit_ble and make sure you only have *.mpy files in the main and sub directories. There is one exception: CIRCUITPY/lib/adafruit_ble/services/standard/__init__.py that I found.

Here's my CIRCUITPY/lib
CIRCUITPY_lib4ble.PNG
CIRCUITPY_lib4ble.PNG (7.54 KiB) Viewed 196 times


CIRCUITPY_lib_adafruit_ble.PNG
CIRCUITPY_lib_adafruit_ble.PNG (5.27 KiB) Viewed 193 times

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by Daisyyy on Tue Dec 03, 2019 1:47 am

I deleted everything and copied the libraries, looked into subdirectories to make sure there're only .mpy files in lib.

I tried the code again. Same error. I didn't even get to check the while loops problem since the error appears in line 13

Traceback (most recent call last):
File "code.py", line 13, in <module>
File "adafruit_ble/services/nordic.py", line 57, in __init__
File "adafruit_ble/services/__init__.py", line 52, in __init__
TypeError: cannot create 'Service' instances

I really tried and did not know what's wrong....

Maybe we used different board?

Information about my board:
Adafruit CircuitPython 5.0.0-alpha.4 on 2019-09-15; Adafruit Circuit Playground Bluefruit with nRF52840

Daisyyy
 
Posts: 4
Joined: Mon Dec 02, 2019 6:22 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Tue Dec 03, 2019 2:02 am

same CPB board.
Adafruit CircuitPython 5.0.0-beta.0 on 2019-11-19; Adafruit Circuit Playground Bluefruit with nRF52840
Update uf2 to CircuitPython 5.0.0-beta.0 from https://circuitpython.org/board/circuitplayground_bluefruit/
and latest Bundle 5.x libraries from https://circuitpython.org/libraries.
I also recommend starting with ble_bluefruit_connect_plotter.py as code.py from adafruit-circuitpython-ble-examples-3.0.0.zip or adafruit-circuitpython-ble-5.x-mpy-3.0.0.zip located https://github.com/adafruit/Adafruit_CircuitPython_BLE/releases
The plotter files are identical. It does not matter which zip file you use.

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by kjackson79 on Tue Dec 03, 2019 1:08 pm

Having a little different problem. I am trying to add the Adafruit nRF52 by Adafruit to the Arduino 1.8.10 board library and it says that version 14 has a CRC that does not match, the file is corrupted. I need it for the Circuit Playground Bluefruit board that I am working with. version 10.1 will install but does not have the board.

kjackson79
 
Posts: 3
Joined: Tue Dec 03, 2019 12:11 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Tue Dec 03, 2019 3:59 pm

I installed Adafruit nRF52 by Adafruit version 0.14.6 using Board Manager last month on Arduino IDE version 1.8.10 without any problem. I am using latest Windows 10 OS.
What does version 10.1 refer to?
I have Adafruit Circuit Playground by Adafruit version 1.10.2 installed under the Library Manager

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by V2man on Wed Dec 04, 2019 12:42 pm

Today the Adafruit Bluefruit app gives me CIRCUITPY Uart capable as a choice. Plotter is still working with adafruit-circuitpython-ble-examples-3.0.0/examples/ble_bluefruit_connect_plotter.py

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by kjackson79 on Wed Dec 04, 2019 1:17 pm

i am running Windows 10 Pro version 1809. I have taken a screen capture of the Board Manager and the 10.1 was the highest version of the nRF52 that I could get to load through board manager. I did download the zip from the web successfully.
Attachments
Capture.PNG
Capture.PNG (138.19 KiB) Viewed 119 times

kjackson79
 
Posts: 3
Joined: Tue Dec 03, 2019 12:11 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Wed Dec 04, 2019 2:26 pm

The latest version of Adafruit nRF52 is version 0.14.6 not 10.1
I have never seen the CRC doesn't match, file is corrupted. It maybe a temporary problem, please try later.
Do you get that error everytime you try to install nRF52?

In Arduino --> Preferences do you have
Additional Boards Manager URLs: https://adafruit.github.io/arduino-boar ... index.json?

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by kjackson79 on Wed Dec 04, 2019 4:17 pm

yes, I did have the path added to the preferences. I will try again once I get out from behind a firewall. don't know if that is it, but at this point, it does not hurt to try.

I moved over to MU 1.0.2 to try to move forward with learning the board and having problems connecting to the CPX. The only way it shows up as a drive is i have to double click the reset and the LEDs go from solid red to solid green. when green it shows up as a drive. I can then save my .py file, but it does not restart and then falls back into a demo mode. I have been looking at the learning portal and cannot find a way around. I have to be doing something critically wrong. do I need to clear a bootup routine and then load the CPX with .py file? Also, do not see the library in the drive structure. Do I need to load that?

Sorry, trying to learn

Thanks,

Kevin

kjackson79
 
Posts: 3
Joined: Tue Dec 03, 2019 12:11 pm

Re: Help! Circuit Playground Bluefruit

by V2man on Wed Dec 04, 2019 5:48 pm

After double clicking the reset the drive you are seeing is the CPLAYBOOT drive if it is a CPX board.
What's in your INFO_UF2.TXT file on that drive?

Did you copy the latest CircuitPython 5.0.0-beta.0 uf2 and Bundle Version 5.x libraries to your CPX?
They can be found here:
https://circuitpython.org/board/circuitplayground_express/
https://circuitpython.org/libraries

Once you have copied the CircuitPython uf2 file above you will see the CIRCUITPY drive.
That is where you copy your code.py file.
Make sure you do not mix library versions by deleting anything under CIRCUITPY/lib.
Now copy Bundle Version 5.x libraries to CIRCUITPY/lib.

Then you can look in CIRCUITPY/boot_out.txt to see what version you have.
Last edited by V2man on Wed Dec 04, 2019 6:27 pm, edited 1 time in total.

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by V2man on Wed Dec 04, 2019 6:03 pm

What board are you trying to use CPX, Circuit Playground Express or CPB, Circuit Playground Bluefruit or both?

If it is CPB then uf2 is here https://circuitpython.org/board/circuitplayground_bluefruit/

i get it now when nRF52 could not install version 0.14.6 you tried earlier versions and the highest you could install was 0.10.1
Strange?

V2man
 
Posts: 399
Joined: Mon Dec 03, 2018 12:38 am

Re: Help! Circuit Playground Bluefruit

by Daisyyy on Wed Dec 04, 2019 10:19 pm

Thank you V2man. You saved my life right before the project deadline.

Once I use the latest CircuitPython 5.0.0-beta.0 uf2 file, everything works!

I really appreciate your help!

Daisyyy
 
Posts: 4
Joined: Mon Dec 02, 2019 6:22 pm

Please be positive and constructive with your questions and comments.