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.

Adding a value indicator below a graph BLE
#3
(10-27-2022, 02:47 PM)Jens Noritzsch Wrote: There is an example on the phyphoxBLE GitHub that demonstrates how to mix view elements (and create multiple views): https://github.com/phyphox/phyphox-ardui...riment.ino

I know this example... and I finally got it working:
____________________________________________________________
#include <phyphoxBle.h>

int AnalogPin=27;
float Messwert;
float Magnetfeld;
float Offset;

void setup() {
    PhyphoxBLE:Confusedtart("Magnetfeldsensor_01");                //Start the BLE server

//Experiment
    PhyphoxBleExperiment experiment;

    experiment.setTitle("Magnetfeld");
    experiment.setCategory("Arduino Experiments");
    experiment.setDescription("Plot the magnetic field of a Hall sensor over time.");

    //View
    PhyphoxBleExperiment::View view;

    //Value
    PhyphoxBleExperiment::Value Value1;     
    Value1.setLabel("B = ");                           
    Value1.setUnit("mT");                   
    Value1.setChannel(1);

    //Graph
    PhyphoxBleExperiment::Graph graph;
    graph.setLabel("B over time");
    graph.setUnitX("s");
    graph.setUnitY("mT");
    graph.setLabelX("time");
    graph.setLabelY("B");


    view.addElement(graph);                //Attach graph to view
    view.addElement(Value1);
    experiment.addView(view);              //Attach view to experiment
    PhyphoxBLE::addExperiment(experiment);  //Attach experiment to server

    //Offsetkorrektur 
  Offset=0;
  for(int i=0;i<7;i++){
    Offset+=analogRead(AnalogPin);
    delay(10);
  }
  Offset=Offset/7;

}

void loop() {
Messwert=analogRead(AnalogPin);
Magnetfeld=(Messwert-Offset)*(-0.0492);
PhyphoxBLE::write(Magnetfeld);
delay(50);
}   
 
____________________________________________________
But the strange thing is that if I change details in the programm as e. g. some smoothing in the loop:

.......
 void loop() {
  for(int i=0;i<37;i++){
    Messwert+=analogRead(AnalogPin);
    delay(10);
  }
  Messwert=Messwert/37;
Magnetfeld=(Messwert-Offset)*(-0.0492);
PhyphoxBLE::write(Magnetfeld);
delay(50);
}   

the compilation stops and gives me the following mistake I don't understand. 

C:\_Phaeno\Make_Physics\B-Sensor_ESP_ValueIndicator_Smooth\B-Sensor_ESP_ValueIndicator_Smooth.ino: In function 'void setup()':
B-Sensor_ESP_ValueIndicator_Smooth:22:27: error: 'Value' is not a member of 'PhyphoxBleExperiment'
    PhyphoxBleExperiment::Value Value1;
                          ^~~~~
B-Sensor_ESP_ValueIndicator_Smooth:23:5: error: 'Value1' was not declared in this scope
    Value1.setLabel("B = ");
    ^~~~~~
C:\_Phaeno\Make_Physics\B-Sensor_ESP_ValueIndicator_Smooth\B-Sensor_ESP_ValueIndicator_Smooth.ino:23:5: note: suggested alternative: '_glue'
    Value1.setLabel("B = ");
    ^~~~~~
    _glue
Mehrere Bibliotheken wurden für "phyphoxBle.h" gefunden
Benutzt: C:\Users\klf\Documents\Arduino\libraries\phyphox-arduino-master
Nicht benutzt: C:\Users\klf\Documents\Arduino\libraries\phyphox_BLE
exit status 1
'Value' is not a member of 'PhyphoxBleExperiment'
Reply


Messages In This Thread
RE: Adding a value indicator below a graph BLE - by TorstenKlf - 10-27-2022, 04:56 PM

Forum Jump: