Im confused with new arduino cloud

Hello,im confused with new arduino cloud UI its different with the old one, the tutorial i have is from old arduino i tried to making smarthome with arduino cloud, when im using from dashboard arduino cloud its dosnt work the lamp wont turn on but when im using manual switch button the lamp is turn on. i really need some help here how to turn it on from arduino cloud idk if im doing it wrong. thx

This link is a long read, but it describes the steps to build a cloud project.

We can't see your computer screen or desk. You need to show us stuff like code that is Auto Formatted and posted in a code block, photos of a hand-drawn wiring diagram, NOT the instructions, your actual wires with labels and datasheet links for non-common parts.

That is an excellent resource!

sry about that, this is my arduino cloud setting

and here the code i used

#include <ArduinoIoTCloud.h>
#include <Arduino_ConnectionHandler.h>
#include <ESP8266Wifi.h>

const char DEVICE_LOGIN_NAME[]  = ""; //Enter DEVICE ID

const char SSID[]               = "";    //Enter WiFi SSID (name)
const char PASS[]               = "";    //Enter WiFi password
const char DEVICE_KEY[]         = "";    //Enter Secret device password (Secret Key)


// define the GPIO connected with Relays and switches
#define RelayPin1 5  //D1
#define RelayPin2 4  //D2
#define RelayPin3 14 //D5
#define RelayPin4 12 //D6

#define SwitchPin1 D4  //D4
#define SwitchPin2 0   //D3 
#define SwitchPin3 13  //D7
#define SwitchPin4 3   //RX

#define wifiLed   16   //D0


int toggleState_1 = 0; //Define integer to remember the toggle state for relay 1
int toggleState_2 = 0; //Define integer to remember the toggle state for relay 2
int toggleState_3 = 0; //Define integer to remember the toggle state for relay 3
int toggleState_4 = 0; //Define integer to remember the toggle state for relay 4

void onSwitch1Change();
void onSwitch2Change();
void onSwitch3Change();
void onSwitch4Change();

CloudSwitch switch1;
CloudSwitch switch2;
CloudSwitch switch3;
CloudSwitch switch4;

void initProperties(){

  ArduinoCloud.setBoardId(DEVICE_LOGIN_NAME);
  ArduinoCloud.setSecretDeviceKey(DEVICE_KEY);

  ArduinoCloud.addProperty(switch1, READWRITE, ON_CHANGE, onSwitch1Change);
  ArduinoCloud.addProperty(switch2, READWRITE, ON_CHANGE, onSwitch2Change);
  ArduinoCloud.addProperty(switch3, READWRITE, ON_CHANGE, onSwitch3Change);
  ArduinoCloud.addProperty(switch4, READWRITE, ON_CHANGE, onSwitch4Change);

}

WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

const int debounceDelay = 200; // Debounce delay in milliseconds
unsigned long lastDebounceTime1 = 0;
unsigned long lastDebounceTime2 = 0;
unsigned long lastDebounceTime3 = 0;
unsigned long lastDebounceTime4 = 0;

// Track the previous state of each switch to handle edge detection
bool previousSwitchState1 = HIGH;
bool previousSwitchState2 = HIGH;
bool previousSwitchState3 = HIGH;
bool previousSwitchState4 = HIGH;

void manual_control() {
  unsigned long currentMillis = millis();

  // Manual Switch Control
  // Check each switch pin and toggle the corresponding relay if the switch is pressed (LOW state)
  
  // Check if Switch 1 is pressed
  if (digitalRead(SwitchPin1) == LOW && previousSwitchState1 == HIGH) {
    if (currentMillis - lastDebounceTime1 >= debounceDelay) {
      toggleState_1 = !toggleState_1;
      digitalWrite(RelayPin1, !toggleState_1);
      switch1 = toggleState_1; // Toggle Relay 1
      lastDebounceTime1 = currentMillis; // Update the last debounce time
    }
  }
  previousSwitchState1 = digitalRead(SwitchPin1);

  // Check if Switch 2 is pressed
  if (digitalRead(SwitchPin2) == LOW && previousSwitchState2 == HIGH) {
    if (currentMillis - lastDebounceTime2 >= debounceDelay) {
      toggleState_2 = !toggleState_2;
      digitalWrite(RelayPin2, !toggleState_2);
      switch2 = toggleState_2; // Toggle Relay 2
      lastDebounceTime2 = currentMillis; // Update the last debounce time
    }
  }
  previousSwitchState2 = digitalRead(SwitchPin2);

  // Check if Switch 3 is pressed
  if (digitalRead(SwitchPin3) == LOW && previousSwitchState3 == HIGH) {
    if (currentMillis - lastDebounceTime3 >= debounceDelay) {
      toggleState_3 = !toggleState_3;
      digitalWrite(RelayPin3, !toggleState_3);
      switch3 = toggleState_3; // Toggle Relay 3
      lastDebounceTime3 = currentMillis; // Update the last debounce time
    }
  }
  previousSwitchState3 = digitalRead(SwitchPin3);

  // Check if Switch 4 is pressed
  if (digitalRead(SwitchPin4) == LOW && previousSwitchState4 == HIGH) {
    if (currentMillis - lastDebounceTime4 >= debounceDelay) {
      toggleState_4 = !toggleState_4;
      digitalWrite(RelayPin4, !toggleState_4);
      switch4 = toggleState_4; // Toggle Relay 4
      lastDebounceTime4 = currentMillis; // Update the last debounce time
    }
  }
  previousSwitchState4 = digitalRead(SwitchPin4);
}


void setup() {
  // Initialize serial and wait for port to open:
  Serial.begin(9600);
  // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
  delay(1500);

  // Defined in thingProperties.h
  initProperties();

  // Connect to Arduino IoT Cloud
  ArduinoCloud.begin(ArduinoIoTPreferredConnection);

  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();

  pinMode(RelayPin1, OUTPUT);
  pinMode(RelayPin2, OUTPUT);
  pinMode(RelayPin3, OUTPUT);
  pinMode(RelayPin4, OUTPUT);

  pinMode(wifiLed, OUTPUT);

  pinMode(SwitchPin1, INPUT_PULLUP);
  pinMode(SwitchPin2, INPUT_PULLUP);
  pinMode(SwitchPin3, INPUT_PULLUP);
  pinMode(SwitchPin4, INPUT_PULLUP);

  //During Starting all Relays should TURN OFF
  digitalWrite(RelayPin1, HIGH);
  digitalWrite(RelayPin2, HIGH);
  digitalWrite(RelayPin3, HIGH);
  digitalWrite(RelayPin4, HIGH);

  digitalWrite(wifiLed, HIGH);  //Turn OFF WiFi LED
}

void loop() {
  ArduinoCloud.update();
  
  manual_control(); //Control relays manually

  if (WiFi.status() != WL_CONNECTED)
  {
    digitalWrite(wifiLed, HIGH); //Turn OFF WiFi LED
    //Serial.println("NO WIFI");
  }
  else{
    digitalWrite(wifiLed, LOW); //Turn ON WiFi LED
    //Serial.println("YES WIFI");
  }
}

void onSwitch1Change() {
  if (switch1 == 1)
  {
    digitalWrite(RelayPin1, LOW);
    Serial.println("Device1 ON");
    toggleState_1 = 1;
  }
  else
  {
    digitalWrite(RelayPin1, HIGH);
    Serial.println("Device1 OFF");
    toggleState_1 = 0;
  }
}

void onSwitch2Change() {
  if (switch2 == 1)
  {
    digitalWrite(RelayPin2, LOW);
    Serial.println("Device2 ON");
    toggleState_2 = 1;
  }
  else
  {
    digitalWrite(RelayPin2, HIGH);
    Serial.println("Device2 OFF");
    toggleState_2 = 0;
  }
}

void onSwitch3Change() {
  if (switch3 == 1)
  {
    digitalWrite(RelayPin3, LOW);
    Serial.println("Device2 ON");
    toggleState_3 = 1;
  }
  else
  {
    digitalWrite(RelayPin3, HIGH);
    Serial.println("Device3 OFF");
    toggleState_3 = 0;
  }
}

void onSwitch4Change() {
  if (switch4 == 1)
  {
    digitalWrite(RelayPin4, LOW);
    Serial.println("Device4 ON");
    toggleState_4 = 1;
  }
  else
  {
    digitalWrite(RelayPin4, HIGH);
    Serial.println("Device4 OFF");
    toggleState_4 = 0;
  }
}


