von
sef (Gast)
15.03.2014 09:14
Hallo,
ich möchte mit einem Arduino Mini Luftfeuchtigkeit, Druck und Temeratur
mittels der Module HH10D und HP03S messen. Der HH10D funktionierte auf
Anhieb. nit dem HP03S habe ich so meine Probleme. Die Werte aus dem
EEProm auszulesen funktioniert ganz gut. Aber bei D1 und D2 kommen ganz
falsche Werte. So sollte D2 bei c.a. 33000 liegen um plausibel zi sein.
Statt dessen bekomme ich einen Wert zwischen 5 und 200 geliefert. 1 HH10D memory:
2 HP03S memory:
3 127; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; ::
4 68; 239; 12; 137; 1; 14; 2; 96; 130; 109; 23; 36; 9; 196; 7; 30; ::
5 6; 9; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; ::
6 127; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; ::
7 114; 130; 18; 139; 16; 163; 243; 157; 80; 6; 67; 8; 134; 182; 136; 182; ::
8 126; 130; 32; 139; 24; 141; 204; 135; 80; 6; 67; 8; 170; 144; 23; 143; ::
9 127; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; ::
10 127; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 255; 232; ::
11
12 HH10D init: 453, 7423
13 HP03S init: 17647, 3209, 270, 608, 33389, 5924, 2500, 7, 30, 6, 9
14 7084, 125, 75, 37.49%, 248.67 °C, 10780.33
15 7083, 125, 76, 37.60%, 248.68 °C, 10780.40
16 7083, 123, 76, 37.60%, 248.68 °C, 10780.02
hier der dazugehörige Code; die HH10D teile habe ich eingekürzt ;-) 1 #include <Wire.h>
2 #include <LiquidCrystal.h>
3 #include <EEPROM.h>
4
5 word Zaehler1 , HH10D_Frequenz , HH10D_Offs , HH10D_Sens ;
6 float HH10D_Hum ;
7 word HP03S_C1 , HP03S_C2 , HP03S_C3 , HP03S_C4 , HP03S_C5 , HP03S_C6 , HP03S_C7 ;
8 byte HP03S_A , HP03S_B , HP03S_C , HP03S_D ;
9 word HP03S_D1 , HP03S_D2 ;
10 float HP03S_dUT , HP03S_Off , HP03S_Sens , HP03S_X , HP03S_P , HP03S_T ;
11 int x1 , x2 ;
12
13
14 void setup () {
15 Wire . begin ();
16 Serial . begin ( 9600 );
17
18 // funktioniert HH10D
19
20 Serial . print ( "HP03S memory: " );
21 Serial . print ( " \n\r " );
22 GET_Memo ( 0x50 , 0x08 );
23 Serial . print ( " \n\r " );
24 delay ( 500 );
25
26 // funktioniert HH10D
27
28 pinMode ( 10 , OUTPUT );
29 digitalWrite ( 10 , LOW );
30 Serial . print ( "HP03S init: " );
31 HP03S_C1 = GET_Word ( 0x50 , 0x10 );
32 Serial . print ( HP03S_C1 );
33 Serial . print ( ", " );
34 delay ( 100 );
35 HP03S_C2 = GET_Word ( 0x50 , 0x12 );
36 Serial . print ( HP03S_C2 );
37 Serial . print ( ", " );
38 delay ( 100 );
39 HP03S_C3 = GET_Word ( 0x50 , 0x14 );
40 Serial . print ( HP03S_C3 );
41 Serial . print ( ", " );
42 delay ( 100 );
43 HP03S_C4 = GET_Word ( 0x50 , 0x16 );
44 Serial . print ( HP03S_C4 );
45 Serial . print ( ", " );
46 delay ( 100 );
47 HP03S_C5 = GET_Word ( 0x50 , 0x18 );
48 Serial . print ( HP03S_C5 );
49 Serial . print ( ", " );
50 delay ( 100 );
51 HP03S_C6 = GET_Word ( 0x50 , 0x1A );
52 Serial . print ( HP03S_C6 );
53 Serial . print ( ", " );
54 delay ( 100 );
55 HP03S_C7 = GET_Word ( 0x50 , 0x1C );
56 Serial . print ( HP03S_C7 );
57 Serial . print ( ", " );
58 delay ( 100 );
59 HP03S_A = GET_Byte ( 0x50 , 0x1E );
60 Serial . print ( HP03S_A );
61 Serial . print ( ", " );
62 delay ( 100 );
63 HP03S_B = GET_Byte ( 0x50 , 0x1F );
64 Serial . print ( HP03S_B );
65 Serial . print ( ", " );
66 delay ( 100 );
67 HP03S_C = GET_Byte ( 0x50 , 0x20 );
68 Serial . print ( HP03S_C );
69 Serial . print ( ", " );
70 delay ( 100 );
71 HP03S_D = GET_Byte ( 0x50 , 0x21 );
72 Serial . print ( HP03S_D );
73 Serial . print ( " \n\r " );
74 // delay(500);
75
76 pinMode ( 2 , INPUT_PULLUP );
77 delay ( 500 );
78 }
79
80 void loop () {
81
82 // funktioniert HH10D
83
84 tone ( 11 , 32768 );
85 digitalWrite ( 10 , HIGH );
86 delay ( 1000 );
87 HP03S_D1 = GET_Data ( 0x77 , 0xF0 );
88 delay ( 250 );
89 HP03S_D2 = GET_Data ( 0x77 , 0xE8 );
90 noTone ( 11 );
91 digitalWrite ( 10 , LOW );
92
93 Serial . print ( HH10D_Frequenz ); // print Frquenz roh
94 Serial . print ( ", " );
95 Serial . print ( HP03S_D1 ); // print D1, sollte etwa bei 16000 liegen
96 Serial . print ( ", " );
97 Serial . print ( HP03S_D2 ); // print D2, sollte bei etwa 33000 liegen
98 Serial . print ( ", " );
99 HH10D_Hum = float ( long (( HH10D_Offs - HH10D_Frequenz )) * HH10D_Sens ) / 4096 ;
100 Serial . print ( HH10D_Hum ); // print humuidy
101 Serial . print ( "%, " );
102 x1 = HP03S_D2 - HP03S_C5 ;
103 if ( HP03S_D2 > HP03S_C5 ) {
104 x2 = HP03S_B ;
105 } else {
106 x2 = HP03S_A ;
107 }
108 HP03S_dUT = x1 - ( float ( x1 ) / 128 ) * ( float ( x1 ) / 128 ) * x2 / ( 2 << ( HP03S_C - 1 )); // pow(2, HP03S_C)
109
110 HP03S_T = 250 + HP03S_dUT * float ( HP03S_C6 ) / 65536 - float ( HP03S_dUT ) / ( 2 << ( HP03S_D - 1 )); // pow(2, HP03S_D)
111 HP03S_T = HP03S_T / 10 ;
112 Serial . print ( HP03S_T ); // print temperature
113 Serial . print ( " °C, " );
114
115 HP03S_Off = ( HP03S_C2 + ( int ( HP03S_C4 ) - 1024 ) * HP03S_dUT / 16384 ) * 4 ;
116 HP03S_Sens = ( HP03S_C1 + HP03S_C3 * HP03S_dUT / 1024 ) * 4 ;
117 HP03S_X = HP03S_Sens * ( HP03S_D1 - 7168 ) / 16384 - HP03S_Off ;
118 HP03S_P = ( HP03S_X * 10 / 32 + HP03S_C7 ) / 10 ;
119 Serial . print ( HP03S_P ); // print pressure
120 Serial . print ( " \n\r " );
121 delay ( 1000 );
122
123 }
124
125 void HH10D_Zaehlen () {
126 // funktioniert HH10D
127 }
128
129 word GET_Word ( char IC , char Addr ) {
130 // funktioniert
131 }
132
133 byte GET_Byte ( char IC , char Addr ) {
134 // funktioniert
135 }
136
137 word GET_Data ( char IC , char Addr ) {
138 byte a , b ;
139 word c ;
140 Wire . beginTransmission ( IC );
141 Wire . write ( 0xFF );
142 Wire . write ( Addr );
143 Wire . endTransmission ();
144 delay ( 41 );
145 Wire . beginTransmission ( IC );
146 Wire . write ( 0xFD );
147 // delay(5);
148 Wire . requestFrom ( IC , 2 );
149 while ( Wire . available ()) {
150 a = b ;
151 b = Wire . read ();
152 }
153 c = word ( a , b );
154 return ( c );
155 }
156
157 void GET_Memo ( char IC , char Anz ) {
158 // funktioniert EEPROM auslesen in 16er Blöcken
159 }
Da ein 2.er HP03S ähnliche Werte liefert, gehe ichvon einem Prblem mit
Ausleseroutine aus.
von
sef (Gast)
19.03.2014 09:56
Hallo,
eine Änderung habe ich schon vorgenommen 1 word GET_Data ( char IC , char Addr ) {
2 byte a , b ;
3 word c ;
4 Wire . beginTransmission ( IC );
5 Wire . write ( 0xFF );
6 Wire . write ( Addr );
7 Wire . endTransmission ();
8 delay ( 41 );
9 Wire . beginTransmission ( IC );
10 Wire . write ( 0xFD );
11 Wire . endTransmission (); // Notwendig, obwohl im Datenblatt nicht vorhanden
12 // delay(5);
13 Wire . requestFrom ( IC , 2 );
14 while ( Wire . available ()) {
15 a = b ;
16 b = Wire . read ();
17 }
18 c = word ( a , b );
19 return ( c );
20 }
Damit stimmt die Teperatur schon mal.
Dar Druck wird aber immen noch zu hoch angezeigt.
Viele Grüße
sef
von
sef (Gast)
20.03.2014 16:30
Hallo,
den Fehler in der Berechnung des Luftdrucks habe ich gefunden.
In der Doku wird Sens folgendermaßen berechnet: C1 + C3 * dUT / 1024) *
4.
In der Beispielimplementierung: C1 + C3 * dUT / 1024.
Damit stimmt der Luftdruck bis auf einige Stellen hinter dem Komma.
:-)
Bitte melde dich an um einen Beitrag zu schreiben. Anmeldung ist kostenlos und dauert nur eine Minute.