Forum: Mikrocontroller und Digitale Elektronik HP203B Druck Sensor I2C


von Stefan A. (ripper121)


Lesenswert?

Ich habe einen HP203B Druck Sensor und möchte ihn über I2C auslesen.
Leider habe ich keine Lib für Arduino gefunden.

Die Adresse vom Sensor ist 0x76

Hier sind die Datenblätter: 
http://www.hoperf.com/upload/sensor/HP203B_ProductDevelopmentGuid_EN_V2.0.pdf
http://www.hoperf.com/upload/sensor/HP203B_DataSheet_EN_V2.0.pdf


Könnte mir bitte jemand helfen den Sensor auszulesen?

von Oliver R. (orb)


Lesenswert?

Wo hapert es denn bzw was fehlt?

von Stefan A. (ripper121)


Lesenswert?

1
#include <Wire.h>
2
byte val0 = 0;
3
byte val1 = 0;
4
byte val2 = 0;
5
byte address = 76;
6
7
void setup() {
8
  Serial.begin(9600);
9
  delay(100);
10
  Wire.begin();
11
  //Do some setup for the sensor
12
  // Set the resolution of the measurement
13
  Wire.beginTransmission(address);
14
  // point to Configuration Register
15
  Wire.write(0x06);
16
  // ends the command
17
  Wire.endTransmission();
18
19
  delay(100);
20
21
}
22
23
void loop() {
24
  // points to the Temperature Register
25
  Wire.beginTransmission(address);
26
  Wire.write(0x32);
27
28
  // Receives data from the Temperature Register
29
  Wire.requestFrom(address, byte(3));
30
  val0 = Wire.read();
31
  val1 = Wire.read();
32
  val2 = Wire.read();
33
34
  Wire.endTransmission();
35
  Serial.println(val0);
36
  Serial.println(val1);
37
  Serial.println(val2);
38
  Serial.println("");
39
  delay(500);
40
}
41
///////////////////////////////////////////////////

Naja ich kann die Adresse des Sensors lesen.
Nur bekomm ich ihn nicht initialsiert und auch keine Werte raus.

von Narfie (Gast)


Lesenswert?

Hast du denn den abgedruckten Flow-Chart mal implementiert? Wenn ja, wo 
ist der Code und welchen Fehler beobachtest du?

von Stefan A. (ripper121)


Lesenswert?

Meine Implementierung:
1
#include <Wire.h>
2
byte val0 = 0;
3
byte val1 = 0;
4
byte val2 = 0;
5
byte val3 = 0;
6
byte val4 = 0;
7
byte val5 = 0;
8
byte address = 0x76;
9
10
void setup() {
11
  Serial.begin(9600);
12
  Serial.println("START");
13
  delay(100);
14
  Wire.begin();
15
16
  Wire.beginTransmission(address);
17
  Wire.write(0x48);
18
  Wire.endTransmission();
19
20
  delay(40);
21
22
  Wire.beginTransmission(address);
23
  Wire.write(0x10);
24
  Wire.endTransmission();
25
26
}
27
28
void loop() {
29
30
31
32
  Wire.requestFrom(address, 6);    // request 6 bytes from slave device #2
33
34
  while (Wire.available())   // slave may send less than requested
35
  {
36
    byte c = Wire.read();    // receive a byte as character
37
    Serial.print(c);         // print the character
38
    Serial.print(",");         // print the character
39
  }
40
  Serial.println("");
41
  delay(500);
42
}

Ist ja soweit richtig oder?

von Narfie (Gast)


Lesenswert?

Was ist mit dem beschriebenen Ablauf auf Seite 1? Und was ist das 
Problem, bekommst du Sensorwerte die falsch sind oder antwortet der 
Sensor nicht?

Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.
Bestehender Account
Schon ein Account bei Google/GoogleMail? Keine Anmeldung erforderlich!
Mit Google-Account einloggen
Noch kein Account? Hier anmelden.