Dont' connect to Mobile Hotspot

Hey everyone,

I have some issues with connecting my Arduino to the WI-FI, the code looks fine, while compiling no errors. What maybe important to know is that I use Mobile Hotspot for this. So, when I turn on Mobile Hotspot on my phone and see this connection on the computer, I don't see any sign that Arduino connected to it. How to check or know that it was connected or no eventually? Is there any good tutorial for that you could share? Here is the code:

#include <SPI.h>
#include <WiFiNINA.h>
#include <WiFiUdp.h>
#include <CapacitiveSensor.h>

// WiFi credentials
#include "arduino_secrets.h"
char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)

// CapacitiveSensor setup
CapacitiveSensor cs_2_4 = CapacitiveSensor(2, 4); // 10 megohm resistor between pins 4 & 2, pin 2 is sensor pin, add wire, foil

// UDP setup
int status = WL_IDLE_STATUS;
unsigned int localPort = 2390; // local port to listen on
char packetBuffer[256]; // buffer to hold incoming packet
char ReplyBuffer[] = "acknowledged"; // a string to send back
WiFiUDP Udp;

void setup() {
Serial.begin(9600);

// CapacitiveSensor setup
cs_2_4.set_CS_AutocaL_Millis(0xFFFFFFFF); // turn off autocalibrate on channel 1 - just as an example

// WiFi setup
while (status != WL_CONNECTED) {
Serial.print("Attempting to connect to SSID: ");
Serial.println(ssid);
status = WiFi.begin(ssid, pass);
delay(10000); // wait 10 seconds for connection
}

Serial.println("Connected to WiFi");

// UDP setup
Udp.begin(localPort);
printWifiStatus();
Serial.println("\nStarting connection to server...");
}

void loop() {
// CapacitiveSensor reading
long total1 = cs_2_4.capacitiveSensor(30);

// UDP packet handling
int packetSize = Udp.parsePacket();
if (packetSize) {
Serial.print("Received packet of size ");
Serial.println(packetSize);
Serial.print("From ");
IPAddress remoteIp = Udp.remoteIP();
Serial.print(remoteIp);
Serial.print(", port ");
Serial.println(Udp.remotePort());
int len = Udp.read(packetBuffer, 255);
if (len > 0) {
packetBuffer[len] = 0;
}
Serial.println("Contents:");
Serial.println(packetBuffer);
Udp.beginPacket(Udp.remoteIP(), Udp.remotePort());
Udp.write(ReplyBuffer);
Udp.endPacket();
}

// Serial print total1 (CapacitiveSensor reading)
Serial.print(total1); // check on performance in milliseconds
Serial.print("\n"); // tab character for debug window spacing
delay(10); // arbitrary delay to limit data to serial port
}

void printWifiStatus() {
// print the SSID of the network you're attached to
Serial.print("SSID: ");
Serial.println(WiFi.SSID());

// print your board's IP address
IPAddress ip = WiFi.localIP();
Serial.print("IP Address: ");
Serial.println(ip);

// print the received signal strength
long rssi = WiFi.RSSI();
Serial.print("Signal strength (RSSI): ");
Serial.print(rssi);
Serial.println(" dBm");
}

Thank you a lot in advance!

Are you getting anything on the serial monitor ? You have it sending status msgs so you
should see it trying to connect.
You could remove all code except the code that connects to wifi. Then go from there.

Hey,

Here is something what I see on serial monitor, does not look like trying to connect. What will you say?

Sketch uses 21872 bytes (8%) of program storage space. Maximum is 262144 bytes.
Global variables use 3676 bytes (11%) of dynamic memory, leaving 29092 bytes for local variables. Maximum is 32768 bytes.
Atmel SMART device 0x10010005 found
Device : ATSAMD21G18A
Chip ID : 10010005
Version : v2.0 [Arduino:XYZ] Mar 19 2018 09:45:14
Address : 8192
Pages : 3968
Page Size : 64 bytes
Total Size : 248KB
Planes : 1
Lock Regions : 16
Locked : none
Security : false
Boot Flash : true
BOD : true
BOR : true
Arduino : FAST_CHIP_ERASE
Arduino : FAST_MULTI_PAGE_WRITE
Arduino : CAN_CHECKSUM_MEMORY_BUFFER
Erase flash
done in 0.832 seconds

Write 21872 bytes to flash (342 pages)

[===== ] 18% (64/342 pages)
[=========== ] 37% (128/342 pages)
[================ ] 56% (192/342 pages)
[====================== ] 74% (256/342 pages)
[============================ ] 93% (320/342 pages)
[==============================] 100% (342/342 pages)
done in 0.167 seconds

Verify 21872 bytes of flash with checksum.
Verify successful
done in 0.020 seconds
CPU reset.

Hi @readheadsthoughts.

The text you shared is what is printed in the "Output" view in the bottom panel of the Arduino IDE window during a successful upload. Although the location of the "Serial Monitor" view is also the bottom panel, this is a completely different thing than the "Output" view.

The bottom panel has a tabbed design. Check to see if there is already a "Serial Monitor" tab in the bottom panel's toolbar:

image

If so, just click on that tab, which will make the "Serial Monitor" view visible.

If you don't see a "Serial Monitor" tab, then simply select Tools > Serial Monitor from the Arduino IDE menus (or click the icon that looks like a magnifying glass at the right side of the Arduino IDE toolbar) to open the "Serial Monitor" view.

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