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.

phyphoxBLE mit 6 Variablen
#4
Hallo,

inzwischen ist das angekündigte Update veröffentlicht! Ich hab mal ein Beispielexperiment erstellt, in dem 6 Werte übertragen und in jeweils einem Graph bzw. einem Value Feld angezeigt werden. Dabei habe ich dann allerdings festgestellt, dass wir das Thema Speicheroptimierung dringend angehen müssen. Als ersten Workaround habe ich die Speicherintensive Experimenterstellung in einen extra "Task" übergeben.
Wir haben auch schon erste Lösungsideen mit der wir das Speicherproblem entschärfen können, benötigen allerdings noch ein wenig Zeit dafür. Ich hoffe der Workaround ist halbwegs verständlich, falls es irgendwo hängt gerne nachfragen!

Falls Arduino Nano User mitlesen: Das Beispiel funktioniert nur mit einem ESP32, die Firmware des Arduino Nano BLE ermöglicht leider nur eine Paketgröße von 20 Byte (obwohl die Hardware mehr könnte).

Viele Grüße
Dominik

Code:
#include <phyphoxBle.h>

void setup()
{
  PhyphoxBLE::start("My Device");
  PhyphoxBLE::setMTU(48); //6 float values 6*4 = 24 bytes

  // An extra task takes care of the experiment creation
  xTaskCreate(
    generateExperiment,    // Function that should be called
    "experimentTask",   // Name of the task (for debugging)
    16000,            // Stack size (bytes)
    NULL,            // Parameter to pass
    1,               // Task priority
    NULL             // Task handle
  );
 
}


void loop()
{

  float value1 = 1+ 0.1*random(0, 10);
  float value2 = 2+ 0.1*random(0, 10);
  float value3 = 3+ 0.1*random(0, 10);
  float value4 = 4+ 0.1*random(0, 10);
  float value5 = 5+ 0.1*random(0, 10);
  float value6 = 6+ 0.1*random(0, 10);

  // store 6 float values in an array
  float values[6] = {value1,value2,value3,value4,value5,value6};

  //send the 6 float values
  PhyphoxBLE::write(&values[0],6);
  delay(100);
}

void generateExperiment(void * parameter){

  //Experiment
  PhyphoxBleExperiment receiveSixFloats;   //generate experiment on Arduino which plot random values
  receiveSixFloats.numberOfChannels = 6;
  receiveSixFloats.setTitle("Random Number Plotter");
  receiveSixFloats.setCategory("Arduino Experiments");
  receiveSixFloats.setDescription("Random numbers are generated on Arduino and visualized with phyphox afterwards");

  //View
  PhyphoxBleExperiment::View firstView;
  firstView.setLabel("FirstView"); //Create a "view"

  PhyphoxBleExperiment::View secondView;
  secondView.setLabel("SecondView"); //Create a "view"
 
  //Value 1
  PhyphoxBleExperiment::Graph Graph1;      //Create graph which will plot random numbers over time
  Graph1.setLabel("Value 1");
  Graph1.setUnitX("s");
  Graph1.setUnitY("");
  Graph1.setLabelX("time");
  Graph1.setLabelY("random number");
  Graph1.setChannel(0, 1);

  PhyphoxBleExperiment::Value Value1;      
  Value1.setLabel("Number 1");                            
  Value1.setUnit("");                     
  Value1.setChannel(1);
 
  //Value 2
  PhyphoxBleExperiment::Graph Graph2;      //Create graph which will plot random numbers over time
  Graph2.setLabel("Value 2");
  Graph2.setUnitX("s");
  Graph2.setUnitY("");
  Graph2.setLabelX("time");
  Graph2.setLabelY("random number");
  Graph2.setChannel(0, 2);
 
  PhyphoxBleExperiment::Value Value2;      
  Value2.setLabel("Number 2");                            
  Value2.setUnit("");                     
  Value2.setChannel(2); 


  //Value 3
  PhyphoxBleExperiment::Graph Graph3;      //Create graph which will plot random numbers over time
  Graph3.setLabel("Value 3");
  Graph3.setUnitX("s");
  Graph3.setUnitY("");
  Graph3.setLabelX("time");
  Graph3.setLabelY("random number");
  Graph3.setChannel(0, 3);
   
  PhyphoxBleExperiment::Value Value3;         //Creates a value-box.
  Value3.setLabel("Number 3");                  //Sets the label
  Value3.setUnit("");                        //The physical unit associated with the displayed value.
  Value3.setChannel(3);

  //Value 4

  PhyphoxBleExperiment::Graph Graph4;      //Create graph which will plot random numbers over time
  Graph4.setLabel("Value 4");
  Graph4.setUnitX("s");
  Graph4.setUnitY("");
  Graph4.setLabelX("time");
  Graph4.setLabelY("random number");
  Graph4.setChannel(0, 4);

  PhyphoxBleExperiment::Value Value4;         //Creates a value-box.
  Value4.setLabel("Number 4");                  //Sets the label
  Value4.setUnit("");                        //The physical unit associated with the displayed value.
  Value4.setChannel(4);

  //Value 5
  PhyphoxBleExperiment::Graph Graph5;      //Create graph which will plot random numbers over time
  Graph5.setLabel("Value 5");
  Graph5.setUnitX("s");
  Graph5.setUnitY("");
  Graph5.setLabelX("time");
  Graph5.setLabelY("random number");
  Graph5.setChannel(0, 5);
   
  PhyphoxBleExperiment::Value Value5;         //Creates a value-box.
  Value5.setLabel("Number 5");                  //Sets the label
  Value5.setUnit("");                        //The physical unit associated with the displayed value.
  Value5.setChannel(5);

  //Value 6
  PhyphoxBleExperiment::Graph Graph6;      //Create graph which will plot random numbers over time
  Graph6.setLabel("Value 6");
  Graph6.setUnitX("s");
  Graph6.setUnitY("");
  Graph6.setLabelX("time");
  Graph6.setLabelY("random number");
  Graph6.setChannel(0, 6);
   
  PhyphoxBleExperiment::Value Value6;         //Creates a value-box.
  Value6.setLabel("Number 6");                  //Sets the label
  Value6.setUnit("");                        //The physical unit associated with the displayed value.
  Value6.setChannel(6);

  firstView.addElement(Graph1);            //attach graph to view
  firstView.addElement(Value1);               //attach value to view
 
  firstView.addElement(Graph2);            //attach graph to view
  firstView.addElement(Value2);               //attach value to view

  firstView.addElement(Graph3);            //attach graph to view 
  firstView.addElement(Value3);               //attach value to view

  firstView.addElement(Graph4);            //attach graph to view
  firstView.addElement(Value4);               //attach value to view
 
  firstView.addElement(Graph5);            //attach graph to view
  firstView.addElement(Value5);               //attach value to view

  firstView.addElement(Graph6);            //attach graph to view 
  firstView.addElement(Value6);               //attach value to view
  receiveSixFloats.addView(firstView);         //attach view to experiment
  PhyphoxBLE::addExperiment(receiveSixFloats);      //attach experiment to server

  vTaskDelete(NULL);
  }
Reply


Messages In This Thread
phyphoxBLE mit 6 Variablen - by MZUL - 02-20-2022, 06:50 PM
RE: phyphoxBLE mit 6 Variablen - by MZUL - 02-21-2022, 06:53 PM
RE: phyphoxBLE mit 6 Variablen - by Dominik Dorsel - 03-04-2022, 06:07 PM
RE: phyphoxBLE mit 6 Variablen - by MZUL - 03-11-2022, 05:21 PM

Forum Jump: