Using Arduino R4 Wifi as IoT Test

My arduino board always appears offline and also there is no trying to connect to wifi message in serial monitor, i wanted to have led matrix toggle via IoT

/* 
  Sketch generated by the Arduino IoT Cloud Thing "Untitled"
  https://create.arduino.cc/cloud/things/5b5820dd-a491-41c7-b41f-faccca926922 

  Arduino IoT Cloud Variables description

  The following variables are automatically generated and updated when changes are made to the Thing

  bool LED;

  Variables which are marked as READ/WRITE in the Cloud Thing will also have functions
  which are called when their values are changed from the Dashboard.
  These functions are generated with the Thing and added at the end of this sketch.
*/

#include "thingProperties.h"
#include "Arduino_LED_Matrix.h"

ArduinoLEDMatrix matrix;

byte frame[8][12] = {
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
  { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }
};

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);
  matrix.begin();
  
  /*
     The following function allows you to obtain more information
     related to the state of network and IoT Cloud connection and errors
     the higher number the more granular information you’ll get.
     The default is 0 (only errors).
     Maximum is 4
 */
  setDebugMessageLevel(2);
  ArduinoCloud.printDebugInfo();
}

void loop() {

}



/*
  Since LED is READ_WRITE variable, onLEDChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onLEDChange()  {
  if(LED){ 
    frame[0][0] = 1;
  } else {
    frame[0][0] = 1;
  }
  matrix.renderBitmap(frame, 8, 12);
}

***** Arduino IoT Cloud - configuration info *****
Device ID: 9b4ec7db-bcf9-44c6##########
MQTT Broker: mqtts-up.iot.arduino.cc:8884

image

I moved your topic to an appropriate forum category @pmalys .

In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.

This is an important part of responsible forum usage, as explained in the "How to get the best out of this forum" guide. The guide contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

I think you should add ArduinoCloud.update() inside your loop function.

void loop() {
  ArduinoCloud.update();
}

And of course, you should switch the value of that single frame from 0 to 1, depending on the value of the cloud variable

  if(LED){ 
    frame[0][0] = 1; // turn it ON
  } else {
    frame[0][0] = 0; // turn it OFF
  }

Best,
Christian.

2 Likes

haven't noticed the error in frame selection, and now it works as expected ty!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.