Arduino Struggles To Stay Connected

• Using Arduino nano 33 IOT
• Using both Android and IOS
• Using Blynk Server
• Blynk Library version 0.6.1

Huge beginner. Don’t know if it’s a network issue, code issue, or both.

Was wondering if there is a code I can include to test my connection to the cloud.


#include <SPI.h>
#include <WiFiNINA.h>
#include <BlynkSimpleWiFiNINA.h>
#include <Wire.h>
#include <OneWire.h>
#include <DallasTemperature.h>
#include <SparkFun_SCD30_Arduino_Library.h>

#define BLYNK_PRINT Serial
#define ONE_WIRE_BUS 2

SCD30 airSensor;
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
BlynkTimer timer;

char auth[] = "----------------------------------------";
char ssid[] = "XXXX";
char pass[] = "XXXX";

void setup()
  pinMode(12, OUTPUT);
  Blynk.begin(auth, ssid, pass);

  timer.setInterval(5000, myTimerEvent);

  if (airSensor.begin() == false)
    Serial.println("Air sensor not detected. Please check wiring. Freezing...");
    while (1)

void myTimerEvent()
  if (airSensor.dataAvailable()){
    Blynk.virtualWrite(V1, airSensor.getTemperature());
    Serial.println(airSensor.getTemperature(), 1);
    Blynk.virtualWrite(V2, airSensor.getHumidity());
    Serial.println(airSensor.getHumidity(), 1);
    Blynk.virtualWrite(V3, airSensor.getCO2());
    Serial.println(airSensor.getCO2(), 1);

    Blynk.virtualWrite(V4, sensors.getTempCByIndex(0));

    Serial.println("Waiting for new data");


void loop()

Remove this for starters…

Also, what youre doing here, and in the subsequent lines of code is bad practice…

It’s better to take one temperature (and humidity, and CO2) reading and save the result, then use that result to write the data to Blynk and the serial monitor…

float air_temp = airSensor.getTemperature());
Blynk.virtualWrite(V1, air_temp ); 
Serial.println(air_temp, 1);

As a general rule, sensors don’t like to be interrogated too often, and this approach halves the number of times you read them.

Also, the serial monitor may give useful information about disconnections.