I have a Feather Huzzah, aka ESP8266, that I am trying to connect to the Wifi.
One major thing is, that my landlord decided to use the worst Wifi SSID and PW.
The SSID contains an ä and a whitespace, and the PW an @.
I scanned successfully the Wifi with the board and the prewritten code and the Wifi shows up.
Now I am using the Wifi client basic, just to check if any connection can established.
I tried to write all special characters in Unicode, but still no change.
Here is my code:
/*
This sketch sends a string to a TCP server, and prints a one-line response.
You must run a TCP server in your local network.
For example, on Linux you can use this command: nc -v -l 3000
*/
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#ifndef STASSID
#define STASSID "XXX XXäXX" //original SSID
#define STASSID "XXX XX\u00e4XX" //Unicode SSID
#define STAPSK "XXX@XXX" //Orginal PW
#define STAPSK "XXX@XXX" //Unicode PW
#endif
const char* ssid = STASSID;
const char* password = STAPSK;
const char* host = "192.168.1.1";
const uint16_t port = 3000;
ESP8266WiFiMulti WiFiMulti;
void setup() {
Serial.begin(115200);
// We start by connecting to a WiFi network
WiFi.mode(WIFI_STA);
WiFiMulti.addAP(ssid, password);
Serial.println();
Serial.println();
Serial.print("Wait for WiFi... ");
while (WiFiMulti.run() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
delay(500);
}
void loop() {
Serial.print("connecting to ");
Serial.print(host);
Serial.print(':');
Serial.println(port);
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(host, port)) {
Serial.println("connection failed");
Serial.println("wait 5 sec...");
delay(5000);
return;
}
// This will send the request to the server
client.println("hello from ESP8266");
// read back one line from server
Serial.println("receiving from remote server");
String line = client.readStringUntil('\r');
Serial.println(line);
Serial.println("closing connection");
client.stop();
Serial.println("wait 5 sec...");
delay(5000);
}
Thank you for any help, and greetings from Sweden.
2 Answers 2
I don't have enough reputation to comment, otherwise this would be a comment, but you could ask your landlord to change the password. If he says no, you could say one of your devices can't type that character.
-
Yeah, I start to belief that this is the only solution :DDaMusikant– DaMusikant2023年06月30日 16:03:51 +00:00Commented Jun 30, 2023 at 16:03
Start with a known simple SSID, and try this:
#define STASSID "mywifi" // For example this is the known SSID that connects
... ... ...
const char ssid[] = "mywifi";
If that works, then you can replace the char
with hex.
const char ssid[] = {0x6D, 0x79, 0x77, 0x69, 0x66, 0x69};
If that works then you can replace the hex bytes with your actual SSID. And in the place of ä
use those two hex bytes as jsotola mentioned, 0xC3
and 0xA4
.
Edit 1:
From the comment, it looks like the receiver never connects to the WiFi. In the receiver hardware, try something simple and see if it gets connected at all or not.
#include <ESP8266WiFi.h>
void setup()
{
Serial.begin(115200);
Serial.println();
WiFi.begin("network-name", "pass-to-network");
Serial.print("Connecting");
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Connected, IP address: ");
Serial.println(WiFi.localIP());
}
void loop() {}
Check what output you get.
-
Good hint. I connected the board to the Hotspot of my phone and it worked. So good so far. But when I try my local wifi again, I does not like it. I replaced the const char ssid[] and password with raw hexadezimals and ran it trough several converters. When I print it out it looks fine. But when i print out the password it is the correct password + the ssid again?! Like it is one variable, added together? Is that only due to the serial printout?DaMusikant– DaMusikant2023年06月26日 19:04:47 +00:00Commented Jun 26, 2023 at 19:04
-
That doesn't sound right. Can you post the code that you mentioned in the comment where the password prints both password and SSID?Fahad– Fahad2023年06月26日 19:10:59 +00:00Commented Jun 26, 2023 at 19:10
-
#ifndef STASSID #define STASSID {0x6D, 0x79, 0x77, 0x69, 0x66, 0x69} #define STAPSK {0x6D, 0x79, 0x70, 0x61, 0x73, 0x73, 0x77} #endif const char ssid[] = STASSID; const char password[] = STAPSK; ... ... ... Serial.print("Connecting to "); Serial.print(ssid); Serial.print(" "); Serial.print(password); Connecting to mywifi mypasswmywifiDaMusikant– DaMusikant2023年06月26日 19:18:25 +00:00Commented Jun 26, 2023 at 19:18
-
Sorry, I cant edit it for better readability. I don't get it how to do thatDaMusikant– DaMusikant2023年06月26日 19:20:09 +00:00Commented Jun 26, 2023 at 19:20
-
ä
into notepad++ and viewed the character using the hex editor plugin ... it consists of two bytesc3 a4