Hello, I'm working on a project where I can remotely toggle a relay from any given distance. I managed to get the code to work on my house's WIFI network however that limits its overall range. I was wondering if there was a way to get the board to connect to my mobile hotspot so I could use it wherever I have service.
The board I'm using is a HiLetgo ESP32-WROOM-32D
I don't think its needed for this problem but here's the code
/*
Sketch generated by the Arduino IoT Cloud Thing "Untitled"
https://create.arduino.cc/cloud/things/32781389-40a5-49db-942e-b3eb8be81091
Arduino IoT Cloud Variables description
The following variables are automatically generated and updated when changes are made to the Thing
CloudSwitch arm;
CloudSwitch launch;
CloudLight 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"
void setup() {
pinMode(LED_BUILTIN, OUTPUT);
pinMode(2, OUTPUT);
// 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();
if (arm == 1) {
if (launch == 1) {
digitalWrite(2, HIGH);
Serial.println("Launching");
}
else
{
digitalWrite(2, LOW);
Serial.println("Waiting");
}
Serial.println("Armed");
delay(1000);
}
else
{
Serial.println("Not Armed");
delay(1000);
}
}
void onArmChange() {
// Do something
}
void onLaunchChange() {
// Do something
}
void onLEDChange() {
// Do something
}
Any help would be appreciated.
Matt.
P.s. If there is another solution that is easier or better please don't hesitate to tell me.
How would I go about setting that up?
For the Arduino IoT all I need is a network SSID and a password for that network and if it works then it will function as intended otherwise it will keep trying to connect but ultimately fail.
Actually scratch that, I didn’t understand the reply at first. The problem is the board doesn’t always have a connection to wifi. Thanks to the Arduino IoT cloud as long as the board is on the same network I put into the code, my phone can be on any network and still communicate with the board. That being said it makes it so I have to keep the board on the same network or else I will need to change the network in the code which I won’t always be able to do. That’s why I was trying to see if I could set it up through my mobile hotspot.
Yeah, I changed the SSID to what I’m assuming is the name of the hotspot and I changed the password to the password I set. After changing those I uploaded it and in the serial monitor it said it failed to connect and that it was trying again in 500ms. I’m using iOS for the hotspot and I’m using the name for the hotspot that displays on other phones in the wifi tab as the SSID, which is the name of my phone. I’m not sure if that is actually the SSID of the hotspot or not.
Thanks.
I'll provide some instructions you can use to determine whether the hotspot is visible to your ESP32, and what its SSID is. Since you are using Arduino IoT Cloud, I'll provide the instructions for doing this using Arduino Web Editor, but if you prefer the desktop Arduino IDE, the equivalent procedure also applies.
Taking the first network on that list for an example:
The "IoTNetwork" part is the SSID.
The "(-62)" part is the RSSI, which indicates the signal strength and might be useful for troubleshooting connection problems caused by too weak of a signal from the WiFi access point.
The "*" indicates that password is required to connect to the access point.
I managed to fix it and it seems that the problem was the SSID of my hotspot had special characters in it so I removed those characters and it worked after that. Thanks for the help though! I’ll be sure to look back to this is the problem comes up again.