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.

Using PhyPhox for lsm9ds1 accelerometer
(05-06-2022, 11:41 AM)Hey Dominik,Thank you for your response. I tried to increase the delay but had no success. Thus I read the thread you posted and concluded that I needed to include the first 4 lines of code in the connectionParameters example. I tweaked them to Gautier's numbers as below:  PhyphoxBLE::minConInterval = 6; //6 = 7.5ms Wrote:   PhyphoxBLE::maxConInterval = 6; //6 = 7.5ms

  PhyphoxBLE:ConfusedlaveLatency = 0; //
  PhyphoxBLE::timeout = 10; //10 = 100ms

However the Arduino still isn't showing up on my phyphox app. Is there something else I am missing? Thank you for your help Dominik!

Dominik DorselHey,

your code looks good! I think the problem is within your loop-block:

  IMU.readAcceleration(x, y, z);

This line will return a 1 when new data is available (and the datapoints itself of course). If the accelerometer is not ready, you get an 0 and NAN as you can see in the libraries repository:

Since the loop is basicly running with no delay (except this very small 1ms) you will call some "readAccelertion" while no data is available. You should get new data every ~10ms, since the output data rate is fixed to 104Hz in this library (if you want to change the data rate, you might switch to another library - i think the sparkfun one is able to set some settings).

To avoid this, you could go with this: 
if (IMU.accelerationAvailable()) {
    IMU.readAcceleration(x, y, z);
    PhyphoxBLE::write(x, y, z);
Next issue might be the limiting bluetooth low energy rate. Depending on your smartphone and connection quality you will not be able to reach 115Hz. You should also check the phyphoxBLE example "connectionParamter" which allows to tweak the bluetooth paramter. This thread might be helpful aswell, since our french colleagues where able to get this rate with the same arduino setup:

Let me know if its still not working.


Sorry for the weird previous font. On another note I did some digging and found Gautier's published code. I edited to the following (below) and I got the acceleration in the right format. However, my goal was to create channels of my own, to allow for maximum customizeability. My guess is that the maxConinterval on my previous code isn't the right number, because I am transmitting more data than what Gautier is using. Is there a method to find the maxConinterval I need?

Gautier's Code (edited with my project):

/* Link between Arduino Nano 33 BLE Sense and phyphox app v1
* Allows to choose which experiment the Arduino Nano 33 BLE Sense should execute, using Phyphox.
* by Gautier Creutzer and Frédéric Bouquet, La Physique Autrement / Physics Reimagined, Laboratoire de Physique des Solides / Laboratory of Solid state Physics, Université Paris-Saclay / Paris-Saclay University
* Check our other projects in English and French:
* This work is based on the phyphox Arduino library developed by the phyphox team at the RWTH Aachen University, which is released under the GNU Lesser General Public Licence v3.0 (or newer).
* This work is released under the GNU Lesser General Public Licence v3.0 (or newer).

#include <phyphoxBle.h>
#include <Arduino_LSM9DS1.h>

char board_name[] = "nano_6"; // to change the name displayed by the board using BLE: no space and no special character

float accx, accy, accz, acc;
unsigned long initial_time, first_time, fourth_time;
float first_difference_float, fourth_difference_float;

void setup()

  PhyphoxBLE::minConInterval = 6; //6 = 7.5ms
  PhyphoxBLE::maxConInterval = 6; //6 = 7.5ms
  PhyphoxBLE:ConfusedlaveLatency = 0; //
  PhyphoxBLE::timeout = 10; //10 = 100ms
  if (!IMU.begin()) { // starting all useful sensors
    while (1);
  PhyphoxBLE:Confusedtart("Manvir's Board"); // the name of the board can be changed at the beginning of the program

void loop() { // if the sensor is available, the acceleration and a timestamp are written to the BLE server, and then to the Phyphox app
    if (IMU.accelerationAvailable()) {
      first_time = millis();
      IMU.readAcceleration(accx, accy, accz);
      first_difference_float = ((float)first_time-(float)initial_time)/1000;
      acc = sqrt(pow(accx, 2) + pow(accy, 2) + pow(accz, 2));
      PhyphoxBLE::write(first_difference_float, accx, accy, accz, acc);

Messages In This Thread
RE: Using PhyPhox for lsm9ds1 accelerometer - by ManvirB - 05-06-2022, 07:29 PM

Forum Jump: