This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

MicroBit Bluetooth UART
#1
Dear Sebastian and colleagues,

in the curriculum of bavaria we should characterize solar cells. So i was thinking of using the Micro:Bit as external sensor.
The Micro:Bit should measure the Rotation and the Voltage on Pin 0 and i would get ideally the sine wave.

I used your wonderful project of measuring voltage on Pin0 and this is working with Micro:Bit and PhyPhox. By using the Flashlight of the Smartphone, you just need some cable, a battery pack and the microbit (see attachement).

But the Micro:Bit has no Characteristic for the Rotation. So i thought of using Overview Characteristics.
With the attached programme i was able to receive the Rotation with BLExplorer (see screenshot), but i failed with PhyPhox.

PhyPhox connects, but nothing is displayed.
Code:
<phyphox version="1.6">
    <title>micro:bit UART</title>
    <category>Bluetooth</category>
    <description>Read UART form micro:bit</description>
    <data-containers>
        <container size="0">rot</container>
        <container size="0">rotcal</container>
        <container size="0">t</container>
    </data-containers>
    <input>
        <bluetooth name="BBC micro:bit">
            <output char="6E400002-B5A3-F393-E0A9-E50E24DCCA9E" conversion="string">rot</output>
            <output char="6E400002-B5A3-F393-E0A9-E50E24DCCA9E" extra="time">t</output>
        </bluetooth>
    </input>
    <views>
        <view label="Raw Data">
            <graph minY="0" scaleMinY="fixed" maxY="90" scaleMaxY="fixed" labelX="time" unitX="s" labelY="Rotation" unitY="V">
                <input axis="x">t</input>
                <input axis="y">rotcal</input>
            </graph>
            <value size="3" unit="DEG" label="Rotation">
                <input>rotcal</input>
            </value>
        </view>
    </views>
    <analysis>
        <multiply>
            <input clear="false">rot</input>
            <input type="value">1.00</input>
            <output>rotcal</output>
        </multiply>
    </analysis>
</phyphox>
Thanks for your help.


Best wishes Johannes


Attached Files Thumbnail(s)
               
Reply
#2
I used also the formattedString BLE Wiki on PhyPhox, but here was the input in PhyPhox empty (no warning for a missing characteristic), but BLExplorer the values showed up (see attached screenshots)
Code:
<phyphox xmlns="http://phyphox.org/xml" xmlns:editor="http://phyphox.org/editor/xml" version="1.7" editor:version="1.0" locale="de">
    <title>micro:bit Voltage &amp; Rotation</title>
    <category>Bluetooth</category>
    <description>Read the rotation and analog voltages from pin 0 </description>
    <translations>
        <translation locale="de">
            <title>Micro:Bit Spannungsmessung</title>
            <description>Den Rotationswinkel und die analoge Spannung an Pin 0 messen.</description>
            <string original="rotation">Winkel</string>
            <string original="voltage">Spannung</string>
            <string original="Voltage">Spannung</string>
            <string original="Rotation">Winkel</string>
        </translation>
    </translations>
    <data-containers>
        <container size="0" static="false">t</container>
        <container size="1000" static="false">Output 3</container>
        <container size="1000" static="false">product</container>
    </data-containers>
    <input>
        <bluetooth editor:uuid="101" editor:posx="26" editor:posy="269"  name="BBC micro:bit"  mode="notification" rate="1" subscribeOnStart="false">
            <output char="6E400002-B5A3-F393-E0A9-E50E24DCCA9E" conversion="formattedString" separator="&quot;;&quot;" index="0">t</output>
            <output char="6E400002-B5A3-F393-E0A9-E50E24DCCA9E" conversion="formattedString" separator="&quot;;&quot;" index="1">Output 3</output>
        </bluetooth>
    </input>
    <output>
    </output>
    <analysis sleep="0"  onUserInput="false">
        <multiply editor:uuid="250" editor:posx="174.03334045410156" editor:posy="519.3500061035156">
            <input as="factor" type="value">0.011764706</input>
            <input as="factor" clear="false">Output 3</input>
            <output as="product">product</output>
        </multiply>
    </analysis>
    <views>
        <view label="Raw Data">
            <graph editor:uuid="156" editor:posx="552" editor:posy="323" label="" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="false" history="1" labelX="rotation" labelY="voltage" labelZ="" unitX="s" unitY="V" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="fixed" scaleMaxY="fixed" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="3" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">product</input>
            </graph>
        </view>
        <view label="Simple">
            <value editor:uuid="200" editor:posx="389.29998779296875" editor:posy="172.0500030517578" label="Voltage" size="1" precision="2" scientific="false" unit="V" factor="1" >
                <input>product</input>
            </value>
            <value editor:uuid="213" editor:posx="294.4666748046875" editor:posy="18.76666259765625" label="Rotation" size="1" precision="2" scientific="false" unit="Deg" factor="1" >
                <input>t</input>
            </value>
        </view>
    </views>
    <export>
        <set name="Data Export">
            <data name="rotation">t</data>
            <data name="voltage">product</data>
        </set>
    </export>
