Hello,
I have recently been experimenting with Node.js to implement my program ideas for Arduino IoT Cloud. Since I am new to this environment, I am relying on example documentation of JavaScript/Node.js on Arduino's site to do basic tasks like sending values to the cloud to update variables, such as updating an integer or string variable (which is included in the example documentation). However, as my project demands the use of complex variable types like DimmedLight and CloudScheduler, I can't seem to figure out how to send values or update these variables through Node.js since there are no examples available. Below, I have included my original code which attempts to send values, but nothing happens on the cloud. Can anyone guide me?
Code that attempts to send values to dimmedlight variable type:
import { ArduinoIoTCloud } from "arduino-iot-js";
import dotenv from 'dotenv';
dotenv.config();
// Example values for CloudDimmedLight (DimmedLight)
let dimmedLight = {
bri: 69.5, // Example brightness value as string
swi: false // Example switch state as string
};
// Connect to Arduino IoT Cloud
(async () => {
try {
const client = await ArduinoIoTCloud.connect({
deviceId: process.env.ARDUINO_CLOUD_DEVICEID,
secretKey: process.env.ARDUINO_CLOUD_SECRETKEY,
onDisconnect: (message) => console.error("Disconnected:", message),
});
// Send CloudDimmedLight (DimmedLight) to Arduino IoT Cloud
client.sendProperty("dimmedLight", dimmedLight);
// Logging for debug purposes
console.log("Sent dimmedLight:", dimmedLight);
// Example of handling additional complex variables
client.onPropertyValue("dimmedLight", (value) => console.log("Received Dimmed Light:", value));
} catch (error) {
console.error("Error connecting to Arduino IoT Cloud:", error.message);
}
})();
For CloudScheduler variable type I can't seem to figure anything out.
Can anyone link to any documentation that may touch on this or guide me here? Thanks!