Difference between revisions of "An external pressure sensor"

From phyphox
Jump to navigation Jump to search
Line 2: Line 2:
 
  | Name = An external pressure sensor
 
  | Name = An external pressure sensor
 
  | Category = Arduino library experiments
 
  | Category = Arduino library experiments
  | Sensors = Magentic Field
+
  | Sensors = MPRLS
 
}}
 
}}
  
Text
+
 
 +
 
 +
[[File:PressureSensor1.jpg]]
  
 
[[File:PressureSensor1.jpg]]
 
[[File:PressureSensor1.jpg]]
  
 +
The pressure sensor MPRLS enables absolute pressure measurements in the range 0 to 25 PSI (1.72 bar). The resolution is so good that a difference in altitude (in air) of 1 m can be resolved. The barometric height step at sea level is 1 hPa at 8 m.
  
  
 
==Setup==
 
==Setup==
==Programmierung==
+
As usual with I2C sensors, the wiring is simple: 3V3 - Vin, Gnd - Gnd, SCL - 22, SDA -21. So no picture was taken before the sensor was taped on with mirror tape and everything was packaged with transparent shrink tube.
 +
If you connect the sensor with a thin hose, you can also measure the gravitational pressure in liquids very well as shown in the picture above.
 +
==Programming==
 
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]].
 
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]].
  
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.
+
It must be ensured that each ESP32 has its own ID (this is defined in ''PhyphoxBLE::start("Barometer_01")''). A Bluetooth experiment can then be added via the plus symbol in phyphox, the experiment will then be loaded automatically.
  
 
<pre>
 
<pre>
Line 68: Line 73:
  
 
</pre>
 
</pre>
 
==Arbeitsmaterialien==
 
Ein mögliches Schülerarbeitsblatt (aktuelle Sicherheitsrichtlinien nach RISU beachten!): [[file:AB_Magnetfeldsensor_Spule.pdf]]
 
[[Category:Arduino library experiments]]
 

Revision as of 11:37, 25 August 2023

An external pressure sensor
Experiment An external pressure sensor
Category Arduino library experiments
Used sensors MPRLS



PressureSensor1.jpg

PressureSensor1.jpg

The pressure sensor MPRLS enables absolute pressure measurements in the range 0 to 25 PSI (1.72 bar). The resolution is so good that a difference in altitude (in air) of 1 m can be resolved. The barometric height step at sea level is 1 hPa at 8 m.


Setup

As usual with I2C sensors, the wiring is simple: 3V3 - Vin, Gnd - Gnd, SCL - 22, SDA -21. So no picture was taken before the sensor was taped on with mirror tape and everything was packaged with transparent shrink tube. If you connect the sensor with a thin hose, you can also measure the gravitational pressure in liquids very well as shown in the picture above.

Programming

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.

It must be ensured that each ESP32 has its own ID (this is defined in PhyphoxBLE::start("Barometer_01")). A Bluetooth experiment can then be added via the plus symbol in phyphox, the experiment will then be loaded automatically.


#include <Wire.h>
#include "Adafruit_MPRLS.h"
#include <phyphoxBle.h>
float Messwert;
#define RESET_PIN -1
#define EOC_PIN -1
Adafruit_MPRLS mpr = Adafruit_MPRLS(RESET_PIN, EOC_PIN);
void setup() {
PhyphoxBLE::start("Barometer_01");
//Experiment
PhyphoxBleExperiment experiment;
experiment.setTitle("Barometer_01");
experiment.setCategory("Arduino Experiments");
experiment.setDescription("Plot the pressure over time.");
//View
PhyphoxBleExperiment::View view;
//Value
PhyphoxBleExperiment::Value Value1;
Value1.setLabel("p = ");
Value1.setUnit("hPa");
Value1.setChannel(1);
//Graph
PhyphoxBleExperiment::Graph graph;
graph.setLabel("Druck");
graph.setUnitX("s");
graph.setUnitY("hPa");
graph.setLabelX("time");
graph.setLabelY("p");
view.addElement(graph);
view.addElement(Value1);
experiment.addView(view);
PhyphoxBLE::addExperiment(experiment);
Serial.begin(38400);
mpr.begin();
}
void loop() {
Messwert=0;
for(int i=0;i<37;i++){
Messwert+=mpr.readPressure();
delay(10);
}
Messwert=Messwert/37;
PhyphoxBLE::write(Messwert);
Serial.println(Messwert);
delay(10);
}