</phyphox>


Attached Files Thumbnail(s)
           
Reply
#3
Cool, love to see the BBC:Microbit being used like that. I was hoping to try it myself today, but am running out of time for today, so I will just tell you what I noticed without testing it:

The separator separator="&quot;;&quot;" does not make sense. I assume that this was introduced by the editor because you used quotation marks around the semicolon. Instead you should just enter the ; without any quotation marks.

Besides that, your first try probably failed because there was no separation between the values at all (if I interpret your screenshot correctly) while I think that the second one should work without the quotation marks.

Well, in practice there always is another pitfall, so let me know if this helped and if it doesn't I will check with my own Microbit here.
Reply
#4
Thanks Sebastian,

i already tried and gave another try. Using separator ; without quotation marks didn't solve the problem.

It is working in BLExplorer but not in PhyPhox.
These Micro:Bits are so exciting, because we can use Physical Computing  in year 7 and afterwards this would be a perfect data aquisition for solar cell characterisation.

The UART service would be nice especially for students (i would use label), so students can calculate, gather, and send data with blocks in Makecode without changing the bluetooth interface from PhyPhox.


Attached Files
.phyphox   Micro Bit Spannungsmessung.phyphox (Size: 35.76 KB / Downloads: 313)
Reply
#5
I got it to work, but this topic really hit every single little problem you could imagine.

First of all, this is the very first Bluetooth device that I found to use "indication" instead of "notification". In the future, phyphox will autodetect which it is, so you do not have to change anything about this now, but the implementation of "indication" was broken on both Android and iOS. In principle, your phyphox-file is absolutely correct, but depending on which phones there are available to you, you need a different workaround until the next phyphox version is released:

Android
Unfortunately, in the current version indications do not work at all. If you need Android-support soon (i.e. students should use it or you do not have an iPhone available for development), let me know and I will try to get a new beta version ready soon.

iOS
Indications work even the file is set to notification (i.e. as it is right now), but there is yet another bug that you will encounter here: At the moment that last value in "formattedString" cannot be parsed if there is no terminating separation character. In other words: Simply add another ";" after the last value in your Microbit sketch and it should work with your current phyphox file on the current iPhone version.
Reply
#6
Dear Sebastian, you are just incredible. Thanks for the help.

For me i can test it on IPads and can wait for the next Android Version. Is there any release date?

