|
| 1 | +--- |
| 2 | +title: Connect UNO Q to the Arduino Cloud |
| 3 | +description: Learn how to connect the UNO Q to the Arduino Cloud |
| 4 | +tags: [UNO Q, Arduino Cloud, IoT] |
| 5 | +author: Karl Söderby |
| 6 | +--- |
| 7 | + |
| 8 | +The [Arduino® UNO Q](https://store.arduino.cc/products/uno-q) is supported by the [Arduino Cloud](https://app.arduino.cc/), allowing it to send and receive data over the Internet. Note that the UNO Q requires the [Arduino App Lab](https://docs.arduino.cc/software/app-lab/) to be programmed, which includes the ready made example that this tutorial is based on. |
| 9 | + |
| 10 | +The communication with Arduino Cloud is enabled by the UNO Q's microprocessor & Wi-Fi® module, and is programmed using Python. |
| 11 | + |
| 12 | +***Currently the UNO Q is set up using the "Manual Device" flow in the Arduino Cloud, using the `SECRET_KEY` and `DEVICE_ID` variables in a Python script running on the board.*** |
| 13 | + |
| 14 | +## Goals |
| 15 | + |
| 16 | +In this tutorial you will learn: |
| 17 | +- How to set up the Arduino Cloud. |
| 18 | +- How to create a manual device (representing the UNO Q). |
| 19 | +- How to turn on an LED on the UNO Q from a dashboard in the Arduino Cloud. |
| 20 | + |
| 21 | +## Hardware & Software Needed |
| 22 | + |
| 23 | +- [Arduino® UNO Q](https://store.arduino.cc/products/uno-q) |
| 24 | +- An [Arduino Cloud account](https://login.arduino.cc/login) |
| 25 | +- [Arduino App Lab](https://www.arduino.cc/en/software) |
| 26 | + |
| 27 | +## Set up Arduino Cloud |
| 28 | + |
| 29 | +First, we need to set up the Arduino Cloud part, including: |
| 30 | +- Creating a Device (manual device type) |
| 31 | +- Creating a Thing and a cloud variable |
| 32 | +- Creating a dashboard and a widget |
| 33 | + |
| 34 | +To set this up, follow the instructions below: |
| 35 | +### Setting Up Arduino Cloud |
| 36 | + |
| 37 | +1. Navigate to the [Arduino Cloud](https://app.arduino.cc/) page and log in / create an account. |
| 38 | +2. Go to the [devices](https://app.arduino.cc/devices) page and create a device, selecting the "manual device" type. Follow the instructions and take note of the **device_id** and **secret_key** provided in the setup. |
| 39 | +  |
| 40 | +3. Go to the [things](https://app.arduino.cc/things) page and create a new thing. |
| 41 | +4. Inside the thing, create a new **boolean** variable, and name it **"led"**. We also need to associate the device we created with this thing. |
| 42 | +  |
| 43 | +5. Finally, navigate to the [dashboards](https://app.arduino.cc/dashboards), and create a dashboard. Inside the dashboard, click on **"Edit"**, and select the thing we just created. This will automatically assign a switch widget to the **led** variable. |
| 44 | +  |
| 45 | + |
| 46 | +## Program the UNO Q (Cloud Example) |
| 47 | + |
| 48 | +To program the UNO Q, we need to use the Arduino App Lab. The example we are going to use are included in the Arduino App Lab. |
| 49 | + |
| 50 | +***If you are new to the UNO Q, you can check out the [Getting Started with Arduino App Lab](https://docs.arduino.cc/software/app-lab/tutorials/getting-started/) guide*** |
| 51 | + |
| 52 | +1. Open the Arduino App Lab and connect (using USB / network option). |
| 53 | +2. Open the **"Examples"** tab in the left side menu. Here you will find the **"Blinking LED from Arduino Cloud"** example. |
| 54 | +3. Duplicate the example, by clicking on **"Copy and edit app"** button in the top right corner |
| 55 | +  |
| 56 | + |
| 57 | +4. On the App page, click on the **"Arduino Cloud"** Brick, then click on the **"Brick Configuration"** button. |
| 58 | +  |
| 59 | + |
| 60 | +5. Enter the cloud credentials (device ID and secret key), replacing the `<YOUR_DEVICE_ID>` and `<YOUR_SECRET>` values. These are the ones retrieved in the Arduino Cloud (previous section). |
| 61 | + |
| 62 | +  |
| 63 | + |
| 64 | +6. Launch the App by clicking on the "Play" button in the top right corner. Wait until the App has launched. |
| 65 | +  |
| 66 | + |
| 67 | +## Testing the Cloud Connection |
| 68 | + |
| 69 | +The example works by establishing a connection between the Arduino Cloud and the UNO Q board. When interacting with the dashboard's switch widget (turn ON/OFF), the cloud updates the `led` variable. |
| 70 | + |
| 71 | +The `main.py` script running on the Linux system listens for changes to this property using the `arduino_cloud` Brick. When a change is detected, the **Bridge** tool is used to send data to the microcontroller, and turn the LED ON. |
| 72 | + |
| 73 | +The flow of the App is: |
| 74 | +1. The switch in the Arduino Cloud dashboard is changed. |
| 75 | +2. The Arduino Cloud updates the device's state. |
| 76 | +3. `main.py` receives the updated state, sends a message to the microcontroller which turns the LED to an ON/OFF state. |
| 77 | + |
| 78 | + |
| 79 | + |
| 80 | +## Summary |
| 81 | + |
| 82 | +In this tutorial, you learned how to connect the UNO Q with the Arduino Cloud. This connection is done by using the **Arduino Cloud Brick** in the Python script running on the UNO Q's microprocessor. |
| 83 | + |
| 84 | +The data that the Python script receives is then sent to the microcontroller, which turns on the built-in LED on the board. For this, the **Bridge** tool is used. |
| 85 | + |
| 86 | +You can read more about the Arduino Cloud & UNO Q through the links below: |
| 87 | +- [Arduino Cloud documentation](https://docs.arduino.cc/arduino-cloud/) |
| 88 | +- [Arduino UNO Q documentation](https://docs.arduino.cc/hardware/uno-q/) |
0 commit comments