My devices doesn't go online, but everything works

Hello, I am currently doing an activity using Arduino Uno Wifi Rev 2, and using DHT11.

Whenever I upload on Arduino Cloud, It says it is done uploading, and the values is reflected on the Serial Monitor. however I don't see any values in the dashboard, I noticed my device was offline even if the upload is working it is still offline. and I am also connected on my Internet i put the SSID and the password already still doesn't work.

Please take note I have three variables on my Thing which are
temperature - for the temperature values
humidity - for the humidity values
message - for the messenger value

Here is my sketch

#include "DHT.h"
#define DHT11_PIN 2

DHT dht11(DHT11_PIN, DHT11);

void setup() {
  Serial.begin(9600);
  dht11.begin(); // initialize the sensor
}

void loop() {
  // wait a few seconds between measurements.
  delay(2000);

  // read humidity
  float humidity = dht11.readHumidity();
  // read temperature as Celsius
  float temperatureC = dht11.readTemperature();
  // read temperature as Fahrenheit
  float temperatureF = dht11.readTemperature(true);

  // check if any reads failed
  if (isnan(humidity) || isnan(temperatureC) || isnan(temperatureF)) {
    Serial.println("Failed to read from DHT11 sensor!");
  } else {
    // Construct message with humidity, temperature in Fahrenheit, and temperature in Celsius
    String message = "Humidity = " + String(humidity) + "%, Temperature (Celsius) = " + String(temperatureC) + "°C, Temperature (Fahrenheit) = " + String(temperatureF) + "°F";
    // Print the message
    Serial.println(message);
  }
}

/*
  Since Message is a READ_WRITE variable, onMessageChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onMessageChange() {
  // Add your code here to act upon Message change
}

/*
  Since Humidity is a READ_WRITE variable, onHumidityChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onHumidityChange() {
  // Add your code here to act upon Humidity change
  float humidity = dht11.readHumidity();
}

/*
  Since Temp is a READ_WRITE variable, onTempChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTempChange() {
  // Add your code here to act upon Temp change
  float temperatureC = dht11.readTemperature();
}

/*
  Since Text is a READ_WRITE variable, onTextChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTextChange() {
  // read humidity
  float humidity = dht11.readHumidity();
  // read temperature as Celsius
  float temperatureC = dht11.readTemperature();
  // read temperature as Fahrenheit
  float temperatureF = dht11.readTemperature(true);
  // Construct message with humidity, temperature in Fahrenheit, and temperature in Celsius
  String message = "Humidity = " + String(humidity) + "%, Temperature (Celsius) = " + String(temperatureC) + "°C, Temperature (Fahrenheit) = " + String(temperatureF) + "°F";
  // Print the message
  Serial.println(message);
}

/*
  Since Temperature is a READ_WRITE variable, onTemperatureChange() is
  executed every time a new value is received from IoT Cloud.
*/
void onTemperatureChange() {
  // Add your code here to act upon Temperature change
}

Hi @acpojol
Check your code, the defiend DH11_PIN 2 is not used anywhere, also the part of the code where the Arduino has to connect with the wifi is also missing, on your arduino cloud, you will get a number which will connect your Arduino with the cloud, when connecting to the wifi, you will have to enter the SSID and password of the router. If it has problems connecting with the router, you can connect another laptop with the main Wifi and turn on laptop hotspot and connect the Arduino to the Laptop wifi.
As your arduino is not connected to the internet or the cloud, it will not publish the data.
As you are getting the data on your serial monitor, you will just have to work on the Data upload.
Do reach me out if you need any help.

1 Like


to confirm, is this the connection of the wifi, it is on another file

Nothing in your sketch attempts to connect to a network; there's no network interface being addressed or even mentioned, let alone any attempt at uploading data to something on the net.

On your laptop, perhaps, but your Arduino is isolated from the world.

It's not included in your sketch. The Arduino will only execute code in the first tab. Anything that is in the other tabs and that's not referenced to in the first tab will be ignored.
Here's a basic WiFi example: How to connect Arduino UNO Wifi Rev.2 to WiFi - DEV Community
Note the code all the way at the bottom of the page.

#include "arduino_secrets.h" 
char ssid[] = SECRET_SSID;
char pass[] = SECRET_PASS;
int status = WL_IDLE_STATUS;

void setup() {
  while ( status != WL_CONNECTED) {
    status = WiFi.begin(ssid, pass);
    delay(5000);
  }

# your code here
}

Im getting an error when running it.

In static member function 'static void SpiDrv::begin()':

error: 'NINA_GPIO0' was not declared in this scope
       pinMode(NINA_GPIO0, OUTPUT);
note: suggested alternative: 'NINA_GPIOIRQ'
       pinMode(NINA_GPIO0, OUTPUT);
In static member function 'static int SpiDrv::available()':
error: 'NINA_GPIO0' was not declared in this scope

I also tried testing one of WifiNina's example it shows the same error.

For initial trial, try to connect the Aruduino to the laptop hotspot and then connect it to the internet, I faced a similar problem, but connecting it to the laptop worked for me

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