http://phyphox.org/wiki/api.php?action=feedcontributions&user=Nefft0n&feedformat=atomphyphox - User contributions [en]2024-03-29T14:47:54ZUser contributionsMediaWiki 1.34.2http://phyphox.org/wiki/index.php?title=Externer_Magnetfeldsensor&diff=21426Externer Magnetfeldsensor2023-11-18T08:16:09Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Externer Magnetfeldsensor<br />
| Category = Arduino library experiments<br />
| Sensors = 49e<br />
}}<br />
<br />
Magnetfeldern von Permanentmagneten oder stromdurchflossenen Spulen lassen sich mit den in Smartphones integrierten Magnetfeldsensoren praktisch nicht messen. Das liegt daran, dass die eingebauten Sensoren für sehr schwache Magnetfelder ausgelegt sind, um eine Kompassfunktion zu ermöglichen. In der Regel geht der Messbereich bis maximal 5 mT.<br />
Möchte man z. B. das Magnetfeld einer Spule entlang der Spulenachse ausmessen, muss der Messbereich eine Größenordnung darüberliegen. Im Folgenden Versuch wird mittels eines Hallsensors (Typ 49e) ein einfach zu benutzender Magnetfeldsensor verwendet, der auch von Oberstufenschülern selbst gebaut werden kann (aktuelle Sicherheitsrichtlinien nach RISU beachten!).<br />
<br />
<gallery widths=500px heights=300px><br />
File:SpulenBFeld.jpg|Aufbau<br />
File:B_Sensor2.jpg|Sensor<br />
</gallery><br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) dppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
<br />
<br />
==Aufbau==<br />
Bei B = 0 beträgt die vom Halsensor (49e) ausgegebene Spannung die Hälfte der dort angelegten Spannung. Somit ist die Differenz zwischen Ausgegebener Spannung und halber angelegter Spannung Proportional zum Magnetfeld:<br />
<br />
V_out-V_DD∼B.<br />
<br />
Die Steigung der Geraden beträgt ca. (3 V)/(200 mT). Die ADCs des ESP32 haben eine Auflösung von 12 Bit. Bei einer anliegenden Spannung U wird somit der Zahlenwert Messwert= U/(3,3 V)⋅4096 herausgegeben. <br />
In unserer Schaltung liegt die Ausgangsspannung am Pin 27 des ESP32 an. Dieser gibt den eben erläuterten zur Spannung proportionalen Messwert als Zahl heraus. Die magnetische Feldstärke berechnet sich dann zu<br />
<br />
B=(Messwert-4096/2)⋅(200 mT)/4096=(Messwert-2048)⋅0,049 mT.<br />
<br />
Da die vorliegende Werte meist etwas driften, wird zu Beginn des Programms wird eine Offsetkorrektur vorgenommen. Das bei Einschalten des Sensors anliegende B-Feld wird als null angenommen. Die Steigung (Faktor 0,049 in Gleichung oben) muss in der Regel individuell an den Sensor angepasst werden. Eine passende Formel findet sich auf dem unten verlinkten Arbeitsblatt. Diese Kalibrierung kann dann mit einer Spule bekannter Geometrie und Windungszahl durchgeführt werden. Beim Programm unten beträgt der Faktor deshalb 0,0492.<br />
Zu guter Letzt wird noch eine Mittelwertbildung über 37 Werte vorgenommen. Auch dies lässt sich natürlich individuell anpassen.<br />
<br />
V_out geht an Pin 27, + an 3,3 V und – an Gnd. Der Hallsensor wurde hier noch nach oben gebogen, da so z. B. das Magnetfeld einer Spule vermessen werden kann. Um das Rauschen zu verringern, empfiehlt es sich, die Vout-Leitung mit einem 10-kOhm-Widerstand auf Masse zu ziehen.<br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) doppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Magnetfeldsensor_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* ////////////////////////////////////////////////////////////////////////////<br />
phyphox ESP32 for hall sensor E49<br />
This program reads out the simple analog values and sends them to phyphox.<br />
TODO: Calibration option<br />
AUTHOR: Torsten Klaffs<br />
LICENSE: CC0<br />
*/<br />
<br />
#include <phyphoxBle.h><br />
<br />
// Der Hall Sensor ist verbunden mit GPIO PIN 2<br />
const int hallPin = 2;<br />
<br />
// Weitere Defintionen<br />
float hallValue;<br />
float meanHallValue;<br />
float magneticField;<br />
int meanCount = 10;<br />
float offset = 0;<br />
<br />
void setup() {<br />
PhyphoxBLE::start("ESP32 Hall-Sensor 01"); // Bluetooth-Name<br />
<br />
// Defintion des Experimentesa<br />
PhyphoxBleExperiment e49;<br />
e49.setTitle("Hall-Sensor");<br />
e49.setCategory("ESP32 Experiment");<br />
<br />
// Views (Tabs in der App)<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Rohdaten");<br />
<br />
// Graph (ein einzelner Graph)<br />
PhyphoxBleExperiment::Graph firstGraph;<br />
firstGraph.setLabel("Stärke Magnetfeld");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("mT");<br />
firstGraph.setLabelX("Zeit");<br />
firstGraph.setLabelY("Magnetfeld");<br />
firstGraph.setChannel(0, 1);<br />
<br />
// Value (zeige Wert, hier den letzten gesendeten)<br />
PhyphoxBleExperiment::Value firstValue;<br />
firstValue.setLabel("Magnetfeld");<br />
firstValue.setUnit("mT");<br />
firstValue.setPrecision(0);<br />
firstValue.setChannel(1);<br />
<br />
// Export derDaten<br />
PhyphoxBleExperiment::ExportSet dataSet; //Provides exporting the data to excel etc.<br />
dataSet.setLabel("Data Set");<br />
PhyphoxBleExperiment::ExportData exportData;<br />
exportData.setLabel("Data Export");<br />
exportData.setDatachannel(1);<br />
<br />
// Experiment zusammen stellen<br />
firstView.addElement(firstGraph);<br />
firstView.addElement(firstValue);<br />
e49.addView(firstView);<br />
dataSet.addElement(exportData);<br />
e49.addExportSet(dataSet);<br />
PhyphoxBLE::addExperiment(e49);<br />
<br />
// Offsetkorrektur<br />
/*<br />
for(int i=0; i<100; i++) {<br />
Offset += analogRead(hallPin);<br />
delay(10);<br />
}<br />
offset = offset/100;<br />
*/<br />
}<br />
<br />
void loop() {<br />
// Mittelwert über "meanCount" Werte bilden, um Rauschen zu minimieren<br />
hallValue = 0;<br />
for (int i = 0; i < meanCount; i++) {<br />
hallValue = hallValue + analogRead(hallPin);<br />
delay(5);<br />
}<br />
<br />
// Genauen Wert ausrechnen<br />
meanHallValue = (hallValue / meanCount);<br />
magneticField = (meanHallValue - offset - 2048) * 0.049;<br />
//magneticField = (meanHallValue - offset) * (-0.0492); // other conversion, need to check which is right<br />
<br />
// Daten senden<br />
PhyphoxBLE::write(magneticField);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt (aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
Das folgende Material ist im Rahmen einer Lehrerfortbildung im Jahre 2022 in Niedersachsen entstanden. Es richtet sich an Physiklehrkräfte, also Fachleute. Jede Lehrkraft ist selbst dafür verantwortlich, die aktuell geltenden sicherheitsrichtlinien nach RISU einzuhalten und im Vorfeld selbst eine Gefährdungsbeurteilung zu schreiben. Der Autor dieses Materials übernimmt keinerlei Haftung für Schäden, die bei der Anwendung entstehen. <br />
<br />
[[file:AB_Magnetfeldsensor_Spule.pdf]]<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Ein_Thermometer_f%C3%BCr_alle_F%C3%A4lle&diff=21425Ein Thermometer für alle Fälle2023-11-18T07:54:43Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Ein Thermometer für alle Fälle<br />
| Category = Arduino library experiments<br />
| Sensors = DS18B20<br />
}}<br />
<br />
Der DS18B20 ist ein sehr weit verbreiteter Temperatursensor. Dank des OneWire-Buses hat der Sensor nur drei Anschlüsse und kann extrem einfach mit einem Mikrocontroller verbunden werden. Zusätzlich wird noch ein 4k7-Widerstand benötigt, um den OneWire-Bus zu stabilisieren. Um den Temperatursensor schön kompakt zu gestalten, wurde auf dem Bild oben ein ESP32-C3 verwendet. Der kann nicht so viel wie der normale ESP32, muss es hier aber auch nicht.<br />
<br />
[[File:DS18B20.jpg]]<br />
<br />
<br />
==Aufbau==<br />
<br />
Der Temperatursensor liefert seine Daten über den OneWire-Bus: 3V3 – Vin, Gnd – Gnd, 2 - Datenbus. Der Datenbus Pin 2 ist, wie oben beschrieben, über Pullup-widerstand auf "High" hochgezogen. Die Bluetooth-Antenne wurde einfach abgeknipst, für kurze Entfernungen reicht es mit dem Rest den Rest den Anschlusskabels. Achtung: Das Koaxialkabel muss so abgekniffen werden, dass nichts kurzgeschlossen wird!<br />
<br />
Ist alles verlötet und funktioniert, kann es kompakt mit Schrupfschlauch eingepackt werden. Nicht vergessen, den dünneren Schrupfschlauch für die Zugentlastung und Knickschutz vor dem Löten übers Kabel zu schieben...<br />
<br />
[[File:DS18B20_2.jpg]]<br />
<br />
<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Thermometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* ////////////////////////////////////////////////////////////////////////////<br />
phyphox ESP32 for temperature sensor DS18B20<br />
TODO: -<br />
AUTHOR: Torsten Klaffs<br />
LICENSE: CC0<br />
*/<br />
<br />
#include <phyphoxBle.h><br />
#include <OneWire.h> // listet in library manager<br />
#include <DallasTemperature.h> // listet in library manager<br />
#define ONE_WIRE_BUS 2 // sensor is connected to GPIO2<br />
<br />
OneWire oneWire(ONE_WIRE_BUS);<br />
DallasTemperature sensors(&oneWire);<br />
<br />
<br />
void setup(void) {<br />
// Start the BLE server, argument is visible name<br />
PhyphoxBLE::start("Thermometer 01");<br />
<br />
//Experiment<br />
PhyphoxBleExperiment thermometer;<br />
thermometer.setTitle("Thermometer");<br />
thermometer.setCategory("ESP32 Experiment");<br />
thermometer.setDescription("Plot the Temperature over time. Used togehter with an DS18B20");<br />
<br />
// View<br />
PhyphoxBleExperiment::View view;<br />
view.setLabel("Raw data");<br />
<br />
// Graph<br />
PhyphoxBleExperiment::Graph tempGraph;<br />
tempGraph.setLabel("Temperatur");<br />
tempGraph.setUnitX("s");<br />
tempGraph.setUnitY("°C");<br />
tempGraph.setLabelX("time");<br />
tempGraph.setLabelY("Theta");<br />
tempGraph.setChannel(0, 1);<br />
<br />
view.addElement(tempGraph); // attach graph to view<br />
thermometer.addView(view); // attach view to experiment<br />
PhyphoxBLE::addExperiment(thermometer); // attach experiment to server<br />
<br />
sensors.begin();<br />
}<br />
<br />
void loop(void) { <br />
sensors.requestTemperatures(); // request all temperatures<br />
float T = sensors.getTempCByIndex(0); // get temperature with index 0<br />
PhyphoxBLE::write(T); // send temperature to phyphox<br />
delay(500); // wait 500ms<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Oxidation_(Photosynthese)&diff=21388Oxidation (Photosynthese)2023-09-30T07:21:15Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Oxidation<br />
| Category = Arduino library experiments<br />
| Sensors = CO2 and O2<br />
}}<br />
<br />
<br />
In diesem Experiment werden ein O2 und ein CO2-Sensor ausgelesen. Damit können Verbrennungsprozesse gemessen werden, was gerade bei Pflanzen im Biologieunterricht (Photosynthese) sehr interessant und vor allem gut messbar ist. Leider sind die Sensoren jedoch recht teuer. <br />
<br />
Mit dem unten gezeigten Messaufbau lässt sich messen, wie sich in Abhängigkeit der Beleuchtungsstärke der Sauerstoff- und CO2-Gehalt in der Messkammer antizyklisch ändern. Die verwendete 9,5-W-LED war während der Beleuchtungsphasen nah über der Kresse positioniert.<br />
<br />
<gallery widths=500px heights=400px><br />
File:Photosynth_withBox.jpg|Messung der Photosythese von Kresse. Der CO2-Sensor war nicht perfekt kalibriert, weshalb der angezeigte CO2-Gehalt etwas zu hoch ist.<br />
</gallery><br />
<br />
<br />
<br />
==Aufbau==<br />
<gallery widths=500px heights=400px><br />
File:Sensormake.jpg|Einbau der Sensoren in die 3-D-gedruckten Gehäuse<br />
File:Messbox.jpg|3-D-gedruckte Messbox<br />
</gallery><br />
<br />
Die Sensoren dieses Versuches sind recht teuer, pro Sensor ist mit ca. 150€ zu rechnen (Stand 09/2023). Sensoren in dieser Qualität sind jedoch nicht viel günstiger zu bekommen. Verwendet werden der LuminOX von [https://sstsensing.com/product/luminox-optical-oxygen-sensors-2/ SST Sensing], der manchmal etwas schwierig zu beschaffen ist, und der ExplorIR, auch von [https://sstsensing.com/product/explorir-m-ndir-co2-sensor/ SST Sensing]. Beim CO2-Sensor können für dieses Experiment auch günstigere Modelle verwendet werden, die bis 5000ppm messen können.<br />
<br />
Um die Sensoren vernünftig handeln zu können, wurden mithilfe eines 3-D-Druckers zwei Gehäuse und eine Messbox gefertigt. Die .stl-Files können gepackt in der folgenden Datei heruntergeladen werden: [[file:Photosynthese_housings.zip]].<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Voltmeter XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* phyphox ESP32 for ExplorIR-M 20 (CO2-sensor) and LuminOX (O2-sensor)<br />
reads out values and sends them to phyphox, option to calibrate CO2 sensor<br />
https://www.gassensing.co.uk/product/explorir-m-co2-sensor/<br />
https://sstsensing.com/wp-content/uploads/2018/01/UG-001_LuminOx_UserGuide_rev2.pdf<br />
AUTHOR: Niklas Westermann<br />
LICENCSE: CC0<br />
*/<br />
<br />
#include <HardwareSerial.h><br />
#include <phyphoxBle.h><br />
<br />
void receivedData();<br />
int co2calibration = 0;<br />
int co2calibrationOld = 0;<br />
<br />
// Define serial ports<br />
// PIN16 and PIN17 are officially, but most ports can be used,<br />
// so 22 and 23 work too. Be careful when changing theses ports!<br />
HardwareSerial explorPort(1); //UART on ESP32 (PIN22 and PIN23)<br />
HardwareSerial luminoxPort(2); //UART on ESP32 (PIN16 and PIN17)<br />
<br />
void setup() {<br />
// Setup serial ports and sensors<br />
Serial.begin(9600); // Port for serial output via USB<br />
Serial.println("Start ESP32...");<br />
explorPort.begin(9600, SERIAL_8N1, 22, 23); // ExplorIR on PIN22-TX and PIN23-RX<br />
luminoxPort.begin(9600, SERIAL_8N1, 16, 17); // luminOX on PIN16-TX and PIN17-RX<br />
explorPort.print("K 2\r\n"); // Set sensor to polling (mode 2)<br />
luminoxPort.print("M 1\r\n"); // Set LuminOX to polling (mode 1)<br />
<br />
// Setup phyphox<br />
PhyphoxBLE::start("Oxidation Sensors");<br />
PhyphoxBLE::configHandler=&receivedData;<br />
<br />
// Experiment<br />
PhyphoxBleExperiment oxidation;<br />
oxidation.setTitle("Oxidation Sensors");<br />
oxidation.setCategory("ESP32 Experiments");<br />
oxidation.setDescription("Read O2 and CO2 Sensors");<br />
<br />
// Views<br />
PhyphoxBleExperiment::View graphView;<br />
graphView.setLabel("Data");<br />
PhyphoxBleExperiment::View calibView;<br />
calibView.setLabel("Calibration");<br />
<br />
// Graphs<br />
PhyphoxBleExperiment::Graph co2Graph;<br />
co2Graph.setLabel("Carbon dioxide");<br />
co2Graph.setLabelX("Time");<br />
co2Graph.setLabelY("Concentration");<br />
co2Graph.setUnitX("s");<br />
co2Graph.setUnitY("ppm");<br />
co2Graph.setChannel(0, 1);<br />
<br />
PhyphoxBleExperiment::Graph o2Graph;<br />
o2Graph.setLabel("Dioxide");<br />
o2Graph.setLabelX("Time");<br />
o2Graph.setLabelY("Concentration");<br />
o2Graph.setUnitX("s");<br />
o2Graph.setUnitY("%");<br />
o2Graph.setChannel(0, 2);<br />
<br />
// Edit<br />
PhyphoxBleExperiment::Edit calibration;<br />
calibration.setLabel("Sensor calibration");<br />
calibration.setUnit("ppm");<br />
calibration.setSigned(false);<br />
calibration.setDecimal(false);<br />
calibration.setChannel(1);<br />
PhyphoxBleExperiment::InfoField calibInfo;<br />
calibInfo.setInfo("To calibrate, enter the value of the actual carbon dioxide concentration. Outside, this should be 440ppm.");<br />
<br />
// Put together experiment<br />
graphView.addElement(co2Graph);<br />
graphView.addElement(o2Graph);<br />
calibView.addElement(calibration);<br />
calibView.addElement(calibInfo);<br />
oxidation.addView(graphView);<br />
oxidation.addView(calibView); //attach view to experiment<br />
PhyphoxBLE::addExperiment(oxidation); //attach experiment to server<br />
}<br />
<br />
void loop() {<br />
/* The ExplorIR outputs a string (in mode 1, streaming) with the following<br />
contents:<br />
"Z AAAAA z BBBBB \r\n" with AAAAA as the filtered value in ppm<br />
and BBBBB as the unfiltered value. This value has to be multiplied<br />
by the multiplier to get the real value in ppm (see below).<br />
To get the values, substring() and toFloat() are used, since there<br />
will be no changes in the output.<br />
Since we use mode 2, the "Z" command is send and then the answer processed<br />
*/<br />
explorPort.print("Z\r\n");<br />
String explorValueStr = explorPort.readStringUntil('\n');<br />
Serial.print("Raw values explor: ");<br />
Serial.println(explorValueStr);<br />
float explorValue = explorValueStr.substring(3).toFloat();<br />
// The two commands below are only needed in combination with mode 1 (streaming)<br />
// and explorPort.available()<br />
//explorValue = explorValueStr.substring(3, 8).toFloat();<br />
//float explorValueUnfilt = explorValueStr.substring(11).toFloat();<br />
<br />
// To get the multiplier, a command is send<br />
explorPort.print(".\r\n");<br />
String explorMultiplierStr = explorPort.readStringUntil('\n');<br />
float explorMultiplier = explorMultiplierStr.substring(3).toFloat();<br />
<br />
// Now we multiply the value with the multiplier<br />
explorValue = explorValue * explorMultiplier;<br />
Serial.println(explorValue);<br />
<br />
/*<br />
LuminOX<br />
The luminox is put in polling mode above, the answer on "% \r\n" is<br />
"% xxxx.xx\r\n" so we need only the chars from place 3 and above<br />
*/<br />
luminoxPort.print("% \r\n");<br />
String luminoxValueStr = luminoxPort.readStringUntil('\n');<br />
Serial.print("Raw values luminox: ");<br />
Serial.println(luminoxValueStr);<br />
float luminoxValue = luminoxValueStr.substring(3).toFloat();<br />
// The two commands below are only needed in combination with mode 1<br />
// and explorPort.available()<br />
luminoxValue = luminoxValueStr.substring(3, 8).toFloat();<br />
Serial.println(luminoxValue);<br />
<br />
// Send data to phyphox<br />
PhyphoxBLE::write(explorValue, luminoxValue);<br />
// In streaming mode, the sensors send a value every 500ms<br />
// to obtain stable values, we measure every second.<br />
// If higher measurement frequency is needed, change this here,<br />
// but be careful on too low values.<br />
delay(1000);<br />
}<br />
<br />
// Function to calibrate the co2 sensor<br />
void receivedData(){<br />
float co2calibFloat;<br />
<br />
PhyphoxBLE::read(co2calibFloat);<br />
co2calibration = (int)co2calibFloat / 10; // TODO better handling for factor<br />
// only change if greater than 0 and a new (!) value<br />
if(co2calibration >= 0 && co2calibration != co2calibrationOld) {<br />
Serial.print("Calibration value: ");<br />
Serial.println(co2calibration);<br />
String calibMessage = "X " + String(co2calibration) + "\r\n";<br />
//Serial.println(calibMessage);<br />
explorPort.print(calibMessage);<br />
String explorAnswer = explorPort.readStringUntil('\n'); // Read answer<br />
//Serial.println(explorAnswer);<br />
co2calibrationOld = co2calibration;<br />
}<br />
}<br />
</pre><br />
<br />
==Auswertung==<br />
<br />
<br />
==Probleme und Lösungen==<br />
Bei diesem Versuch kann es nach längerer Beleuchtung passieren, dass die Luftfeuchtigkeit zu sehr ansteigt und die angezeigte CO2-Konzentration stark verfälscht (erhöht) ist.<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Distanzsensor_(Federpendel)&diff=21385Distanzsensor (Federpendel)2023-09-27T14:30:21Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Distanzsensor (Federpendel)<br />
| Category = Arduino library experiments<br />
| Sensors = Distance<br />
}}<br />
Die verschiedenen Arten einer Pendelschwingung sind integraler Bestandteil des Lehrplans. mit phyphox können direkt nur die Beuschleunigung und die Drehrate des Smartphones gemessen werden und so die Schwingung dargestellt werden.<br />
<br />
Mit einem Distanzsensor kann die Schwingung eines Federpendels sehr simpel gemessen werden. Generell ist natürlich die Messung sämtlicher Distanzen möglich, beim Federpendel ist der Aufbau jedoch am einfachsten.<br />
<br />
==Aufbau==<br />
Zuerst muss der ESP32 programmiert und verbunden werden. Der Sensor wird mit Plus und Minus an den 3,3V-PIN und den GND-PIN des ESP angeschlossen. SDA kommen an PIN21 und SCL an PIN22. Wir verwenden an dieser Stelle den Time of Flight (ToF) Sensor VL32L0X, dieser misst mittels Lichtpulsen die Distanz zum Objekt recht genau. Als Reflektionsfläche reicht ein größeres Stück Papier, das auf den Pendelkörper geklebt wird.<br />
<br />
Als Pendelkörper kann ein Glas verwendet werden, in dessen Deckel ein kleines Loch gebohrt wird und eine Schnur befestigt wird. Dann kann das ganze Glas an eine Feder gehängt werden und das Gewicht mittels Wasser im Glas verändert werden. Unten auf das Glas wird ein festes Stück Papier geklebt.<br />
<br />
Anschließend wird der Sensor unter das Glas gelegt (am besten mit Doppelseitigem Klebeband befestigen) und die Messung kann gestartet werden.<br />
<br />
<gallery widths=500px heights=400px><br />
File:ESP pendulum.jpg<br />
</gallery><br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Distance-Sensor XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* phyphox ESP32 for distance sensor VL53L0X<br />
reads out values and sends them to phyphox<br />
AUTHOR: Niklas Westermann<br />
LICENCSE: CC0<br />
*/<br />
<br />
#include <phyphoxBle.h><br />
#include "Adafruit_VL53L0X.h" // needs to be installed!<br />
<br />
// SDA to PIN21 und SCL to PIN22<br />
Adafruit_VL53L0X distSensor = Adafruit_VL53L0X();<br />
float distValue;<br />
<br />
void setup() {<br />
PhyphoxBLE::start("ESP32 Distance-Sensor");<br />
<br />
PhyphoxBleExperiment vl53l0x;<br />
<br />
vl53l0x.setTitle("Distance-Sensor");<br />
vl53l0x.setCategory("ESP32 Experiment");<br />
<br />
// Views (Tabs in der App)<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Rohdaten");<br />
<br />
// Graph (ein einzelner Graph)<br />
PhyphoxBleExperiment::Graph firstGraph;<br />
firstGraph.setLabel("Abstand");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("mm");<br />
firstGraph.setLabelX("Zeit");<br />
firstGraph.setLabelY("Abstand");<br />
firstGraph.setChannel(0, 1);<br />
<br />
// Value (zeige letzten Wert)<br />
PhyphoxBleExperiment::Value firstValue;<br />
firstValue.setLabel("Abstand");<br />
firstValue.setUnit("mm");<br />
firstValue.setPrecision(0);<br />
firstValue.setChannel(1);<br />
<br />
// Export<br />
PhyphoxBleExperiment::ExportSet dataSet; //Provides exporting the data to excel etc.<br />
dataSet.setLabel("Data Set");<br />
PhyphoxBleExperiment::ExportData exportData;<br />
exportData.setLabel("Data Export");<br />
exportData.setDatachannel(1);<br />
<br />
// Attach to experiment<br />
firstView.addElement(firstGraph); //attach graph to view<br />
firstView.addElement(firstValue); //attach graph to view<br />
//secondView.addElement(myInfo); //attach info to view<br />
//secondView.addElement(calibrate); //attach separator to view<br />
vl53l0x.addView(firstView); //attach view to experiment<br />
//vl53l0x.addView(secondView);<br />
dataSet.addElement(exportData); //attach data to exportSet<br />
vl53l0x.addExportSet(dataSet); //attach exportSet to experiment<br />
PhyphoxBLE::addExperiment(vl53l0x); //attach experiment to server<br />
<br />
// Test distance sensor<br />
Serial.println("Adafruit VL53L0X test");<br />
if (!distSensor.begin()) {<br />
Serial.println(F("Failed to boot VL53L0X"));<br />
while(1);<br />
}<br />
}<br />
<br />
void loop() {<br />
// read data<br />
VL53L0X_RangingMeasurementData_t distMeas;<br />
distSensor.rangingTest(&distMeas, false); // pass in 'true' to get debug data printout!<br />
<br />
// phase failures have incorrect data<br />
if (distMeas.RangeStatus != 4) {<br />
Serial.print("Distance (mm): "); Serial.println(distMeas.RangeMilliMeter);<br />
distValue = distMeas.RangeMilliMeter;<br />
PhyphoxBLE::write(distValue);<br />
}<br />
else {<br />
Serial.println("out of range");<br />
}<br />
<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterial==<br />
Hier sind zwei Arbeitsblätter zu finden: [[file:distanzsensor_1.pdf]] und [[file:distanzsensor_2.pdf]]<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Distanzsensor_2.pdf&diff=21384File:Distanzsensor 2.pdf2023-09-27T14:28:43Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Distanzsensor_1.pdf&diff=21383File:Distanzsensor 1.pdf2023-09-27T14:28:37Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Distanzsensor_(Federpendel)&diff=21382Distanzsensor (Federpendel)2023-09-27T13:34:56Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Distanzsensor (Federpendel)<br />
| Category = Arduino library experiments<br />
| Sensors = Distance<br />
}}<br />
Die verschiedenen Arten einer Pendelschwingung sind integraler Bestandteil des Lehrplans. mit phyphox können direkt nur die Beuschleunigung und die Drehrate des Smartphones gemessen werden und so die Schwingung dargestellt werden.<br />
<br />
Mit einem Distanzsensor kann die Schwingung eines Federpendels sehr simpel gemessen werden. Generell ist natürlich die Messung sämtlicher Distanzen möglich, beim Federpendel ist der Aufbau jedoch am einfachsten.<br />
<br />
==Aufbau==<br />
Zuerst muss der ESP32 programmiert und verbunden werden. Der Sensor wird mit Plus und Minus an den 3,3V-PIN und den GND-PIN des ESP angeschlossen. SDA kommen an PIN21 und SCL an PIN22. Wir verwenden an dieser Stelle den Time of Flight (ToF) Sensor VL32L0X, dieser misst mittels Lichtpulsen die Distanz zum Objekt recht genau. Als Reflektionsfläche reicht ein größeres Stück Papier, das auf den Pendelkörper geklebt wird.<br />
<br />
Als Pendelkörper kann ein Glas verwendet werden, in dessen Deckel ein kleines Loch gebohrt wird und eine Schnur befestigt wird. Dann kann das ganze Glas an eine Feder gehängt werden und das Gewicht mittels Wasser im Glas verändert werden. Unten auf das Glas wird ein festes Stück Papier geklebt.<br />
<br />
Anschließend wird der Sensor unter das Glas gelegt (am besten mit Doppelseitigem Klebeband befestigen) und die Messung kann gestartet werden.<br />
<br />
<gallery widths=500px heights=400px><br />
File:ESP pendulum.jpg<br />
</gallery><br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Distance-Sensor XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* phyphox ESP32 for distance sensor VL53L0X<br />
reads out values and sends them to phyphox<br />
AUTHOR: Niklas Westermann<br />
LICENCSE: CC0<br />
*/<br />
<br />
#include <phyphoxBle.h><br />
#include "Adafruit_VL53L0X.h" // needs to be installed!<br />
<br />
// SDA to PIN21 und SCL to PIN22<br />
Adafruit_VL53L0X distSensor = Adafruit_VL53L0X();<br />
float distValue;<br />
<br />
void setup() {<br />
PhyphoxBLE::start("ESP32 Distance-Sensor");<br />
<br />
PhyphoxBleExperiment vl53l0x;<br />
<br />
vl53l0x.setTitle("Distance-Sensor");<br />
vl53l0x.setCategory("ESP32 Experiment");<br />
<br />
// Views (Tabs in der App)<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Rohdaten");<br />
<br />
// Graph (ein einzelner Graph)<br />
PhyphoxBleExperiment::Graph firstGraph;<br />
firstGraph.setLabel("Abstand");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("mm");<br />
firstGraph.setLabelX("Zeit");<br />
firstGraph.setLabelY("Abstand");<br />
firstGraph.setChannel(0, 1);<br />
<br />
// Value (zeige letzten Wert)<br />
PhyphoxBleExperiment::Value firstValue;<br />
firstValue.setLabel("Abstand");<br />
firstValue.setUnit("mm");<br />
firstValue.setPrecision(0);<br />
firstValue.setChannel(1);<br />
<br />
// Export<br />
PhyphoxBleExperiment::ExportSet dataSet; //Provides exporting the data to excel etc.<br />
dataSet.setLabel("Data Set");<br />
PhyphoxBleExperiment::ExportData exportData;<br />
exportData.setLabel("Data Export");<br />
exportData.setDatachannel(1);<br />
<br />
// Attach to experiment<br />
firstView.addElement(firstGraph); //attach graph to view<br />
firstView.addElement(firstValue); //attach graph to view<br />
//secondView.addElement(myInfo); //attach info to view<br />
//secondView.addElement(calibrate); //attach separator to view<br />
vl53l0x.addView(firstView); //attach view to experiment<br />
//vl53l0x.addView(secondView);<br />
dataSet.addElement(exportData); //attach data to exportSet<br />
vl53l0x.addExportSet(dataSet); //attach exportSet to experiment<br />
PhyphoxBLE::addExperiment(vl53l0x); //attach experiment to server<br />
<br />
// Test distance sensor<br />
Serial.println("Adafruit VL53L0X test");<br />
if (!distSensor.begin()) {<br />
Serial.println(F("Failed to boot VL53L0X"));<br />
while(1);<br />
}<br />
}<br />
<br />
void loop() {<br />
// read data<br />
VL53L0X_RangingMeasurementData_t distMeas;<br />
distSensor.rangingTest(&distMeas, false); // pass in 'true' to get debug data printout!<br />
<br />
// phase failures have incorrect data<br />
if (distMeas.RangeStatus != 4) {<br />
Serial.print("Distance (mm): "); Serial.println(distMeas.RangeMilliMeter);<br />
distValue = distMeas.RangeMilliMeter;<br />
PhyphoxBLE::write(distValue);<br />
}<br />
else {<br />
Serial.println("out of range");<br />
}<br />
<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Auswertung==<br />
<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:ESP_pendulum.jpg&diff=21381File:ESP pendulum.jpg2023-09-27T13:34:02Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Category:Arduino_library_experiments&diff=21380Category:Arduino library experiments2023-09-26T13:16:46Z<p>Nefft0n: </p>
<hr />
<div>This category contains experiments, which use the Arduino library (https://github.com/phyphox/phyphox-arduino). The Arduino library allows the usage of, for example, an ESP8266, an ESP32 or an classic Arduino.<br />
<br />
You can find a (german) video tutorial at https://youtu.be/ujQSpkRf5s4. The general usage of the library is quite simple and needs not a lot of code. Just look into the different examples in this category.</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21358Barometrische Höhenstufe2023-09-25T15:09:01Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500px heights=400px><br />
File:IMG_3042.jpg|Aufbau<br />
</gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, GND – GND, SCL – GPIO22, SDA – GPIO21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Amontons%E2%80%98sches_Gesetz&diff=21357Amontons‘sches Gesetz2023-09-25T15:08:15Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Amontons'sches Gesetz<br />
| Category = Arduino library experiments<br />
| Sensors = MPRLS, DS18B20<br />
}}<br />
Amontons‘sches Gesetz: Gleichzeitige Messung von Druck und Temperatur in einem Gas.<br />
<br />
Die Notwendigkeit der Einführung der Kelvinskala erschließt sich, wenn man den Druck eines idealen Gases in Abhängigkeit der Temperatur bei konstantem Volumen misst. Bei einer ordentlichen Messung sollte p(Theta) einen linearen Zusammenhang zeigen, wobei der Wert p = 0 extrapoliert bei Theta ≈ -273 °C erreicht werden sollte. Experimentell lässt sich dies im Physikunterricht nur sehr schwer zeigen, weshalb meist auf Filme oder Simulationen zurückgegriffen wird. Um so interessanter ist es, die bereits verwendeten Temperatur- und Drucksensoren für diesen Zweck auszuprobieren. Hierfür werden beide Sensoren gemeinsam, wie bereits einzeln beschrieben, mit einem ESP32 verbunden.<br />
<br />
Hier wurde das Glas mit den Sensoren zuerst offen bei Theta = 60 °C im Backofen temperiert. Hier ist es natürlich ganz wichtig einen Akku zu verwenden, der für diese Temperatur spezifiziert ist.<br />
<br />
Anschließend wurde das Glas geschlossen, aus dem Backofen genommen und die Messung gestartet. Aufgenommen werden jetzt drei Diagramme: p (t), Theta (t) und p (Theta).<br />
<br />
Schon nach kurzer Zeit zeigt sich der zu erwartende lineare Zusammenhang zwischen dem Druck im Glas und der Temperatur (3. Graph). Den absoluten Temperaturnullpunkt erhält man hier mithilfe einer Ausgleichsgeraden. Hier lautet das Ergebnis der Regression:<br />
<br />
p(Theta) = 2,972 hPa/°C Theta +834,4 hPa.<br />
<br />
Die Nullstelle liegt demnach bei - 834,4: 2,972 °C = - 281 °C. Dies liegt für so einen primitiven Versuchsaufbau erstaunlich nahe beim echten Wert von - 273 °C.<br />
<br />
<gallery widths=500px heights=300px><br />
File:Amontons_Glas_1.jpg|Aufbau mit Glas im Backofen<br />
File:Amontons_Glas_mess.jpg|Aufbau bei der Messung<br />
File:IMG_0033.PNG|Messdaten Temperatur über Druck mit Ausgleichsgerade<br />
</gallery><br />
<br />
==Aufbau==<br />
Der Drucksensor MPRLS ist über den I2C-Bus mit dem ESP32 verbunden. Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, GND – GND, SCL – GPIO22, SDA – GPIO21. Der Temperatursensor liefert seine Daten über den OneWire-Bus: 3V3 – Vin, GND – GND, Datenbus - GPIO4. Der Pin des Datenbus sollte noch mit einem Pullup-Widerstand (z. B. 4k7) von 3V3 hochgezogen werden.<br />
<br />
Die Stromversorgung liefert ein 3,7 LiPo-Akku mit 1,2 Wh. Hier ist darauf zu achten, dass der Akku möglichst klein geweählt wird (störende Wärmekapazität), aber über ausreichend Kapazität verfügt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Baro_Therm_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <Wire.h><br />
#include "Adafruit_MPRLS.h"<br />
#include <OneWire.h><br />
#include <DallasTemperature.h><br />
#define ONE_WIRE_BUS 4<br />
OneWire oneWire(ONE_WIRE_BUS);<br />
DallasTemperature sensors(&oneWire);<br />
#include <phyphoxBle.h><br />
float p;<br />
#define RESET_PIN -1<br />
#define EOC_PIN -1<br />
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);<br />
<br />
void setup() {<br />
PhyphoxBLE::start("Baro_Therm_01");<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
experiment.setTitle("Baro_Therm_01");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
PhyphoxBleExperiment::Value Value2;<br />
Value2.setLabel("Theta = ");<br />
Value2.setUnit("°C");<br />
Value2.setChannel(2);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph1;<br />
graph1.setLabel("Druck");<br />
graph1.setUnitX("s");<br />
graph1.setUnitY("hPa");<br />
graph1.setLabelX("time");<br />
graph1.setLabelY("p");<br />
graph1.setChannel(0,1);<br />
PhyphoxBleExperiment::Graph graph2;<br />
graph2.setLabel("Temperatur");<br />
graph2.setUnitX("s");<br />
graph2.setUnitY("°C");<br />
graph2.setLabelX("time");<br />
graph2.setLabelY("Theta");<br />
graph2.setChannel(0,2);<br />
PhyphoxBleExperiment::Graph graph3;<br />
graph3.setLabel("p over Theta");<br />
graph3.setUnitX("°C");<br />
graph3.setUnitY("hPa");<br />
graph3.setLabelX("Theta");<br />
graph3.setLabelY("p");<br />
graph3.setStyle("dots");<br />
graph3.setChannel(2,1);<br />
view.addElement(graph1);<br />
view.addElement(Value1);<br />
view.addElement(graph2);<br />
view.addElement(Value2);<br />
view.addElement(graph3);<br />
experiment.addView(view);<br />
PhyphoxBLE::addExperiment(experiment);<br />
<br />
Serial.begin(38400);<br />
sensors.begin();<br />
mpr.begin();<br />
}<br />
<br />
void loop() {<br />
p = 0;<br />
for(int i = 0; i < 37; i++) {<br />
p+=mpr.readPressure();<br />
delay(10);<br />
}<br />
p=p/37;<br />
sensors.requestTemperatures();<br />
float T = sensors.getTempCByIndex(0);<br />
PhyphoxBLE::write(p,T);<br />
Serial.print(p);<br />
Serial.print(" ");<br />
Serial.println(T);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Auf-_und_Endladung_eines_Kondensators&diff=21356Auf- und Endladung eines Kondensators2023-09-25T15:06:32Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Auf- und Entladung eines Kondensators<br />
| Category = Arduino library experiments<br />
| Sensors = Owon OW18B<br />
}}<br />
'''Achtung: Dieser Versuch funktioniert nur mit dem Owon OW18B Multimeter!'''<br />
<br />
Das folgende Material ist im Rahmen einer Lehrerfortbildung im Jahre 2022 in Niedersachsen entstanden. Es richtet sich an Physiklehrkräfte, also Fachleute. Jede Lehrkraft ist selbst dafür verantwortlich, die aktuell geltenden sicherheitsrichtlinien nach RISU einzuhalten und im Vorfeld selbst eine Gefährdungsbeurteilung zu schreiben. Der Autor dieses Materials übernimmt keinerlei Haftung für Schäden, die bei der Anwendung entstehen. <br />
<br />
<gallery widths=500px heights=300px><br />
File:Kondensator_1.jpg|Aufbau des Versuches<br />
File:Kondensator_2.jpg|Benötige Materialien<br />
</gallery><br />
<br />
==Aufbau==<br />
Materialbedarf:<br />
<br />
2 Messkabel, 1 Elektrolytkondensator (C =1000 mF), 3 Widerstände (R = 6,8 kW, 10 kW, 15 kW), eine 3er-Klemme, ein Kurzschlusskabel, sowie eine Batteriebox mit Schutzklemme. Achtung: Der Elektrolytkondensator muss richtig gepolt angeschlossen werden. Das lange Beinchen gehört an Plus, die Beschriftung „ - “ an Minus. Falsch angeschlossene Elektrolytkondensatoren können explodieren!<br />
<br />
==Programmierung==<br />
Das Experiment wird einfach über den QR-Code im Arbeitsmaterial geladen.<br />
<br />
==Arbeitsmaterialien==<br />
[[file:Kondensator.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Oxidation_(Photosynthese)&diff=21355Oxidation (Photosynthese)2023-09-23T09:16:59Z<p>Nefft0n: Created page with "{{Infobox Experiment | Name = Oxidation | Category = Arduino library experiments | Sensors = CO2 and O2 }} In diesem Experiment werden ein O2 und ein CO2-Sensor ausgelesen...."</p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Oxidation<br />
| Category = Arduino library experiments<br />
| Sensors = CO2 and O2<br />
}}<br />
In diesem Experiment werden ein O2 und ein CO2-Sensor ausgelesen. Damit können Verbrennungsprozesse gemessen werden, was gerade bei Pflanzen im Biologieunterricht (Photosynthese) sehr interessant und vor allem gut messbar ist. Leider sind die Sensoren jedoch recht teuer.<br />
<br />
==Aufbau==<br />
<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Voltmeter XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* phyphox ESP32 for ExplorIR-M 20 (CO2-sensor) and LuminOX (O2-sensor)<br />
reads out values and sends them to phyphox, option to calibrate CO2 sensor<br />
https://www.gassensing.co.uk/product/explorir-m-co2-sensor/<br />
https://sstsensing.com/wp-content/uploads/2018/01/UG-001_LuminOx_UserGuide_rev2.pdf<br />
AUTHOR: Niklas Westermann<br />
LICENCSE: CC0<br />
*/<br />
<br />
#include <HardwareSerial.h><br />
#include <phyphoxBle.h><br />
<br />
void receivedData();<br />
int co2calibration = 0;<br />
int co2calibrationOld = 0;<br />
<br />
// Define serial ports<br />
// PIN16 and PIN17 are officially, but most ports can be used,<br />
// so 22 and 23 work too. Be careful when changing theses ports!<br />
HardwareSerial explorPort(1); //UART on ESP32 (PIN22 and PIN23)<br />
HardwareSerial luminoxPort(2); //UART on ESP32 (PIN16 and PIN17)<br />
<br />
void setup() {<br />
// Setup serial ports and sensors<br />
Serial.begin(9600); // Port for serial output via USB<br />
Serial.println("Start ESP32...");<br />
explorPort.begin(9600, SERIAL_8N1, 22, 23); // ExplorIR on PIN22-TX and PIN23-RX<br />
luminoxPort.begin(9600, SERIAL_8N1, 16, 17); // luminOX on PIN16-TX and PIN17-RX<br />
explorPort.print("K 2\r\n"); // Set sensor to polling (mode 2)<br />
luminoxPort.print("M 1\r\n"); // Set LuminOX to polling (mode 1)<br />
<br />
// Setup phyphox<br />
PhyphoxBLE::start("Oxidation Sensors");<br />
PhyphoxBLE::configHandler=&receivedData;<br />
<br />
// Experiment<br />
PhyphoxBleExperiment oxidation;<br />
oxidation.setTitle("Oxidation Sensors");<br />
oxidation.setCategory("ESP32 Experiments");<br />
oxidation.setDescription("Read O2 and CO2 Sensors");<br />
<br />
// Views<br />
PhyphoxBleExperiment::View graphView;<br />
graphView.setLabel("Data");<br />
PhyphoxBleExperiment::View calibView;<br />
calibView.setLabel("Calibration");<br />
<br />
// Graphs<br />
PhyphoxBleExperiment::Graph co2Graph;<br />
co2Graph.setLabel("Carbon dioxide");<br />
co2Graph.setLabelX("Time");<br />
co2Graph.setLabelY("Concentration");<br />
co2Graph.setUnitX("s");<br />
co2Graph.setUnitY("ppm");<br />
co2Graph.setChannel(0, 1);<br />
<br />
PhyphoxBleExperiment::Graph o2Graph;<br />
o2Graph.setLabel("Dioxide");<br />
o2Graph.setLabelX("Time");<br />
o2Graph.setLabelY("Concentration");<br />
o2Graph.setUnitX("s");<br />
o2Graph.setUnitY("%");<br />
o2Graph.setChannel(0, 2);<br />
<br />
// Edit<br />
PhyphoxBleExperiment::Edit calibration;<br />
calibration.setLabel("Sensor calibration");<br />
calibration.setUnit("ppm");<br />
calibration.setSigned(false);<br />
calibration.setDecimal(false);<br />
calibration.setChannel(1);<br />
PhyphoxBleExperiment::InfoField calibInfo;<br />
calibInfo.setInfo("To calibrate, enter the value of the actual carbon dioxide concentration. Outside, this should be 440ppm.");<br />
<br />
// Put together experiment<br />
graphView.addElement(co2Graph);<br />
graphView.addElement(o2Graph);<br />
calibView.addElement(calibration);<br />
calibView.addElement(calibInfo);<br />
oxidation.addView(graphView);<br />
oxidation.addView(calibView); //attach view to experiment<br />
PhyphoxBLE::addExperiment(oxidation); //attach experiment to server<br />
}<br />
<br />
void loop() {<br />
/* The ExplorIR outputs a string (in mode 1, streaming) with the following<br />
contents:<br />
"Z AAAAA z BBBBB \r\n" with AAAAA as the filtered value in ppm<br />
and BBBBB as the unfiltered value. This value has to be multiplied<br />
by the multiplier to get the real value in ppm (see below).<br />
To get the values, substring() and toFloat() are used, since there<br />
will be no changes in the output.<br />
Since we use mode 2, the "Z" command is send and then the answer processed<br />
*/<br />
explorPort.print("Z\r\n");<br />
String explorValueStr = explorPort.readStringUntil('\n');<br />
Serial.print("Raw values explor: ");<br />
Serial.println(explorValueStr);<br />
float explorValue = explorValueStr.substring(3).toFloat();<br />
// The two commands below are only needed in combination with mode 1 (streaming)<br />
// and explorPort.available()<br />
//explorValue = explorValueStr.substring(3, 8).toFloat();<br />
//float explorValueUnfilt = explorValueStr.substring(11).toFloat();<br />
<br />
// To get the multiplier, a command is send<br />
explorPort.print(".\r\n");<br />
String explorMultiplierStr = explorPort.readStringUntil('\n');<br />
float explorMultiplier = explorMultiplierStr.substring(3).toFloat();<br />
<br />
// Now we multiply the value with the multiplier<br />
explorValue = explorValue * explorMultiplier;<br />
Serial.println(explorValue);<br />
<br />
/*<br />
LuminOX<br />
The luminox is put in polling mode above, the answer on "% \r\n" is<br />
"% xxxx.xx\r\n" so we need only the chars from place 3 and above<br />
*/<br />
luminoxPort.print("% \r\n");<br />
String luminoxValueStr = luminoxPort.readStringUntil('\n');<br />
Serial.print("Raw values luminox: ");<br />
Serial.println(luminoxValueStr);<br />
float luminoxValue = luminoxValueStr.substring(3).toFloat();<br />
// The two commands below are only needed in combination with mode 1<br />
// and explorPort.available()<br />
luminoxValue = luminoxValueStr.substring(3, 8).toFloat();<br />
Serial.println(luminoxValue);<br />
<br />
// Send data to phyphox<br />
PhyphoxBLE::write(explorValue, luminoxValue);<br />
// In streaming mode, the sensors send a value every 500ms<br />
// to obtain stable values, we measure every second.<br />
// If higher measurement frequency is needed, change this here,<br />
// but be careful on too low values.<br />
delay(1000);<br />
}<br />
<br />
// Function to calibrate the co2 sensor<br />
void receivedData(){<br />
float co2calibFloat;<br />
<br />
PhyphoxBLE::read(co2calibFloat);<br />
co2calibration = (int)co2calibFloat / 10; // TODO better handling for factor<br />
// only change if greater than 0 and a new (!) value<br />
if(co2calibration >= 0 && co2calibration != co2calibrationOld) {<br />
Serial.print("Calibration value: ");<br />
Serial.println(co2calibration);<br />
String calibMessage = "X " + String(co2calibration) + "\r\n";<br />
//Serial.println(calibMessage);<br />
explorPort.print(calibMessage);<br />
String explorAnswer = explorPort.readStringUntil('\n'); // Read answer<br />
//Serial.println(explorAnswer);<br />
co2calibrationOld = co2calibration;<br />
}<br />
}<br />
</pre><br />
<br />
==Auswertung==<br />
<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Main_Page&diff=21354Main Page2023-09-23T09:13:57Z<p>Nefft0n: </p>
<hr />
<div><strong>Welcome to the phyphox wiki.</strong><br />
<br />
This wiki is meant to document and share more in-depth information on phyphox, experiments and projects. If you have anything interesting worth sharing, please, don't hesitate, create an account and add it to this Wiki.<br />
<br />
For now, the wiki is only available in English to encourage user participation without splitting up the users into regional communities.<br />
<br />
== Resources outside this Wiki ==<br />
* [http://phyphox.org/source/ phyphox source code]<br />
* [http://phyphox.org/sensordb/ sensor database]<br />
* [http://phyphox.org/forums/ phyphox forums]<br />
<br />
Introduction to the remote access<br />
* [http://phyphox.org/remote-control/ Remote control (web interface)]<br />
* [http://phyphox.org/fernsteuerung/ Fernsteuerung (German version)]<br />
<br />
Arduino, MicroPython, ESP32<br />
* [https://github.com/phyphox/phyphox-arduino Arduino library]<br />
* [https://github.com/phyphox/phyphox-micropython MicroPython library]<br />
* [https://github.com/vChavezB/zephyr_phyphox-ble Zephyr OS library] (by Victor Chávez-Bermúdez, not maintained by the phyphox team)<br />
<br />
== Experiments ==<br />
* [[:Category: Built-in experiments]]<br />
* [[:Category: User experiments]]<br />
* The [[Bluetooth device database|Bluetooth device database]]<br />
* [[:Category: Arduino library experiments]] (in german)<br />
<br />
Experiments and discussions can also be found in our [http://phyphox.org/forums/ forums].<br />
<br />
== Creating experiments ==<br />
* The [[experiment editor]]<br />
* The [[phyphox file format]]<br />
* [[Transferring phyphox experiments]]<br />
<br />
== In-depth topics ==<br />
* [[Version history]]<br />
* [[Bluetooth Low Energy]] (Interface for external sensors.)<br />
* [[Remote-interface communication]] (REST API)<br />
* [[Network Connections]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Druckmesungen&diff=21340Druckmesungen2023-09-21T13:23:42Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = MPRLS<br />
}}<br />
Der Drucksensor MPRLS ermöglicht Absolutdruckmessungen im Bereich 0 bis 25 PSI (1,72 bar). Die Auflösung ist so gut, dass sich 1 m Höhendifferenz auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. Schlauerweise wurde kein Foto gemacht, bevor der Sensor mit Spiegeltape aufgeklebt und alles schön mit Schrumpfschlauch verpackt wurde.<br />
<br />
Verbindet man den Sensor mit einem dünnen Schlauch, kann man auch sehr gut den Schweredruck in Flüssigkeiten messen.<br />
<br />
<gallery widths=500px heights=400px><br />
File:PressureSensor2.jpg|Verkabelung<br />
File:PressureSensor1.jpg|Aufbau eines Experimentes<br />
</gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. Schlauerweise wurde kein Foto gemacht, bevor der Sensor mit Spiegeltape aufgeklebt und alles schön mit Schrumpfschlauch verpackt wurde.<br />
Verbindet man den Sensor mit einem dünnen Schlauch, kann man auch sehr gut den Schweredruck in Flüssigkeiten messen. Achtung: aufpassen, dass keine Flüssigkeit über die Kapillarwirkung in den Sensor gerät.<br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
Der Sensor ist sehr schnell. Deshalb wird stark gemittelt.<br />
<br />
<pre><br />
#include <Wire.h><br />
#include "Adafruit_MPRLS.h"<br />
#include <phyphoxBle.h><br />
<br />
float Messwert;<br />
#define RESET_PIN -1<br />
#define EOC_PIN -1<br />
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);<br />
<br />
void setup() {<br />
PhyphoxBLE::start("Barometer_01");<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
experiment.setTitle("Barometer_01");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("p");<br />
view.addElement(graph);<br />
view.addElement(Value1);<br />
experiment.addView(view);<br />
PhyphoxBLE::addExperiment(experiment);<br />
Serial.begin(38400);<br />
mpr.begin();<br />
}<br />
<br />
void loop() {<br />
Messwert=0;<br />
for(int i=0;i<37;i++){<br />
Messwert+=mpr.readPressure();<br />
delay(10);<br />
}<br />
<br />
Messwert=Messwert/37;<br />
PhyphoxBLE::write(Messwert);<br />
Serial.println(Messwert);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Drehrate_und_Beschleunigung&diff=21339Drehrate und Beschleunigung2023-09-21T13:19:15Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Drehrate und Beschleunigung<br />
| Category = Arduino library experiments<br />
| Sensors = MPU-6050<br />
}}<br />
Auch wenn man für viele Beschleunigungsexperimente prinzipiell den im Smartphone verbauten Beschleunigungs- und Drehratensensor verwenden könnte, macht auch hier ein externer Sensor sehr viel Sinn:<br />
<br />
1. Man möchte nicht, dass ein Smartphone bei einer Messung Schaden nimmt.<br />
<br />
2. Man weiß nicht millimetergenau, wo genau die Sensoren im Smartphone verbaut sind.<br />
<br />
3. Sensoren wie der hier verwendete MPU-6050 sind günstig, gut und dank der I2C-Bus-Schnittstelle sehr einfach zu verlöten.<br />
<br />
Hier soll der Sensor für Beschleunigungsmessungen auf der Luftkissenbahn sowie für Drehraten- und Zentrifugalbeschleunigungsmessungen eingesetzt werden. Aus diesem Grund ist das Programm so aufgebaut, dass der Sensor die Resultierende aus ax und ay sowie die Resultierende Drehrate aller drei Achsen übermittelt. Direkt nach dem Starten oder einem Reset muss der Sensor einige Sekunden ruhen. Während dieser Zeit wird die Beschleunigung auf null Tariert. So wird die Erdbeschleunigung rausgerechnet, falls der Sensor schief liegt. Der Sensor funktioniert so gut, dass aus den Parabeln im 3. Graph millimetergenau der Radius zur Dreachse ermittelt werden kann.<br />
<br />
<gallery widths=500px heights=400px><br />
File:Drehrate.jpg|Aufbau<br />
File:Drehrate_2.jpg|Aufbau mit Schumpfschlauch und Klettband<br />
</gallery><br />
<br />
==Aufbau==<br />
Die Verkabelung des Sensors ist wieder wie üblich: 3V3 – Vin, Gnd – Gnd, SCL – 22, <br />
SDA –21. Als Stromversorgung dient hier einfach eine kleine Powerbank, auf die der ESP32 mit Doppelseitigem Klebeband befestigt wird. Der MPU-6050 wurde mit etwas Heißkleber auf den ESP32 neben das Kommunikationsmodul geklebt und am Ende alles mit Schrumpfschlauch versiegelt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Thermometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <Adafruit_MPU6050.h><br />
#include <Adafruit_Sensor.h><br />
#include <Wire.h><br />
#include <phyphoxBle.h> <br />
Adafruit_MPU6050 mpu;<br />
<br />
float Beschleunigung = 0; <br />
float Drehrate = 0;<br />
float ZeroX = 0;<br />
float ZeroY = 0;<br />
<br />
void setup(void) {<br />
PhyphoxBLE::start("Beschleunigungssensor"); <br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Beschleunigungssensor");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the acceleration over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph1;<br />
graph1.setLabel("Beschleunigung");<br />
graph1.setUnitX("s");<br />
graph1.setUnitY("m/s2");<br />
graph1.setLabelX("time");<br />
graph1.setLabelY("ax");<br />
graph1.setChannel(0,1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph2;<br />
graph2.setLabel("Drehrate");<br />
graph2.setUnitX("s");<br />
graph2.setUnitY("1/s");<br />
graph2.setLabelX("time");<br />
graph2.setLabelY("omega");<br />
graph2.setChannel(0,2);<br />
<br />
<br />
PhyphoxBleExperiment::Graph graph3;<br />
graph3.setLabel("Beschleunigung");<br />
graph3.setUnitX("1/s");<br />
graph3.setUnitY("m/s2");<br />
graph3.setLabelX("omega");<br />
graph3.setLabelY("ax");<br />
graph3.setStyle("dots");<br />
graph3.setChannel(2,1);<br />
<br />
<br />
view.addElement(graph1); //Attach graph to view<br />
view.addElement(graph2); //Attach graph to view<br />
view.addElement(graph3); //Attach graph to view<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
mpu.begin();<br />
mpu.setAccelerometerRange(MPU6050_RANGE_4_G);<br />
mpu.setGyroRange(MPU6050_RANGE_1000_DEG);<br />
mpu.setFilterBandwidth(MPU6050_BAND_21_HZ);<br />
delay(1000);<br />
<br />
//Offsetkorrektur <br />
ZeroX=0;<br />
ZeroY=0;<br />
for(int i=0;i<7;i++){<br />
sensors_event_t a, g, temp;<br />
mpu.getEvent(&a, &g, &temp);<br />
ZeroX+=a.acceleration.x;<br />
ZeroY+=a.acceleration.y;<br />
delay(10);<br />
}<br />
ZeroX=ZeroX/7;<br />
ZeroY=ZeroY/7;<br />
}<br />
<br />
void loop() {<br />
sensors_event_t a, g, temp;<br />
mpu.getEvent(&a, &g, &temp);<br />
Beschleunigung = sqrt(sq(a.acceleration.x-ZeroX)+sq(a.acceleration.y-ZeroY));<br />
Drehrate = sqrt(sq(g.gyro.x)+sq(g.gyro.y)+sq(g.gyro.z));<br />
PhyphoxBLE::write(Beschleunigung, Drehrate);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Amontons%E2%80%98sches_Gesetz&diff=21338Amontons‘sches Gesetz2023-09-21T13:14:16Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Amontons'sches Gesetz<br />
| Category = Arduino library experiments<br />
| Sensors = MPRLS, DS18B20<br />
}}<br />
Amontons‘sches Gesetz: Gleichzeitige Messung von Druck und Temperatur in einem Gas.<br />
<br />
Die Notwendigkeit der Einführung der Kelvinskala erschließt sich, wenn man den Druck eines idealen Gases in Abhängigkeit der Temperatur bei konstantem Volumen misst. Bei einer ordentlichen Messung sollte p(Theta) einen linearen Zusammenhang zeigen, wobei der Wert p = 0 extrapoliert bei Theta ≈ -273 °C erreicht werden sollte. Experimentell lässt sich dies im Physikunterricht nur sehr schwer zeigen, weshalb meist auf Filme oder Simulationen zurückgegriffen wird. Um so interessanter ist es, die bereits verwendeten Temperatur- und Drucksensoren für diesen Zweck auszuprobieren. Hierfür werden beide Sensoren gemeinsam, wie bereits einzeln beschrieben, mit einem ESP32 verbunden.<br />
<br />
Hier wurde das Glas mit den Sensoren zuerst offen bei Theta = 60 °C im Backofen temperiert. Hier ist es natürlich ganz wichtig einen Akku zu verwenden, der für diese Temperatur spezifiziert ist.<br />
<br />
Anschließend wurde das Glas geschlossen, aus dem Backofen genommen und die Messung gestartet. Aufgenommen werden jetzt drei Diagramme: p (t), Theta (t) und p (Theta).<br />
<br />
Schon nach kurzer Zeit zeigt sich der zu erwartende lineare Zusammenhang zwischen dem Druck im Glas und der Temperatur (3. Graph). Den absoluten Temperaturnullpunkt erhält man hier mithilfe einer Ausgleichsgeraden. Hier lautet das Ergebnis der Regression:<br />
<br />
p(Theta) = 2,972 hPa/°C Theta +834,4 hPa.<br />
<br />
Die Nullstelle liegt demnach bei - 834,4: 2,972 °C = - 281 °C. Dies liegt für so einen primitiven Versuchsaufbau erstaunlich nahe beim echten Wert von - 273 °C.<br />
<br />
<gallery widths=500px heights=300px><br />
File:Amontons_Glas_1.jpg|Aufbau mit Glas im Backofen<br />
File:Amontons_Glas_mess.jpg|Aufbau bei der Messung<br />
File:IMG_0033.PNG|Messdaten Temperatur über Druck mit Ausgleichsgerade<br />
</gallery><br />
<br />
==Aufbau==<br />
Der Drucksensor MPRLS ist über den I2C-Bus mit dem ESP32 verbunden. Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21<br />
Der Temperatursensor liefert seine Daten über den OneWire-Bus: 3V3 – Vin, Gnd – Gnd, 4 - Datenbus. Der Pin des Datenbus sollte noch mit einem Pullup-Widerstand (z. B. 4k7) von 3V3 hochgezogen werden.<br />
<br />
Die Stromversorgung liefert ein 3,7 LiPo-Akku mit 1,2 Wh. Hier ist darauf zu achten, dass der Akku möglichst klein geweählt wird (störende Wärmekapazität), aber über ausreichend Kapazität verfügt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Baro_Therm_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <Wire.h><br />
#include "Adafruit_MPRLS.h"<br />
#include <OneWire.h><br />
#include <DallasTemperature.h><br />
#define ONE_WIRE_BUS 4<br />
OneWire oneWire(ONE_WIRE_BUS);<br />
DallasTemperature sensors(&oneWire);<br />
#include <phyphoxBle.h><br />
float p;<br />
#define RESET_PIN -1<br />
#define EOC_PIN -1<br />
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);<br />
<br />
void setup() {<br />
PhyphoxBLE::start("Baro_Therm_01");<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
experiment.setTitle("Baro_Therm_01");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
PhyphoxBleExperiment::Value Value2;<br />
Value2.setLabel("Theta = ");<br />
Value2.setUnit("°C");<br />
Value2.setChannel(2);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph1;<br />
graph1.setLabel("Druck");<br />
graph1.setUnitX("s");<br />
graph1.setUnitY("hPa");<br />
graph1.setLabelX("time");<br />
graph1.setLabelY("p");<br />
graph1.setChannel(0,1);<br />
PhyphoxBleExperiment::Graph graph2;<br />
graph2.setLabel("Temperatur");<br />
graph2.setUnitX("s");<br />
graph2.setUnitY("°C");<br />
graph2.setLabelX("time");<br />
graph2.setLabelY("Theta");<br />
graph2.setChannel(0,2);<br />
PhyphoxBleExperiment::Graph graph3;<br />
graph3.setLabel("p over Theta");<br />
graph3.setUnitX("°C");<br />
graph3.setUnitY("hPa");<br />
graph3.setLabelX("Theta");<br />
graph3.setLabelY("p");<br />
graph3.setStyle("dots");<br />
graph3.setChannel(2,1);<br />
view.addElement(graph1);<br />
view.addElement(Value1);<br />
view.addElement(graph2);<br />
view.addElement(Value2);<br />
view.addElement(graph3);<br />
experiment.addView(view);<br />
PhyphoxBLE::addExperiment(experiment);<br />
<br />
Serial.begin(38400);<br />
sensors.begin();<br />
mpr.begin();<br />
}<br />
<br />
void loop() {<br />
p = 0;<br />
for(int i = 0; i < 37; i++) {<br />
p+=mpr.readPressure();<br />
delay(10);<br />
}<br />
p=p/37;<br />
sensors.requestTemperatures();<br />
float T = sensors.getTempCByIndex(0);<br />
PhyphoxBLE::write(p,T);<br />
Serial.print(p);<br />
Serial.print(" ");<br />
Serial.println(T);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21337Barometrische Höhenstufe2023-09-21T13:09:04Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500px heights=400px><br />
File:IMG_3042.jpg|Aufbau<br />
</gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21336Barometrische Höhenstufe2023-09-21T13:08:03Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500px hieghts=400px><br />
File:IMG_3042.jpg|Aufbau<br />
</gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21335Barometrische Höhenstufe2023-09-21T13:07:45Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500 hieghts=300><br />
File:IMG_3042.jpg|Aufbau<br />
</gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21334Barometrische Höhenstufe2023-09-21T13:07:14Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500 hieghts=300><br />
IMG_3042.jpg|Aufbau<br />
<gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Barometrische_H%C3%B6henstufe&diff=21333Barometrische Höhenstufe2023-09-21T13:07:02Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Druckmessungen<br />
| Category = Arduino library experiments<br />
| Sensors = BMP581<br />
}}<br />
Der Drucksensor BMP581 ist für die Messung atmosphärischer Drücke ausgelegt. Er misst sehr schnell und hat eine so gute Auflösung, dass sich Höhendifferenz von nur wenigen Zentimetern auflösen lassen. Die barometrische Höhenstufe auf Meeresniveaus beträgt 1 hPa auf 8 m.<br />
<br />
<gallery widths=500 hieghts=300><br />
File:IMG_3042.jpg|Aufbau<br />
<gallery><br />
<br />
==Setup==<br />
Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21. <br />
<br />
==Programming==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Barometer_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h> <br />
#include <Wire.h><br />
#include "SparkFun_BMP581_Arduino_Library.h"<br />
<br />
BMP581 pressureSensor;<br />
uint8_t i2cAddress = BMP581_I2C_ADDRESS_DEFAULT; // 0x47<br />
<br />
void setup()<br />
{<br />
PhyphoxBLE::start("Barometer_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Barometer");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("Druck");<br />
graph.setUnitX("s");<br />
graph.setUnitY("hPa");<br />
graph.setLabelX("time");<br />
graph.setLabelY("Druck");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
Serial.begin(115200);<br />
Wire.begin();<br />
pressureSensor.beginI2C(i2cAddress);<br />
bmp5_iir_config config =<br />
{<br />
.set_iir_p = BMP5_IIR_FILTER_COEFF_127, // Set filter coefficient<br />
.shdw_set_iir_p = BMP5_ENABLE, // Store filtered data in data registers<br />
.iir_flush_forced_en = BMP5_DISABLE // Flush filter in forced mode<br />
};<br />
}<br />
<br />
void loop()<br />
{<br />
bmp5_sensor_data data = {0,0};<br />
int8_t err = pressureSensor.getSensorData(&data);<br />
//Serial.print(data.temperature);<br />
float p = data.pressure/100;<br />
Serial.println(p)/100;<br />
PhyphoxBLE::write(p);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt zur barometrischen Höhenstufe, wo die Höhe eines Treppenhauses bestimmt werden soll.<br />
(aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
<br />
<br />
[[file:AB_Barometrische_Höhenstufe.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Auf-_und_Endladung_eines_Kondensators&diff=21332Auf- und Endladung eines Kondensators2023-09-21T08:36:18Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Auf- und Entladung eines Kondensators<br />
| Category = Arduino library experiments<br />
| Sensors = Owon OW18B<br />
}}<br />
'''Achtung: Dieser Versuch funktioniert nur mit dem Owon OW18B Multimeter!'''<br />
<br />
Das folgende Material ist im Rahmen einer Lehrerfortbildung im Jahre 2022 in Niedersachsen entstanden. Es richtet sich an Physiklehrkräfte, also Fachleute. Jede Lehrkraft ist selbst dafür verantwortlich, die aktuell geltenden sicherheitsrichtlinien nach RISU einzuhalten und im Vorfeld selbst eine Gefährdungsbeurteilung zu schreiben. Der Autor dieses Materials übernimmt keinerlei Haftung für Schäden, die bei der Anwendung entstehen. <br />
<br />
<br />
<gallery widths=500px heights=300px><br />
File:Kondensator_1.jpg|Aufbau des Versuches<br />
File:Kondensator_2.jpg|Benötige Materialien<br />
</gallery><br />
<br />
==Aufbau==<br />
Materialbedarf:<br />
<br />
2 Messkabel, 1 Elektrolytkondensator (C =1000 mF), 3 Widerstände (R = 6,8 kW, 10 kW, 15 kW), eine 3er-Klemme, ein Kurzschlusskabel, sowie eine Batteriebox mit Schutzklemme. Achtung: Der Elektrolytkondensator muss richtig gepolt angeschlossen werden. Das lange Beinchen gehört an Plus, die Beschriftung „ - “ an Minus. Falsch angeschlossene Elektrolytkondensatoren können explodieren!<br />
<br />
<br />
==Programmierung==<br />
Das Experiment wird einfach über den QR-Code im Arbeitsmaterial geladen.<br />
<br />
==Arbeitsmaterialien==<br />
[[file:Kondensator.pdf]]<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Amontons%E2%80%98sches_Gesetz&diff=21331Amontons‘sches Gesetz2023-09-21T08:18:40Z<p>Nefft0n: Optische Verbesserungen</p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Amontons'sches Gesetz<br />
| Category = Arduino library experiments<br />
| Sensors = MPRLS, DS18B20<br />
}}<br />
<br />
Amontons‘sches Gesetz: Gleichzeitige Messung von Druck und Temperatur in einem Gas.<br />
<br />
Die Notwendigkeit der Einführung der Kelvinskala erschließt sich, wenn man den Druck eines idealen Gases in Abhängigkeit der Temperatur bei konstantem Volumen misst. Bei einer ordentlichen Messung sollte p(Theta) einen linearen Zusammenhang zeigen, wobei der Wert p = 0 extrapoliert bei Theta ≈ -273 °C erreicht werden sollte.<br />
<br />
Experimentell lässt sich dies im Physikunterricht nur sehr schwer zeigen, weshalb meist auf Filme oder Simulationen zurückgegriffen wird. Um so interessanter ist es, die bereits verwendeten Temperatur- und Drucksensoren für diesen Zweck auszuprobieren. Hierfür werden beide Sensoren gemeinsam, wie bereits einzeln beschrieben, mit einem ESP32 verbunden.<br />
<br />
Hier wurde das Glas mit den Sensoren zuerst offen bei Theta = 60 °C im Backofen temperiert. Hier ist es natürlich ganz wichtig einen Akku zu verwenden, der für diese Temperatur spezifiziert ist.<br />
<br />
Anschließend wurde das Glas geschlossen, aus dem Backofen genommen und die Messung gestartet. Aufgenommen werden jetzt drei Diagramme: p (t), Theta (t) und p (Theta).<br />
<br />
Schon nach kurzer Zeit zeigt sich der zu erwartende lineare Zusammenhang zwischen dem Druck im Glas und der Temperatur (3. Graph). Den absoluten Temperaturnullpunkt erhält man hier mithilfe einer Ausgleichsgeraden. Hier lautet das Ergebnis der Regression:<br />
<br />
p(Theta) = 2,972 hPa/°C Theta +834,4 hPa.<br />
<br />
Die Nullstelle liegt demnach bei - 834,4: 2,972 °C = - 281 °C. Dies liegt für so einen primitiven Versuchsaufbau erstaunlich nahe beim echten Wert von - 273 °C.<br />
<br />
<br />
<gallery widths=500px heights=300px><br />
File:Amontons_Glas_1.jpg|Aufbau mit Glas im Backofen<br />
File:Amontons_Glas_mess.jpg|Aufbau bei der Messung<br />
File:IMG_0033.PNG|Messdaten Temperatur über Druck mit Ausgleichsgerade<br />
</gallery><br />
<br />
==Aufbau==<br />
Der Drucksensor MPRLS ist über den I2C-Bus mit dem ESP32 verbunden. Die Verdrahtung ist wie üblich bei I2C-Sensoren trivial: 3V3 – Vin, Gnd – Gnd, SCL – 22, SDA –21<br />
Der Temperatursensor liefert seine Daten über den OneWire-Bus: 3V3 – Vin, Gnd – Gnd, 4 - Datenbus. Der Pin des Datenbus sollte noch mit einem Pullup-Widerstand (z. B. 4k7) von 3V3 hochgezogen werden.<br />
<br />
Die Stromversorgung liefert ein 3,7 LiPo-Akku mit 1,2 Wh. Hier ist darauf zu achten, dass der Akku möglichst klein geweählt wird (störende Wärmekapazität), aber über ausreichend Kapazität verfügt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Baro_Therm_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <Wire.h><br />
#include "Adafruit_MPRLS.h"<br />
#include <OneWire.h><br />
#include <DallasTemperature.h><br />
#define ONE_WIRE_BUS 4<br />
OneWire oneWire(ONE_WIRE_BUS);<br />
DallasTemperature sensors(&oneWire);<br />
#include <phyphoxBle.h><br />
float p;<br />
#define RESET_PIN -1<br />
#define EOC_PIN -1<br />
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);<br />
<br />
void setup() {<br />
PhyphoxBLE::start("Baro_Therm_01");<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
experiment.setTitle("Baro_Therm_01");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the pressure over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("p = ");<br />
Value1.setUnit("hPa");<br />
Value1.setChannel(1);<br />
PhyphoxBleExperiment::Value Value2;<br />
Value2.setLabel("Theta = ");<br />
Value2.setUnit("°C");<br />
Value2.setChannel(2);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph1;<br />
graph1.setLabel("Druck");<br />
graph1.setUnitX("s");<br />
graph1.setUnitY("hPa");<br />
graph1.setLabelX("time");<br />
graph1.setLabelY("p");<br />
graph1.setChannel(0,1);<br />
PhyphoxBleExperiment::Graph graph2;<br />
graph2.setLabel("Temperatur");<br />
graph2.setUnitX("s");<br />
graph2.setUnitY("°C");<br />
graph2.setLabelX("time");<br />
graph2.setLabelY("Theta");<br />
graph2.setChannel(0,2);<br />
PhyphoxBleExperiment::Graph graph3;<br />
graph3.setLabel("p over Theta");<br />
graph3.setUnitX("°C");<br />
graph3.setUnitY("hPa");<br />
graph3.setLabelX("Theta");<br />
graph3.setLabelY("p");<br />
graph3.setStyle("dots");<br />
graph3.setChannel(2,1);<br />
view.addElement(graph1);<br />
view.addElement(Value1);<br />
view.addElement(graph2);<br />
view.addElement(Value2);<br />
view.addElement(graph3);<br />
experiment.addView(view);<br />
PhyphoxBLE::addExperiment(experiment);<br />
<br />
Serial.begin(38400);<br />
sensors.begin();<br />
mpr.begin();<br />
}<br />
<br />
void loop() {<br />
p = 0;<br />
for(int i = 0; i < 37; i++) {<br />
p+=mpr.readPressure();<br />
delay(10);<br />
}<br />
p=p/37;<br />
sensors.requestTemperatures();<br />
float T = sensors.getTempCByIndex(0);<br />
PhyphoxBLE::write(p,T);<br />
Serial.print(p);<br />
Serial.print(" ");<br />
Serial.println(T);<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Externer_Magnetfeldsensor&diff=21330Externer Magnetfeldsensor2023-09-20T10:07:17Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Externer Magnetfeldsensor<br />
| Category = Arduino library experiments<br />
| Sensors = 49e<br />
}}<br />
<br />
Magnetfeldern von Permanentmagneten oder stromdurchflossenen Spulen lassen sich mit den in Smartphones integrierten Magnetfeldsensoren praktisch nicht messen. Das liegt daran, dass die eingebauten Sensoren für sehr schwache Magnetfelder ausgelegt sind, um eine Kompassfunktion zu ermöglichen. In der Regel geht der Messbereich bis maximal 5 mT.<br />
Möchte man z. B. das Magnetfeld einer Spule entlang der Spulenachse ausmessen, muss der Messbereich eine Größenordnung darüberliegen. Im Folgenden Versuch wird mittels eines Hallsensors (Typ 49e) ein einfach zu benutzender Magnetfeldsensor verwendet, der auch von Oberstufenschülern selbst gebaut werden kann (aktuelle Sicherheitsrichtlinien nach RISU beachten!).<br />
<br />
<gallery widths=500px heights=300px><br />
File:SpulenBFeld.jpg|Aufbau<br />
File:B_Sensor2.jpg|Sensor<br />
</gallery><br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) dppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
<br />
<br />
==Aufbau==<br />
Bei B = 0 beträgt die vom Halsensor (49e) ausgegebene Spannung die Hälfte der dort angelegten Spannung. Somit ist die Differenz zwischen Ausgegebener Spannung und halber angelegter Spannung Proportional zum Magnetfeld:<br />
<br />
V_out-V_DD∼B.<br />
<br />
Die Steigung der Geraden beträgt ca. (3 V)/(200 mT). Die ADCs des ESP32 haben eine Auflösung von 12 Bit. Bei einer anliegenden Spannung U wird somit der Zahlenwert Messwert= U/(3,3 V)⋅4096 herausgegeben. <br />
In unserer Schaltung liegt die Ausgangsspannung am Pin 27 des ESP32 an. Dieser gibt den eben erläuterten zur Spannung proportionalen Messwert als Zahl heraus. Die magnetische Feldstärke berechnet sich dann zu<br />
<br />
B=(Messwert-4096/2)⋅(200 mT)/4096=(Messwert-2048)⋅0,049 mT.<br />
<br />
Da die vorliegende Werte meist etwas driften, wird zu Beginn des Programms wird eine Offsetkorrektur vorgenommen. Das bei Einschalten des Sensors anliegende B-Feld wird als null angenommen. Die Steigung (Faktor 0,049 in Gleichung oben) muss in der Regel individuell an den Sensor angepasst werden. Eine passende Formel findet sich auf dem unten verlinkten Arbeitsblatt. Diese Kalibrierung kann dann mit einer Spule bekannter Geometrie und Windungszahl durchgeführt werden. Beim Programm unten beträgt der Faktor deshalb 0,0492.<br />
Zu guter Letzt wird noch eine Mittelwertbildung über 37 Werte vorgenommen. Auch dies lässt sich natürlich individuell anpassen.<br />
<br />
V_out geht an Pin 27, + an 3,3 V und – an Gnd. Der Hallsensor wurde hier noch nach oben gebogen, da so z. B. das Magnetfeld einer Spule vermessen werden kann. Um das Rauschen zu verringern, empfiehlt es sich, die Vout-Leitung mit einem 10-kOhm-Widerstand auf Masse zu ziehen.<br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) doppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Magnetfeldsensor_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h><br />
int AnalogPin=27;<br />
float Messwert;<br />
float Magnetfeld;<br />
float Offset;<br />
void setup() {<br />
PhyphoxBLE::start("Magnetfeldsensor_01");<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
experiment.setTitle("Magnetfeld");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the magnetic field over time.");<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
//Value<br />
PhyphoxBleExperiment::Value Value1;<br />
Value1.setLabel("B = ");<br />
Value1.setUnit("mT");<br />
Value1.setChannel(1);<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("B over time");<br />
graph.setUnitX("s");<br />
graph.setUnitY("mT");<br />
graph.setLabelX("time");<br />
graph.setLabelY("B");<br />
view.addElement(graph);<br />
view.addElement(Value1);<br />
experiment.addView(view);<br />
PhyphoxBLE::addExperiment(experiment);<br />
//Offsetkorrektur<br />
Offset=0;<br />
for(int i=0;i<100;i++){<br />
Offset+=analogRead(AnalogPin);<br />
delay(10);<br />
}<br />
Offset=Offset/100;<br />
Serial.begin(38400);<br />
}<br />
void loop() {<br />
Messwert=0;<br />
for(int i=0;i<7;i++){<br />
Messwert+=analogRead(AnalogPin);<br />
delay(10);<br />
}<br />
Messwert=Messwert/7;<br />
Magnetfeld=(Messwert-Offset)*(-0.0492); //Kalibrierung überprüfen<br />
PhyphoxBLE::write(Magnetfeld);<br />
Serial.println(Magnetfeld);<br />
delay(50);<br />
}<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt (aktuelle Sicherheitsrichtlinien nach RISU beachten!)<br />
Das folgende Material ist im Rahmen einer Lehrerfortbildung im Jahre 2022 in Niedersachsen entstanden. Es richtet sich an Physiklehrkräfte, also Fachleute. Jede Lehrkraft ist selbst dafür verantwortlich, die aktuell geltenden sicherheitsrichtlinien nach RISU einzuhalten und im Vorfeld selbst eine Gefährdungsbeurteilung zu schreiben. Der Autor dieses Materials übernimmt keinerlei Haftung für Schäden, die bei der Anwendung entstehen. <br />
<br />
[[file:AB_Magnetfeldsensor_Spule.pdf]]<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Distanzsensor_(Federpendel)&diff=21317Distanzsensor (Federpendel)2023-09-12T10:59:05Z<p>Nefft0n: Created page with "{{Infobox Experiment | Name = Distanzsensor (Federpendel) | Category = Arduino library experiments | Sensors = Distance }} Die verschiedenen Arten einer Pendelschwingung si..."</p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Distanzsensor (Federpendel)<br />
| Category = Arduino library experiments<br />
| Sensors = Distance<br />
}}<br />
Die verschiedenen Arten einer Pendelschwingung sind integraler Bestandteil des Lehrplans. mit phyphox können direkt nur die Beuschleunigung und die Drehrate des Smartphones gemessen werden und so die Schwingung dargestellt werden.<br />
<br />
Mit einem Distanzsensor kann die Schwingung eines Federpendels sehr simpel gemessen werden. Generell ist natürlich die Messung sämtlicher Distanzen möglich, beim Federpendel ist der Aufbau jedoch am einfachsten.<br />
<br />
==Aufbau==<br />
Zuerst muss der ESP32 programmiert und verbunden werden. Der Sensor wird mit Plus und Minus an den 3,3V-PIN und den GND-PIN des ESP angeschlossen. SDA kommen an PIN21 und SCL an PIN22. Wir verwenden an dieser Stelle den Time of Flight (ToF) Sensor VL32L0X, dieser misst mittels Lichtpulsen die Distanz zum Objekt recht genau. Als Reflektionsfläche reicht ein größeres Stück Papier, das auf den Pendelkörper geklebt wird.<br />
<br />
Als Pendelkörper kann ein Glas verwendet werden, in dessen Deckel ein kleines Loch gebohrt wird und eine Schnur befestigt wird. Dann kann das ganze Glas an eine Feder gehängt werden und das Gewicht mittels Wasser im Glas verändert werden. Unten auf das Glas wird ein festes Stück Papier geklebt.<br />
<br />
Anschließend wird der Sensor unter das Glas gelegt (am besten mit Doppelseitigem Klebeband befestigen) und die Messung kann gestartet werden.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Distance-Sensor XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
/* phyphox ESP32 for distance sensor VL53L0X<br />
reads out values and sends them to phyphox<br />
AUTHOR: Niklas Westermann<br />
LICENCSE: CC0<br />
*/<br />
<br />
#include <phyphoxBle.h><br />
#include "Adafruit_VL53L0X.h" // needs to be installed!<br />
<br />
// SDA to PIN21 und SCL to PIN22<br />
Adafruit_VL53L0X distSensor = Adafruit_VL53L0X();<br />
float distValue;<br />
<br />
void setup() {<br />
PhyphoxBLE::start("ESP32 Distance-Sensor");<br />
<br />
PhyphoxBleExperiment vl53l0x;<br />
<br />
vl53l0x.setTitle("Distance-Sensor");<br />
vl53l0x.setCategory("ESP32 Experiment");<br />
<br />
// Views (Tabs in der App)<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Rohdaten");<br />
<br />
// Graph (ein einzelner Graph)<br />
PhyphoxBleExperiment::Graph firstGraph;<br />
firstGraph.setLabel("Abstand");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("mm");<br />
firstGraph.setLabelX("Zeit");<br />
firstGraph.setLabelY("Abstand");<br />
firstGraph.setChannel(0, 1);<br />
<br />
// Value (zeige letzten Wert)<br />
PhyphoxBleExperiment::Value firstValue;<br />
firstValue.setLabel("Abstand");<br />
firstValue.setUnit("mm");<br />
firstValue.setPrecision(0);<br />
firstValue.setChannel(1);<br />
<br />
// Export<br />
PhyphoxBleExperiment::ExportSet dataSet; //Provides exporting the data to excel etc.<br />
dataSet.setLabel("Data Set");<br />
PhyphoxBleExperiment::ExportData exportData;<br />
exportData.setLabel("Data Export");<br />
exportData.setDatachannel(1);<br />
<br />
// Attach to experiment<br />
firstView.addElement(firstGraph); //attach graph to view<br />
firstView.addElement(firstValue); //attach graph to view<br />
//secondView.addElement(myInfo); //attach info to view<br />
//secondView.addElement(calibrate); //attach separator to view<br />
vl53l0x.addView(firstView); //attach view to experiment<br />
//vl53l0x.addView(secondView);<br />
dataSet.addElement(exportData); //attach data to exportSet<br />
vl53l0x.addExportSet(dataSet); //attach exportSet to experiment<br />
PhyphoxBLE::addExperiment(vl53l0x); //attach experiment to server<br />
<br />
// Test distance sensor<br />
Serial.println("Adafruit VL53L0X test");<br />
if (!distSensor.begin()) {<br />
Serial.println(F("Failed to boot VL53L0X"));<br />
while(1);<br />
}<br />
}<br />
<br />
void loop() {<br />
// read data<br />
VL53L0X_RangingMeasurementData_t distMeas;<br />
distSensor.rangingTest(&distMeas, false); // pass in 'true' to get debug data printout!<br />
<br />
// phase failures have incorrect data<br />
if (distMeas.RangeStatus != 4) {<br />
Serial.print("Distance (mm): "); Serial.println(distMeas.RangeMilliMeter);<br />
distValue = distMeas.RangeMilliMeter;<br />
PhyphoxBLE::write(distValue);<br />
}<br />
else {<br />
Serial.println("out of range");<br />
}<br />
<br />
delay(10);<br />
}<br />
</pre><br />
<br />
==Auswertung==<br />
<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Externer_Magnetfeldsensor&diff=21245Externer Magnetfeldsensor2023-08-22T13:52:16Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Externer Magnetfeldsensor<br />
| Category = Arduino library experiments<br />
| Sensors = Magentic Field<br />
}}<br />
<br />
Magnetfeldern von Permanentmagneten oder stromdurchflossenen Spulen lassen sich mit den in Smartphones integrierten Magnetfeldsensoren praktisch nicht messen. Das liegt daran, dass die eingebauten Sensoren für sehr schwache Magnetfelder ausgelegt sind, um eine Kompassfunktion zu ermöglichen. In der Regel geht der Messbereich bis maximal 5 mT.<br />
Möchte man z. B. das Magnetfeld einer Spule entlang der Spulenachse ausmessen, muss der Messbereich eine Größenordnung darüberliegen. Im Folgenden Versuch wird mittels eines Hallsensors (Typ 49e) ein einfach zu benutzender Magnetfeldsensor verwendet, der auch von Oberstufenschülern selbst gebaut werden kann (aktuelle Sicherheitsrichtlinien nach RISU beachten!).<br />
<br />
[[File:SpulenBFeld.jpg|Sensor]]<br />
<br />
[[File:B_Sensor2.jpg|Sensor]]<br />
<br />
<br />
<br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) dppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
<br />
<br />
==Aufbau==<br />
Bei B = 0 beträgt die ausgegebene Spannung die Hälfte der angelegten Spannung. Somit ist die Differenz zwischen Ausgegebener Spannung und halber angelegter Spannung Proportional zum Magnetfeld:<br />
<br />
V_out-V_DD∼B.<br />
<br />
Die Steigung der Geraden beträgt ca. (3 V)/(200 mT). Die ADCs des ESP32 eine Auflösung von 12 Bit. Bei einer anliegenden Spannung U wird somit der Zahlenwert Messwert= U/(3,3 V)⋅4096 herausgegeben. <br />
In unserer Schaltung liegt die Ausgangsspannung am Pin 27 des ESP32 an. Dieser gibt den eben erläuterten zur Spannung proportionalen Messwert als Zahl heraus. Die magnetische Feldstärke berechnet sich dann zu<br />
<br />
B=(Messwert-4096/2)⋅(200 mT)/4096=(Messwert-2048)⋅0,049 mT.<br />
<br />
Da die vorliegende Werte meist etwas driften, wird zu Beginn des Programms wird eine Offsetkorrektur vorgenommen. Das bei Einschalten des Sensors anliegende B-Feld wird als null angenommen. Die Steigung (Faktor 0,049 in Gleichung oben) muss in der Regel individuell an den Sensor angepasst werden. Eine passende Formel findet sich auf dem unten verlinkten Arbeitsblatt. Diese Kalibrierung kann einfach mit einer Spule bekannter Geometrie und Windungszahl durchgeführt werden. Bei Programm unten beträgt der Faktor deshalb 0,0492.<br />
Zu guter Letzt wird noch eine Mittelwertbildung über 37 Werte vorgenommen. Auch dies lässt sich natürlich individuell anpassen.<br />
<br />
V_out geht an Pin 27, + an 3,3 V und – an Gnd. Der Hallsensor wurde hier noch nach oben gebogen, da so z. B. das Magnetfeld einer Spule vermessen werden kann. Um das Rauschen zu verringern, empfiehlt es sich, die Vout-Leitung mit einem 10-kOhm-Widerstand auf Masse zu ziehen.<br />
<br />
Das grüne Kabel unten im Bild ist ein Relikt eines anderen Versuchs und hat hier keine Bewandtnis.<br />
Die Platine kann man mit dickem (Kurzschlussgefahr!) doppelseitigen Klebeband aufs ESP-Board kleben. Als Packaging hat sich transparenter Schumpfschlauch bewährt.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''PhyphoxBLE::start("Magnetfeldsensor_01")'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
<br />
#include <phyphoxBle.h> <br />
<br />
int AnalogPin=27;<br />
float Messwert;<br />
float Offset;<br />
float Magnetfeld;<br />
<br />
void setup() {<br />
PhyphoxBLE::start("Magnetfeldsensor_01"); //Start the BLE server<br />
<br />
//Experiment<br />
PhyphoxBleExperiment experiment;<br />
<br />
experiment.setTitle("Magnetfeld");<br />
experiment.setCategory("Arduino Experiments");<br />
experiment.setDescription("Plot the magnetic field of a Hall sensor over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View view;<br />
<br />
//Value<br />
// PhyphoxBleExperiment::Value Value1; <br />
// Value1.setLabel("B = "); <br />
// Value1.setUnit("mT"); <br />
// Value1.setChannel(1);<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph graph;<br />
graph.setLabel("B over time");<br />
graph.setUnitX("s");<br />
graph.setUnitY("mT");<br />
graph.setLabelX("time");<br />
graph.setLabelY("B");<br />
<br />
view.addElement(graph); //Attach graph to view<br />
<br />
// view.addElement(Value1);<br />
experiment.addView(view); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(experiment); //Attach experiment to server<br />
<br />
//Offsetkorrektur <br />
Offset=0;<br />
for(int i=0;i<7;i++){<br />
Offset+=analogRead(AnalogPin);<br />
delay(10);<br />
}<br />
Offset=Offset/7;<br />
<br />
}<br />
<br />
void loop() {<br />
<br />
Messwert=0;<br />
for(int i=0;i<37;i++){<br />
Messwert+=analogRead(AnalogPin);<br />
delay(10);<br />
}<br />
Messwert=Messwert/37;<br />
<br />
Magnetfeld=(Messwert-Offset)*(-0.0492);<br />
PhyphoxBLE::write(Magnetfeld);<br />
// delay(50);<br />
}<br />
<br />
</pre><br />
<br />
==Arbeitsmaterialien==<br />
Ein mögliches Schülerarbeitsblatt (aktuelle Sicherheitsrichtlinien nach RISU beachten!): [[file:AB_Magnetfeldsensor_Spule.pdf]]<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Entladung_eines_Kondensators&diff=21244Entladung eines Kondensators2023-08-22T13:07:37Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Entladung eines Kondensators<br />
| Category = Arduino library experiments<br />
| Sensors = Voltage<br />
}}<br />
In diesem Experiment sollen die Schülerinnen und Schüler die Entladungskurve eines Kondensators messen. Dafür wird der analoge Eingang eines ESP32 (ein günstiger Mikrocontroller) verwendet. Der ESP wird mithilfe der Arduino-Bibliothek so programmiert, dass er die Daten an phyphox übertragen kann.<br />
<br />
==Aufbau==<br />
Zuerst muss der ESP32 programmiert und verbunden werden. Die Spannung wird zwischen PINXY und GND gemessen.<br />
<br />
''Aufbauanleitung''<br />
<br />
Anschließend kann direkt losgelegt werden. Die entsprechenden Schaltbilder sind in den Arbeitsblättern zu finden.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Voltmeter XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h><br />
<br />
int ADC_GPIO = 25; // ESP32<br />
//int ADC_GPIO = A0; // Arduino Nano 33 BLE<br />
<br />
void setup() {<br />
<br />
<br />
// put your setup code here, to run once:<br />
Serial.begin(115200);<br />
PhyphoxBLE::start("ESP32 Voltmeter");<br />
<br />
PhyphoxBleExperiment Voltmeter;<br />
<br />
Voltmeter.setTitle("Voltmeter");<br />
Voltmeter.setCategory("ESP32 Experiments");<br />
Voltmeter.setDescription("This experiment will plot the measured voltage over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Data"); //Create a "view"<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph firstGraph; //Create graph which will plot random numbers over time<br />
firstGraph.setLabel("Voltmeter");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("V");<br />
firstGraph.setLabelX("time");<br />
firstGraph.setLabelY("Voltage");<br />
<br />
/* Assign Channels, so which data is plotted on x or y axis<br />
first parameter represents x-axis, second y-axis<br />
Channel 0 means a timestamp is created after the BLE package arrives in phyphox<br />
Channel 1 to N corresponding to the N-parameter which is written in server.write()<br />
*/<br />
<br />
firstGraph.setChannel(0, 1);<br />
<br />
firstView.addElement(firstGraph); //attach graph to view<br />
Voltmeter.addView(firstView); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(Voltmeter); //Attach experiment to server<br />
}<br />
<br />
void loop() {<br />
// put your main code here, to run repeatedly:<br />
// measures the voltage as fast as possible, then calculates the mean over 100 values<br />
int meas = 0;<br />
for (int i = 0; i < 100; i++) {<br />
meas = meas + analogRead(ADC_GPIO);<br />
}<br />
<br />
meas = meas / 100;<br />
<br />
float meanvoltage = 3.3 * meas / 4095;<br />
<br />
//float voltage = 3.3 * analogRead(ADC_GPIO)/4095;<br />
//delay(1);<br />
<br />
PhyphoxBLE::write(meanvoltage);<br />
<br />
//Serial.print("Voltage = ");<br />
Serial.println(meanvoltage);<br />
<br />
delay(5); // approx 100Hz<br />
}<br />
<br />
/*<br />
Over serial with delay(10): approx 100Hz<br />
Without delay: much higher<br />
*/<br />
</pre><br />
<br />
==Auswertung==<br />
Die Unterrichtseinheit gliedert sich in drei Teile: Zuerst wird eine einfache Entladekurve aufgenommen und die Spannung am Kondensator gemessen, dann wird der ''Strom gemessen'' und zuletzt der Spannungsverlauf bei verschiedenen Widerständen gemessen.<br />
<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Entladung_eines_Kondensators&diff=21207Entladung eines Kondensators2023-08-16T15:10:22Z<p>Nefft0n: Erster Entwurf Kondensatorentladung</p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Entladung eines Kondensators<br />
| Category = Arduino library experiments<br />
| Sensors = Voltage<br />
}}<br />
<br />
In diesem Experiment sollen die Schülerinnen und Schüler die Entladungskurve eines Kondensators messen. Dafür wird der analoge Eingang eines ESP32 (ein günstiger Mikrocontroller) verwendet. Der ESP wird mithilfe der Arduino-Bibliothek so programmiert, dass er die Daten an phyphox übertragen kann.<br />
<br />
==Aufbau==<br />
Zuerst muss der ESP32 programmiert und verbunden werden. Die Spannung wird zwischen PINXY und GND gemessen.<br />
<br />
''Aufbauanleitung''<br />
<br />
Anschließend kann direkt losgelegt werden. Die entsprechenden Schaltbilder sind in den Arbeitsblättern zu finden.<br />
<br />
==Programmierung==<br />
Der ESP32 wird über die Arduino IDE programmiert. Es müssen die Definitionen für den ESP32 und die phyphox-Bibliothek installiert sein. Siehe dazu das Video unter [[:Category: Arduino library experiments]].<br />
<br />
Es ist darauf zu achten, dass jeder ESP32 eine eigene Kennung hat (diese wird in ''::start(ESP Voltmeter XY)'' festgelegt). Anschließend kann über das Plus-Symbol in phyphox ein Bluetooth-Experiment hinzugefügt werden, das Experiment wird dann automatisch geladen.<br />
<br />
<pre><br />
#include <phyphoxBle.h><br />
<br />
int ADC_GPIO = 25; // ESP32<br />
//int ADC_GPIO = A0; // Arduino Nano 33 BLE<br />
<br />
void setup() {<br />
<br />
<br />
// put your setup code here, to run once:<br />
Serial.begin(115200);<br />
PhyphoxBLE::start("ESP32 Voltmeter");<br />
<br />
PhyphoxBleExperiment Voltmeter;<br />
<br />
Voltmeter.setTitle("Voltmeter");<br />
Voltmeter.setCategory("ESP32 Experiments");<br />
Voltmeter.setDescription("This experiment will plot the measured voltage over time.");<br />
<br />
//View<br />
PhyphoxBleExperiment::View firstView;<br />
firstView.setLabel("Data"); //Create a "view"<br />
<br />
//Graph<br />
PhyphoxBleExperiment::Graph firstGraph; //Create graph which will plot random numbers over time<br />
firstGraph.setLabel("Voltmeter");<br />
firstGraph.setUnitX("s");<br />
firstGraph.setUnitY("V");<br />
firstGraph.setLabelX("time");<br />
firstGraph.setLabelY("Voltage");<br />
<br />
/* Assign Channels, so which data is plotted on x or y axis<br />
first parameter represents x-axis, second y-axis<br />
Channel 0 means a timestamp is created after the BLE package arrives in phyphox<br />
Channel 1 to N corresponding to the N-parameter which is written in server.write()<br />
*/<br />
<br />
firstGraph.setChannel(0, 1);<br />
<br />
firstView.addElement(firstGraph); //attach graph to view<br />
Voltmeter.addView(firstView); //Attach view to experiment<br />
PhyphoxBLE::addExperiment(Voltmeter); //Attach experiment to server<br />
}<br />
<br />
void loop() {<br />
// put your main code here, to run repeatedly:<br />
// measures the voltage as fast as possible, then calculates the mean over 100 values<br />
int meas = 0;<br />
for (int i = 0; i < 100; i++) {<br />
meas = meas + analogRead(ADC_GPIO);<br />
}<br />
<br />
meas = meas / 100;<br />
<br />
float meanvoltage = 3.3 * meas / 4095;<br />
<br />
//float voltage = 3.3 * analogRead(ADC_GPIO)/4095;<br />
//delay(1);<br />
<br />
PhyphoxBLE::write(meanvoltage);<br />
<br />
//Serial.print("Voltage = ");<br />
Serial.println(meanvoltage);<br />
<br />
delay(5); // approx 100Hz<br />
}<br />
<br />
/*<br />
Over serial with delay(10): approx 100Hz<br />
Without delay: much higher<br />
*/<br />
</pre><br />
<br />
==Auswertung==<br />
Die Unterrichtseinheit gliedert sich in drei Teile: Zuerst wird eine einfache Entladekurve aufgenommen und die Spannung am Kondensator gemessen, dann wird der ''Strom gemessen'' und zuletzt der Spannungsverlauf bei verschiedenen Widerständen gemessen.<br />
<br />
<br />
==Probleme und Lösungen==<br />
<br />
* test<br />
* test<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Entladung_eines_Kondensators&diff=21206Entladung eines Kondensators2023-08-15T17:16:58Z<p>Nefft0n: Created page with "{{Infobox Experiment | Name = Acceleration Spectrum | Category = Tools | Sensors = Acceleration with g }} The experiment "Acceleration Spectrum" displays the frequency spe..."</p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Acceleration Spectrum<br />
| Category = Tools<br />
| Sensors = Acceleration with g<br />
}}<br />
<br />
The experiment "Acceleration Spectrum" displays the frequency spectrum as well as the peak frequency of acceleration data. You can choose the number of samples used for the spectrum. If you incease the number, the spectrum will have a higher resolution allowing for more precise frequencies. If you decrease the number, you will get faster responses to changes.<br />
<br />
The maximum frequency in the spectrum is determined by the acquisition rate of the sensor (actually, it is half the acquisition rate). So, the spectrum will depend strongly on the device.<br />
<br />
==Requirements==<br />
There are no hardware requirements. The accelerometer is used for this measurement.<br />
<br />
==Setup==<br />
<br />
There is no specific setup.<br />
<br />
==Analysis==<br />
This experiments records the acceleration and keeps a history of the values. The Fourier transform is calculated over the last N samples, with N being chosen by the user. The peak frequency is the frequency of the maximum of the Fourier transform.<br />
<br />
<br />
==Problems and resolutions==<br />
<br />
* The frequency resolution is too low. The frequency resolution is limited by the length of the recording. By increasing the number of samples, you can increase the resolution, but this will also slow down the response to changes.<br />
* The maximum frequency is too low. The maximum frequency is half the acquisition rate of the sensor (Nyquist frequency). So, the maximum frequency is a limitation of your device.<br />
<br />
[[Category:Arduino library experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Category:Arduino_library_experiments&diff=21205Category:Arduino library experiments2023-08-15T17:13:23Z<p>Nefft0n: Created page with "This category contains experiments, which use the Arduino library (Todo Link). The Arduino library allows the usage of, for example, an ESP8266, an ESP32 or an classic Arduino."</p>
<hr />
<div>This category contains experiments, which use the Arduino library (Todo Link). The Arduino library allows the usage of, for example, an ESP8266, an ESP32 or an classic Arduino.</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Main_Page&diff=21204Main Page2023-08-15T17:11:33Z<p>Nefft0n: </p>
<hr />
<div><strong>Welcome to the phyphox wiki.</strong><br />
<br />
This wiki is meant to document and share more in-depth information on phyphox, experiments and projects. If you have anything interesting worth sharing, please, don't hesitate, create an account and add it to this Wiki.<br />
<br />
For now, the wiki is only available in English to encourage user participation without splitting up the users into regional communities.<br />
<br />
== Resources outside this Wiki ==<br />
* [http://phyphox.org/source/ phyphox source code]<br />
* [http://phyphox.org/sensordb/ sensor database]<br />
* [http://phyphox.org/forums/ phyphox forums]<br />
<br />
Introduction to the remote access<br />
* [http://phyphox.org/remote-control/ Remote control (web interface)]<br />
* [http://phyphox.org/fernsteuerung/ Fernsteuerung (German version)]<br />
<br />
Arduino, MicroPython, ESP32<br />
* [https://github.com/phyphox/phyphox-arduino Arduino library]<br />
* [https://github.com/phyphox/phyphox-micropython MicroPython library]<br />
* [https://github.com/vChavezB/zephyr_phyphox-ble Zephyr OS library] (by Victor Chávez-Bermúdez, not maintained by the phyphox team)<br />
<br />
== Experiments ==<br />
* [[:Category: Built-in experiments]]<br />
* [[:Category: User experiments]]<br />
* The [[Bluetooth device database|Bluetooth device database]]<br />
* [[:Category: Arduino library experiments]]<br />
<br />
Experiments and discussions can also be found in our [http://phyphox.org/forums/ forums].<br />
<br />
== Creating experiments ==<br />
* The [[experiment editor]]<br />
* The [[phyphox file format]]<br />
* [[Transferring phyphox experiments]]<br />
<br />
== In-depth topics ==<br />
* [[Version history]]<br />
* [[Bluetooth Low Energy]] (Interface for external sensors.)<br />
* [[Remote-interface communication]] (REST API)<br />
* [[Network Connections]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Sensor:_Magnetic_field&diff=21170Sensor: Magnetic field2023-01-12T18:00:38Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Magnetic field<br />
| Category = Raw sensors<br />
| Sensors = Magnetometer<br />
}}<br />
<br />
The experiment "Magnetic field" just gives the raw data from the phone's magnetometer.<br />
<br />
The magnetometer is quite sensitive as it is designed to measure the earth's magnetic field to act as a compass. However, you should not trust its absolute values as they are easily influenced by magnetizations in the phone (which can even be altered by external fields) and since most phones try to recalibrate this sensor once in a while to compensate for these influences.<br />
<br />
'''Do not expose your phone to strong magnetic fields!'''<br />
<br />
If you accidentally expose your phone to a strong field, this may magnetize parts within your phone, leading to a constant field measured by the magnetometer. This will render the compass function of your phone useless as it becomes stuck. However, most phones will recalibrate the compass function after a while to compensate for this and the compass will start working again without any limitations - Nevertheless, you should not risk this.<br />
<br />
<br />
==Finding the sensor==<br />
<br />
[[File:Find_magnet_sensor.mp4|400px|thumb|right|Finding the magnetic sensor]]<br />
<br />
The sensor can be found approximately with a slightly magnetized nail (if a strong magnet is used, the sensor saturates too fast). The phone and the nail are placed on a table, so the movement of the nail (which is laying on the table) is locked to the xy-plane. If the nail is moved alongside the phone (the tip points into the direction of the phone), the position of the sensor can be "triangulated" by using the nail orientation where the magnetic field is at its maximum. See the video for a instruction.<br />
<br />
[[Category:Built-in experiments]]<br />
[[Category:Sensor]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Sensor:_Magnetic_field&diff=21169Sensor: Magnetic field2023-01-12T18:00:25Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Magnetic field<br />
| Category = Raw sensors<br />
| Sensors = Magnetometer<br />
}}<br />
<br />
The experiment "Magnetic field" just gives the raw data from the phone's magnetometer.<br />
<br />
The magnetometer is quite sensitive as it is designed to measure the earth's magnetic field to act as a compass. However, you should not trust its absolute values as they are easily influenced by magnetizations in the phone (which can even be altered by external fields) and since most phones try to recalibrate this sensor once in a while to compensate for these influences.<br />
<br />
'''Do not expose your phone to strong magnetic fields!'''<br />
<br />
If you accidentally expose your phone to a strong field, this may magnetize parts within your phone, leading to a constant field measured by the magnetometer. This will render the compass function of your phone useless as it becomes stuck. However, most phones will recalibrate the compass function after a while to compensate for this and the compass will start working again without any limitations - Nevertheless, you should not risk this.<br />
<br />
<br />
==Finding the sensor==<br />
<br />
[[File:Find_magnet_sensor.mp4|100px|thumb|right|Finding the magnetic sensor]]<br />
<br />
The sensor can be found approximately with a slightly magnetized nail (if a strong magnet is used, the sensor saturates too fast). The phone and the nail are placed on a table, so the movement of the nail (which is laying on the table) is locked to the xy-plane. If the nail is moved alongside the phone (the tip points into the direction of the phone), the position of the sensor can be "triangulated" by using the nail orientation where the magnetic field is at its maximum. See the video for a instruction.<br />
<br />
[[Category:Built-in experiments]]<br />
[[Category:Sensor]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Find_magnet_sensor.mp4&diff=21168File:Find magnet sensor.mp42023-01-12T17:57:56Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=BBC:Microbit_/_Calliope&diff=21167BBC:Microbit / Calliope2022-12-21T16:45:45Z<p>Nefft0n: </p>
<hr />
<div>The BBC micro:bit is a Microcontroller that is designed to be easily programmable by young students. The Calliope is a very similar device, designed to be compatible to the Microbit. Hence, we discuss both on the same page with a focus on the Microbit. You should be able to load the same programs onto the Calliope (for differences, see section [[#Calliope]]).<br />
<br />
Which experiment configuration you can use with the Microbit depends on the program loaded onto the microcontroller. You will need to enable the Bluetooth functions with such a program first, so there are no experiments included with phyphox, but example combination of Microbit code and phyphox configurations can be found below.<br />
<br />
'''Important: Unlike most other Bluetooth Low Energy devices, the microbit needs to be paired with the phone to be used. You should use the Microbit app to do that (or the Bluetooth settings on Android - was not able to do this without the Microbit app on iOS).'''<br />
<br />
== Read magnetometer ==<br />
<br />
To make the magnetometer available via Bluetooth, you just need to write a minimal program for the Microbit that starts the magnetometer Bluetooth Service once:<br />
<br />
[[File:mb_mag.png]]<br />
<br />
Reading the magnetometer in phyphox can simply be done by reading the characteristic E95DFB11-251D-470A-A062-FA1922DFA9A8 as defined in the documentation. This returns three unsigned 16bit little endian integers, so we only need to pick them at their respective offsets:<br />
<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="0" conversion="int16LittleEndian">Bx</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="2" conversion="int16LittleEndian">By</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="4" conversion="int16LittleEndian">Bz</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
Unfortunately, the unit is not entirely clear and on the device we used to test, each value overflowed upon rotation. The result is that we get numbers in the range of -32000 to +32000 which overflow at several points during rotation from one end to the other. It is not clear to us whether this is an issue for the specific micro:bit we used for testing, but this behavior can clearly be seen in the raw data when reading the magnetometer service with other apps as well.<br />
<br />
You can use the following ready-to-use configuration in phyphox to try it yourself. Don't forget to load the correct code onto your micro:bit first and to freshly pair it with your phone:<br />
<br />
[[Media:BBC Microbit Magnetometer.phyphox]]<br />
<br />
== Read acceleration sensor ==<br />
The acceleration sensor is read similarly to the magnetometer, the only difference is the characteristic, which is "E95DCA4B-251D-470A-A062-FA1922DFA9A8". One has to change the axis labels, but that is all. For the the acceleration sensor of the Calliope, here is an experiment file: [[Media:Calliope_Acceleration.phyphox]].<br />
<br />
== Read IO Pins ==<br />
<br />
To make the IO pins available via Bluetooth, you just need to write a minimal program for the Microbit that starts the IO Bluetooth Service once:<br />
<br />
[[File:Microbit io.png]]<br />
<br />
That's it. Upload it to your Microbit and it is ready to be used (don't forget to pair it).<br />
<br />
Now, at the phyphox end, you need to figure out, on which characteristic the data can be received and how it is formatted. According to the Microbit documentation, this is E95D8D00-251D-470A-A062-FA1922DFA9A8, but the response will be a series of byte pairs and each pair gives the pin number and its value. In principle, we could even match and parse these in phyphox, but for this simple example, we can make our life a bit easier by only using a single pin. If there is only one pin that is read, the io data will be a single pair of bytes. The first will always be the pin number and the second will be the value. Therefore, if set up correctly, we only need to read the second byte of E95D8D00-251D-470A-A062-FA1922DFA9A8:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
</code><br />
<br />
Now, how do we tell the Microbit that we only want a single pin? Well, there are the characteristic E95DB9FE-251D-470A-A062-FA1922DFA9A8, which is a bit mask (a series of 1s and 0s, where each digit represents an option), that defines which pin is an input and which is an output. We only set one of those to "1" and the others to "0", which means that only one pin is an input. Also, there is characteristic E95D5899-251D-470A-A062-FA1922DFA9A8 with a similar bit mask, with which we can tell the Microbit that we want to do an analog read. So, we do the following config:<br />
<br />
<nowiki><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
</nowiki><br />
<br />
(A little detail as this might be confusing: The Microbit looks at the 20 least significant bits, so we want to set the "x" in the pattern xxxxxxxxxxxxxxxxxxxx000000000000 (20 "x" and 12 "0" to get a total of 32 bits). phyphox requires an input in hexadecimal, so groups of 8 bits are expressed as a byte in hexadecimal: xxxxxxxx xxxxxxxx xxxx0000 00000000. Setting the first bit leads to the hexadecimal number 01 00 00 00. Why not 80 00 00 00? Because we want to set the least significant bit, not the first one in the first one written in our notation.)<br />
<br />
Finally, we also want to have a time axis, so we tell phyphox to also save the time when a new value arrives:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</code><br />
<br />
So, in total we have<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
The following experiment configuration does all the above and also adds a little calibration. This calibration assumes that the range is 3V and that we have a single byte (a number from 0 to 255), so it is just 3V/255. Note, that the Microbit is designed to measure voltages. This is only an estimate and you will encounter effects that would be unusual for a real voltmeter, but that are typical for analog inputs of a microprocessor (like floating voltages and a battery dependent logic level as reference).<br />
<br />
So, just try this configuration in phyphox:<br />
<br />
[[Media:BBC Microbit Voltage.phyphox]]<br />
<br />
<br />
== Write number to LED service ==<br />
<br />
This example works in the other direction. We will use the accelerometer of the phone to detect a shake. For each shake, we count upwards and write the numer of shakes to the LEDs of the Microbit.<br />
<br />
On the Microbit, you only have to enable the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The phyphox experiment can now simply write numbers to the characteristic E95D93EE-251D-470A-A062-FA1922DFA9A8, so any number we want to show on the Microbit, can be written as follows:<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<input char="E95D93EE-251D-470A-A062-FA1922DFA9A8" conversion="singleByte">char</input><br />
</bluetooth><br />
</nowiki><br />
<br />
The rest of the experiment simply reads the accelerometer, checks if it is above a threshold and than adds one to the counter. You can try it below:<br />
<br />
[[Media:BBC Microbit Counter.phyphox]]<br />
<br />
<br />
== Move point on LED service ==<br />
<br />
This is just another example. As above, it only requires the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The experiment configuration is rather complex because it needs to compose the bits that have to be written to the LED service. It is probably only relevant if you want to do something similar and you should really know how the phyphox experiment configurations work:<br />
<br />
[[Media:BBC Microbit Matrix.phyphox]]<br />
<br />
<br />
== Measuring the voltage at a potentiometer and calculate its current resistance value ==<br />
<br />
'''Note: Each of the following experiment configurations uses the 3V- and GND-PIN of the BBC micro:bit as supply voltage and the voltage is measured using the I/O-PIN 0. The measured voltage data is transferred from the BBC micro:bit to the smartphone via BLE with a resolution of 3,3V/255.'''<br />
<br />
[[Media:Aufbau_Potentiometer.png]]<br />
<br />
This experiment configuration measures the variable voltage while changing the resistance value of a potentiometer. The configuration calculates the current resistance value and plots the calculated Resistance R with the measured Voltage V on the x- and y-axis and vice versa. <br />
<br />
[[File:R-U-Plot.jpg]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Potentiometer.png]]<br />
<br />
<br />
== Measuring the voltage drop and the illumination value of a photoresistor ==<br />
<br />
[[Media:Aufbau_Fotowiderstand.jpg]]<br />
<br />
This experiment configuration measures the voltage drop of a photoresistor as a function of its illumination level or both as functions of time (synchronous).<br />
<br />
[[File:V-Lux-Plot.png]]<br />
<br />
[[File:Lux-V-t-Plots.png]]<br />
<br />
The voltage is measured with the micro:bit, the illumination in Lux is measured with the intern light sensor of the smartphone.<br />
Just place the smartphone light sensor next to the photoresistance and use a variable light source with illumination uniformity. Start the exeriment with a low illumination level, then increase the illumination of the light source.<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Photoresistor.png]]<br />
<br />
== Measuring the capacitor voltage while (dis-)charging a capacitor ==<br />
<br />
[[Media:Kondensatorschaltung.png]]<br />
<br />
This experiment configuration measures the voltage drop of a capacitor in series with a resistance as a function of time.<br />
<br />
[[File:phyphox_charging.png]]<br />
<br />
The data is analysed by logarithmic functions, so that a linear regression in the phyphox app is possible for both charging and discharging. In each case the negative, inverse slope value represents the time constant τ.<br />
<br />
[[File:phyphox_linRegression.png]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Capacitor.png]]<br />
<br />
== Calliope ==<br />
To connect to the Calliope, it is best to connect the Calliope with the official Calliope Application to the device running phyphox. If the Calliope is not connecting, try reflashing the start program with USB [https://calliope.cc/programmieren/mobil/hilfe] and connect the Calliope again with the official app. If it is not shown in phyphox, try to hit the reset button once.<br />
<br />
In the phyphox experiments for the micro_Bit above, the "bluetooth name" tag has to be changed to "Calliope mini".<br />
<br />
Here are two simple files to read the magnetometer and the acceleration sensor: [[Media:Calliope_Magnetometer.phyphox]] and [[Media:Calliope_Acceleration.phyphox]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=BBC:Microbit_/_Calliope&diff=21165BBC:Microbit / Calliope2022-12-20T15:23:04Z<p>Nefft0n: </p>
<hr />
<div>The BBC micro:bit is a Microcontroller that is designed to be easily programmable by young students. The Calliope is a very similar device, designed to be compatible to the Microbit. Hence, we discuss both on the same page with a focus on the Microbit. You should be able to load the same programs onto the Calliope (for differences, see section [[#Calliope]]).<br />
<br />
Which experiment configuration you can use with the Microbit depends on the program loaded onto the microcontroller. You will need to enable the Bluetooth functions with such a program first, so there are no experiments included with phyphox, but example combination of Microbit code and phyphox configurations can be found below.<br />
<br />
'''Important: Unlike most other Bluetooth Low Energy devices, the microbit needs to be paired with the phone to be used. You should use the Microbit app to do that (or the Bluetooth settings on Android - was not able to do this without the Microbit app on iOS).'''<br />
<br />
== Read magnetometer ==<br />
<br />
To make the magnetometer available via Bluetooth, you just need to write a minimal program for the Microbit that starts the magnetometer Bluetooth Service once:<br />
<br />
[[File:mb_mag.png]]<br />
<br />
Reading the magnetometer in phyphox can simply be done by reading the characteristic E95DFB11-251D-470A-A062-FA1922DFA9A8 as defined in the documentation. This returns three unsigned 16bit little endian integers, so we only need to pick them at their respective offsets:<br />
<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="0" conversion="int16LittleEndian">Bx</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="2" conversion="int16LittleEndian">By</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="4" conversion="int16LittleEndian">Bz</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
Unfortunately, the unit is not entirely clear and on the device we used to test, each value overflowed upon rotation. The result is that we get numbers in the range of -32000 to +32000 which overflow at several points during rotation from one end to the other. It is not clear to us whether this is an issue for the specific micro:bit we used for testing, but this behavior can clearly be seen in the raw data when reading the magnetometer service with other apps as well.<br />
<br />
You can use the following ready-to-use configuration in phyphox to try it yourself. Don't forget to load the correct code onto your micro:bit first and to freshly pair it with your phone:<br />
<br />
[[Media:BBC Microbit Magnetometer.phyphox]]<br />
<br />
== Read acceleration sensor ==<br />
The acceleration sensor is read similarly to the magnetometer, the only difference is the characteristic, which is "E95DCA4B-251D-470A-A062-FA1922DFA9A8". One has to change the axis labels, but that is all. For the the acceleration sensor of the Calliope, here is an experiment file: [[Media:Calliope_Acceleration.phyphox]].<br />
<br />
== Read IO Pins ==<br />
<br />
To make the IO pins available via Bluetooth, you just need to write a minimal program for the Microbit that starts the IO Bluetooth Service once:<br />
<br />
[[File:Microbit io.png]]<br />
<br />
That's it. Upload it to your Microbit and it is ready to be used (don't forget to pair it).<br />
<br />
Now, at the phyphox end, you need to figure out, on which characteristic the data can be received and how it is formatted. According to the Microbit documentation, this is E95D8D00-251D-470A-A062-FA1922DFA9A8, but the response will be a series of byte pairs and each pair gives the pin number and its value. In principle, we could even match and parse these in phyphox, but for this simple example, we can make our life a bit easier by only using a single pin. If there is only one pin that is read, the io data will be a single pair of bytes. The first will always be the pin number and the second will be the value. Therefore, if set up correctly, we only need to read the second byte of E95D8D00-251D-470A-A062-FA1922DFA9A8:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
</code><br />
<br />
Now, how do we tell the Microbit that we only want a single pin? Well, there are the characteristic E95DB9FE-251D-470A-A062-FA1922DFA9A8, which is a bit mask (a series of 1s and 0s, where each digit represents an option), that defines which pin is an input and which is an output. We only set one of those to "1" and the others to "0", which means that only one pin is an input. Also, there is characteristic E95D5899-251D-470A-A062-FA1922DFA9A8 with a similar bit mask, with which we can tell the Microbit that we want to do an analog read. So, we do the following config:<br />
<br />
<nowiki><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
</nowiki><br />
<br />
(A little detail as this might be confusing: The Microbit looks at the 20 least significant bits, so we want to set the "x" in the pattern xxxxxxxxxxxxxxxxxxxx000000000000 (20 "x" and 12 "0" to get a total of 32 bits). phyphox requires an input in hexadecimal, so groups of 8 bits are expressed as a byte in hexadecimal: xxxxxxxx xxxxxxxx xxxx0000 00000000. Setting the first bit leads to the hexadecimal number 01 00 00 00. Why not 80 00 00 00? Because we want to set the least significant bit, not the first one in the first one written in our notation.)<br />
<br />
Finally, we also want to have a time axis, so we tell phyphox to also save the time when a new value arrives:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</code><br />
<br />
So, in total we have<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
The following experiment configuration does all the above and also adds a little calibration. This calibration assumes that the range is 3V and that we have a single byte (a number from 0 to 255), so it is just 3V/255. Note, that the Microbit is designed to measure voltages. This is only an estimate and you will encounter effects that would be unusual for a real voltmeter, but that are typical for analog inputs of a microprocessor (like floating voltages and a battery dependent logic level as reference).<br />
<br />
So, just try this configuration in phyphox:<br />
<br />
[[Media:BBC Microbit Voltage.phyphox]]<br />
<br />
<br />
== Write number to LED service ==<br />
<br />
This example works in the other direction. We will use the accelerometer of the phone to detect a shake. For each shake, we count upwards and write the numer of shakes to the LEDs of the Microbit.<br />
<br />
On the Microbit, you only have to enable the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The phyphox experiment can now simply write numbers to the characteristic E95D93EE-251D-470A-A062-FA1922DFA9A8, so any number we want to show on the Microbit, can be written as follows:<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<input char="E95D93EE-251D-470A-A062-FA1922DFA9A8" conversion="singleByte">char</input><br />
</bluetooth><br />
</nowiki><br />
<br />
The rest of the experiment simply reads the accelerometer, checks if it is above a threshold and than adds one to the counter. You can try it below:<br />
<br />
[[Media:BBC Microbit Counter.phyphox]]<br />
<br />
<br />
== Move point on LED service ==<br />
<br />
This is just another example. As above, it only requires the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The experiment configuration is rather complex because it needs to compose the bits that have to be written to the LED service. It is probably only relevant if you want to do something similar and you should really know how the phyphox experiment configurations work:<br />
<br />
[[Media:BBC Microbit Matrix.phyphox]]<br />
<br />
<br />
== Measuring the voltage at a potentiometer and calculate its current resistance value ==<br />
<br />
'''Note: Each of the following experiment configurations uses the 3V- and GND-PIN of the BBC micro:bit as supply voltage and the voltage is measured using the I/O-PIN 0. The measured voltage data is transferred from the BBC micro:bit to the smartphone via BLE with a resolution of 3,3V/255.'''<br />
<br />
[[Media:Aufbau_Potentiometer.png]]<br />
<br />
This experiment configuration measures the variable voltage while changing the resistance value of a potentiometer. The configuration calculates the current resistance value and plots the calculated Resistance R with the measured Voltage V on the x- and y-axis and vice versa. <br />
<br />
[[File:R-U-Plot.jpg]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Potentiometer.png]]<br />
<br />
<br />
== Measuring the voltage drop and the illumination value of a photoresistor ==<br />
<br />
[[Media:Aufbau_Fotowiderstand.jpg]]<br />
<br />
This experiment configuration measures the voltage drop of a photoresistor as a function of its illumination level or both as functions of time (synchronous).<br />
<br />
[[File:V-Lux-Plot.png]]<br />
<br />
[[File:Lux-V-t-Plots.png]]<br />
<br />
The voltage is measured with the micro:bit, the illumination in Lux is measured with the intern light sensor of the smartphone.<br />
Just place the smartphone light sensor next to the photoresistance and use a variable light source with illumination uniformity. Start the exeriment with a low illumination level, then increase the illumination of the light source.<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Photoresistor.png]]<br />
<br />
== Measuring the capacitor voltage while (dis-)charging a capacitor ==<br />
<br />
[[Media:Kondensatorschaltung.png]]<br />
<br />
This experiment configuration measures the voltage drop of a capacitor in series with a resistance as a function of time.<br />
<br />
[[File:phyphox_charging.png]]<br />
<br />
The data is analysed by logarithmic functions, so that a linear regression in the phyphox app is possible for both charging and discharging. In each case the negative, inverse slope value represents the time constant τ.<br />
<br />
[[File:phyphox_linRegression.png]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Capacitor.png]]<br />
<br />
== Calliope ==<br />
To connect to the calliope, it is best to connect the Calliope with the official Calliope Application to the device running phyphox. If the Calliope is not connecting, try reflashing the start program with USB [https://calliope.cc/programmieren/mobil/hilfe] and connect the Calliope again with the official app.<br />
<br />
In the phyphox experiments, the "bluetooth name" tag has to be changed to "Calliope mini".<br />
<br />
Here are two simple files to read the magnetometer and the acceleration sensor: [[Media:Calliope_Magnetometer.phyphox]] and [[Media:Calliope_Acceleration.phyphox]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=BBC:Microbit_/_Calliope&diff=21164BBC:Microbit / Calliope2022-12-20T15:12:45Z<p>Nefft0n: /* Calliope */</p>
<hr />
<div>The BBC micro:bit is a Microcontroller that is designed to be easily programmable by young students. The Calliope is a very similar device, designed to be compatible to the Microbit. Hence, we discuss both on the same page with a focus on the Microbit. You should be able to load the same programs onto the Calliope (for differences, see section [[#Calliope]]).<br />
<br />
Which experiment configuration you can use with the Microbit depends on the program loaded onto the microcontroller. You will need to enable the Bluetooth functions with such a program first, so there are no experiments included with phyphox, but example combination of Microbit code and phyphox configurations can be found below.<br />
<br />
'''Important: Unlike most other Bluetooth Low Energy devices, the microbit needs to be paired with the phone to be used. You should use the Microbit app to do that (or the Bluetooth settings on Android - was not able to do this without the Microbit app on iOS).'''<br />
<br />
== Read magnetometer ==<br />
<br />
To make the magnetometer available via Bluetooth, you just need to write a minimal program for the Microbit that starts the magnetometer Bluetooth Service once:<br />
<br />
[[File:mb_mag.png]]<br />
<br />
Reading the magnetometer in phyphox can simply be done by reading the characteristic E95DFB11-251D-470A-A062-FA1922DFA9A8 as defined in the documentation. This returns three unsigned 16bit little endian integers, so we only need to pick them at their respective offsets:<br />
<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="0" conversion="int16LittleEndian">Bx</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="2" conversion="int16LittleEndian">By</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="4" conversion="int16LittleEndian">Bz</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
Unfortunately, the unit is not entirely clear and on the device we used to test, each value overflowed upon rotation. The result is that we get numbers in the range of -32000 to +32000 which overflow at several points during rotation from one end to the other. It is not clear to us whether this is an issue for the specific micro:bit we used for testing, but this behavior can clearly be seen in the raw data when reading the magnetometer service with other apps as well.<br />
<br />
You can use the following ready-to-use configuration in phyphox to try it yourself. Don't forget to load the correct code onto your micro:bit first and to freshly pair it with your phone:<br />
<br />
[[Media:BBC Microbit Magnetometer.phyphox]]<br />
<br />
== Read acceleration sensor ==<br />
The acceleration sensor is read similarly to the magnetometer, the only difference is the characteristic, which is "E95DCA4B-251D-470A-A062-FA1922DFA9A8". One has to change the axis labels, but that is all. For the the acceleration sensor of the Calliope, here is an experiment file: [[Media:Calliope_Acceleration.phyphox]].<br />
<br />
== Read IO Pins ==<br />
<br />
To make the IO pins available via Bluetooth, you just need to write a minimal program for the Microbit that starts the IO Bluetooth Service once:<br />
<br />
[[File:Microbit io.png]]<br />
<br />
That's it. Upload it to your Microbit and it is ready to be used (don't forget to pair it).<br />
<br />
Now, at the phyphox end, you need to figure out, on which characteristic the data can be received and how it is formatted. According to the Microbit documentation, this is E95D8D00-251D-470A-A062-FA1922DFA9A8, but the response will be a series of byte pairs and each pair gives the pin number and its value. In principle, we could even match and parse these in phyphox, but for this simple example, we can make our life a bit easier by only using a single pin. If there is only one pin that is read, the io data will be a single pair of bytes. The first will always be the pin number and the second will be the value. Therefore, if set up correctly, we only need to read the second byte of E95D8D00-251D-470A-A062-FA1922DFA9A8:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
</code><br />
<br />
Now, how do we tell the Microbit that we only want a single pin? Well, there are the characteristic E95DB9FE-251D-470A-A062-FA1922DFA9A8, which is a bit mask (a series of 1s and 0s, where each digit represents an option), that defines which pin is an input and which is an output. We only set one of those to "1" and the others to "0", which means that only one pin is an input. Also, there is characteristic E95D5899-251D-470A-A062-FA1922DFA9A8 with a similar bit mask, with which we can tell the Microbit that we want to do an analog read. So, we do the following config:<br />
<br />
<nowiki><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
</nowiki><br />
<br />
(A little detail as this might be confusing: The Microbit looks at the 20 least significant bits, so we want to set the "x" in the pattern xxxxxxxxxxxxxxxxxxxx000000000000 (20 "x" and 12 "0" to get a total of 32 bits). phyphox requires an input in hexadecimal, so groups of 8 bits are expressed as a byte in hexadecimal: xxxxxxxx xxxxxxxx xxxx0000 00000000. Setting the first bit leads to the hexadecimal number 01 00 00 00. Why not 80 00 00 00? Because we want to set the least significant bit, not the first one in the first one written in our notation.)<br />
<br />
Finally, we also want to have a time axis, so we tell phyphox to also save the time when a new value arrives:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</code><br />
<br />
So, in total we have<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
The following experiment configuration does all the above and also adds a little calibration. This calibration assumes that the range is 3V and that we have a single byte (a number from 0 to 255), so it is just 3V/255. Note, that the Microbit is designed to measure voltages. This is only an estimate and you will encounter effects that would be unusual for a real voltmeter, but that are typical for analog inputs of a microprocessor (like floating voltages and a battery dependent logic level as reference).<br />
<br />
So, just try this configuration in phyphox:<br />
<br />
[[Media:BBC Microbit Voltage.phyphox]]<br />
<br />
<br />
== Write number to LED service ==<br />
<br />
This example works in the other direction. We will use the accelerometer of the phone to detect a shake. For each shake, we count upwards and write the numer of shakes to the LEDs of the Microbit.<br />
<br />
On the Microbit, you only have to enable the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The phyphox experiment can now simply write numbers to the characteristic E95D93EE-251D-470A-A062-FA1922DFA9A8, so any number we want to show on the Microbit, can be written as follows:<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<input char="E95D93EE-251D-470A-A062-FA1922DFA9A8" conversion="singleByte">char</input><br />
</bluetooth><br />
</nowiki><br />
<br />
The rest of the experiment simply reads the accelerometer, checks if it is above a threshold and than adds one to the counter. You can try it below:<br />
<br />
[[Media:BBC Microbit Counter.phyphox]]<br />
<br />
<br />
== Move point on LED service ==<br />
<br />
This is just another example. As above, it only requires the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The experiment configuration is rather complex because it needs to compose the bits that have to be written to the LED service. It is probably only relevant if you want to do something similar and you should really know how the phyphox experiment configurations work:<br />
<br />
[[Media:BBC Microbit Matrix.phyphox]]<br />
<br />
<br />
== Measuring the voltage at a potentiometer and calculate its current resistance value ==<br />
<br />
'''Note: Each of the following experiment configurations uses the 3V- and GND-PIN of the BBC micro:bit as supply voltage and the voltage is measured using the I/O-PIN 0. The measured voltage data is transferred from the BBC micro:bit to the smartphone via BLE with a resolution of 3,3V/255.'''<br />
<br />
[[Media:Aufbau_Potentiometer.png]]<br />
<br />
This experiment configuration measures the variable voltage while changing the resistance value of a potentiometer. The configuration calculates the current resistance value and plots the calculated Resistance R with the measured Voltage V on the x- and y-axis and vice versa. <br />
<br />
[[File:R-U-Plot.jpg]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Potentiometer.png]]<br />
<br />
<br />
== Measuring the voltage drop and the illumination value of a photoresistor ==<br />
<br />
[[Media:Aufbau_Fotowiderstand.jpg]]<br />
<br />
This experiment configuration measures the voltage drop of a photoresistor as a function of its illumination level or both as functions of time (synchronous).<br />
<br />
[[File:V-Lux-Plot.png]]<br />
<br />
[[File:Lux-V-t-Plots.png]]<br />
<br />
The voltage is measured with the micro:bit, the illumination in Lux is measured with the intern light sensor of the smartphone.<br />
Just place the smartphone light sensor next to the photoresistance and use a variable light source with illumination uniformity. Start the exeriment with a low illumination level, then increase the illumination of the light source.<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Photoresistor.png]]<br />
<br />
== Measuring the capacitor voltage while (dis-)charging a capacitor ==<br />
<br />
[[Media:Kondensatorschaltung.png]]<br />
<br />
This experiment configuration measures the voltage drop of a capacitor in series with a resistance as a function of time.<br />
<br />
[[File:phyphox_charging.png]]<br />
<br />
The data is analysed by logarithmic functions, so that a linear regression in the phyphox app is possible for both charging and discharging. In each case the negative, inverse slope value represents the time constant τ.<br />
<br />
[[File:phyphox_linRegression.png]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Capacitor.png]]<br />
<br />
== Calliope ==<br />
To connect to the calliope, it is best to connect the Calliope with the official Calliope Application to the device running phyphox.<br />
<br />
In the phyphox experiments, the "bluetooth name" tag has to be changed to "Calliope mini".<br />
<br />
Here are two simple files to read the magnetometer and the acceleration sensor: [[Media:Calliope_Magnetometer.phyphox]] and [[Media:Calliope_Acceleration.phyphox]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=BBC:Microbit_/_Calliope&diff=21163BBC:Microbit / Calliope2022-12-20T15:11:54Z<p>Nefft0n: </p>
<hr />
<div>The BBC micro:bit is a Microcontroller that is designed to be easily programmable by young students. The Calliope is a very similar device, designed to be compatible to the Microbit. Hence, we discuss both on the same page with a focus on the Microbit. You should be able to load the same programs onto the Calliope (for differences, see section [[#Calliope]]).<br />
<br />
Which experiment configuration you can use with the Microbit depends on the program loaded onto the microcontroller. You will need to enable the Bluetooth functions with such a program first, so there are no experiments included with phyphox, but example combination of Microbit code and phyphox configurations can be found below.<br />
<br />
'''Important: Unlike most other Bluetooth Low Energy devices, the microbit needs to be paired with the phone to be used. You should use the Microbit app to do that (or the Bluetooth settings on Android - was not able to do this without the Microbit app on iOS).'''<br />
<br />
== Read magnetometer ==<br />
<br />
To make the magnetometer available via Bluetooth, you just need to write a minimal program for the Microbit that starts the magnetometer Bluetooth Service once:<br />
<br />
[[File:mb_mag.png]]<br />
<br />
Reading the magnetometer in phyphox can simply be done by reading the characteristic E95DFB11-251D-470A-A062-FA1922DFA9A8 as defined in the documentation. This returns three unsigned 16bit little endian integers, so we only need to pick them at their respective offsets:<br />
<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="0" conversion="int16LittleEndian">Bx</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="2" conversion="int16LittleEndian">By</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="4" conversion="int16LittleEndian">Bz</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
Unfortunately, the unit is not entirely clear and on the device we used to test, each value overflowed upon rotation. The result is that we get numbers in the range of -32000 to +32000 which overflow at several points during rotation from one end to the other. It is not clear to us whether this is an issue for the specific micro:bit we used for testing, but this behavior can clearly be seen in the raw data when reading the magnetometer service with other apps as well.<br />
<br />
You can use the following ready-to-use configuration in phyphox to try it yourself. Don't forget to load the correct code onto your micro:bit first and to freshly pair it with your phone:<br />
<br />
[[Media:BBC Microbit Magnetometer.phyphox]]<br />
<br />
== Read acceleration sensor ==<br />
The acceleration sensor is read similarly to the magnetometer, the only difference is the characteristic, which is "E95DCA4B-251D-470A-A062-FA1922DFA9A8". One has to change the axis labels, but that is all. For the the acceleration sensor of the Calliope, here is an experiment file: [[Media:Calliope_Acceleration.phyphox]].<br />
<br />
== Read IO Pins ==<br />
<br />
To make the IO pins available via Bluetooth, you just need to write a minimal program for the Microbit that starts the IO Bluetooth Service once:<br />
<br />
[[File:Microbit io.png]]<br />
<br />
That's it. Upload it to your Microbit and it is ready to be used (don't forget to pair it).<br />
<br />
Now, at the phyphox end, you need to figure out, on which characteristic the data can be received and how it is formatted. According to the Microbit documentation, this is E95D8D00-251D-470A-A062-FA1922DFA9A8, but the response will be a series of byte pairs and each pair gives the pin number and its value. In principle, we could even match and parse these in phyphox, but for this simple example, we can make our life a bit easier by only using a single pin. If there is only one pin that is read, the io data will be a single pair of bytes. The first will always be the pin number and the second will be the value. Therefore, if set up correctly, we only need to read the second byte of E95D8D00-251D-470A-A062-FA1922DFA9A8:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
</code><br />
<br />
Now, how do we tell the Microbit that we only want a single pin? Well, there are the characteristic E95DB9FE-251D-470A-A062-FA1922DFA9A8, which is a bit mask (a series of 1s and 0s, where each digit represents an option), that defines which pin is an input and which is an output. We only set one of those to "1" and the others to "0", which means that only one pin is an input. Also, there is characteristic E95D5899-251D-470A-A062-FA1922DFA9A8 with a similar bit mask, with which we can tell the Microbit that we want to do an analog read. So, we do the following config:<br />
<br />
<nowiki><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
</nowiki><br />
<br />
(A little detail as this might be confusing: The Microbit looks at the 20 least significant bits, so we want to set the "x" in the pattern xxxxxxxxxxxxxxxxxxxx000000000000 (20 "x" and 12 "0" to get a total of 32 bits). phyphox requires an input in hexadecimal, so groups of 8 bits are expressed as a byte in hexadecimal: xxxxxxxx xxxxxxxx xxxx0000 00000000. Setting the first bit leads to the hexadecimal number 01 00 00 00. Why not 80 00 00 00? Because we want to set the least significant bit, not the first one in the first one written in our notation.)<br />
<br />
Finally, we also want to have a time axis, so we tell phyphox to also save the time when a new value arrives:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</code><br />
<br />
So, in total we have<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
The following experiment configuration does all the above and also adds a little calibration. This calibration assumes that the range is 3V and that we have a single byte (a number from 0 to 255), so it is just 3V/255. Note, that the Microbit is designed to measure voltages. This is only an estimate and you will encounter effects that would be unusual for a real voltmeter, but that are typical for analog inputs of a microprocessor (like floating voltages and a battery dependent logic level as reference).<br />
<br />
So, just try this configuration in phyphox:<br />
<br />
[[Media:BBC Microbit Voltage.phyphox]]<br />
<br />
<br />
== Write number to LED service ==<br />
<br />
This example works in the other direction. We will use the accelerometer of the phone to detect a shake. For each shake, we count upwards and write the numer of shakes to the LEDs of the Microbit.<br />
<br />
On the Microbit, you only have to enable the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The phyphox experiment can now simply write numbers to the characteristic E95D93EE-251D-470A-A062-FA1922DFA9A8, so any number we want to show on the Microbit, can be written as follows:<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<input char="E95D93EE-251D-470A-A062-FA1922DFA9A8" conversion="singleByte">char</input><br />
</bluetooth><br />
</nowiki><br />
<br />
The rest of the experiment simply reads the accelerometer, checks if it is above a threshold and than adds one to the counter. You can try it below:<br />
<br />
[[Media:BBC Microbit Counter.phyphox]]<br />
<br />
<br />
== Move point on LED service ==<br />
<br />
This is just another example. As above, it only requires the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The experiment configuration is rather complex because it needs to compose the bits that have to be written to the LED service. It is probably only relevant if you want to do something similar and you should really know how the phyphox experiment configurations work:<br />
<br />
[[Media:BBC Microbit Matrix.phyphox]]<br />
<br />
<br />
== Measuring the voltage at a potentiometer and calculate its current resistance value ==<br />
<br />
'''Note: Each of the following experiment configurations uses the 3V- and GND-PIN of the BBC micro:bit as supply voltage and the voltage is measured using the I/O-PIN 0. The measured voltage data is transferred from the BBC micro:bit to the smartphone via BLE with a resolution of 3,3V/255.'''<br />
<br />
[[Media:Aufbau_Potentiometer.png]]<br />
<br />
This experiment configuration measures the variable voltage while changing the resistance value of a potentiometer. The configuration calculates the current resistance value and plots the calculated Resistance R with the measured Voltage V on the x- and y-axis and vice versa. <br />
<br />
[[File:R-U-Plot.jpg]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Potentiometer.png]]<br />
<br />
<br />
== Measuring the voltage drop and the illumination value of a photoresistor ==<br />
<br />
[[Media:Aufbau_Fotowiderstand.jpg]]<br />
<br />
This experiment configuration measures the voltage drop of a photoresistor as a function of its illumination level or both as functions of time (synchronous).<br />
<br />
[[File:V-Lux-Plot.png]]<br />
<br />
[[File:Lux-V-t-Plots.png]]<br />
<br />
The voltage is measured with the micro:bit, the illumination in Lux is measured with the intern light sensor of the smartphone.<br />
Just place the smartphone light sensor next to the photoresistance and use a variable light source with illumination uniformity. Start the exeriment with a low illumination level, then increase the illumination of the light source.<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Photoresistor.png]]<br />
<br />
== Measuring the capacitor voltage while (dis-)charging a capacitor ==<br />
<br />
[[Media:Kondensatorschaltung.png]]<br />
<br />
This experiment configuration measures the voltage drop of a capacitor in series with a resistance as a function of time.<br />
<br />
[[File:phyphox_charging.png]]<br />
<br />
The data is analysed by logarithmic functions, so that a linear regression in the phyphox app is possible for both charging and discharging. In each case the negative, inverse slope value represents the time constant τ.<br />
<br />
[[File:phyphox_linRegression.png]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Capacitor.png]]<br />
<br />
== Calliope ==<br />
To connect to the calliope, it is best to connect the Calliope with the official Calliope Application to the device. The "bluetooth name" tag has to be changed to "Calliope mini". Here are two simple files to read the magnetometer and the acceleration sensor: [[Media:Calliope_Magnetometer.phyphox]] and [[Media:Calliope_Acceleration.phyphox]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=BBC:Microbit_/_Calliope&diff=21162BBC:Microbit / Calliope2022-12-20T15:11:39Z<p>Nefft0n: </p>
<hr />
<div>The BBC micro:bit is a Microcontroller that is designed to be easily programmable by young students. The Calliope is a very similar device, designed to be compatible to the Microbit. Hence, we discuss both on the same page with a focus on the Microbit. You should be able to load the same programs onto the Calliope (for differences, see section [[#Calliope]].<br />
<br />
Which experiment configuration you can use with the Microbit depends on the program loaded onto the microcontroller. You will need to enable the Bluetooth functions with such a program first, so there are no experiments included with phyphox, but example combination of Microbit code and phyphox configurations can be found below.<br />
<br />
'''Important: Unlike most other Bluetooth Low Energy devices, the microbit needs to be paired with the phone to be used. You should use the Microbit app to do that (or the Bluetooth settings on Android - was not able to do this without the Microbit app on iOS).'''<br />
<br />
== Read magnetometer ==<br />
<br />
To make the magnetometer available via Bluetooth, you just need to write a minimal program for the Microbit that starts the magnetometer Bluetooth Service once:<br />
<br />
[[File:mb_mag.png]]<br />
<br />
Reading the magnetometer in phyphox can simply be done by reading the characteristic E95DFB11-251D-470A-A062-FA1922DFA9A8 as defined in the documentation. This returns three unsigned 16bit little endian integers, so we only need to pick them at their respective offsets:<br />
<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="0" conversion="int16LittleEndian">Bx</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="2" conversion="int16LittleEndian">By</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" offset="4" conversion="int16LittleEndian">Bz</output><br />
<output char="E95DFB11-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
Unfortunately, the unit is not entirely clear and on the device we used to test, each value overflowed upon rotation. The result is that we get numbers in the range of -32000 to +32000 which overflow at several points during rotation from one end to the other. It is not clear to us whether this is an issue for the specific micro:bit we used for testing, but this behavior can clearly be seen in the raw data when reading the magnetometer service with other apps as well.<br />
<br />
You can use the following ready-to-use configuration in phyphox to try it yourself. Don't forget to load the correct code onto your micro:bit first and to freshly pair it with your phone:<br />
<br />
[[Media:BBC Microbit Magnetometer.phyphox]]<br />
<br />
== Read acceleration sensor ==<br />
The acceleration sensor is read similarly to the magnetometer, the only difference is the characteristic, which is "E95DCA4B-251D-470A-A062-FA1922DFA9A8". One has to change the axis labels, but that is all. For the the acceleration sensor of the Calliope, here is an experiment file: [[Media:Calliope_Acceleration.phyphox]].<br />
<br />
== Read IO Pins ==<br />
<br />
To make the IO pins available via Bluetooth, you just need to write a minimal program for the Microbit that starts the IO Bluetooth Service once:<br />
<br />
[[File:Microbit io.png]]<br />
<br />
That's it. Upload it to your Microbit and it is ready to be used (don't forget to pair it).<br />
<br />
Now, at the phyphox end, you need to figure out, on which characteristic the data can be received and how it is formatted. According to the Microbit documentation, this is E95D8D00-251D-470A-A062-FA1922DFA9A8, but the response will be a series of byte pairs and each pair gives the pin number and its value. In principle, we could even match and parse these in phyphox, but for this simple example, we can make our life a bit easier by only using a single pin. If there is only one pin that is read, the io data will be a single pair of bytes. The first will always be the pin number and the second will be the value. Therefore, if set up correctly, we only need to read the second byte of E95D8D00-251D-470A-A062-FA1922DFA9A8:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
</code><br />
<br />
Now, how do we tell the Microbit that we only want a single pin? Well, there are the characteristic E95DB9FE-251D-470A-A062-FA1922DFA9A8, which is a bit mask (a series of 1s and 0s, where each digit represents an option), that defines which pin is an input and which is an output. We only set one of those to "1" and the others to "0", which means that only one pin is an input. Also, there is characteristic E95D5899-251D-470A-A062-FA1922DFA9A8 with a similar bit mask, with which we can tell the Microbit that we want to do an analog read. So, we do the following config:<br />
<br />
<nowiki><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
</nowiki><br />
<br />
(A little detail as this might be confusing: The Microbit looks at the 20 least significant bits, so we want to set the "x" in the pattern xxxxxxxxxxxxxxxxxxxx000000000000 (20 "x" and 12 "0" to get a total of 32 bits). phyphox requires an input in hexadecimal, so groups of 8 bits are expressed as a byte in hexadecimal: xxxxxxxx xxxxxxxx xxxx0000 00000000. Setting the first bit leads to the hexadecimal number 01 00 00 00. Why not 80 00 00 00? Because we want to set the least significant bit, not the first one in the first one written in our notation.)<br />
<br />
Finally, we also want to have a time axis, so we tell phyphox to also save the time when a new value arrives:<br />
<br />
<code><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</code><br />
<br />
So, in total we have<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<config char="E95D5899-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<config char="E95DB9FE-251D-470A-A062-FA1922DFA9A8" conversion="hexadecimal">01000000</config><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" offset="1" conversion="singleByte">v0</output><br />
<output char="E95D8D00-251D-470A-A062-FA1922DFA9A8" extra="time">t</output><br />
</bluetooth><br />
</nowiki><br />
<br />
The following experiment configuration does all the above and also adds a little calibration. This calibration assumes that the range is 3V and that we have a single byte (a number from 0 to 255), so it is just 3V/255. Note, that the Microbit is designed to measure voltages. This is only an estimate and you will encounter effects that would be unusual for a real voltmeter, but that are typical for analog inputs of a microprocessor (like floating voltages and a battery dependent logic level as reference).<br />
<br />
So, just try this configuration in phyphox:<br />
<br />
[[Media:BBC Microbit Voltage.phyphox]]<br />
<br />
<br />
== Write number to LED service ==<br />
<br />
This example works in the other direction. We will use the accelerometer of the phone to detect a shake. For each shake, we count upwards and write the numer of shakes to the LEDs of the Microbit.<br />
<br />
On the Microbit, you only have to enable the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The phyphox experiment can now simply write numbers to the characteristic E95D93EE-251D-470A-A062-FA1922DFA9A8, so any number we want to show on the Microbit, can be written as follows:<br />
<nowiki><br />
<bluetooth name="BBC micro:bit"><br />
<input char="E95D93EE-251D-470A-A062-FA1922DFA9A8" conversion="singleByte">char</input><br />
</bluetooth><br />
</nowiki><br />
<br />
The rest of the experiment simply reads the accelerometer, checks if it is above a threshold and than adds one to the counter. You can try it below:<br />
<br />
[[Media:BBC Microbit Counter.phyphox]]<br />
<br />
<br />
== Move point on LED service ==<br />
<br />
This is just another example. As above, it only requires the LED service:<br />
<br />
[[File:Microbit led.png]]<br />
<br />
The experiment configuration is rather complex because it needs to compose the bits that have to be written to the LED service. It is probably only relevant if you want to do something similar and you should really know how the phyphox experiment configurations work:<br />
<br />
[[Media:BBC Microbit Matrix.phyphox]]<br />
<br />
<br />
== Measuring the voltage at a potentiometer and calculate its current resistance value ==<br />
<br />
'''Note: Each of the following experiment configurations uses the 3V- and GND-PIN of the BBC micro:bit as supply voltage and the voltage is measured using the I/O-PIN 0. The measured voltage data is transferred from the BBC micro:bit to the smartphone via BLE with a resolution of 3,3V/255.'''<br />
<br />
[[Media:Aufbau_Potentiometer.png]]<br />
<br />
This experiment configuration measures the variable voltage while changing the resistance value of a potentiometer. The configuration calculates the current resistance value and plots the calculated Resistance R with the measured Voltage V on the x- and y-axis and vice versa. <br />
<br />
[[File:R-U-Plot.jpg]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Potentiometer.png]]<br />
<br />
<br />
== Measuring the voltage drop and the illumination value of a photoresistor ==<br />
<br />
[[Media:Aufbau_Fotowiderstand.jpg]]<br />
<br />
This experiment configuration measures the voltage drop of a photoresistor as a function of its illumination level or both as functions of time (synchronous).<br />
<br />
[[File:V-Lux-Plot.png]]<br />
<br />
[[File:Lux-V-t-Plots.png]]<br />
<br />
The voltage is measured with the micro:bit, the illumination in Lux is measured with the intern light sensor of the smartphone.<br />
Just place the smartphone light sensor next to the photoresistance and use a variable light source with illumination uniformity. Start the exeriment with a low illumination level, then increase the illumination of the light source.<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Photoresistor.png]]<br />
<br />
== Measuring the capacitor voltage while (dis-)charging a capacitor ==<br />
<br />
[[Media:Kondensatorschaltung.png]]<br />
<br />
This experiment configuration measures the voltage drop of a capacitor in series with a resistance as a function of time.<br />
<br />
[[File:phyphox_charging.png]]<br />
<br />
The data is analysed by logarithmic functions, so that a linear regression in the phyphox app is possible for both charging and discharging. In each case the negative, inverse slope value represents the time constant τ.<br />
<br />
[[File:phyphox_linRegression.png]]<br />
<br />
Experiment configuration (QR-Code):<br />
<br />
[[File:Capacitor.png]]<br />
<br />
== Calliope ==<br />
To connect to the calliope, it is best to connect the Calliope with the official Calliope Application to the device. The "bluetooth name" tag has to be changed to "Calliope mini". Here are two simple files to read the magnetometer and the acceleration sensor: [[Media:Calliope_Magnetometer.phyphox]] and [[Media:Calliope_Acceleration.phyphox]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Calliope_Magnetometer.phyphox&diff=21161File:Calliope Magnetometer.phyphox2022-12-20T15:01:05Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Calliope_Acceleration.phyphox&diff=21160File:Calliope Acceleration.phyphox2022-12-20T15:00:52Z<p>Nefft0n: </p>
<hr />
<div></div>Nefft0nhttp://phyphox.org/wiki/index.php?title=LC_circuit&diff=21159LC circuit2022-12-15T10:04:22Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = RC circuit<br />
| Category = Magnetism<br />
| Sensors = magnetometer<br />
}}<br />
<br />
The magnetic sensor is used to display the magnetic field of a coil in a RC circuit.<br />
<br />
<br />
==Requirements and experimental material==<br />
<br />
In this experiment a very simple LC circuit is created with a coil and a capacitor. To measure the magnetic field the coil has to have a low resistance and a high inductance. Such coils can be bought in audio supply and can be a bit expensive. The used coils for this experiment can be found at [https://www.hammfg.com/electronics/transformers/choke/195-196] and [https://www.monacor.de/produkte/components/lautsprechertechnik/frequenzweichen-und-bauteile-/lsi-100t/].<br />
<br />
Material:<br />
<br />
- smartphone (with phyphox-app and magnetic sensors) <br />
<br />
- a coil with low resistance and high inductance (for more information see paper)<br />
<br />
- some capacitors between 470uF and 22.000uF<br />
<br />
- a battery (9V) or power supply<br />
<br />
==Setup==<br />
<br />
The capacitor is charged with a battery or power supply and then shortened with the coil (directly connected to the coil). The phone is placed on the coil (the z-axis of the magnetometer points "into" the core of the coil, how to find its position is described in [[Sensor:_Magnetic_field]] ). The best results can be obtained if the magnetic sensor is placed exactly above the core. Due to the high sensitivity of the magnetic sensor, low magnetic fields can be measured easily. Because of the high sensitivity, the sensor saturates quite fast. The saturation can be prevented simply by adding some pieces of cardboard between the coil and the smartphone.<br />
<br />
[[File:Lccircuit.png|100px|thumb|right|Example of an oscillation]]<br />
<br />
==Paper and work sheets==<br />
The experiment was developed in a thesis for education students (Staatsexamensarbeit, [[File:Wiss-arbeit-westermann.pdf]]) at the University of Konstanz. The results where published in an open access paper [https://iopscience.iop.org/article/10.1088/1361-6552/ac920e], where a lot of additional information can be found.<br />
<br />
Work sheets in German where developed and can be found here: [[File:Abs-westermann.pdf]] (free to use, the sources are available on request).<br />
<br />
[[Category:User_experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=LC_circuit&diff=21158LC circuit2022-12-15T10:02:47Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = RC circuit<br />
| Category = Magnetism<br />
| Sensors = magnetometer<br />
}}<br />
<br />
The magnetic sensor is used to display the magnetic field of a coil in a RC circuit.<br />
<br />
<br />
==Requirements and experimental material==<br />
<br />
In this experiment a very simple LC circuit is created with a coil and a capacitor. To measure the magnetic field the coil has to have a low resistance and a high inductance. Such coils can be bought in audio supply and can be a bit expensive. The used coils for this experiment can be found at [https://www.hammfg.com/electronics/transformers/choke/195-196] and [https://www.monacor.de/produkte/components/lautsprechertechnik/frequenzweichen-und-bauteile-/lsi-100t/]<br />
<br />
- smartphone (with phyphox-app and magnetic sensors) <br />
<br />
- a coil with low resistance and high inductance (for more information see paper)<br />
<br />
- some capacitors between 470uF and 22.000uF<br />
<br />
- a battery (9V) or power supply<br />
<br />
==Setup==<br />
<br />
The capacitor is charged with a battery or power supply and then shortened with the coil (directly connected to the coil). The phone is placed on the coil (the z-axis of the magnetometer points "into" the core of the coil, how to find its position is described in [[Sensor:_Magnetic_field]] ). The best results can be obtained if the magnetic sensor is placed exactly above the core. Due to the high sensitivity of the magnetic sensor, low magnetic fields can be measured easily. Because of the high sensitivity, the sensor saturates quite fast. The saturation can be prevented simply by adding some pieces of cardboard between the coil and the smartphone.<br />
<br />
[[File:Lccircuit.png|100px|thumb|right|Example of an oscillation]]<br />
<br />
==Paper and work sheets==<br />
The experiment was developed in a thesis for education students (Staatsexamensarbeit, [[File:Wiss-arbeit-westermann.pdf]]) at the University of Konstanz. The results where published in an open access paper [https://iopscience.iop.org/article/10.1088/1361-6552/ac920e], where a lot of additional information can be found.<br />
<br />
Work sheets in German where developed and can be found here: [[File:Abs-westermann.pdf]] (free to use, the sources are available on request).<br />
<br />
[[Category:User_experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=Sensor:_Magnetic_field&diff=21157Sensor: Magnetic field2022-12-15T10:01:18Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = Magnetic field<br />
| Category = Raw sensors<br />
| Sensors = Magnetometer<br />
}}<br />
<br />
The experiment "Magnetic field" just gives the raw data from the phone's magnetometer.<br />
<br />
The magnetometer is quite sensitive as it is designed to measure the earth's magnetic field to act as a compass. However, you should not trust its absolute values as they are easily influenced by magnetizations in the phone (which can even be altered by external fields) and since most phones try to recalibrate this sensor once in a while to compensate for these influences.<br />
<br />
'''Do not expose your phone to strong magnetic fields!'''<br />
<br />
If you accidentally expose your phone to a strong field, this may magnetize parts within your phone, leading to a constant field measured by the magnetometer. This will render the compass function of your phone useless as it becomes stuck. However, most phones will recalibrate the compass function after a while to compensate for this and the compass will start working again without any limitations - Nevertheless, you should not risk this.<br />
<br />
<br />
==Finding the sensor==<br />
<br />
The sensor can be found approximately with a slightly magnetized nail (if a magnet is used, the sensor saturates too fast). The phone and the nail are placed on a table, so the movement of the nail (which is laying on the table) is locked to the xy-plane. If the nail is moved alongside the phone (the tip points into the direction of the phone), the position of the sensor can be "triangulated" by using the nail orientation where the magnetic field is at its maximum.<br />
<br />
[[Category:Built-in experiments]]<br />
[[Category:Sensor]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=LC_circuit&diff=21156LC circuit2022-12-15T09:24:26Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = RC circuit<br />
| Category = Magnetism<br />
| Sensors = magnetometer<br />
}}<br />
<br />
The magnetic sensor is used to display the magnetic field of a coil in a RC circuit.<br />
<br />
<br />
==Requirements and experimental material==<br />
<br />
In this experiment a very simple LC circuit is created with a coil and a capacitor. To measure the magnetic field the coil has to have a low resistance and a high inductance. Such coils can be bought in audio supply and can be a bit expensive. The used coils for this experiment can be found at [https://www.hammfg.com/electronics/transformers/choke/195-196] and [https://www.monacor.de/produkte/components/lautsprechertechnik/frequenzweichen-und-bauteile-/lsi-100t/]<br />
<br />
- smartphone (with phyphox-app and magnetic sensors) <br />
<br />
- a coil with low resistance and high inductance (for more information see paper)<br />
<br />
- some capacitors between 470uF and 22.000uF<br />
<br />
- a battery (9V) or power supply<br />
<br />
==Setup==<br />
<br />
The capacitor is charged with a battery or power supply and then shortened with the coil (directly connected to the coil). The phone is placed on the coil (the z-axis of the magnetometer points "into" the core of the coil). Due to the high sensitivity of the magnetic sensor, low magnetic fields can be measured easily. Because of the high sensitivity, the sensor saturates quite fast. The saturation can be prevented simply by adding some pieces of cardboard between the coil and the smartphone.<br />
<br />
[[File:Lccircuit.png|100px|thumb|right|Example of an oscillation]]<br />
<br />
==Paper and work sheets==<br />
The experiment was developed in a thesis for education students (Staatsexamensarbeit, [[File:Wiss-arbeit-westermann.pdf]]) at the University of Konstanz. The results where published in an open access paper [https://iopscience.iop.org/article/10.1088/1361-6552/ac920e], where a lot of additional information can be found.<br />
<br />
Work sheets in German where developed and can be found here: [[File:Abs-westermann.pdf]] (free to use, the sources are available on request).<br />
<br />
[[Category:User_experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=LC_circuit&diff=21155LC circuit2022-12-15T09:23:20Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = RC circuit<br />
| Category = Magnetism<br />
| Sensors = magnetometer<br />
}}<br />
<br />
The magnetic sensor is used to display the magnetic field of a coil in a RC circuit.<br />
<br />
<br />
==Requirements and experimental material==<br />
<br />
In this experiment a very simple LC circuit is created with a coil and a capacitor. To measure the magnetic field the coil has to have a low resistance and a high inductance. Such coils can be bought in audio supply and can be a bit expensive. The used coils for this experiment can be found at [https://www.hammfg.com/electronics/transformers/choke/195-196] and [https://www.monacor.de/produkte/components/lautsprechertechnik/frequenzweichen-und-bauteile-/lsi-100t/]<br />
<br />
- smartphone (with phyphox-app and magnetic sensors) <br />
<br />
- a coil with low resistance and high inductance (for more information see paper)<br />
<br />
- some capacitors between 470uF and 22.000uF<br />
<br />
- a battery (9V) or power supply<br />
<br />
==Setup==<br />
<br />
The capacitor is charged with a battery or power supply and then shortened with the coil (directly connected to the coil). The phone is placed on the coil (the z-axis of the magnetometer points "into" the core of the coil). Due to the high sensitivity of the magnetic sensor, low magnetic fields can be measured easily. Because of the high sensitivity, the sensor saturates quite fast. The saturation can be prevented simply by adding some pieces of cardboard between the coil and the smartphone.<br />
<br />
[[File:Lccircuit.png|100px|thumb|right|Example of an oscillation]]<br />
<br />
==Paper and work sheets==<br />
The experiment was developed in a thesis for education students (Staatsexamensarbeit, [[File:Wiss-arbeit-westermann.pdf]]) at the University of Konstanz. The results where published in an open access paper [https://iopscience.iop.org/article/10.1088/1361-6552/ac920e], where a lot of additional information can be found.<br />
<br />
Work sheets in German where developed and can be found here: [[File:Abs-westermann.pdf]].<br />
<br />
[[Category:User_experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=LC_circuit&diff=21154LC circuit2022-12-15T08:46:06Z<p>Nefft0n: </p>
<hr />
<div>{{Infobox Experiment<br />
| Name = RC circuit<br />
| Category = Magnetism<br />
| Sensors = magnetometer<br />
}}<br />
<br />
The magnetic sensor is used to display the magnetic field of a coil in a RC circuit.<br />
<br />
<br />
==Requirements and experimental material==<br />
<br />
In this experiment a very simple LC circuit is created with a coil and a capacitor. To measure the magnetic field the coil has to have a low resistance and a high inductance. Such coils can be bought in audio supply and can be a bit expensive. The used coils for this experiment can be found at [https://www.hammfg.com/electronics/transformers/choke/195-196] and [https://www.monacor.de/produkte/components/lautsprechertechnik/frequenzweichen-und-bauteile-/lsi-100t/]<br />
<br />
- smartphone (with phyphox-app and magnetic sensors) <br />
<br />
- a coil with low resistance and high inductance (for more information see paper)<br />
<br />
- some capacitors between 470uF and 22.000uF<br />
<br />
- a battery (9V) or power supply<br />
<br />
==Setup==<br />
<br />
The capacitor is charged with a battery or power supply and then shortened with the coil (directly connected to the coil). The phone is placed on the coil (the z-axis of the magnetometer points "into" the core of the coil). Due to the high sensitivity <br />
<br />
<br />
==Examples==<br />
[[File:Lccircuit.png|100px|thumb|right|Example of an oscillation]]<br />
TODO<br />
<br />
==Paper, and work sheets==<br />
The experiment was developed in a thesis for education students (Staatsexamensarbeit) at the University of Konstanz. The results where published in an open access paper [https://iopscience.iop.org/article/10.1088/1361-6552/ac920e], where a lot of additional information can be found.<br />
<br />
Work sheets in German where developed and can be found here. TODO<br />
<br />
[[Category:User_experiments]]</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Abs-westermann.pdf&diff=21153File:Abs-westermann.pdf2022-12-15T08:32:21Z<p>Nefft0n: Arbeitsblätter aus der wissenschaftlichen Arbeit Westermann</p>
<hr />
<div>== Summary ==<br />
Arbeitsblätter aus der wissenschaftlichen Arbeit Westermann</div>Nefft0nhttp://phyphox.org/wiki/index.php?title=File:Wiss-arbeit-westermann.pdf&diff=21152File:Wiss-arbeit-westermann.pdf2022-12-15T08:31:46Z<p>Nefft0n: Staatsexamensarbeit Westermann</p>
<hr />
<div>== Summary ==<br />
Staatsexamensarbeit Westermann</div>Nefft0n