Using IoT cloud remotely without being connected to a computer

Hello There........

I had recently completed my IoT Cloud project using a dashboard to show and visualize data from a DHT22, but now I wanted to use the dashboard when the board (nano 33 iot) and DHT22 are not connected to the computer. Is it possible?

Please let me know.........

Thanking you
Johan

hi Johan

Of course it is, this is the whole point of making an Internet connected Object :slight_smile:

If you power your board with a USB battery pack, as long as it can reach the WiFi signal, it will connect and you'll be able to use the dashboard to control it.

Also: do you know we have released a mobile app to control your Things? Go grab it

Hi @ubidefeo............

I've tried that before but it didn't work. But maybe I could have made a mistake somewhere. So I will do it again today. And is there a method to view the dashboard from and iPad?

Thanking you
Johan

can you post your sketch ino?
maybe you have a

while(!Serial){};

in your setup and that blocks the program from running until a serial port/monitor (from the computer) is available.
I use this configuration all the time.

The Dashboards run in a browser and are pure HTML and Javascript so they do work on the iPad.
We also use them on mobile phones via the browser.
I do suggest you install the Arduino IoT Cloud Remote app to control the dashboards, but to create and edit them you should have no problem on an iPad (I have not tried that myself)

1 Like

Hello there....
Thank you for taking the time to help me

#include "thingProperties.h"
#include <SimpleDHT.h>

#define DHTPIN 2

SimpleDHT22 dht22(DHTPIN);


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);
  
  /*
     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() {
  ArduinoCloud.update();
 
  float temperature_raw = 0;
  float humidity_raw = 0;
  int err = SimpleDHTErrSuccess;
  if ((err = dht22.read2(&temperature_raw, &humidity_raw, NULL)) != SimpleDHTErrSuccess) {
    delay(1000);
    return;
  }
  temperature = temperature_raw;
  humidity = humidity_raw;
  Serial.println(temperature);
  Serial.println(humidity);

This is my code
P.S Thank you for your feedback on using an iPad

There is nothing in your code which prevents it from working when not attached to a computer.
Use a USB charger or battery pack and you'll be ok.
Make sure the board turns on, because some packs need to have a certain power request from the attached device in order to turn on :slight_smile:

Good luck
u.

Thank you.......
I will do what you said and update you once I do.

I have one more doubt (which is not related to this), which is how do we control a relay from a dashboard using the switch? The relay is set to boolean (bool) but I don't know how to toggle it ON/OFF from the dashboard using a switch

To turn on a relay you should refer to a basic tutorial.
When you trigger a switch in the dashboard there is a function that is automatically generated by IoT Cloud in your Sketch .ino file

if your Thing Switch Property is called "lightSwitch" you'll have a function

void onLightSwitchChange(){

}

inside that function you can check the value of the varialble lightSwitch and if it's TRUE you'll turn on the pin for the LED, if it is FALSE you'l turn it off.

Please go through a few tutorials for IoT Cloud before posting questions to the forums.
I know you'll find the information you need

u.

Hello There again.....
I am sorry I didn't check the tutorials

void onRelayChange() {
  if (relay == true) {
    digitalWrite(relaypin, HIGH);
  }
  else {
    digitalWrite(relaypin, LOW);
  }
}

I have done what you told (at least I did what I think you told

That looks correct

The best way to know if it works is to attach an LED to that pin and see if it comes alive.
Please go through the tutorials, we get a lot of questions in this forum and cannot put too much time on helping unless a real troubleshooting is required.

Tutorials, tutorials, tutorials, we spend a lot of time making them :slight_smile:

good luck with your project
u.

I am sorry for not looking up the tutorials. And once again thank you for your time.

I will do it and update you soon.........
Thank you

P.S I can't do it now because I have school (sorry!)

You didn't post your entire sketch so I can't see if you are connected to WiFi. I have an IoT Cloud project that does something similar using a MKR WiFi 1010 and MKR ENV Shield. I included code in the sketch that was generated by IoT Cloud to connect to my WiFi network. The sketch runs fine when I disconnect from my Mac and run through WiFi. I use the IoT Remote app on my iPhone to view the dashboard.

The same would hold true if you have a GSM connection to the Internet. I'm waiting to receive the Arduino SIM for my GSM 1400 board to try it out where there is no WiFi. You will need a power source when not connected to your computer. You can use an external power supply like a 5 volt brick plugged into an AC outlet or a battery

My project uses a 2,500 mAh LiPo battery which runs for about two days in normal power mode, which draws about 100 mA due mostly to the WiFi connection. I've also done some variations of the project using low power mode for the MKR 1010 and WiFiNINA modules, which can dramatically lengthen battery time. In my case it extended it to 5 days. You have to wake up the microcontroller with some kind of interrupt when using low power modes. There are good tutorials out there on how to do that.

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