3

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.

4
  • I copied ä into notepad++ and viewed the character using the hex editor plugin ... it consists of two bytes c3 a4
    – jsotola
    Jun 24, 2023 at 15:21
  • Don't get me wrong, but what am I supposed to do with that answer? I am not deep into Arduino programming unfortunatly. Can I convert bytes into chars?
    – DaMusikant
    Jun 24, 2023 at 15:46
  • 1
    it is just information, not an answer ... an answer would be in the "answer" section ... this site is not a forum
    – jsotola
    Jun 24, 2023 at 18:25
  • 1
    convert the bytes to char and insert them into the SSID ... I have no idea if the result will work ... I would start with a known SSID that does not include problem characters ... connect the usual way to confirm connectivity ... then replace one of the characters with same character and confirm that connectivity is still good ... that will ensure that the character insertion code is valid
    – jsotola
    Jun 24, 2023 at 18:28

2 Answers 2

1

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.

1
  • Yeah, I start to belief that this is the only solution :D
    – DaMusikant
    Jun 30, 2023 at 16:03
0

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.

9
  • 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
    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
    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 mypasswmywifi
    – DaMusikant
    Jun 26, 2023 at 19:18
  • Sorry, I cant edit it for better readability. I don't get it how to do that
    – DaMusikant
    Jun 26, 2023 at 19:20
  • No worries. Let me check.
    – Fahad
    Jun 26, 2023 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.