Issue with Arduino IoT Cloud code

Hey Guys,

I was working on an automates hydroponics system, when I came across the Arduino IoT cloud platform. I decided to use it for my project. But I was facing an issue as when my code was uploaded my sensors were not being read.

I have an Arduino nano 33 IoT, a DHT22 sensor attached to pin 2, a 5v Relay module attached to pin 3 and an analog temperature sensor on analog pin A1. And the sensors are powered from an external breadboard power supply as I am not sure if the nano 33 IoT has a 5v pin.

This is my main code

#include "thingProperties.h"
#define HUM_PIN 2
#define Relay_PIN 3
#define TEMP_PIN A1

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

  // Defined in thingProperties.h

  // Connect to Arduino IoT Cloud

     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

void loop() {


void onTemperatureChange() {
  analogWrite(TEMP_PIN, INPUT);
  temperature = ((analogRead(TEMP_PIN) * 3.3) / 1024.0 - 0.5) * 100.0;

void onHumidityChange() {
  digitalWrite(HUM_PIN, INPUT);
  humidity = digitalRead(HUM_PIN);

void onRelayChange() {
  digitalWrite(Relay_PIN, OUTPUT);
  digitalWrite(Relay_PIN, relay);
  if (relay) {
  } else {

This is ‘thingproperties.h’ code

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

const char THING_ID[] = "";

const char SSID[]     = SECRET_SSID;    // Network SSID (name)
const char PASS[]     = SECRET_PASS;    // Network password (use for WPA, or use as key for WEP)

void onHumidityChange();
void onRelayChange();
void onTemperatureChange();

float humidity;
bool relay;
float temperature;

void initProperties(){

  ArduinoCloud.addProperty(humidity, READWRITE, 3 * SECONDS, onHumidityChange);
  ArduinoCloud.addProperty(relay, READWRITE, ON_CHANGE, onRelayChange);
  ArduinoCloud.addProperty(temperature, READWRITE, 3 * SECONDS, onTemperatureChange);


WiFiConnectionHandler ArduinoIoTPreferredConnection(SSID, PASS);

I’m not sure what is wrong with my code and even the Arduino code compiler did not show any errors but once the code is uploaded only the relay works and the other humidity and temperature sensor does not show any readings.


And the sensors are powered from an external breadboard power supply as I am not sure if the nano 33 IoT has a 5v pin.

The documentation states

5V: This pin outputs 5V from the board when powered from the USB connector. Note: for it to work, you need to short theor VBUS jumper on the back of the board. If you power the board from the VIN pin, you won’t get any regulated 5V and even if you do the solder bridge.

May be you should be more worried about sending 5v into your pins depending on what you connect