@@ -10,28 +10,28 @@ The library it's a wrapper of some libraries to use with the ![Arduino Sensor Ki
10
10
#### Constructor of the object
11
11
12
12
``` cpp
13
- #include " Arduino_SensorKit.h"
13
+ #include " Arduino_SensorKit.h"
14
14
15
- SensorKit kit; // Declare the object to use it later
15
+ SensorKit kit; // Declare the object to use it later
16
16
17
- void setup (){}
18
- void loop (){}
17
+ void setup (){}
18
+ void loop (){}
19
19
```
20
20
21
21
#### Initialization
22
22
23
23
Using the function ` begin() ` at the beginning of the ` setup() `
24
24
25
25
``` cpp
26
- #include " Arduino_SensorKit.h"
26
+ #include " Arduino_SensorKit.h"
27
27
28
- SensorKit kit; // Declare the object to use it later
28
+ SensorKit kit; // Declare the object to use it later
29
29
30
- void setup (){
31
- kit.begin();
32
- }
30
+ void setup (){
31
+ kit.begin();
32
+ }
33
33
34
- void loop (){}
34
+ void loop(){}
35
35
```
36
36
37
37
### Oled
@@ -46,57 +46,203 @@ github.com/Seeed-Studio/Seeed_Arduino_LIS3DHTR
46
46
#### Using the Accelerometer
47
47
48
48
```cpp
49
- #include " Arduino_SensorKit.h"
49
+ #include "Arduino_SensorKit.h"
50
50
51
- SensorKit kit; // Declare the object to use it later
51
+ SensorKit kit; //Declare the object to use it later
52
52
53
- float acceleration;
53
+ float acceleration;
54
54
55
- void setup (){
56
- kit.begin();
57
- }
55
+ void setup(){
56
+ kit.begin();
57
+ }
58
58
59
- void loop (){
60
- Serial.begin(9600);
61
- acceleration = Accelerometer.readX();
62
- Serial.println(acceleration);
59
+ void loop(){
60
+ Serial.begin(9600);
61
+ acceleration = Accelerometer.readX();
62
+ Serial.println(acceleration);
63
63
}
64
64
```
65
65
66
- #### bool begin()
66
+ #### Init the sensor
67
67
68
68
Init and returns true if success, already done in the ` SensorKit ` 's object ` begin() `
69
+ ``` cpp
70
+ if (!Accelerometer.begin()){
71
+ Serial.println("Error"); // Accelerometer didnt initialized
72
+ while(1); // Stop the program
73
+ }
74
+ Serial.println("Init complete");
75
+ ```
76
+
77
+ #### Read values
78
+ ```cpp
79
+ #include "Arduino_SensorKit.h"
80
+ SensorKit kit;
69
81
70
- #### bool available()
82
+ float x,y,z; // Values for the readings
71
83
84
+ setup(){
85
+ Serial.begin(9600);
86
+ kit.begin();
87
+ }
88
+
89
+ loop{
90
+ x = Accelerometer.readX();
91
+ y = Accelerometer.readY();
92
+ z = Accelerometer.readZ();
93
+
94
+ Serial.print("X axis: "); Serial.println(x);
95
+ Serial.print("Y axis: "); Serial.println(y);
96
+ Serial.print("Z axis: "); Serial.println(z);
97
+ }
98
+ ```
99
+
100
+ #### Check if the sensor has reads available
101
+
72
102
Return if the sensor its good to give the data
73
103
74
- #### float readX()
104
+ ``` cpp
105
+ #include " Arduino_SensorKit.h"
106
+ SensorKit kit;
107
+
108
+ float x,y,z; // Values for the readings
109
+
110
+ setup (){
111
+ Serial.begin(9600);
112
+ kit.begin();
113
+ }
114
+
115
+ loop{
116
+ if(Accelerometer.available()){
117
+ x = Accelerometer.readX();
118
+ Serial.print("X axis: "); Serial.println(x);
119
+ }
120
+ }
121
+ ```
122
+
123
+ ### Pressure
124
+
125
+ #### Init the sensor
126
+ Init and returns true if success, already done in the `SensorKit`'s object `begin()`
127
+ ```cpp
128
+ if (!Pressure.begin()){
129
+ Serial.println("Error"); // Accelerometer didnt initialized
130
+ while(1); // Stop the program
131
+ }
132
+ Serial.println("Init complete");
133
+ ```
134
+
135
+ #### Get values
136
+ The Pressure sensor can get temperature, pressure and altitude
137
+
138
+ ##### Temperature
139
+ ``` cpp
140
+ #include " Arduino_SensorKit.h"
141
+ SensorKit kit;
142
+
143
+ float temperature; // Value for the reading
75
144
76
- Return X axis acceleration
145
+ setup (){
146
+ Serial.begin(9600);
147
+ kit.begin();
148
+ }
77
149
78
- #### float readY()
150
+ loop{
151
+ temperature = Pressure.readTemperature();
152
+ Serial.print("temperature :"); Serial.println(temperature);
153
+ }
154
+ }
155
+ ```
79
156
80
- Return Y axis acceleration
157
+ ##### Pressure
158
+ ```cpp
159
+ #include "Arduino_SensorKit.h"
160
+ SensorKit kit;
81
161
82
- #### float readZ()
162
+ uint32_t pressure; // Value for the reading
83
163
84
- Return Z axis acceleration
164
+ setup(){
165
+ Serial.begin(9600);
166
+ kit.begin();
167
+ }
85
168
86
- #### void setOutputDataRate(odr_type_t odr);
169
+ loop{
170
+ pressure = Pressure.readPressure();
171
+ Serial.print("pressure :"); Serial.println(pressure);
172
+ }
173
+ }
174
+ ```
175
+
176
+
177
+ ##### Altitude
178
+ ``` cpp
179
+ #include " Arduino_SensorKit.h"
180
+ SensorKit kit;
181
+
182
+ float altitude; // Value for the reading
183
+
184
+ setup (){
185
+ Serial.begin(9600);
186
+ kit.begin();
187
+ }
188
+
189
+ loop{
190
+ altitude = Pressure.readAltitude();
191
+ Serial.print("altitude :"); Serial.println(altitude);
192
+ }
193
+ }
194
+ ```
87
195
88
- ### Pressure
196
+ ### Environment
197
+ DHT sensor can read Temperature and Humidity
89
198
#### DHTPIN
90
- By default, once you include the library it has been set to digital pin 3 , it can be changed by adding
199
+ By default, once you include the library it has been set to digital pin `3` , it can be changed by adding
91
200
`#define DHTPIN yourPin`
92
- #### bool begin();
93
- Init and returns true if success, already done in the ` SensorKit ` 's object ` begin() `
94
- #### void end();
201
+
202
+ #### Init the sensor
203
+ ```cpp
204
+ if (!Environment.begin()){
205
+ Serial.println("Error"); // Accelerometer didnt initialized
206
+ while(1); // Stop the program
207
+ }
208
+ Serial.println("Init complete");
209
+ ```
95
210
96
- #### float readTemperature();
97
- #### uint32_t readPressure();
98
- #### float readAltitude();
99
-
100
- ### Environment
101
- It has DHTPIN defined by default to digital pin 3, you can redefine it by adding
102
- `#define DHTPIN yourPin`
211
+ #### Temperature
212
+ ``` cpp
213
+ #include " Arduino_SensorKit.h"
214
+ SensorKit kit;
215
+
216
+ float temperature;
217
+
218
+ void setup () {
219
+ Serial.begin(9600);
220
+ kit.begin();
221
+ }
222
+
223
+ void loop() {
224
+ temperature = Environment.readTemperature();
225
+
226
+ Serial.print("Temperature: ");
227
+ Serial.print(temperature); //print temperature
228
+ }
229
+ ```
230
+
231
+ #### Humidity
232
+ ```cpp
233
+ #include "Arduino_SensorKit.h"
234
+ SensorKit kit;
235
+
236
+ float humidity;
237
+
238
+ void setup() {
239
+ Serial.begin(9600);
240
+ kit.begin();
241
+ }
242
+
243
+ void loop() {
244
+ humidity = Environment.readHumidity();
245
+ Serial.print("Temperature: ");
246
+ Serial.print(temperature); //print temperature
247
+ }
248
+ ```
0 commit comments