Best wishes Johannes
Reply
#7
I am about to release a public beta test for Android, which will include the fix along with new MQTT support (not related to this question). When I get around to implement MQTT (that's why I mention it) for iOS, I will also release an iPhone beta version that also fixes the semicolon-at-the-end problem and that accepts "indication" as well as "notification" (probably not important for you if you add that last semicolon and set the mode to notification).

I will answer your PM shortly when the beta is ready.
Reply
#8
(11-09-2020, 05:06 PM)Sebastian Staacks Wrote: I am about to release a public beta test for Android, which will include the fix along with new MQTT support (not related to this question). When I get around to implement MQTT (that's why I mention it) for iOS, I will also release an iPhone beta version that also fixes the semicolon-at-the-end problem and that accepts "indication" as well as "notification" (probably not important for you if you add that last semicolon and set the mode to notification).

I will answer your PM shortly when the beta is ready.

Dear Sebastian,

i tried with the public beta (I hope it is the right version) and changed the value to indication, but still i can't see any values. With BLExporer the values appear.

Thanks Johannes


Attached Files Thumbnail(s)
       

.phyphox   Micro_Bit Solarpaket UART.phyphox (Size: 2.8 KB / Downloads: 305)
Reply
#9
Now that is weird. With the recent beta (indeed 1.1.7-beta2) and scanning the QR code from your attachment it is working for me... Do you have a particulary old phone or anything else that is unusual? Could you post the device info from the main menu? Maybe, could you try resetting the Microbit and re-pair it to your phone? (I am wondering if there could be a not entirely closed connection from BLExplorer? Not familiar with this app.)

(BTW: You can now set indication or notification as phyphox now autodetects which it is.)
Reply
#10
(11-18-2020, 05:22 PM)Sebastian Staacks Wrote: Now that is weird. With the recent beta (indeed 1.1.7-beta2) and scanning the QR code from your attachment it is working for me... Do you have a particulary old phone or anything else that is unusual? Could you post the device info from the main menu? Maybe, could you try resetting the Microbit and re-pair it to your phone? (I am wondering if there could be a not entirely closed connection from BLExplorer? Not familiar with this app.)

(BTW: You can now set indication or notification as phyphox now autodetects which it is.)

Dear Sebastian,

i just went to school to test with our Ipads and the same programme on the MicroBit (although the same) and within PhyPhox is working just fine. I closed the App BLExplorer for testing.


Code:
phyphox
Version: 1.1.6
Build: 1010603
File format: 1.10

Permissions
INTERNET: yes
RECORD_AUDIO: yes
READ_EXTERNAL_STORAGE: no
BLUETOOTH: yes
BLUETOOTH_ADMIN: yes
ACCESS_COARSE_LOCATION: no
ACCESS_FINE_LOCATION: yes
CAMERA: yes

Device
Model: SM-G900F
Brand: samsung
Board: klte
Manufacturer: samsung
ABIS: armeabi-v7a, armeabi
Base OS:
Codename: REL
Release: 9
Patch: 2020-08-05

Sensors

Beschleunigungssensor (type 1)
- Name: MPU6500 Acceleration Sensor
- Range: 19.6133 m/s²
- Resolution: 5.985504E-4 m/s²
- Min delay: 5000 µs
- Max delay: 200000 µs
- Power: 0.25 mA
- Vendor: Invensense
- Version: 1

Gyroskop (type 4)
- Name: MPU6500 Gyroscope Sensor
- Range: 34.906586 rad/s
- Resolution: 0.0010652645 rad/s
- Min delay: 5000 µs
- Max delay: 200000 µs
- Power: 6.1 mA
- Vendor: Invensense
- Version: 1

unbekannt (type 16)
- Name: MPU6500 Uncalibrated Gyroscope Sensor
- Range: 34.906586
- Resolution: 0.0010652645
- Min delay: 5000 µs
- Max delay: 200000 µs
- Power: 6.1 mA
- Vendor: Invensense
- Version: 1

Magnetfeld (type 2)
- Name: AK09911C Magnetic field Sensor
- Range: 2000.0 µT
- Resolution: 0.06 µT
- Min delay: 10000 µs
- Max delay: 200000 µs
- Power: 6.0 mA
- Vendor: Asahi Kasei Microdevices
- Version: 1

Magnetfeld (type 14)
- Name: AK09911C Magnetic Sensor UnCalibrated
- Range: 1200.0 µT
- Resolution: 0.06 µT
- Min delay: 10000 µs
- Max delay: 200000 µs
- Power: 6.0 mA
- Vendor: Asahi Kasei Microdevices
- Version: 1

Druck (type 6)
- Name: Barometer Sensor
- Range: 1013.25 hPa
- Resolution: 1.0 hPa
- Min delay: 180000 µs
- Max delay: 180000 µs
- Power: 1.0 mA
- Vendor: STM
- Version: 1

Annäherung (type 8)
- Name: TMG399X Proximity Sensor
- Range: 8.0 cm
- Resolution: 8.0 cm
- Min delay: 0 µs
- Max delay: 0 µs
- Power: 0.75 mA
- Vendor: AMS, Inc.
- Version: 1

Licht (type 5)
- Name: TMG399X RGB Sensor
- Range: 60000.0 lx
- Resolution: 1.0 lx
- Min delay: 200000 µs
- Max delay: 200000 µs
- Power: 0.75 mA
- Vendor: AMS, Inc.
- Version: 1

Lage (type 11)
- Name: MPL Rotation Vector
- Range: 1.0
- Resolution: 5.9604645E-8
- Min delay: 10000 µs
- Max delay: 200000 µs
- Power: 6.0 mA
- Vendor: Invensense
- Version: 1

unbekannt (type 15)
- Name: MPL Game Rotation Vector
- Range: 1.0
- Resolution: 5.9604645E-8
- Min delay: 10000 µs
- Max delay: 200000 µs
- Power: 6.0 mA
- Vendor: Invensense
- Version: 1

unbekannt (type 18)
- Name: SAMSUNG Step Detector Sensor
- Range: 1.0
- Resolution: 1.0
- Min delay: 0 µs
- Max delay: 0 µs
- Power: 0.3 mA
- Vendor: Samsung Inc.
- Version: 1

unbekannt (type 19)
- Name: SAMSUNG Step Counter Sensor
- Range: 4.2949673E9
- Resolution: 1.0
- Min delay: 0 µs
- Max delay: 0 µs
- Power: 0.3 mA
- Vendor: Samsung Inc.
- Version: 1

unbekannt (type 17)
- Name: SAMSUNG Significant Motion Sensor
- Range: 1.0
- Resolution: 1.0
- Min delay: -1 µs
- Max delay: 0 µs
- Power: 0.3 mA
- Vendor: Samsung Inc.
- Version: 2

Herstellerspezifisch (type 65562)
- Name: HRM Sensor
- Range: 200.0
- Resolution: 1.0
- Min delay: 1000000 µs
- Max delay: 1000000 µs
- Power: 1.0 mA
- Vendor: MAXIM
- Version: 1

unbekannt (type 21)
- Name: HeartRate Sensor
- Range: 200.0
- Resolution: 1.0
- Min delay: 1000000 µs
- Max delay: 1000000 µs
- Power: 1.0 mA
- Vendor: MAXIM
- Version: 1

Herstellerspezifisch (type 65561)
- Name: MAX86900
- Range: 65535.0
- Resolution: 1.0
- Min delay: 10000 µs
- Max delay: 10000 µs
- Power: 1.0 mA
- Vendor: MAXIM
- Version: 1

Gyroskop (type 4)
- Name: Corrected Gyroscope Sensor
- Range: 34.906586 rad/s
- Resolution: 0.0010652645 rad/s
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 1

unbekannt (type 15)
- Name: Game Rotation Vector Sensor
- Range: 1.0
- Resolution: 5.9604645E-8
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 3

Beschleunigungssensor (type 1)
- Name: Gyroscope Bias (debug)
- Range: 1.0 m/s²
- Resolution: 5.9604645E-8 m/s²
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 1

unbekannt (type 20)
- Name: GeoMag Rotation Vector Sensor
- Range: 1.0
- Resolution: 5.9604645E-8
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 3

unbekannt (type 9)
- Name: Gravity Sensor
- Range: 19.6133
- Resolution: 5.985504E-4
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 3

Lineare Beschleunigung (type 10)
- Name: Linear Acceleration Sensor
- Range: 19.6133 m/s²
- Resolution: 5.985504E-4 m/s²
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 3

Lage (type 11)
- Name: Rotation Vector Sensor
- Range: 1.0
- Resolution: 5.9604645E-8
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 3

unbekannt (type 3)
- Name: Orientation Sensor
- Range: 360.0
- Resolution: 0.00390625
- Min delay: 5000 µs
- Max delay: 0 µs
- Power: 12.35 mA
- Vendor: AOSP
- Version: 1
Reply


Forum Jump: