ESP8266 as access point

Hello blynkers. Im working on a project and need your help. I want to use the esp8266 and blynk app without connecting to the internet/router. So far i figured I should set esp8266 as an AP and connect blynk app using IP or other authentification. Then maybe I will be able to directly switch an LED using blynk app connected to esp. Am I on the right track? Can someone help me for setup? Thank you

I used this as reference:
///////////////////////////////////////////
Change you sketch

Blynk.begin(auth, “you_host”);
or

Blynk.begin(auth, IPAddress(xxx,xxx,xxx,xxx));
//////////////////////////////////////////////////////////////////////////////////////

 #include <ESP8266WiFi.h>
    #include <BlynkSimpleEsp8266.h>
    // You should get Auth Token in the Blynk App.
    // Go to the Project Settings (nut icon).
    char auth[] = "8d82695bxxxxxxxxx";
    const char* ssid     = "esp12";
    const char* password = "09xxxxx3";
    void setup() {
      Serial.begin(9600);
      WiFi.softAP(ssid, password);
      Serial.println();
      Serial.println(WiFi.softAPIP());
      Serial.println();
      Blynk.begin(auth, IPAddress(192,168,4,1));
      while (!Blynk.connect()) {
        // Wait until connected
      }
    }
    
    void loop() {
      // put your main code here, to run repeatedly:
     Blynk.run();
    }

with this code it throws the following error:

no matching function for call to 'BlynkWifi::begin(char [33], IPAddress)'

is this code ok? or do I need to use

IPAddress server_ip (10, 0, 0, 10);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 10,   0,   0,  20);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 10,   0,   0,   1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  //Blynk.begin(auth, "server.org", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

As far as I can tell, the Blynk library needs to talk to a server, and can’t just talk from the library to the app. So unless you have a Blynk server running on your phone, I don’t think it will work.

@Rahul, CptanPanic is right, this is not possible right now. But we will add support of bluetooth someday so you’ll be able to do that without server. But still you could install local server within your local network, so you could connect app with hardware without internet but via router if that what you need.

Oh… Is it so?
How to proceed with sketch in arduino? do i need to set up as below if I use esp-12 standalone?

IPAddress server_ip (10, 0, 0, 10);

// Mac address should be different for each device in your LAN
byte arduino_mac[] = { 0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED };
IPAddress arduino_ip ( 10,   0,   0,  20);
IPAddress dns_ip     (  8,   8,   8,   8);
IPAddress gateway_ip ( 10,   0,   0,   1);
IPAddress subnet_mask(255, 255, 255,   0);

void setup()
{
  Serial.begin(9600);
  Blynk.begin(auth, server_ip, 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
  // Or like this:
  //Blynk.begin(auth, "server.org", 8442, arduino_ip, dns_ip, gateway_ip, subnet_mask, arduino_mac);
}

or is the above code only for ethernet?
can I only login with the ip and port on app and simply run blynk.run() etc in sketch?

@Rahul

For any case you need we have an example sketch =). For ESP standalone use this one. Hope this helps.

can I only login with the ip and port on app

Do you mean direct connection between app and hardware?

app and hardware separately connected to server…I changed to server in app and input ip/port but everytime I try to connect the app says" Request Timeout:: server don’t respond in time"

or when I try this in sketch

Blynk.begin(auth, IPAddress(192,168,4,1), 80);

this error is occurs : invalid user-defined conversion from 'IPAddress' to 'const char*' [-fpermissive]

@Rahul

Do you connect to local server? Does your server behind WI-FI router?

For ESP use this sketch.

OK I’ve been trying to set up local server for some days now… I don’t think it works. When I put the IP in Blynk.begin(auth, IPAddress(192,168,4,1), 80); the sketch does not compile…

I want to try a new way around… Can you please guide me or tell me if what I/m trying is even possible :smiley:

Here is the new approach I want to try:

  1. Set ESP as access point and provide a server on it
    I want to implement this sketch check it on github
  2. with above up and running, use configured IP and Port to connect app to server on ESP
  3. Try to blink a LED without access to internet or a separate router… Just using esp and iphone

This has been successful using nodemcu firmware and lua scripts… however they connect to IP on browser whereby and index.html provides interface for interacting and then trigger an action such as set specific gpio HIGH or LOW

I am really frustrated right now… Been trying this on blynk. that is set server, and access point… connect phone to esp then use the blynk app to trigger gpio output instead of using browser

hey, do i use Blynk.begin(auth, "ssid", "pass"); even if i’m trying to connect to local server without internet access?

just try writing “192.168.4.1” as text. It should work.

hey there… is it like this? cause I still get same problem

well, sorry, actually it should be Blynk.begin(auth, “ssid”, “pass”, “host”, port);
using IPAddress should also work

have you been able to set up something like this/?
and what should I write for host? 192.168.4.1?
when I use the ESP as access point and wifi server alone, and connect using web browser, everything works fine but as soon as I try to implement blynk code, the sketch either compliles without error or throws those invalid error

above pic is my iphone connected to access point…

I have been tinkering… still no luck… even changed esp mode to both ap and station
using serial to monitor, seems to hang at blynk.begin()
here is code for setup

void setup() {
  delay(1000);
  Serial.begin(115200);
  Serial.println();
  WiFi.mode(WIFI_AP_STA);
  Serial.println("mode is ap and station");
  Serial.println("begin wifi...");
  WiFi.begin(ssid, password);
  
   Serial.println("Configuring access point...");
  /* You can remove the password parameter if you want the AP to be open. */
  WiFi.softAP(ssid, password);
  IPAddress myIP = WiFi.softAPIP();
  Serial.print("AP IP address: ");
  Serial.println(myIP);
  server.on("/", handleRoot);
  server.begin();
  Serial.println("HTTP server started");
  Serial.println("blynking...");
  
  Blynk.begin(auth, ssid, password, "192.68.4.1", 80);
  Serial.println("blynking done...");
  
}

here is monitor

Hi. Reading the thread once again, I understand your problem.
Unfortunately this scenario won’t work right now, as the App uses SSL connection to the server.
So it will never connect (Arduino for ESP has only TCP server as of writing).
If it had SSL, then the steps would be:

  1. Create a User Defined Connection (there is an example for that)
    this should be a server SSL listener
  2. Modify BlynkProtocol.h to handle server-side authentication
    (these are small changes and we will include them later I think)

This could be done (with ordinary TCP) if App allowed non-SSL connections (but it doesn’t, yet).
@Pavel, @Dmitriy what do you think?

1 Like

Thank you so much for such a detailed respons @vhymanskyy I appreciate it… It would be awesome if this could be available because I plan on using the priject outiside and using iphone running app as a remote :smiley: thank you again