Skip to content

Commit d03a967

Browse files
authored
Add files via upload
1 parent 61b38a0 commit d03a967

File tree

1 file changed

+287
-0
lines changed

1 file changed

+287
-0
lines changed

docs/Readme.md

Lines changed: 287 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,287 @@
1+
# **MKR IoT Carrier Reference**
2+
3+
This is a basic documentation about the library used in the *MKR IoT Carrier* made for internal purposes to make the Kit’s content.
4+
5+
For any question/suggestion please message @marqdevx
6+
7+
The library can be downloaded from the Arduino IDE’s library manager or by going to the [github repository](https://github.com/arduino-libraries/Arduino_MKRIoTCarrier)
8+
9+
This library has been made to use it with the IoT Starter Kit Carrier
10+
11+
12+
13+
## Examples Included
14+
* Actuators
15+
* Buzzer_Melody
16+
* Relays_blink
17+
* All Features
18+
* Display
19+
* LEDs
20+
* SD_card
21+
* Sensors
22+
* Environment
23+
* IMU
24+
* Light
25+
* Pressure
26+
* TouchPads
27+
* getTouch
28+
* Relays_control_Qtouch
29+
* Touch_and_LEDs
30+
* TouchTypes
31+
* Interruptions (TODO)
32+
* Arduino Cloud (TODO)
33+
34+
## Classes
35+
36+
### MKRIoTCarrier
37+
38+
Constructor of the object
39+
```cpp
40+
MKRIoTCarrier yourName; //In the examples we name it as *carrier*
41+
```
42+
43+
Intialization example sketch
44+
```cpp
45+
#include <Arduino_MKRIoTCarrier.h>
46+
MKRIoTCarrier carrier;
47+
48+
//Needs to be declared in order to setup correctly the touch pads
49+
bool CARRIER_CASE = false;
50+
51+
setup(){
52+
if(!carrier.begin(){ //It will see any sensor failure
53+
Serial.println("Failure on init");
54+
while(1);
55+
}
56+
}
57+
```
58+
59+
### SD CARD
60+
This can be accessed using the SD library commands that is already #included inside the library
61+
62+
The SD class initialized in the main `begin()`
63+
64+
The chip select (CS) pin can be known with SD_CS
65+
66+
67+
**Syntax Example**
68+
```cpp
69+
#include <Arduino_MKRIoTCarrier.h>
70+
MKRIoTCarrier carrier;
71+
bool CARRIER_CASE = false;
72+
73+
File myFile;
74+
75+
setup(){
76+
carrier.begin(); //SD card initialized here
77+
78+
myFile = SD.open("test.txt", FILE_WRITE);
79+
80+
}
81+
```
82+
83+
### Buttons class
84+
85+
Mandatory to create the bool `bool CARRIER_CASE = true/false`
86+
87+
Init the calaibration and the set up for the touchable pads (Already done in the MKRIoTCarrier class' begin())
88+
```cpp
89+
Buttons.begin()
90+
```
91+
Read the state of the pads and save them to be analize in the diferent type of touch events
92+
```cpp
93+
Buttons.update()
94+
```
95+
96+
### ButtonX class
97+
98+
Get if the pad is getting touched, true until it gets released
99+
```cpp
100+
ButtonX.getTouch()
101+
```
102+
103+
Get when have been a touch down
104+
```cpp
105+
ButtonX.onTouchDown()
106+
```
107+
108+
Get when the button has been released
109+
```cpp
110+
ButtonX.onTouchUp()
111+
```
112+
113+
Get both, touched and released
114+
```cpp
115+
ButtonX.onTouchChange()
116+
```
117+
118+
In case you have another enclosure you can change the sensivity of the pads, 3-100
119+
Automatically configured in the main class begin() when you declare the `CARRIER_CASE` boolean
120+
```cpp
121+
ButtonX.updateConfig(int newSens)
122+
```
123+
124+
#### Syntax example
125+
```cpp
126+
#include <Arduino_MKRIoTCarrier.h>
127+
MKRIoTCarrier carrier;
128+
bool CARRIER_CASE = true/false;
129+
130+
void setup(){
131+
Serial.begin(9600);
132+
carrier.begin();
133+
}
134+
135+
void loop(){
136+
carrier.Buttons.update(); // Read the buttons state
137+
138+
//Check if the Button 1 is being touched
139+
if (carrier.Button1.getTouch()){
140+
Serial.println("Touching Button 1");
141+
}
142+
143+
//You can replace getTouch(), with the other types of touch events
144+
//If you use more than one type of events in the same Button its not going to be stable, watch out
145+
//In case you need it, after each touch event make a Buttons.update() to read it correctly
146+
}
147+
148+
```
149+
150+
### Buzzer class
151+
152+
Equivalent to tone(), it will make the tone with the selected frequency
153+
```cpp
154+
Buzzer.sound(freq)
155+
```
156+
Equivalent to noTone(), it will stop the tone signal
157+
```cpp
158+
Buzzer.noSound()
159+
```
160+
161+
### Relay class
162+
163+
Control both relays and get the status of them
164+
165+
You can control them by using `Relay1 `and `Relay2`
166+
167+
Swap to the NormallyOpen (NO) circuit from the relay
168+
```cpp
169+
RelayX.open()
170+
```
171+
Swap to the NormallyClosed (NC) circuit from the relay, default mode on power off
172+
```cpp
173+
RelayX.close()
174+
```
175+
176+
Bool, returns the status LOW means NC and HIGH means NO
177+
```cpp
178+
RelayX.getStatus()
179+
```
180+
181+
### DotStar LEDs
182+
183+
It is controlled with the Adafruit’s DotStar library
184+
185+
The documentation form Adafruit [here](https://learn.adafruit.com/adafruit-dotstar-leds/arduino-library-use)
186+
187+
**Syntax Example**
188+
```cpp
189+
#include <Arduino_MKRIoTCarrier.h>
190+
MKRIoTCarrier carrier;
191+
bool CARRIER_CASE = false;
192+
193+
uint32_t myCustomColor = carrier.leds.Color(255,100,50);
194+
195+
void setup(){
196+
carrier.begin();
197+
carrier.leds.fill(myCustomColor, 0, 5);
198+
carrier.leds.show();
199+
}
200+
201+
void loop(){}
202+
```
203+
204+
Some examples
205+
Init the LEDs strip, done by default using the main begin()
206+
```cpp
207+
leds.begin()
208+
```
209+
210+
Sets the color of the index’s LED
211+
```cpp
212+
leds.setPixelColor(index, green, red, blue)
213+
```
214+
215+
In case you have custom colors you can use this method too
216+
```cpp
217+
leds.setPixelColor(index, color)
218+
```
219+
220+
Set the overall brightness
221+
```cpp
222+
leds.setBrightness(0-255)
223+
```
224+
225+
Update the LEDs with the new values
226+
```cpp
227+
leds.show()
228+
```
229+
230+
Clear the buffer of the LEDs
231+
```cpp
232+
leds.clear()
233+
```
234+
235+
Fill X amount of the LEDs with the same color
236+
```cpp
237+
leds.fill(color, firstLedToCount, count)
238+
```
239+
240+
Save your custom color:
241+
```cpp
242+
uint32_t myColor = carrier.leds.Color(green, red, blue)
243+
```
244+
245+
### Pressure sensor - LPS22HB (Barometric)
246+
Visit our reference about [LPS22HB](https://www.arduino.cc/en/Reference/ArduinoLPS22HB)
247+
**Syntax Example**
248+
```cpp
249+
float pressure;
250+
pressure = carrier.Light.readPressure()
251+
```
252+
253+
### IMU - LSM6DS3
254+
Visit our reference about [LSM6DS3](https://www.arduino.cc/en/Reference/Arduino_LSM6DS3)
255+
**Syntax Example**
256+
```cpp
257+
float aX,aY,aZ;
258+
carrier.IMUmodule.getAcceleration(aX, aY, aZ);
259+
```
260+
261+
### Humidity and Temperature - HTS221
262+
Visit our reference about [HTS221](https://www.arduino.cc/en/Reference/ArduinoHTS221)
263+
**Syntax Example**
264+
```cpp
265+
float humidity;
266+
humidity = carrier.Env.readHumidity();
267+
```
268+
269+
### Ambient light, Gesture and Proximity - APDS9960
270+
Visit our reference about [APDS9960](https://www.arduino.cc/en/Reference/ArduinoAPDS9960)
271+
**Syntax Example**
272+
```cpp
273+
int proximity;
274+
proximity = carrier.Light.readProximity();
275+
```
276+
277+
## Display
278+
279+
It is controlled through the Adafruit-ST7735-Library
280+
281+
The resolution is 240 x 240.
282+
283+
Initialized inside the main `begin()`
284+
285+
You can find the library documentation from Adafruit to draw [here](https://learn.adafruit.com/adafruit-gfx-graphics-library/graphics-primitives)
286+
287+
Colors : every color with the prefix ‘ST77XX_’ i.e. ST77XX_BLACK. Colors available from the library are BLACK, WHITE, RED, GREEN, BLUE, CYAN, MAGENTA, YELLOW, ORANGE

0 commit comments

Comments
 (0)