• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » ESP32 Arduino Wi-Fi Access Point with Wi-Fi Connection (Station)

By Abhishek Ghosh April 28, 2019 12:18 am Updated on April 28, 2019

ESP32 Arduino Wi-Fi Access Point with Wi-Fi Connection (Station)

Advertisement

It is possible to setup ESP32’s Wi-Fi to access point and station. ESP32 can connect to another hotspot and share the connection. An access point (AP) is a networking hardware device which allows other Wi-Fi devices to connect to a network. Some basic theory required to know for making basic code better.

An AP is different from a hotspot.
Hotspot is the physical location (and the device) where Wi-Fi access to a WLAN is available. SoftAP or software enabled access point is software enabling a
device which is not router but creates access point by software/coding. Wireless access has special security considerations. Many wired networks base the security on physical access control. Modern access points come with built-in encryption. The first generation encryption scheme, WEP, proved easy to crack; the second and third generation schemes, WPA and WPA2, are considered secure if a strong enough password or passphrase is used.

ESP32 Arduino Wi-Fi Access Point with Wi-Fi Connection

What is the usage? If we have one ESP32 running as an access point (AP) and a second ESP32 running as a station (STA). When the access point (AP) ESP32 starts up and the STA ESP32 connects to it, then we should be able to form a connection from a client application running on AP. This actually increase the range in some specific use-case.
We can set a soft AP using the ESP32 and the Arduino core. This way, other devices can connect to the ESP32 without the need to connect to a router. This is soft AP :

Advertisement

---

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include "WiFi.h"
const char *ssid = "MyESP32AP";
const char *password = "testpassword";
void setup() {
  Serial.begin(115200);
  WiFi.softAP(ssid, password);
  Serial.println();
  Serial.print("IP address: ");
  Serial.println(WiFi.softAPIP());
}
void loop() {}

Basic example code for ESP32 Arduino is like below :

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <WiFi.h>
#include <WiFiAP.h>
 
 
const char* ssid     = "wifi name"; // the esp will be connected to
const char* password = "wifi password"; // the password of it
 
const char* assid = "AccessPoint"; // devices will connect
const char* asecret = "something"; // password for it
 
void setup(){
  Serial.begin(115200);
  
  WiFi.mode(WIFI_AP_STA);
 
  //access point
  Serial.println("Creating Accesspoint");
  WiFi.softAP(assid,asecret,7,0,5);
  Serial.print("IP address:\t");
  Serial.println(WiFi.softAPIP());
 
  //station
  Serial.print("connecting to...");
  Serial.println(ssid);
 
  WiFi.begin(ssid,password);
 
  while(WiFi.status() != WL_CONNECTED){
    delay(500);
    Serial.print(".");
  }
 
  Serial.println("");
  Serial.println("WiFi connected");
  Serial.println("IP address: ");
  Serial.println(WiFi.localIP());  
  
}
 
void loop(){
  
}

ESP32 WIFI_AP_STA mode has known issues which results to the condition of not working as intended. This is related to the fact that STA will switch to the channel of the AP it is trying to connect to, and SoftAP will have to switch to the same channel. So the client will have to reconnect to the SoftAP on its new channel. In most cases this causes TCP connections to be reset.

Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <WiFi.h>
#include <WiFiClient.h>
#include <WebServer.h>
#include "esp_log.h"
 
const char* ssid = "your ssid";
const char* password = "password";
 
WebServer server(80);
 
void setup(void) {
 
Serial.begin(115200);
esp_log_level_set("*", ESP_LOG_VERBOSE);
WiFi.mode(WIFI_AP_STA);
WiFi.softAP("new_TEST","43255234",6);
WiFi.begin(ssid, password);
Serial.println("");
// Wait for connection
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.print("Connected to ");
Serial.println(ssid);
Serial.print("IP address: ");
Serial.println(WiFi.localIP());
}
 
void loop(void) {
}

Tagged With arduino wifi access point , esp32 wifi , esp32 connect wifi , duino softap , arduino wifi begin , esp32 arduino baord wifi access point , esp32 wifi SSID , Node js Aduino ESP32 AP , esp32 access point , esp32 arduino wifi example
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to ESP32 Arduino Wi-Fi Access Point with Wi-Fi Connection (Station)

  • WROOM ESP32 Example Codes For IBM Watson IoT Platform

    Here Are Few WROOM ESP32 Example Codes For IBM Watson IoT Platform So That Anyone Can Get Started With Both of Them Without Huge Experience.

  • How to Control Multiple Relays With Single Arduino ESP32?

    Before How to Control Multiple Relays With Single Arduino ESP32 Testing, You Need to Learn How to Create Multiple MQTT Channels & Fetch Data.

  • Connecting ESP32 Arduino with DHT11 with IBM Watson IoT

    Earlier, we described how to create graph on IBM Watson IoT dashboard by using the default widgets. In previous guide, we described how to use ESP32 Arduino with DHT11 sensor. Here is the Code and Diagram to Connect ESP32 Arduino with DHT11 with IBM Watson IoT and Get Odometer Like Gauges on Dashboard. For this […]

  • Detect Smartwatch With ESP32 on IBM Watson IoT Widget

    In our previous guide, we have shown that we can trigger ESP32 (with Arduino IDE) to send message to IBM Watson IoT in Presence of a Particular Samsung Galaxy Smartwatch. That process involves BLE and WiFi. In our one series of articles on Samsung Smartwatch as Proximity Switch, we triggered a local event, such as […]

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy