#include int AnalogPin=27; float Messwert; float Offset; float Magnetfeld; void setup() { PhyphoxBLE::start("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=0; // for(int i=0;i<37;i++){ // Messwert+=analogRead(AnalogPin); //delay(10); // } // Messwert=Messwert/37; Messwert=analogRead(AnalogPin); Magnetfeld=(Messwert-Offset)*(-0.0492); PhyphoxBLE::write(Magnetfeld); delay(50); }