Skip to content

Commit 17a89a7

Browse files
committed
User's manual preparation
1 parent 7914fc4 commit 17a89a7

File tree

12 files changed

+148
-13
lines changed

12 files changed

+148
-13
lines changed

examples/7_distance_and_light_sensor/7_distance_and_light_sensor.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ void setup() {
2626
Serial.print("\n*** Live Objects for Arduino MKR boards, revision ");
2727
Serial.print(SW_REVISION);
2828
Serial.println(" ***");
29-
lo.setSecurity(TLS);
29+
lo.setSecurity(NONE);
3030
lo.begin(MQTT, BINARY, true);
3131
lo.connect(); // connects to the network + Live Objects
3232
}
Lines changed: 147 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,158 @@
1-
# Send data to Live Objects
1+
# Send data from VL6180 sensor to Live Objects
22

3-
This example shows how to send some sample data (device uptime) to Live Objects using Arduino MKR NB 1500.
4-
![diagram](img/send_data_diagram.png)
3+
This example shows how to send real data from sensor [VL6180X](https://www.st.com/resource/en/datasheet/vl6180x.pdf). Sensor delivers two useful values:
4+
- ambient light [[lx](https://en.wikipedia.org/wiki/Lux)],
5+
- distance from disturbance [mm].
6+
7+
In this use-case [an example of board using sensor](https://kamami.pl/en/kamod-kamami-peripheral-modules/559362-kamodvl6180x-a-module-with-distance-gesture-and-als-sensor.html) was being used.
8+
9+
![sensor](img/KAmodVL6180X_module.png)
10+
11+
## Our Setup view:
12+
13+
![setup_view](img/setup_view.jpg)
14+
15+
## Preparations
16+
### Installation VL6180X library
17+
Using **Library Manager** from Arduino IDE (*Tools -> Manage Libraries...*) you need to install library:
18+
19+
![library_installation](img/VL6180X_libr.png)
20+
21+
### Diagram of connection
22+
Module is controlled via I<sup>2</sup>C and accepts power and signal levels 3.3V.
23+
MKR1010 WiFi setup diagram:
24+
25+
![setup_diagram](img/setup_diagram.png)
26+
27+
For your board you need to connect power lines (**+3.3V, GND**) and I<sup>2</sup>C lines (**SDA, SCL**) to corresponding VL6180X lines.
28+
29+
### Decoder's preparation for MQTT devices
30+
If you want to limit amount of data which are being sent from board to Live Objects portal you can use **BINARY** mode which is defined in ```lo.begin()``` in *7_distance_and_light_sensor.ino*: ```lo.begin(MQTT, BINARY, true);```. In this case both values: ambient light (1 byte) and distance (4 bytes) will be sent as only five bytes (see terminal output in point 6).
31+
32+
To achieve this goal, you need to create **private binary decoder** in Live Objects portal. Use: *Data -> Decoders -> +Add*. You an enter data as below and click **Save**.
33+
34+
![binary_decoder](img/binary_decoder.png)
35+
36+
<br>
37+
38+
### MQTT interface modification
39+
40+
You need to select your device for which you want to activate previously created **private binary decoder**. Click selected device from the list uder tab **Devices**.
41+
42+
![select_dev](img/select_device_1.png)
43+
44+
<br>
45+
46+
Then click **Identity** and next click icon in red circle. After that in field **Decoder** you can select your decoder. Clicking **Save** finishes this step and activates our private decoder **VL6180Xbin** for MQTT interface for selected device.
47+
48+
![mod_interface](img/mod_interface_1.png)
549

650
## Running
7-
First of all, be sure that you installed the required libraries and generated an API key mentioned in the main README file, then:
8-
1. Open "1_send_data.ino" sketch using Arduino IDE
9-
2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in arduino_secrets.h with API key you generated
10-
3. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md**
11-
4. Upload *1_send_data.ino* sketch to your Arduino MKR NB 1500 board
51+
First of all, be sure that you installed the required libraries and generated an API key mentioned in the main **README.md** file, then:
52+
1. Open *7_distance_and_light_sensor.ino* sketch using Arduino IDE,
53+
2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in *arduino_secrets.h* with API key you generated,
54+
3. Define necessary credentials for your board in *arduino_secrets.h*:
55+
- for WiFi boards:
56+
- ```extern const String SECRET_SSID = "...;```
57+
- ```extern const String SECRET_WIFI_PASS = "...";```
58+
- for cellular boards:
59+
- ```extern const String SECRET_PINNUMBER = "...";``` (if needed),
60+
- ```extern const String SECRET_APN = "";``` (if needed),
61+
- ```extern const String SECRET_APN_USER = "...";``` (if needed),
62+
- ```extern const String SECRET_APN_PASS = "...";``` (if needed),
63+
4. In ```lo.setSecurity()``` select security mode using ```TLS``` or ```NONE``` according to board abilities shown in **Compatibility** point in main **README.md**,
64+
5. Upload *7_distance_and_light_sensor.ino* sketch to your board.
65+
6. In your terminal window you should see similiar output:
1266

67+
```
68+
15:31:22.732 ->
69+
15:31:22.732 -> VL6180X sensor
70+
15:31:22.732 -> Model ID = 180
71+
15:31:22.732 -> Model Rev = 13
72+
15:31:22.732 -> Module Rev = 12
73+
15:31:22.732 -> Manufacture Date = 16/11/14 Phase: 1
74+
15:31:22.732 ->
75+
15:31:23.762 ->
76+
15:31:23.762 -> *** Live Objects for Arduino MKR boards, revision 2.1.0 ***
77+
15:31:24.526 -> [INFO] WiFi firmware version 1.2.4
78+
15:31:24.526 -> [INFO] Attempting to connect to SSID: EdekAD57BA
79+
15:31:28.279 ->
80+
15:31:28.279 -> [INFO] Connecting to MQTT broker mqtt.liveobjects.orange-business.com:1883
81+
15:31:30.439 -> [INFO] You're connected to the MQTT broker
82+
15:31:30.439 -> Sampling data
83+
15:31:30.572 -> Sending data to Live Objects
84+
15:31:30.572 -> [INFO] Publishing message on topic: dev/v1/data/binary
85+
15:31:30.572 -> [INFO] 4041A9C28F
86+
15:31:35.554 -> Sampling data
87+
15:31:35.687 -> Sending data to Live Objects
88+
15:31:35.687 -> [INFO] Publishing message on topic: dev/v1/data/binary
89+
15:31:35.687 -> [INFO] 4841AEE148
90+
...
91+
```
1392

1493
## Verify
15-
**Is device online:**<br>
16-
If all went fine under **devices** tab on Live Live Objects portal you should see online your device identified by its modem IMEI:
94+
**Is device online:**
95+
If all went fine under **Devices** tab on Live Live Objects portal you should see online your device identified by its modem IMEI or WiFi MAC address:
1796

1897
![device_online](img/device_online.png)
1998

20-
**Is device sending data:**<br>
21-
Under data tab on Live Objects portal you should see messages sent by your device, along with values *{ "uptime": xxxxx }*
99+
**Is device sending data:**
100+
Under **Data** tab on Live Objects portal you should see messages sent by your device, along with values eg. *{ "distance": 110, "amblight": 192.63 }*
22101

23102
![data_portal](img/data_portal.png)
103+
104+
<br><br>
105+
106+
***
107+
## SMS (cellular boards)
108+
109+
## Preparations
110+
111+
### SMS device creation
112+
You need to manually add your cellular device as it is described in [this point](../6_sms_send_data/README.md).
113+
114+
### Decoder's preparation for SMS devices
115+
If you want to limit amount of data which are being sent from board to Live Objects portal you can use pure **TEXT** mode which is defined in ```lo.begin()``` in *7_distance_and_light_sensor.ino*: ```lo.begin(SMS, TEXT, true);```. In this case both values: ambient light and distance will be transmitted as raw text.
116+
117+
To achieve this goal, you need to create **private sms decoder** in Live Objects portal. Use: *Data -> Decoders -> +Add*. You an enter data as below and click **Save**.
118+
119+
![sms_decoder](img/sms_decoder.png)
120+
121+
### SMS interface modification
122+
123+
You need to modify SMS interface for you device in similar way as for MQTT device selecting **VL6180Xsms** decoder.
124+
125+
## Running
126+
First of all, be sure that you installed the required libraries and generated an API key mentioned in the main **README.md** file, then:
127+
1. Open *7_distance_and_light_sensor.ino* sketch using Arduino IDE,
128+
2. Replace ```const char SECRET_LIVEOBJECTS_API_KEY[]="...";``` in *arduino_secrets.h* with API key you generated,
129+
3. Specify the number of sever (gate) in *arduino_secrets.h*:
130+
- ```extern const String SECRET_SERVER_MSISDN = "...";```,
131+
4. In ```lo.setSecurity()``` select security mode ```NONE```
132+
5. Upload *7_distance_and_light_sensor.ino* sketch to your board.
133+
6. In your terminal window you should see similiar output:
134+
135+
```
136+
3:00:46.470 -> VL6180X sensor
137+
13:00:46.470 -> Model ID = 180
138+
13:00:46.470 -> Model Rev = 13
139+
13:00:46.470 -> Module Rev = 12
140+
13:00:46.470 -> Manufacture Date = 16/11/14 Phase: 1
141+
13:00:46.470 ->
142+
13:00:47.467 ->
143+
13:00:47.467 -> *** Live Objects for Arduino MKR boards, revision 2.1.0 ***
144+
13:00:52.151 -> [INFO] Connecting to cellular network
145+
13:01:00.558 ->
146+
13:01:00.758 -> [INFO] You're connected to the network
147+
13:01:00.758 -> Sampling data
148+
13:01:00.891 -> Sending data to Live Objects
149+
13:01:00.891 -> [INFO] Publishing message: 122;310.17;
150+
13:01:06.740 -> Sampling data
151+
13:01:06.840 -> Sending data to Live Objects
152+
13:01:06.840 -> [INFO] Publishing message: 255;300.67;
153+
...
154+
```
155+
156+
## Verify
157+
158+
You can verify if device is online and data are delivered in the same way as it is described for MQTT device.
464 KB
Loading
22.9 KB
Loading
34.1 KB
Loading
49.4 KB
Loading
46.8 KB
Loading
73.1 KB
Loading
51.9 KB
Loading
80.7 KB
Loading

0 commit comments

Comments
 (0)