i deleted the ID number and my wifi information from the code i send here but in the code my ESP have the wifi connected

Show your wiring.

Do you mean the WiFi LED?

void loop() {
  ArduinoCloud.update();

  manual_control(); //Control relays manually

  if (WiFi.status() != WL_CONNECTED)
  {
    digitalWrite(wifiLed, HIGH); //Turn OFF WiFi LED
    //Serial.println("NO WIFI");
  }
  else {
    digitalWrite(wifiLed, LOW); //Turn ON WiFi LED
    //Serial.println("YES WIFI");
  }
}

Hi @ramava416. From the screenshot you shared in post #5, I see the status of your Device is "offline":

This means the Device is not communicating with the Arduino Cloud server. The board will only react to changes you make via the Dashboard if it is in an "online" state.

Was your board powered and running the Thing sketch at the time you took that screenshot? If not, please check the status again when the board is powered.

If the Device has an "offline" status even when the board is powered and running the Thing sketch, you must focus on finding the problem that is causing the Device to not be able to communicate with the Arduino Cloud server. We can guide you in investigating and solving the problem.

oh sry when i toke this SS i was not turn on the ESP but when its turn on the status was showing online but still when i tried to turn on the switch button from dashboard nothing happened to the lamp, same in google home too i still dont know what the problem

Thanks for the clarification.

Please perform the following investigative procedure:

  1. Open the "Things" page on the Arduino Cloud website:
    https://app.arduino.cc/things
  2. Select your Thing from the list on that page.
    The Thing page will open.
  3. The Thing page contains a list of Variables. The current value of each Variable is shown there.

Does the value of the Variable shown on the Thing page reflect what you expect from the position of the switch on the Dashboard?

If you change the position of the switch on the dashboard, do you see the value of the Variable shown on the Thing page change accordingly?

yes the value is changed when i turn on or off the switch in dashboard


i was uploading my code from arduino ide so its fine right not from the arduino cloud sketch, and here from the yt tutorial is old arduino cloud right because right now so different


here the yt link for the tutorial https://youtu.be/K09vSRz3Ugk?si=s8W784030zbfoDM2
maybe you can help me with the new arduino cloud ver to make that

Please try this experiment:

  1. Connect the board that is running the Thing sketch to your computer with a USB cable.
  2. Open the Arduino IDE Serial Monitor.
    ⓘ Alternatively, you can use the Arduino Cloud Editor Serial Monitor if you prefer.
  3. Make sure "9600" is selected from the baud rate menu near the top right corner of the Serial Monitor panel in the Arduino IDE window.
  4. Change the position of one of the switches in the Dashboard.

The expected result is that you would see a message printed in Serial Monitor something like:

Device1 ON

or:

Device1 OFF

This is due to the debugging code that was included in the sketch:

(note the Serial.println calls)

Do you see the expected messages in Serial Monitor?

It is fine to use Arduino IDE to develop and upload Thing sketches. However, it is essential that the sketch code matches against the configuration of the Thing.

When you create a Thing on Arduino Cloud, it also generates the skeleton of the Thing sketch, which reflects the Thing configuration. So when you start from that generated code, you are less likely to end up with a sketch that does not match the Thing configuration.

However, the fact that Arduino Cloud does recognize your Device as having an "online" status indicates that the board is able to communicate with the Arduino Cloud server. Additionally, I don't see any mismatch between the configuration of the Variables shown in the screenshot and the sketch code you shared.

i tried it and i dont see the messages, its only show connected to arduino cloud
image

its fixed now, i can turn the lamp from the dashboard i found the problem, its just typo in the declaration in cloud was Switch1 meanwhile in the code its switch1 thats why it dosnt want to respond because its different capital of letter S, im really appreciate your help with my problem and even tho its human error, really tyy for helping me


image

Ah, I missed that. Great work troubleshooting the cause of the problem! Thanks for taking the time to post an update with your solution.

This does highlight that it is generally a good idea to start from the skeleton sketch code generated by Arduino Cloud. However, I guess that wasn't really an option in this specific case where you were using some existing code from a tutorial.