It's Holiday Sale Weekend at Adafruit - use the code ADATY to get 15% off items storewide! Some restrictions apply.
0

mprls pressure sensor on Circuit Bluefruit Playground
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

mprls pressure sensor on Circuit Bluefruit Playground

by rgopalan on Mon Oct 18, 2021 10:15 am

Hello, I am trying to use the BLuefruit Connect App on the iphone to read out the Adafruit. MPRLS pressure sensor wired to the SCL/SDA and Power/ GND connections on the
Circuit Playground Bluefruit.
i found the circuitpython example code :
adafruit_mprls.mpy
but not sure how to include it on the CIRCUITPY drive : should i rename it: code.py or code.mpy or something else?
Any other tips appreciated.
thanks
rameshg

rgopalan
 
Posts: 20
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by dastels on Mon Oct 18, 2021 3:35 pm

adafruit_mprls.mpy is the library you use to interface with the MPRLS sensor. Put it in CIRCUITPY/lib along with any other libraries you're using. Then you'll need CIRCUITPY/code.py that uses it.

This is the simple example from the repo (https://github.com/adafruit/Adafruit_CircuitPython_MPRLS):
Code: Select all | TOGGLE FULL SIZE
import time
import board
import adafruit_mprls

i2c = board.I2C()

# Simplest use, connect to default over I2C
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)

while True:
    print((mpr.pressure,))
    time.sleep(1)

For more information see the tutorial guide: https://learn.adafruit.com/adafruit-mprls-ported-pressure-sensor-breakout.

Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by rgopalan on Sat Oct 23, 2021 7:10 pm

thank you Dave for your response.
note that I am trying to report the MPRLS pressure reading out to Serial UART serial monitor on Bluefruit connect app:
i modified the code.py uploaded to my Bluefruit Circuit Playground as below, only changing print( to ble.print( - but althought my iPhone app recognizes the CIRCUITPY it does not print out the mprls.pressure reading as used to be able to do off a Feather nRF82532 with Arduino code appended .
i am still a python novice, any tips appreciated.
Code: Select all | TOGGLE FULL SIZE
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

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

ble.start_advertising(advertisement)
while True:
   pass
 # ----below code pasted from  adafruit forum__________
import time
import board
import adafruit_mprls

i2c = board.I2C()

# Simplest use, connect to default over I2C
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)

while True:
# changed print(  to ble.print(
    ble.print((mpr.pressure,))
    time.sleep(1)




rgopalan
 
Posts: 20
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by dastels on Sat Oct 23, 2021 9:33 pm

Hmm... ble.print might be confused by being passed a tuple rather than just a value. Try:
Code: Select all | TOGGLE FULL SIZE
ble.print(mpr.pressure)


Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by rgopalan on Sat Nov 06, 2021 7:15 pm

Hello, i am still not able to serial print to the UART console on Bluefruit connect app the data from the MPRLS sensor - i am quite sure i have connected the MPRLS sensor to the Circuit Bluefruit Playground just as I had successfully done before on the Feather nrf82532 earlier.
the Bluefruit Connect app detects my CIRCUITPY9571 but does not receive /print the UART data stream.
my code.py, as per previous recommendation is :
Code: Select all | TOGGLE FULL SIZE
from adafruit_ble import BLERadio
from adafruit_ble.advertising.standard import ProvideServicesAdvertisement
from adafruit_ble.services.nordic import UARTService

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

ble.start_advertising(advertisement)
while True:
   pass
 # ----below code pasted from  adafruit forum__________
import time
import board
import adafruit_mprls

i2c = board.I2C()

# Simplest use, connect to default over I2C
mpr = adafruit_mprls.MPRLS(i2c, psi_min=0, psi_max=25)

while True:
# changed print(  to ble.print(
    ble.print(mpr.pressure)
    time.sleep(1)

rgopalan
 
Posts: 20
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by dastels on Sat Nov 06, 2021 8:41 pm

Is there a println function? Maybe it doesn't flush it out until a line terminator is encountered.

Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by rgopalan on Sun Nov 07, 2021 11:58 am

so i changed it to ble.println ("Test serial") and still nothing showed up to the UART console...
possible something more basic wrong with my board - i have updated the firmware /circuit python on it several times. may need to replace the board...

rgopalan
 
Posts: 20
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by dastels on Sun Nov 07, 2021 3:36 pm

I've asked around to see if anyone has an idea.

Dave

dastels
 
Posts: 7871
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

by danhalbert on Mon Nov 08, 2021 3:21 pm

This code fragment is incomplete:
Code: Select all | TOGGLE FULL SIZE
ble.start_advertising(advertisement)
while True:
   pass

This wil just hang forever in the `while True: pass` loop.

The code should be something like this:
Code: Select all | TOGGLE FULL SIZE
ble.start_advertising(advertisement)
while True:
    ble.start_advertising(advertisement)
    while not ble.connected:
        pass
    while ble.connected:
           # Do what you need to do to report results.
           ble.print(....)   # etc.

danhalbert
 
Posts: 2585
Joined: Tue Aug 08, 2017 12:37 pm

Please be positive and constructive with your questions and comments.