10-27-2022, 04:56 PM
(This post was last modified: 10-27-2022, 09:15 PM by TorstenKlf.)
(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:tart("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'