Skip to content

Commit 75051cc

Browse files
committed
Fix iot section content
1 parent 206e4cb commit 75051cc

File tree

1 file changed

+101
-15
lines changed
  • content/hardware/09.kits/maker/nesso-n1/tutorials/user-manual

1 file changed

+101
-15
lines changed

content/hardware/09.kits/maker/nesso-n1/tutorials/user-manual/content.md

Lines changed: 101 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -93,31 +93,119 @@ Please use the **Arduino IDE** (desktop version) to compile and upload code to t
9393

9494
## Arduino IoT Cloud
9595

96-
Although the Nesso N1 cannot yet be programmed directly via the Cloud Editor, you can still use it with **Arduino IoT Cloud** dashboards and variables by configuring it as a "Manual Device" and uploading the sketch from your desktop IDE.
96+
Although the Nesso N1 cannot yet be programmed directly via the Cloud Editor, you can still use it with **Arduino IoT Cloud** dashboards and variables. This is done by configuring it as a "Manual Device" and uploading the sketch from your desktop IDE.
97+
98+
Follow these steps to connect your Nesso N1 to the Cloud.
9799

98100
### 1. Create a Manual Device
101+
99102
1. Go to the [Arduino IoT Cloud Devices page](https://app.arduino.cc/devices).
100103
2. Click **+ CREATE**.
101-
3. Select **Any Device** (do not search for Nesso N1).
104+
3. Select **Any Device** (do not search for Nesso N1, as it is not yet listed).
102105
4. Click **Continue**.
103106
5. Name your device (e.g., "MyNessoN1") and click **Next**.
104-
6. **Important:** Save the **Device ID** and **Secret Key**. You will need these later in your code.
107+
6. **Important:** A screen will appear with your **Device ID** and **Secret Key**. Save these credentials in a secure place immediately; you will not be able to view the Secret Key again.
105108
7. Check the box confirming you have saved your credentials and click **Continue**.
106109

107110
### 2. Create a Thing
111+
108112
1. Go to the [Things page](https://app.arduino.cc/things).
109-
2. Create a new Thing and associate it with the "Manual Device" you just created.
110-
3. Add your desired Cloud Variables (e.g., an LED switch or sensor value).
113+
2. Click **+ THING** to create a new Thing.
114+
3. Click **Select Device** and associate it with the "Manual Device" you just created.
115+
4. Click **Add Variable** to create a test variable:
116+
* **Name**: `led`
117+
* **Type**: Boolean
118+
* **Permission**: Read & Write
119+
* **Update Policy**: On Change
120+
5. Click **Add Variable** to confirm.
121+
122+
### 3. Create a Dashboard
123+
124+
1. Go to the [Dashboards page](https://app.arduino.cc/dashboards).
125+
2. Click **+ DASHBOARD**.
126+
3. Click **ADD** and select the **Things** tab.
127+
4. Select your Thing and create a widget for the `led` variable (a Switch widget is recommended).
128+
129+
### 4. Program the Board via Desktop IDE
130+
131+
Because "Manual Devices" do not automatically generate a downloadable sketch, you must create one manually.
111132

112-
### 3. Program the Board via Desktop IDE
113133
1. Open the **Arduino IDE** on your computer.
114-
2. Install the **ArduinoIoTCloud** library via the Library Manager.
115-
3. Copy the sketch generated by the Cloud "Thing" (from the "Sketch" tab in the web interface) into the Arduino IDE.
116-
4. Open the `thingProperties.h` tab in your local sketch.
117-
5. Manually enter your Wi-Fi credentials and the **Device ID** and **Secret Key** you saved in step 1.
118-
6. Select **Arduino Nesso N1** as your board and upload the sketch.
134+
2. Install the **ArduinoIoTCloud** library via the Library Manager (**Tools > Manage Libraries...**).
135+
3. Create a new sketch (**File > New**).
136+
4. To keep your credentials secure, create a new tab named `arduino_secrets.h` (click the 3-dot icon near the tab bar > **New Tab**).
137+
5. Paste the following code into `arduino_secrets.h` and fill in your details:
138+
139+
```cpp
140+
#define SECRET_SSID "YOUR_WIFI_SSID"
141+
#define SECRET_OPTIONAL_PASS "YOUR_WIFI_PASSWORD"
142+
#define SECRET_DEVICE_LOGIN_NAME "YOUR_DEVICE_ID" // From Step 1
143+
#define SECRET_DEVICE_KEY "YOUR_SECRET_KEY" // From Step 1
144+
```
145+
146+
6. Create another new tab named `thingProperties.h` and paste the following configuration code:
147+
148+
```cpp
149+
#include <ArduinoIoTCloud.h>
150+
#include <Arduino_ConnectionHandler.h>
151+
#include "arduino_secrets.h"
152+
153+
const char SSID[] = SECRET_SSID;
154+
const char PASS[] = SECRET_OPTIONAL_PASS;
155+
const char DEVICE_LOGIN_NAME[] = SECRET_DEVICE_LOGIN_NAME;
156+
const char DEVICE_KEY[] = SECRET_DEVICE_KEY;
119157

120-
The board will now connect to the Arduino IoT Cloud, allowing you to control it via dashboards despite not using the Cloud Editor.
158+
void onLedChange();
159+
160+
bool led;
161+
162+
void initProperties(){
163+
ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
164+
ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);
165+
ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);
166+
}
167+
168+
WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);
169+
```
170+
171+
7. Finally, paste the main application code into your `.ino` file:
172+
173+
```cpp
174+
#include "thingProperties.h"
175+
176+
void setup() {
177+
Serial.begin(115200);
178+
delay(1500); // Wait for Serial Monitor
179+
180+
// Initialize the Nesso N1 built-in LED
181+
pinMode(LED_BUILTIN, OUTPUT);
182+
183+
// Initialize Cloud properties and connection
184+
initProperties();
185+
ArduinoCloud.begin(ArduinoIoTPreferredConnection);
186+
187+
// Set debug level to see connection status in Serial Monitor
188+
setDebugMessageLevel(2);
189+
ArduinoCloud.printDebugInfo();
190+
}
191+
192+
void loop() {
193+
ArduinoCloud.update();
194+
}
195+
196+
// This function is called whenever the 'led' variable changes in the Cloud
197+
void onLedChange() {
198+
// The Nesso N1 LED uses inverted logic (LOW is ON)
199+
if (led) {
200+
digitalWrite(LED_BUILTIN, LOW);
201+
} else {
202+
digitalWrite(LED_BUILTIN, HIGH);
203+
}
204+
}
205+
```
206+
207+
8. Select **Arduino Nesso N1** as your board and upload the sketch.
208+
9. Open the **Serial Monitor** to verify the connection. Once connected, you can toggle the switch on your Cloud Dashboard to control the LED on the board.
121209

122210
## First Use
123211

@@ -1444,6 +1532,4 @@ Join our community forum to connect with other Nesso N1 users, share your experi
14441532

14451533
Please get in touch with our support team if you need personalized assistance or have questions not covered by the help and support resources described before. We are happy to help you with any issues or inquiries about the Nesso N1.
14461534

1447-
- [Contact us page](https://www.arduino.cc/en/contact-us/)
1448-
1449-
1535+
- [Contact us page](https://www.arduino.cc/en/contact-us/)

0 commit comments

Comments
 (0)