![]() |
|
"Mashing" smartphone GSP and Arduino sensor data - Printable Version +- phyphox Forums (https://phyphox.org/forums) +-- Forum: Discussion (https://phyphox.org/forums/forumdisplay.php?fid=1) +--- Forum: General (https://phyphox.org/forums/forumdisplay.php?fid=3) +--- Thread: "Mashing" smartphone GSP and Arduino sensor data (/showthread.php?tid=2240) |
"Mashing" smartphone GSP and Arduino sensor data - LordHefekloß - 03-11-2026 Hi, not sure if this is the right subforum, please move if necessary. I am trying to combine the data from an Arduino Uno R4 that has a dust sensor connected with GPS data from a smartphone. I fail with both possibilities: 1) Reading Arduino data in Phyphox I cannot get the BLE handshake on phyphox working when creating own experiments with the editor. Bluetooth connection works, but then I get a "Write error on characteristics UUID cddf1002-...." error message. Tried tons on things and yes, PhyphoxBLE::poll() is called <bluetooth name="R4_Test" mode="poll" rate="1"> <config char="cddf1002-30f7-4671-8b43-5e40ba53514a" conversion="float32LittleEndian">TestValue</config> </bluetooth> Happy if somebody has a hint, but I would prefer to get #2 working - just mentioning #1 in case #2 is not possible 2) Reading smartphone GSP data from Arduino In the phyphoxBLE library I do not find any GPS / Location sensor #define SENSOR_ACCELEROMETER "accelerometer" #define SENSOR_ACCELEROMETER_WITHOUT_G "linear_acceleration" #define SENSOR_GYROSCOPE "gyroscope" #define SENSOR_MAGNETOMETER "magnetometer" #define SENSOR_PRESSURE "pressure" #define SENSOR_TEMPERATURE "temperature" #define SENSOR_LIGHT "light" #define SENSOR_HUMIDITY "humidity" #define SENSOR_PROXIMITY "proximity" Is it impossible to read GPS via phyphox library on the Arduino? Cheers B. RE: "Mashing" smartphone GSP and Arduino sensor data - Sebastian Staacks - 04-10-2026 Sorry, we must have someone missed this post. Are you still trying to do this? 1) The issue here is that you are using the "config" tag. This is used to write configuration data (like setting a data rate on a sensor) right after phyphox has established a connection. So, in this case it is converting "TestValue" to a floating point value (not entirely sure, but that should turn into "Not a Number") and try to write it to the given cahracteristic on the Arduino. In order to read a value from the Arduino, this should be an output tag and the bluetooth tag should be within an input tag. Indeed, the Arduino library currently does not include the GPS sensor, so the XML file like this: Code: <input>
<bluetooth name="..." uuid="..." id="..." autoConnect="..." mode="..." rate="..." subscribeOnStart="...">
<output ...>...</output>
</bluetooth>
</input>Also, I would not use poll if it is not strictly necessary for your Arduino code. Notifications are usually a much better solution as the timing of the sensor is usually not controlled by the phone. 2) Unfortunately, the library currently does not support GPS (I am reallizing this myself just now). Since you are already writing your own XML config, I would recommend using the output from the library for any other sensor and then replacing the "sensor" tag in the input block with a "location" tag and the channels that you are interested in. Let me know if you are still interested in this. I have now subscribed to this thread and should not miss your next post. RE: "Mashing" smartphone GSP and Arduino sensor data - justus.goergens@gmx.net - 05-22-2026 [BUG] <location> sensor produces no data in BLE experiments on iOS Hi, following up on this thread — I'm running into the exact issue described in point 2, where the library doesn't support GPS, and I've implemented the recommended workaround (replacing <sensor> with <location> in the input block). However, the GPS data never arrives on iOS, even though it works perfectly in standalone phyphox experiments. Setup
What works
What doesn't work
Current XML (relevant excerpt) Code: <data-containers>
<container size="0" static="false">tGPS</container>
<container size="0" static="false">lat</container>
<container size="0" static="false">lon</container>
<container size="0" static="false">alt</container>
</data-containers>
<input>
<location>
<output component="lat">lat</output>
<output component="lon">lon</output>
<output component="altitude">alt</output>
<output component="time">tGPS</output>
</location>
<bluetooth name="BikeDetector" id="phyphoxBLE"
mode="notification" subscribeOnStart="true">
<output char="cddf1002-30f7-4671-8b43-5e40ba53514a"
conversion="float32LittleEndian" offset="0">aX</output>
<!-- ... remaining channels ... -->
<output char="cddf1002-30f7-4671-8b43-5e40ba53514a"
extra="time">t</output>
</bluetooth>
</input>Arduino loop (no poll, as recommended) Code: static const unsigned long SEND_INTERVAL_MS = 33; // ~30 Hz
void loop() {
if (PhyphoxBLE::currentConnections == 0) {
delay(10);
return;
}
static unsigned long lastSend = 0;
unsigned long now = millis();
if (now - lastSend < SEND_INTERVAL_MS) return;
lastSend = now;
if (!IMU.accelerationAvailable() || !IMU.gyroscopeAvailable()) return;
float ax, ay, az, gx, gy, gz;
IMU.readAcceleration(ax, ay, az);
IMU.readGyroscope(gx, gy, gz);
PhyphoxBLE::write(ax, ay, az, gx, gy);
}Things I have already tried
In all cases: BLE IMU data works, GPS tab renders, GPS containers remain empty. Is this a known iOS-specific limitation? The standalone Location experiment works fine, so location permission and hardware are not the issue — it seems specifically related to how the location manager is initialized in the context of a BLE experiment. RE: "Mashing" smartphone GSP and Arduino sensor data - Sebastian Staacks - 05-29-2026 Sorry once again for the late reply. (I am beginning to wonder if this thread is cursed. I am subscribed to this thread, but I cannot find an email notification anywhere...) I do not see the issue immediately, but if I understand you correctly, the problem is only that the GPS data is not plotted while the latest values are shown. Could you post the entire XML file? It could be the configuration of the graph. I mean, since you are receiving the BLE data and the current GPS data is shown, I suspect that either mismatching data containers are used for x and y or that - if there is also an analysis block - the data is removed in the analysis process. About the things you tried: 1+2. As you are getting a location, everything should be there for plotting 3. That should not make a difference. Internally, the same parser is used and the same classes are initialized with the result - it is just different methods to load the XML from different locations. If it loads it should be the same. 4. That's just for cleaner code. On microcontrollers that do not need it, it is just an empty function call. 5. There are indeed some cases when the app has not been "destroyed" by the system and you open the same file from the same location, it might just come to the foreground instead of reloading it. Returning to the main menu should make sure that it is reloaded next time, though. (If you are unsure if a new file arrives, just change a letter in the title )So, please post the entire XML and I can test it on a phone here. (Also, I set myself a reminder to check this thread regularly. Wondering if the email notifications are having a problem...) RE: "Mashing" smartphone GSP and Arduino sensor data - justus.goergens@gmx.net - 06-01-2026 Hi, Thanks for looking into this! In the meanwhile I figured it out. Turns out you were right about mismatching containers. The data might have been recorded the whole time — after some more changes I exported the CSV and lat/lon values are all there. Seems the problem was purely in the graph: I had tGPS on the x-axis, but that container is always empty. phyphox never writes anything into it, at least not in my setup (iOS, BLE experiment). So the graph had an empty x-axis and silently showed nothing. The fix was removing the timestamp axis entirely and just plotting lat vs lon directly: Code: <graph label="Route" labelX="Longitude" labelY="Latitude" unitX="deg" unitY="deg">
<input axis="x">lon</input>
<input axis="y">lat</input>
</graph>Both containers get populated, graph renders fine. Thanks for the reply, Justus PS: Is component="time" on <location> output expected to work? In my exported CSV the timestamp column is completely empty for every GPS row. RE: "Mashing" smartphone GSP and Arduino sensor data - Sebastian Staacks - 06-01-2026 Yes, it should also give a timestamp, but I think the problem is just that it should be component="t" and not component="time". (Of course, ideally phyphox should complain about this.) |