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.

Internal and external Sensors in one Experiment
#5
Here the current project status:
I first worked on the xml files to make sure that I understand the concept correctly and get everthing implemented.
For this I combined the Acceleration, GPS and Gyro Sensors in one experiment.
The XML file looks like this and works fine:
Code:
<phyphox xmlns="http://phyphox.org/xml" xmlns:editor="http://phyphox.org/editor/xml" version="1.7" editor:version="1.0" locale="en">
    <title>Acceleration, Gyro and GPS</title>
    <category>X-Test</category>
    <color>00ff00</color>
    <description>Get raw data from the accelerometer and GPS. This sensor will not subtract the gravitational force, so it will report an acceleration of 9.81 m/s² even when the phone is resting.</description>
     <icon format="string">X01</icon>
    <data-containers>
        <container size="0" static="false">accX</container>
        <container size="0" static="false">accY</container>
        <container size="0" static="false">accZ</container>
        <container size="0" static="false">acc</container>
        <container size="0" static="false">acc_time</container>
        <container size="0" static="false">lat</container>
        <container size="0" static="false">lon</container>
        <container size="0" static="false">z</container>
        <container size="0" static="false">v</container>
        <container size="0" static="false">dir</container>
        <container size="0" static="false">accuracy</container>
        <container size="0" static="false">zAccuracy</container>
        <container size="0" static="false">t</container>
        <container size="1" static="false">status</container>
        <container size="0" static="false">satellites</container>
        <container size="1" init="0" static="false">countT</container>
        <container size="0" static="false">d</container>
        <container size="0" static="false">dist</container>
        <container size="0" static="false">dnew</container>
        <container size="1" init="0" static="false">countUpdated</container>
        <container size="1" init="1" static="false">countUpdated+1</container>
        <container size="0" static="false">subLat</container>
        <container size="0" static="false">subLon</container>
        <container size="0" static="false">dLat</container>
        <container size="0" static="false">dLon</container>
        <container size="1" static="false">startLat</container>
        <container size="1" static="false">startLon</container>
        <container size="1" static="false">diststart</container>
        <container size="0" static="false">gyrX</container>
        <container size="0" static="false">gyrY</container>
        <container size="0" static="false">gyrZ</container>
        <container size="0" static="false">gyr</container>
        <container size="0" static="false">gyr_time</container>        
    </data-containers>
    <input>
        <sensor editor:uuid="257" rate="0" average="false" type="accelerometer">
            <output component="x">accX</output>
            <output component="y">accY</output>
            <output component="z">accZ</output>
            <output component="t">acc_time</output>
            <output component="abs">acc</output>
        </sensor>
        <location editor:uuid="101">
            <output component="lat">lat</output>
            <output component="lon">lon</output>
            <output component="z">z</output>
            <output component="v">v</output>
            <output component="dir">dir</output>
            <output component="t">t</output>
            <output component="accuracy">accuracy</output>
            <output component="zAccuracy">zAccuracy</output>
            <output component="status">status</output>
            <output component="satellites">satellites</output>
        </location>
        <sensor editor:uuid="101" rate="0" average="false" type="gyroscope">
            <output component="x">gyrX</output>
            <output component="y">gyrY</output>
            <output component="z">gyrZ</output>
            <output component="t">gyr_time</output>
            <output component="abs">gyr</output>
        </sensor>        
    </input>
    <output>
    </output>
