Go Down

Topic: configuting wifi via serial monitor(ssid and password) (Read 35 times) previous topic - next topic

museigen

So, i'm using NodeMCU v1.0, and i wonder if i can change the SSID of the wifi via serial monitor..
I was expecting this similar output from serial monitor :

Code: [Select]
Input your SSID
"nodemcuAP"
Input your Password
"flippedtable"
Configure complete


This is what i'e tried so far, using different source
Code: [Select]

#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
SoftwareSerial BTserial(13, 15); // RX, TX

String ssid = "indeed"; //nama SSID
String password = "11111111";
void(* resetFunc) (void) = 0;
int x = 0;
int counter = 1;
const long baudRate = 9600;
boolean NL = true;
void setup()
{
  awal:
  Serial.begin(9600);
  BTserial.begin(baudRate);
  WiFi.softAP(ssid, password);
}
void loop()
{
awal:
  while (x < 1)
  {
    Serial.println("Initializing");
    delay(500);
    BTserial.println("Initializing");
    x++;
  }
  String s1 = Serial.readString();// s1 is String type variable.
  Serial.print("Received Data => ");
  Serial.println(s1);//display same received Data back in serial monitor.
  if (BTserial.available())
  {
    String b = BTserial.readString();

    if (b.indexOf("reboot") >= 0)
    {
      Serial.println("rebooting");
      BTserial.println("rebooting");
      x = 0;
      goto awal;
    }
    else if (b.indexOf("ping") >= 0)
    {
      Serial.println("pong");
      BTserial.println("pong");
    }
    else if (b.indexOf("ssid") >=0)//this is what i've tried changing ssid
    {
      ssid = b;
      x=0;
      resetFunc();
    }
  }
}
// i seriously have no idea about Wifi and stuff


i hope it's clear enough..
if it's not i will reply ASAP
Thank you

J-M-L

really?
Code: [Select]
     goto awal;

setup() is where the set up is done. Keep the loop for what needs to happen all the time.

I would suggest to study Serial Input Basics to handle this
Hello - Please do not PM me for help,  others will benefit as well if you post your question publicly on the forums.
Bonjour Pas de messages privés SVP, postez dans le forum directement pour que ça profite à tous

Go Up