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
mprls pressure sensor on Circuit Bluefruit Playground
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- rgopalan
- Posts: 24
- Joined: Thu Nov 26, 2020 10:38 pm
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
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):
For more information see the tutorial guide: https://learn.adafruit.com/adafruit-mpr ... r-breakout.
Dave
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)
Dave
- rgopalan
- Posts: 24
- Joined: Thu Nov 26, 2020 10:38 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
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.
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)
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
Hmm... ble.print might be confused by being passed a tuple rather than just a value. Try:
Dave
Code: Select all
ble.print(mpr.pressure)
- rgopalan
- Posts: 24
- Joined: Thu Nov 26, 2020 10:38 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
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 :
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)
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
Is there a println function? Maybe it doesn't flush it out until a line terminator is encountered.
Dave
Dave
- rgopalan
- Posts: 24
- Joined: Thu Nov 26, 2020 10:38 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
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...
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...
- dastels
- Posts: 15659
- Joined: Tue Oct 20, 2015 3:22 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
I've asked around to see if anyone has an idea.
Dave
Dave
- danhalbert
- Posts: 4652
- Joined: Tue Aug 08, 2017 12:37 pm
Re: mprls pressure sensor on Circuit Bluefruit Playground
This code fragment is incomplete:
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:
pass
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.
Please be positive and constructive with your questions and comments.