<analysis sleep="0.1"  onUserInput="false">
        <count editor:uuid="149">
            <input as="buffer" clear="false">t</input>
            <output as="count" clear="false">countT</output>
        </count>
        <count editor:uuid="150">
            <input as="buffer" clear="false">d</input>
            <output as="count">countUpdated</output>
        </count>
        <add editor:uuid="151">
            <input as="summand" clear="false">countUpdated</input>
            <input as="summand" type="value">1</input>
            <output as="sum">countUpdated+1</output>
        </add>
        <subrange editor:uuid="152">
            <input as="in" clear="false">lat</input>
            <input as="from" clear="false">countUpdated</input>
            <output as="out">subLat</output>
        </subrange>
        <subrange editor:uuid="153">
            <input as="in" clear="false">lon</input>
            <input as="from" clear="false">countUpdated</input>
            <output as="out">subLon</output>
        </subrange>
        <differentiate editor:uuid="154">
            <input as="in" clear="false">subLat</input>
            <output as="out">dLat</output>
        </differentiate>
        <differentiate editor:uuid="155">
            <input as="in" clear="false">subLon</input>
            <output as="out">dLon</output>
        </differentiate>
        <formula editor:uuid="156" formula="0.01745329252*sqrt((cos(0.01745329252*[1_])*[2_])^2+[1_]*[1_])*6371">
            <input as="in">dLat</input>
            <input as="in">dLon</input>
            <output as="out">dnew</output>
        </formula>
        <if editor:uuid="157" less="false" equal="false" greater="true">
            <input as="a" clear="false">countT</input>
            <input as="b" clear="false">countUpdated+1</input>
            <input as="true" clear="false">dnew</input>
            <output as="result" clear="false">d</output>
        </if>
        <integrate editor:uuid="158">
            <input as="in" clear="false">d</input>
            <output as="out">dist</output>
        </integrate>
        <first editor:uuid="159">
            <input as="value" clear="false">lon</input>
            <output as="first">startLon</output>
        </first>
        <first editor:uuid="160">
            <input as="value" clear="false">lat</input>
            <output as="first">startLat</output>
        </first>
        <formula editor:uuid="161" formula="6371*acos(sin(0.01745329252*[1])*sin(0.01745329252*[3])+cos(0.01745329252*[1])*cos(0.01745329252*[3])*cos(0.01745329252*([2]-[4])))">
            <input as="in">startLat</input>
            <input as="in">startLon</input>
            <input as="in" clear="false">lat</input>
            <input as="in" clear="false">lon</input>
            <output as="out">diststart</output>
        </formula>
    </analysis>
    <views>
        <view label="Graph">
            <graph editor:uuid="311" label="Accelerometer x" aspectRatio="2.5" style="lines" lineWidth="1" color="green" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">accX</input>
            </graph>
            <graph editor:uuid="312" label="Accelerometer y" aspectRatio="2.5" style="lines" lineWidth="1" color="blue" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">accY</input>
            </graph>
            <graph editor:uuid="313" label="Accelerometer z" aspectRatio="2.5" style="lines" lineWidth="1" color="yellow" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">accZ</input>
            </graph>
        </view>
        <view label="Absolute">
            <graph editor:uuid="314" label="Absolute acceleration" aspectRatio="2.5" style="lines" lineWidth="1" color="white" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">acc</input>
            </graph>
            <value editor:uuid="315" label="Absolute acceleration" size="2" precision="2" scientific="false" unit="m/s²" factor="1" >
                <input>acc</input>
            </value>
        </view>
        <view label="Multi">
            <graph editor:uuid="316" label="Acceleration" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="a" labelZ="" unitX="s" unitY="m/s²" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">acc_time</input>
                <input axis="y">accX</input>
                <input axis="x">acc_time</input>
                <input axis="y">accY</input>
                <input axis="x">acc_time</input>
                <input axis="y">accZ</input>
                <input axis="x">acc_time</input>
                <input axis="y">acc</input>
            </graph>
            <value editor:uuid="317" label="Accelerometer x" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="green">
                <input>accX</input>
            </value>
            <value editor:uuid="318" label="Accelerometer y" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="blue">
                <input>accY</input>
            </value>
            <value editor:uuid="319" label="Accelerometer z" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="yellow">
                <input>accZ</input>
            </value>
            <value editor:uuid="320" label="Absolute acceleration" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="white">
                <input>acc</input>
            </value>
        </view>
        <view label="Simple">
            <value editor:uuid="321" label="Accelerometer x" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="green">
                <input>accX</input>
            </value>
            <value editor:uuid="322" label="Accelerometer y" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="blue">
                <input>accY</input>
            </value>
            <value editor:uuid="323" label="Accelerometer z" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="yellow">
                <input>accZ</input>
            </value>
            <value editor:uuid="324" label="Absolute acceleration" size="2" precision="2" scientific="false" unit="m/s²" factor="1" color="white">
                <input>acc</input>
            </value>
        </view>
        <view label="Position">
            <value editor:uuid="168" label="Status" size="1" precision="2" scientific="false"  factor="1" >
                <input>status</input>
                <map  max="-1">GPS disabled</map>
                <map min="0" >GPS active</map>
            </value>
            <separator editor:uuid="169" height="1" color="404040">
            </separator>
            <graph editor:uuid="170" label="Latitude" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="φ" labelZ="" unitX="s" unitY="°" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">lat</input>
            </graph>
            <graph editor:uuid="171" label="Longitude" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="λ" labelZ="" unitX="s" unitY="°" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">lon</input>
            </graph>
            <graph editor:uuid="172" label="Height" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="z" labelZ="" unitX="s" unitY="m" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">z</input>
            </graph>
        </view>
        <view label="Movement">
            <value editor:uuid="173" label="Status" size="1" precision="2" scientific="false"  factor="1" >
                <input>status</input>
                <map  max="-1">GPS disabled</map>
                <map min="0" >GPS active</map>
            </value>
            <separator editor:uuid="174" height="1" color="404040">
            </separator>
            <graph editor:uuid="175" label="Speed" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="v" labelZ="" unitX="s" unitY="m/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">v</input>
            </graph>
            <graph editor:uuid="176" label="Direction" aspectRatio="2.5" style="dots" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="Direction" labelZ="" unitX="s" unitY="°" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">dir</input>
            </graph>
            <graph editor:uuid="177" label="Distance travelled" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="d" labelZ="" unitX="s" unitY="km" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">t</input>
                <input axis="y">dist</input>
            </graph>
        </view>
        <view label="Simple">
            <value editor:uuid="178" label="Status" size="1" precision="2" scientific="false"  factor="1" >
                <input>status</input>
                <map  max="-1">GPS disabled</map>
                <map min="0" >GPS active</map>
            </value>
            <separator editor:uuid="179" height="1" color="404040">
            </separator>
            <value editor:uuid="180" label="Latitude" size="1" precision="6" scientific="false" unit="°" factor="1" >
                <input>lat</input>
            </value>
            <value editor:uuid="181" label="Longitude" size="1" precision="6" scientific="false" unit="°" factor="1" >
                <input>lon</input>
            </value>
            <value editor:uuid="182" label="Height" size="1" precision="1" scientific="false" unit="m" factor="1" >
                <input>z</input>
            </value>
            <separator editor:uuid="183" height="1" color="404040">
            </separator>
            <value editor:uuid="184" label="Speed" size="1" precision="1" scientific="false" unit="m/s" factor="1" >
                <input>v</input>
            </value>
            <value editor:uuid="185" label="Speed" size="1" precision="1" scientific="false" unit="km/h" factor="3.6" >
                <input>v</input>
            </value>
            <separator editor:uuid="186" height="1" color="404040">
            </separator>
            <value editor:uuid="187" label="Direction" size="1" precision="1" scientific="false" unit="°" factor="1" >
                <input>dir</input>
            </value>
            <value editor:uuid="188" label="Compass" size="1" precision="2" scientific="false"  factor="1" >
                <input>dir</input>
                <map  max="-157.5">S</map>
                <map  max="-112.5">SW</map>
                <map  max="-67.5">W</map>
                <map  max="-22.5">NW</map>
                <map  max="22.5">N</map>
                <map  max="67.5">NE</map>
                <map  max="112.5">E</map>
                <map  max="157.5">SE</map>
                <map  max="202.5">S</map>
                <map  max="247.5">SW</map>
                <map  max="292.5">W</map>
                <map  max="337.5">NW</map>
                <map  >N</map>
            </value>
            <separator editor:uuid="189" height="1" color="404040">
            </separator>
            <value editor:uuid="190" label="Distance travelled" size="1" precision="3" scientific="false" unit="km" factor="1" >
                <input>dist</input>
            </value>
            <value editor:uuid="191" label="Distance from start" size="1" precision="3" scientific="false" unit="km" factor="1" >
                <input>diststart</input>
            </value>
            <separator editor:uuid="192" height="1" color="404040">
            </separator>
            <value editor:uuid="193" label="Horizontal Accuracy" size="1" precision="1" scientific="false" unit="m" factor="1" >
                <input>accuracy</input>
            </value>
            <value editor:uuid="194" label="Vertical Accuracy" size="1" precision="1" scientific="false" unit="m" factor="1" >
                <input>zAccuracy</input>
            </value>
            <value editor:uuid="195" label="Satellites" size="1" precision="0" scientific="false"  factor="1" >
                <input>satellites</input>
            </value>
            <separator editor:uuid="196" height="1" color="404040">
            </separator>
            <info editor:uuid="197" label="Note, that some devices do not have a GPS sensor, but provide location data through mobile or WIFI connections. These data sources produce data with bad accuracy." >
            </info>
            <separator editor:uuid="198" height="1" color="404040">
            </separator>
            <info editor:uuid="199" label="Also make sure that your system's location setting is not set to &quot;Power saving&quot; because this usually turns off the precise GPS source." >
            </info>
            <separator editor:uuid="200" height="1" color="404040">
            </separator>
            <info editor:uuid="201" label="The horizontal accuracy is the uncertainty of your location, while the vertical accuracy is the (usually worse) uncertainty of your elevation (height). If the accuracy is zero, this information is not available." >
            </info>
        </view>
        <view label="Graph">
            <graph editor:uuid="155" label="Gyroscope x" aspectRatio="2.5" style="lines" lineWidth="1" color="green" partialUpdate="true" history="1" labelX="t" labelY="ω" labelZ="" unitX="s" unitY="rad/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">gyr_time</input>
                <input axis="y">gyrX</input>
            </graph>
            <graph editor:uuid="156" label="Gyroscope y" aspectRatio="2.5" style="lines" lineWidth="1" color="blue" partialUpdate="true" history="1" labelX="t" labelY="ω" labelZ="" unitX="s" unitY="rad/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">gyr_time</input>
                <input axis="y">gyrY</input>
            </graph>
            <graph editor:uuid="157" label="Gyroscope z" aspectRatio="2.5" style="lines" lineWidth="1" color="yellow" partialUpdate="true" history="1" labelX="t" labelY="ω" labelZ="" unitX="s" unitY="rad/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">gyr_time</input>
                <input axis="y">gyrZ</input>
            </graph>
        </view>
        <view label="Absolute">
            <graph editor:uuid="158" label="Absolute" aspectRatio="2.5" style="lines" lineWidth="1" color="white" partialUpdate="true" history="1" labelX="t" labelY="ω" labelZ="" unitX="s" unitY="rad/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">gyr_time</input>
                <input axis="y">gyr</input>
            </graph>
            <value editor:uuid="159" label="Absolute" size="2" precision="3" scientific="false" unit="rad/s" factor="1" >
                <input>gyr</input>
            </value>
        </view>
        <view label="Multi">
            <graph editor:uuid="160" label="Gyroscope" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="true" history="1" labelX="t" labelY="ω" labelZ="" unitX="s" unitY="rad/s" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">gyr_time</input>
                <input axis="y">gyrX</input>
                <input axis="x">gyr_time</input>
                <input axis="y">gyrY</input>
                <input axis="x">gyr_time</input>
                <input axis="y">gyrZ</input>
                <input axis="x">gyr_time</input>
                <input axis="y">gyr</input>
            </graph>
            <value editor:uuid="161" label="Gyroscope x" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="green">
                <input>gyrX</input>
            </value>
            <value editor:uuid="162" label="Gyroscope y" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="blue">
                <input>gyrY</input>
            </value>
            <value editor:uuid="163" label="Gyroscope z" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="yellow">
                <input>gyrZ</input>
            </value>
            <value editor:uuid="164" label="Absolute" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="white">
                <input>gyr</input>
            </value>
        </view>
        <view label="Simple">
            <value editor:uuid="165" label="Gyroscope x" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="green">
                <input>gyrX</input>
            </value>
            <value editor:uuid="166" label="Gyroscope y" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="blue">
                <input>gyrY</input>
            </value>
            <value editor:uuid="167" label="Gyroscope z" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="yellow">
                <input>gyrZ</input>
            </value>
            <value editor:uuid="168" label="Absolute" size="2" precision="3" scientific="false" unit="rad/s" factor="1" color="white">
                <input>gyr</input>
            </value>
        </view>        
    </views>
    <export>
        <set name="Raw Data">
            <data name="Time (s)">acc_time</data>
            <data name="Acceleration x (m/s^2)">accX</data>
            <data name="Acceleration y (m/s^2)">accY</data>
            <data name="Acceleration z (m/s^2)">accZ</data>
            <data name="Absolute acceleration (m/s^2)">acc</data>
            <data name="Latitude (°)">lat</data>
            <data name="Longitude (°)">lon</data>
            <data name="Height (m)">z</data>
            <data name="Speed (m/s)">v</data>
            <data name="Direction (°)">dir</data>
            <data name="Distance (km)">dist</data>
            <data name="Horizontal Accuracy (m)">accuracy</data>
            <data name="Vertical Accuracy (m)">zAccuracy</data>
            <data name="Satellites">satellites</data>
            <data name="Time (s)">gyr_time</data>
            <data name="Gyroscope x (rad/s)">gyrX</data>
            <data name="Gyroscope y (rad/s)">gyrY</data>
            <data name="Gyroscope z (rad/s)">gyrZ</data>
            <data name="Absolute (rad/s)">gyr</data>
        </set>        
    </export>
