• Skip to main content
  • Skip to primary sidebar

RNTLab.com

The Ultimate Shortcut to Learn Electronics and Programming with Open Source Hardware and Software

  • Courses
  • Forum
    • Forum
    • Ask Question
  • Shop
  • Account
  • Blog
  • Login

SSID

Q&A Forum › Category: ESP32 › SSID
0 Vote Up Vote Down
Robert Barbirič asked 3 years ago

Hello,
A cant figure it out how to use char* for SSID name.
Example:
String SN = “20210000”;
char* esp_ssid = “myNetwork”;
So, ESP will create Access point with name myNetwork. I want my SSID name to be myNetwork-20210000.
I tried:
char* esp_ssid = “myNetwork” + SN; or
char* esp_ssid = (“myNetwork-” + SN).c_str();
None works. Can you help me please.
Best regards,
Robert

3 Answers
0 Vote Up Vote Down
Bernie answered 3 years ago

Yes, I have the same problem.  How does one convert String to char *?
c_str() does not seem to be in the library.

0 Vote Up Vote Down
Bernie answered 3 years ago

The following compiles, and surely works:

String SN = “20210000”;
const char *esp_ssid = (“myNetwork-” + SN).c_str();

Note the “const” for the char * pointer.

But you are better off not using String, and esp_ssid does not have to be const:

char esp_ssid[32];
char *SN = "20220000";
strcopy(strcopy(esp_ssid, “myNetwork-”), SN);

where

char *strcopy(char *p, const char *s) {
  while (*s != '\0') *p++ = *s++;
  *p = '\0';
  return p;
}
0 Vote Up Vote Down
Sara Santos Staff answered 3 years ago

Hi.
Bernie, thanks for answering.
Robert, can I close this issue?
Regards,
Sara

Primary Sidebar

Login to Ask or Answer Questions

This Forum is private and it’s only available for members enrolled in our Courses.

Login »

Latest Course Updates

  • [eBook Updated] Learn Raspberry Pi Pico/Pico W with MicroPython eBook – Version 1.2 May 26, 2025
  • [New Edition] Build ESP32-CAM Projects eBook – 2nd Edition April 16, 2025

You must be logged in to view this content.

Contact Support - Refunds - Privacy - Terms - MakerAdvisor.com - Member Login

Copyright © 2013-2025 · RandomNerdTutorials.com · All Rights Reserved

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.