mprls pressure sensor on Circuit Bluefruit Playground

CircuitPython on hardware including Adafruit's boards, and CircuitPython libraries using Blinka on host computers.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rgopalan
 
Posts: 24
Joined: Thu Nov 26, 2020 10:38 pm

mprls pressure sensor on Circuit Bluefruit Playground

Post by rgopalan »

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

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by dastels »

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_Ci ... thon_MPRLS):

Code: Select all

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-mpr ... r-breakout.

Dave

User avatar
rgopalan
 
Posts: 24
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by rgopalan »

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

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)




User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by dastels »

Hmm... ble.print might be confused by being passed a tuple rather than just a value. Try:

Code: Select all

ble.print(mpr.pressure)
Dave

User avatar
rgopalan
 
Posts: 24
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by rgopalan »

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

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)

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by dastels »

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

Dave

User avatar
rgopalan
 
Posts: 24
Joined: Thu Nov 26, 2020 10:38 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by rgopalan »

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...

User avatar
dastels
 
Posts: 15659
Joined: Tue Oct 20, 2015 3:22 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by dastels »

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

Dave

User avatar
danhalbert
 
Posts: 4652
Joined: Tue Aug 08, 2017 12:37 pm

Re: mprls pressure sensor on Circuit Bluefruit Playground

Post by danhalbert »

This code fragment is incomplete:

Code: Select all

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

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.

Locked
Please be positive and constructive with your questions and comments.

Return to “Adafruit CircuitPython”