</phyphox>

I then tired to connect the ESP32 C3 via BLE not over the BLE button in the app but over a selfemade project in the project editor. 
I tried 2 tutorials to set up the arduino, but could not get it running. 
Bluetooth | Seeed Studio Wiki
ESP32 BLE Server and Client (Bluetooth Low Energy) | Random Nerd Tutorials

With the first tutorial I was able to change the Device name of the ESP32. 
With the second one I was able to generate some input to the App but not my sensor readings. 

The code after the first tutorial looked like this: 
Code:
#include "Adafruit_MCP9601.h"
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <phyphoxBle.h>
#include <Adafruit_MLX90614.h>
#define SERVICE_UUID        "885b0ed0-67c1-47b1-9886-08eb03048e8d"
#define CHARACTERISTIC_UUID "bd7e95b8-7cb1-4e3e-8f27-56d22523d9a3"
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
//RR mcp4 67
#define I2C_ADDRESS1 (0x67)
#define temp_alert1 100
#define temp_alert2 300
#define temp_alert3 400
#define temp_alert4 500
class MyCallbacks: public BLECharacteristicCallbacks {
    void onWrite(BLECharacteristic *pCharacteristic) {
      std::string value = pCharacteristic->getValue();
      if (value.length() > 0) {
        Serial.println("*********");
        Serial.print("New value: ");
        for (int i = 0; i < value.length(); i++)
          Serial.print(value[i]);
        Serial.println();
        Serial.println("*********");
      }
    }
};
Adafruit_MCP9601 mcp1;
void setup()
{
  BLEDevice::init("Temp_Control");
  BLEServer *pServer = BLEDevice::createServer();
  BLEService *pService = pServer->createService(SERVICE_UUID);
  BLECharacteristic *pCharacteristic = pService->createCharacteristic(
                                         CHARACTERISTIC_UUID,
                                         BLECharacteristic::PROPERTY_READ |
                                         BLECharacteristic::PROPERTY_WRITE
                                       );
  pCharacteristic->setCallbacks(new MyCallbacks());
  pCharacteristic->setValue("Hello World");
  pService->start();
  BLEAdvertising *pAdvertising = pServer->getAdvertising();
  pAdvertising->start();
   
PhyphoxBLE::start();
Serial.begin(9600);
mlx.begin();
/* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
if (! mcp1.begin(I2C_ADDRESS1)) {
    Serial.println("Sensor not found. Check wiring!");
    while (1);
    }
  Serial.println("Found MCP9601!");
  mcp1.setADCresolution(MCP9600_ADCRESOLUTION_18);
  Serial.print("ADC resolution set to ");
  switch (mcp1.getADCresolution()) {
    case MCP9600_ADCRESOLUTION_18:   Serial.print("18"); break;
    case MCP9600_ADCRESOLUTION_16:   Serial.print("16"); break;
    case MCP9600_ADCRESOLUTION_14:   Serial.print("14"); break;
    case MCP9600_ADCRESOLUTION_12:   Serial.print("12"); break;
  }
  Serial.println(" bits");
  mcp1.setThermocoupleType(MCP9600_TYPE_N);
  Serial.print("Thermocouple type set to ");
  switch (mcp1.getThermocoupleType()) {
    case MCP9600_TYPE_K:  Serial.print("K"); break;
    case MCP9600_TYPE_J:  Serial.print("J"); break;
    case MCP9600_TYPE_T:  Serial.print("T"); break;
    case MCP9600_TYPE_N:  Serial.print("N"); break;
    case MCP9600_TYPE_S:  Serial.print("S"); break;
    case MCP9600_TYPE_E:  Serial.print("E"); break;
    case MCP9600_TYPE_B:  Serial.print("B"); break;
    case MCP9600_TYPE_R:  Serial.print("R"); break;
  }
  Serial.println(" type");
  mcp1.setFilterCoefficient(0);
  Serial.print("Filter coefficient value set to: ");
  Serial.println(mcp1.getFilterCoefficient());
  mcp1.setAlertTemperature(1, temp_alert1);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(1, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(2, temp_alert2);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(2, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(3, temp_alert3);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(3, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(4, temp_alert4);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(3, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert

  mcp1.enable(true);
  Serial.println(F("------------------------------"));

}
void loop()
{
float temp = mlx.readObjectTempC(); //Generate random number in the range 0 to 100
float temp_IR = mcp1.readThermocouple(); //Generate random number in the range 0 to 100
PhyphoxBLE::write(temp_IR);//Send value to phyphox
    Serial.print(mlx.readObjectTempC());
    Serial.println("*C");
    Serial.println();
//PhyphoxBLE::write(temp_IR);
delay(50);
}

And after the second tutorial it looked like this: 
Code:
#include <BLEDevice.h>
#include <BLEServer.h>
#include <BLEUtils.h>
#include <BLE2902.h>
#include <phyphoxBle.h>
#include <Wire.h>
#include "Adafruit_MCP9601.h"
#include <Adafruit_GFX.h>
#include <Adafruit_MLX90614.h>
//RR mcp4 67
#define I2C_ADDRESS1 (0x67)
#define temp_alert1 100
#define temp_alert2 300
#define temp_alert3 400
#define temp_alert4 500
//BLE server name
#define bleServerName "TempControl"
Adafruit_MLX90614 mlx = Adafruit_MLX90614();
Adafruit_MCP9601 mcp1;
float  temp;
// Timer variables
unsigned long lastTime = 0;
unsigned long timerDelay = 30000;
bool deviceConnected = false;
// See the following for generating UUIDs:
// https://www.uuidgenerator.net/
#define SERVICE_UUID "0ef187e8-eb07-45d3-9a5a-0c736f917661"
// Temperature Characteristic and Descriptor
BLECharacteristic TemperatureCharacteristics("813b7a91-c7ef-47fd-844e-dc28ffdf9dfe", BLECharacteristic::PROPERTY_NOTIFY);
BLEDescriptor bmeTemperatureDescriptor(BLEUUID((uint16_t)0x2902));
//Setup callbacks onConnect and onDisconnect
class MyServerCallbacks: public BLEServerCallbacks {
  void onConnect(BLEServer* pServer) {
    deviceConnected = true;
  };
  void onDisconnect(BLEServer* pServer) {
    deviceConnected = false;
  }
};
// ... //
void setup()

PhyphoxBLE::start();
Serial.begin(115200);
// Create the BLE Device
BLEDevice::init(bleServerName);
// Create the BLE Server
BLEServer *pServer = BLEDevice::createServer();
pServer->setCallbacks(new MyServerCallbacks());
// Create the BLE Service
BLEService *bmeService = pServer->createService(SERVICE_UUID);
// Create BLE Characteristics and Create a BLE Descriptor
// Temperature
bmeService->addCharacteristic(&TemperatureCharacteristics);
bmeTemperatureDescriptor.setValue("IR Temperature Celsius");
TemperatureCharacteristics.addDescriptor(&bmeTemperatureDescriptor);
 
// Start the service
bmeService->start();
// Start advertising
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(SERVICE_UUID);
pServer->getAdvertising()->start();
Serial.println("Waiting a client connection to notify...");
mlx.begin();
/* Initialise the driver with I2C_ADDRESS and the default I2C bus. */
if (! mcp1.begin(I2C_ADDRESS1)) {
    Serial.println("Sensor not found. Check wiring!");
    while (1);
    }
  Serial.println("Found MCP9601!");
  mcp1.setADCresolution(MCP9600_ADCRESOLUTION_18);
  Serial.print("ADC resolution set to ");
  switch (mcp1.getADCresolution()) {
    case MCP9600_ADCRESOLUTION_18:   Serial.print("18"); break;
    case MCP9600_ADCRESOLUTION_16:   Serial.print("16"); break;
    case MCP9600_ADCRESOLUTION_14:   Serial.print("14"); break;
    case MCP9600_ADCRESOLUTION_12:   Serial.print("12"); break;
  }
  Serial.println(" bits");
  mcp1.setThermocoupleType(MCP9600_TYPE_N);
  Serial.print("Thermocouple type set to ");
  switch (mcp1.getThermocoupleType()) {
    case MCP9600_TYPE_K:  Serial.print("K"); break;
    case MCP9600_TYPE_J:  Serial.print("J"); break;
    case MCP9600_TYPE_T:  Serial.print("T"); break;
    case MCP9600_TYPE_N:  Serial.print("N"); break;
    case MCP9600_TYPE_S:  Serial.print("S"); break;
    case MCP9600_TYPE_E:  Serial.print("E"); break;
    case MCP9600_TYPE_B:  Serial.print("B"); break;
    case MCP9600_TYPE_R:  Serial.print("R"); break;
  }
  Serial.println(" type");
  mcp1.setFilterCoefficient(0);
  Serial.print("Filter coefficient value set to: ");
  Serial.println(mcp1.getFilterCoefficient());
  mcp1.setAlertTemperature(1, temp_alert1);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(1, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(2, temp_alert2);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(2, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(3, temp_alert3);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(3, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert
  mcp1.setAlertTemperature(4, temp_alert4);
  Serial.print("Alert #1 temperature set to ");
  Serial.println(mcp1.getAlertTemperature(1));
  mcp1.configureAlert(3, true, true, false, true, true);  // alert 1, enabled, rising temp, cold junction,high on alert

  mcp1.enable(true);
  Serial.println(F("------------------------------"));

}
void loop()
{
// Read temperature as Celsius (the default)
float temp = mlx.readObjectTempC();
//Notify temperature reading from BME sensor
//Set temperature Characteristic value and notify connected client
TemperatureCharacteristics.setValue(temp);
TemperatureCharacteristics.notify();
Serial.print("Temperature Celsius: ");
Serial.print(temp);
Serial.print(" ºC");
delay(50);
}
The xml file for the second tutorial looks like this:
Code:
<phyphox xmlns="http://phyphox.org/xml" xmlns:editor="http://phyphox.org/editor/xml" version="1.7" editor:version="1.0" locale="en">
    <title>BLE Test</title>
    <category>BLE</category>
    <color>00ff00</color>
    <description>BLE Test</description>
    <icon format="string">BLE</icon>
    <data-containers>
        <container size="1000" static="false">Output 1</container>
        <container size="1000" static="false">out</container>
    </data-containers>
    <input>
        <bluetooth editor:uuid="97" editor:posx="102.890625" editor:posy="151.328125"    mode="notification" rate="0" subscribeOnStart="false">
            <output char="813b7a91-c7ef-47fd-844e-dc28ffdf9dfe" conversion="float64BigEndian" label="Temperature">Output 1</output>
        </bluetooth>
    </input>
    <output>
    </output>
    <analysis sleep="0"  onUserInput="false">
        <timer editor:uuid="136" editor:posx="108.546875" editor:posy="43.53125">
            <output as="out">out</output>
        </timer>
    </analysis>
    <views>
        <view label="Raw Data">
            <graph editor:uuid="104" editor:posx="811.109375" editor:posy="70.046875" label="Temperature" aspectRatio="2.5" style="lines" lineWidth="1" color="ff7e22" partialUpdate="false" history="1" labelX="Time" labelY="Temperature" labelZ="" unitX="t" unitY="°C" unitZ="" logX="false" logY="false" logZ="false" xPrecision="3" yPrecision="3" zPrecision="3" scaleMinX="auto" scaleMaxX="auto" scaleMinY="auto" scaleMaxY="auto" scaleMinZ="auto" scaleMaxZ="auto" minX="0" maxX="0" minY="0" maxY="0" minZ="0" maxZ="0"  mapWidth="0"       >
                <input axis="x">out</input>
                <input axis="y">Output 1</input>
            </graph>
            <info editor:uuid="129" label="Temperature" color="00ff00">
            </info>
        </view>
    </views>
    <export>
        <set name="Temp01">
            <data name="Temp01">Output 1</data>
        </set>
    </export>
</phyphox>


I guess my problem after the second tutorial is that I send the wrong values (or format?!) to the phyphox app. 
But I am not sure what to change tbh.
Reply


Messages In This Thread
RE: Internal and external Sensors in one Experiment - by Andreas Weskamp - 07-26-2023, 07:25 PM

Forum Jump: