Skip to content

Commit b4d2494

Browse files
committed
Merge remote-tracking branch 'private/main' into marqdevx/opta/public-launch
2 parents 54cd0e9 + 7fe2247 commit b4d2494

File tree

196 files changed

+503469
-153
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

196 files changed

+503469
-153
lines changed
Loading
Loading
Loading
Loading
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
---
2+
title: 'Use Sensor Data From Your Phone'
3+
description: 'Stream sensor data from your phone live to the Arduino IoT Cloud'
4+
tags:
5+
- Arduino IoT Cloud
6+
- Remote app
7+
- Mobile sensors
8+
- Android
9+
- iOS
10+
author: 'Jacob Hylén'
11+
---
12+
13+
The Arduino IoT Cloud is a powerful platform that can help you with setting up your own IoT devices within minutes.
14+
15+
It is now possible to synchronize your phone's sensor data with the cloud, using the Arduino Remote App for [iOS](https://apps.apple.com/us/app/arduino-iot-cloud-remote/id1514358431) and [Android](https://play.google.com/store/apps/details?id=cc.arduino.cloudiot&hl=en&gl=US). Furthermore, this data can also be used to control your Arduino boards, such as mapping a value from a sensor on your phone to an actuator on your Arduino.
16+
17+
Your smartphone is absolutely **packed** with sophisticated sensors that constantly measure everything from GPS position, to magnetic fields, acceleration, and so on. But they're difficult for a maker to take advantage of without having extensive knowledge of mobile development.
18+
19+
That is changed by the Arduino IoT Remote app - as you are able to, with the latest version of the app for [Android](https://play.google.com/store/apps/details?id=cc.arduino.cloudiot&hl=en&gl=US) and [iOS](https://apps.apple.com/us/app/arduino-iot-cloud-remote/id1514358431), set up a dashboard in the Arduino IoT Cloud that tracks and displays all your sensor data in a neat dashboard within a minute.
20+
21+
The goal with this project is to learn about how you can use your smartphone as a remote, sending sensor data to the Arduino IoT Cloud. You'll also learn how this sensor data can be used by other Things in your Arduino Cloud account, essentially letting you control your IoT devices depending on your variables such as GPS position, compass orientation, or any of the other in the long list of variables the IoT Remote app can stream live to the cloud.
22+
23+
You will learn this by making a small project where a servo motor reacts to where you point your phone, as shown below.
24+
25+
![Expected Outcome](assets/expected-outcome.gif)
26+
27+
## Requirements
28+
To Follow along with this article, you will need the following:
29+
30+
- An Android or iOS Smartphone/tablet
31+
- An [Arduino Cloud](https://cloud.arduino.cc/home/) Account
32+
- An Arduino IoT Cloud-compatible board (optional).
33+
- A Servo motor (optional).
34+
35+
## Phone Setup
36+
To start this process, you will need to download the Arduino IoT Cloud Remote app from either the [Google Play Store](https://play.google.com/store/apps/details?id=cc.arduino.cloudiot&hl=en&gl=US) or the[ Apple App store](https://apps.apple.com/us/app/arduino-iot-cloud-remote/id1514358431) depending on your device, if you don't already have it installed. If you do have it installed already you may need to update it, so take a quick look to make sure that you have the latest version downloaded.
37+
38+
Once you have the app installed, open it and log into your [Arduino Cloud](https://cloud.arduino.cc/home/) account. At this point you should be presented with a list of all your previous dashboards if you have any.
39+
40+
![Dashboards](assets/dashboards.png)
41+
42+
Tap the hamburger-menu in the top left of your screen, if you're using version 1.1 of the app or later you should have two options, press "**Use data from your phone**".
43+
44+
At this point, if you expand the section, you can see all the sensors that can be tracked in the Arduino IoT Cloud listed. You'll need to consent to the sensor data being sent to the Arduino IoT Cloud by checking the box, then you're ready to start the automated process of building the dashboard. Tap "**SET YOUR PHONE**" and sit back, relax, while the app takes care of everything else for you.
45+
46+
Once done, check out all the sensor data in the dashboard. How neat is that?
47+
48+
![Dashboard](assets/dashboard.png)
49+
50+
Try manipulating your phone in different ways to see how the data reacts, move it around, bring magnets close, make sounds, try anything you can think of!
51+
52+
## Use the Data
53+
Now that you've got your sensor data in the Arduino IoT Cloud, the next step is to use it for a project. As an example, let's sync the compass orientation of your phone to a variable controlling the angle of a servo motor.
54+
55+
The mobile "**Thing**" can't be programmed, but you can sync the variables from it with variables in other "**Things**"
56+
57+
So go to the [Arduino IoT Cloud](https://create.arduino.cc/iot/things) on your computer, and create a new **Thing**.
58+
59+
Grab your **Arduino IoT Cloud** compatible Arduino board and connect it to your computer, and configure it with your thing. I am using an **Arduino Nano 33 IoT**, and I am going with the suggested name for my device, which happens to be "**Robby**"
60+
61+
You will also need to enter your network credentials at this stage.
62+
63+
Now you can add a new variable in your **Thing**. When configuring this variable, you have the option to sync it to variables in other **Things**. This is very powerful and lets your devices talk to each other seamlessly, while still acting just like the variables you are familiar with in the code you're writing.
64+
65+
Name the variable something appropriate, "Compass" for example. Click the **"Sync with other Things"** button to open up the syncing menu, search for **"compass"** and make sure to tick the box of the compass variable tied to your mobile devices Thing.
66+
67+
![Variable syncing](assets/variablesync.png)
68+
69+
When one of the variables are updated, the other one will sync to the same value. This means that if we refer to the Compass variable in the sketch of our Arduino Thing we can access the values from the mobile device.
70+
71+
Now that the input is figured out, let's move on to creating our sketch. If you want to skip the code explanation, the full sketch can be found at the bottom of this section.
72+
73+
At the very top of the sketch we want to do three things, the first one is to include the servo library, the second one is to initialise the servo library, and the third is to create a variable to hold a mapped value from the compass. The compass in your phone reports a value between 0-360, but because servo motors usually cannot rotate 360 degrees we need to make sure that the value we send to the servo is witing the acceptables ranges for the servo we're using. Most small servos can move within a 90 or 180 degree range.
74+
75+
So start by including and initialising the servo library, and creating an empty integer variable at the top of your sketch.
76+
77+
```arduino
78+
#include <Servo.h>
79+
80+
Servo myServo;
81+
82+
int mappedCompass;
83+
```
84+
85+
Within `void setup()` we'll need select a pin for the servo motor. We'll also write it to a default starting position.
86+
87+
Add the following code somwehere in the setup function:
88+
```
89+
myServo.attach(2);
90+
myServo.write(80);
91+
```
92+
93+
In `void loop()` we need to remap the compass value like explained earlier, but once that is done all we need to do is to write the remapped value to the servo motor.
94+
95+
Add the following code in the loop function:
96+
```
97+
mappedCompass = map(compass, 0, 360, 0, 90);
98+
99+
myServo.write(mappedCompass);
100+
```
101+
102+
The full code can be found here:
103+
```
104+
/*
105+
Arduino IoT Cloud Variables description
106+
107+
The following variables are automatically generated and updated when changes are made to the Thing
108+
109+
float compass;
110+
111+
Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
112+
which are called when their values are changed from the Dashboard.
113+
These functions are generated with the Thing and added at the end of this sketch.
114+
*/
115+
116+
#include "thingProperties.h"
117+
#include <Servo.h>
118+
119+
Servo myServo;
120+
121+
int mappedCompass;
122+
123+
void setup() {
124+
// Initialize serial and wait for port to open:
125+
Serial.begin(9600);
126+
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
127+
delay(1500);
128+
129+
myServo.attach(2);
130+
myServo.write(80);
131+
132+
// Defined in thingProperties.h
133+
initProperties();
134+
135+
// Connect to Arduino IoT Cloud
136+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
137+
138+
/*
139+
The following function allows you to obtain more information
140+
related to the state of network and IoT Cloud connection and errors
141+
the higher number the more granular information you’ll get.
142+
The default is 0 (only errors).
143+
Maximum is 4
144+
*/
145+
setDebugMessageLevel(2);
146+
ArduinoCloud.printDebugInfo();
147+
}
148+
149+
void loop() {
150+
ArduinoCloud.update();
151+
// Your code here
152+
mappedCompass = map(compass, 0, 360, 0, 90);
153+
154+
myServo.write(mappedCompass);
155+
156+
}
157+
158+
/*
159+
Since Compass is READ_WRITE variable, onCompassChange() is
160+
executed every time a new value is received from IoT Cloud.
161+
*/
162+
void onCompassChange() {
163+
// Add your code here to act upon Compass change
164+
}
165+
166+
```
167+
168+
Once the sketch is uploaded to your board, wait for it to connect to your network, then open the IoT Remote app on your phone and watch as the Servo reacts when you rotate your phone.
169+
170+
## Conclusion
171+
With this tutorial, you have learned how to connect your android or iOS smartphone to the Arduino IoT Cloud and send all sorts of sensor data from your device, and how to integrate this sensor data with your other Arduino IoT Cloud Things.
172+
173+
The small project done in this tutorial is just the tip of the iceberg, you could take what you learned here and apply it in other ways to create an endless amount of cool interactive IoT projects that take advantage of the sophisticated sensors you carry in your pocket every day.

content/hardware/01.mkr/01.boards/mkr-1000-wifi/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ url_shop: https://store.arduino.cc/arduino-mkr1000-wifi
44
url_guide: /software/ide-v1/tutorials/getting-started/cores/arduino-samd
55
core: arduino:samd
66
forumCategorySlug: '/hardware/mkr-boards/mkr1000/137'
7+
certifications: [CE]
78
status: end-of-life
89
productCode: '017'
910
---

content/hardware/01.mkr/01.boards/mkr-gsm-1400/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ url_guide: /software/ide-v1/tutorials/getting-started/cores/arduino-samd
44
core: arduino:samd
55
forumCategorySlug: '/hardware/mkr-boards/mkrgsm1400/146'
66
status: end-of-life
7+
certifications: [CE]
78
productCode: '021'
89
---
910

content/hardware/01.mkr/01.boards/mkr-vidor-4000/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ url_shop: https://store.arduino.cc/arduino-mkr-vidor-4000
44
url_guide: /software/ide-v1/tutorials/getting-started/cores/arduino-samd
55
core: arduino:samd
66
forumCategorySlug: '/hardware/mkr-boards/mkrvidor4000/150'
7+
certifications: [CE]
78
productCode: '024'
89
---
910

content/hardware/01.mkr/01.boards/mkr-wan-1300/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ url_shop: https://store.arduino.cc/arduino-mkr-wan-1300
44
url_guide: /software/ide-v1/tutorials/getting-started/cores/arduino-samd
55
core: arduino:samd
66
forumCategorySlug: '/hardware/mkr-boards/mkrwan1310/161'
7+
certifications: [CE]
78
productCode: '129'
89
---
910

content/hardware/01.mkr/02.shields/mkr-485-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR 485 Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-485-shield
44
url_guide: /tutorials/mkr-485-shield/mkr-485-communication
5+
certifications: [CE]
56
---
67

78
The MKR 485 Shield makes it possible to communicate with legacy industrial systems that uses the RS-485 protocol. The shield is simply mounted on a MKR family board, easily turning your old local system into a modern IoT system.

content/hardware/01.mkr/02.shields/mkr-can-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR CAN Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-can-shield
44
url_guide: /tutorials/mkr-can-shield/mkr-can-communication
5+
certifications: [CE]
56
---
67

78
The MKR CAN Shield is a great addon for MKR family boards, and allows you to connect to a CAN (Controller Area Network) bus, widely used in the automotive industry.

content/hardware/01.mkr/02.shields/mkr-env-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR ENV Shield
33
url_shop: https://store.arduino.cc/mkr-env-shield-r2
44
url_guide: /tutorials/mkr-env-shield/mkr-env-shield-basic
5+
certifications: [CE]
56
---
67

78
The MKR ENV Shield is a perfect addon for the MKR family series, and is capable of reading temperature, humidity, light and pressure. The data is acquired easily through an easy-to-use library, and has an SD card slot for offline data logging.

content/hardware/01.mkr/02.shields/mkr-imu-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR IMU Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-imu-shield
44
url_guide: /tutorials/mkr-imu-shield/mkr-imu-shield-basics
5+
certifications: [CE]
56
---
67

78
The MKR IMU Shield helps you integrate inertial measurements with your projects. Read three-dimensional acceleration, yaw rate and magnetical field by simply mounting it on top of a MKR family board.

content/hardware/01.mkr/02.shields/mkr-mem-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR MEM Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-mem-shield
44
url_guide: /tutorials/mkr-mem-shield/mkr-mem-shield-data-logger
5+
certifications: [CE]
56
---
67

78
Add extra flash memory (2MB) and store larger files on a Micro SD card with the MKR MEM Shield. As a bonus, the shield has a prototyping area, for adding e.g. smaller displays, sensors, actuators and more. Compatible with all MKR family boards.

content/hardware/01.mkr/02.shields/mkr-relay-proto-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR Relay Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-relay-proto-shield
44
url_guide: /tutorials/mkr-relay-proto-shield/mkr-relay-shield-basic
5+
certifications: [CE]
56
---
67

78
The MKR Relay Shield has two relays mounted that can be used for loads up to 24V. It also features two status LEDs and a prototyping area for adding your own components.

content/hardware/01.mkr/02.shields/mkr-therm-shield/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR Therm Shield
33
url_shop: https://store.arduino.cc/arduino-mkr-therm-shield
44
url_guide: /tutorials/mkr-therm-shield/mkr-therm-shield-basic
5+
certifications: [CE]
56
---
67

78
The MKR Therm Shield is a great addon for MKR family boards, and allows you to connect high quality thermocouplers, and can calculate temperatures from -200°C to +700°C. An ideal solution to use for ovens, freezers, smokers and similar environments.

content/hardware/01.mkr/03.carriers/mkr-connector-carrier/product.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
title: MKR Connector Carrier
33
url_shop: https://store.arduino.cc/arduino-mkr-connector-carrier
44
url_guide: /tutorials/mkr-connector-carrier/connector-basics
5+
certifications: [CE]
56
---
67

78
The MKR Connector Carrier is a really useful extension for MKR family boards. It features 14 grove compatible connectors, which allows you to choose between hundreds of different sensors and actuators for your project.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
software: ~
2+
hardware:
3+
shields: ~
4+
carriers: ~
5+
boards:
6+
- mkr-zero
7+
- mkr-1000-wifi
8+
- mkr-wifi-1010
9+
- mkr-fox-1200
10+
- mkr-wan-1300
11+
- mkr-wan-1310
12+
- mkr-gsm-1400
13+
- mkr-nb-1500
14+
- mkr-vidor-4000
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../mkr-iot-carrier/datasheet/assets/Pinout.png
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../mkr-iot-carrier/datasheet/assets/Power_Tree_MKR_IoT_Carrier.png

0 commit comments

Comments
 (0)