Skip to content

Commit e3b1c37

Browse files
authored
Update readme.md
1 parent 4eb09f3 commit e3b1c37

File tree

1 file changed

+187
-41
lines changed

1 file changed

+187
-41
lines changed

docs/readme.md

Lines changed: 187 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,28 @@ The library it's a wrapper of some libraries to use with the ![Arduino Sensor Ki
1010
#### Constructor of the object
1111

1212
```cpp
13-
#include "Arduino_SensorKit.h"
13+
#include "Arduino_SensorKit.h"
1414

15-
SensorKit kit; //Declare the object to use it later
15+
SensorKit kit; //Declare the object to use it later
1616

17-
void setup(){}
18-
void loop(){}
17+
void setup(){}
18+
void loop(){}
1919
```
2020

2121
#### Initialization
2222

2323
Using the function `begin()` at the beginning of the `setup()`
2424

2525
```cpp
26-
#include "Arduino_SensorKit.h"
26+
#include "Arduino_SensorKit.h"
2727

28-
SensorKit kit; //Declare the object to use it later
28+
SensorKit kit; //Declare the object to use it later
2929

30-
void setup(){
31-
kit.begin();
32-
}
30+
void setup(){
31+
kit.begin();
32+
}
3333

34-
void loop(){}
34+
void loop(){}
3535
```
3636
3737
### Oled
@@ -46,57 +46,203 @@ github.com/Seeed-Studio/Seeed_Arduino_LIS3DHTR
4646
#### Using the Accelerometer
4747
4848
```cpp
49-
#include "Arduino_SensorKit.h"
49+
#include "Arduino_SensorKit.h"
5050
51-
SensorKit kit; //Declare the object to use it later
51+
SensorKit kit; //Declare the object to use it later
5252
53-
float acceleration;
53+
float acceleration;
5454
55-
void setup(){
56-
kit.begin();
57-
}
55+
void setup(){
56+
kit.begin();
57+
}
5858
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);
6363
}
6464
```
6565

66-
#### bool begin()
66+
#### Init the sensor
6767

6868
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;
6981
70-
#### bool available()
82+
float x,y,z; // Values for the readings
7183
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+
72102
Return if the sensor its good to give the data
73103

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
75144

76-
Return X axis acceleration
145+
setup(){
146+
Serial.begin(9600);
147+
kit.begin();
148+
}
77149

78-
#### float readY()
150+
loop{
151+
temperature = Pressure.readTemperature();
152+
Serial.print("temperature :"); Serial.println(temperature);
153+
}
154+
}
155+
```
79156
80-
Return Y axis acceleration
157+
##### Pressure
158+
```cpp
159+
#include "Arduino_SensorKit.h"
160+
SensorKit kit;
81161
82-
#### float readZ()
162+
uint32_t pressure; // Value for the reading
83163
84-
Return Z axis acceleration
164+
setup(){
165+
Serial.begin(9600);
166+
kit.begin();
167+
}
85168
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+
```
87195
88-
### Pressure
196+
### Environment
197+
DHT sensor can read Temperature and Humidity
89198
#### 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
91200
`#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+
```
95210

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

Comments
 (0)