Join Stack Overflow

By clicking “Sign up”, you agree to our terms of service and acknowledge you have read our privacy policy.

Sign up with Google

Sign up with GitHub

OR

Email

Password

Sign up

Already have an account? Log in

Skip to main content

Stack Overflow

About

Products

OverflowAI

Stack Overflow for Teams
Where developers & technologists share private knowledge with coworkers

Advertising & Talent
Reach devs & technologists worldwide about your product, service or employer brand

OverflowAI
GenAI features for Teams

OverflowAPI
Train & fine-tune LLMs

Labs
The future of collective knowledge sharing

About the company

Visit the blog

Loading…

current community

Stack Overflow

help
chat

Meta Stack Overflow

your communities

Sign up or log in to customize your list.

more stack exchange communities

company blog

Log in

Sign up

Let's set up your homepage Select a few topics you're interested in:

pythonjavascriptc#reactjsjavaandroidhtmlflutterc++node.jstypescriptcssrphpangularnext.jsspring-bootmachine-learningsqlexceliosazuredocker

Or search from our full list:

javascript

python

java

c#

php

android

html

jquery

c++

css

ios

sql

mysql

r

reactjs

node.js

arrays

c

asp.net

json

python-3.x

.net

ruby-on-rails

sql-server

swift

django

angular

objective-c

excel

pandas

angularjs

regex

typescript

ruby

linux

ajax

iphone

vba

xml

laravel

spring

asp.net-mvc

database

wordpress

string

flutter

postgresql

mongodb

wpf

windows

amazon-web-services

xcode

bash

git

oracle-database

spring-boot

dataframe

azure

firebase

list

multithreading

docker

vb.net

react-native

eclipse

algorithm

powershell

macos

visual-studio

numpy

image

forms

scala

function

vue.js

performance

twitter-bootstrap

selenium

winforms

kotlin

loops

express

dart

hibernate

sqlite

matlab

python-2.7

shell

rest

apache

entity-framework

android-studio

csv

maven

api

linq

qt

dictionary

unit-testing

asp.net-core

facebook

tensorflow

apache-spark

file

swing

class

unity-game-engine

sorting

date

authentication

go

symfony

t-sql

opencv

matplotlib

.htaccess

google-chrome

for-loop

datetime

codeigniter

http

perl

validation

sockets

google-maps

object

uitableview

xaml

oop

if-statement

visual-studio-code

cordova

ubuntu

web-services

email

android-layout

github

elasticsearch

spring-mvc

kubernetes

selenium-webdriver

ms-access

user-interface

parsing

ggplot2

pointers

machine-learning

google-sheets

c++11

security

flask

google-apps-script

ruby-on-rails-3

templates

nginx

variables

exception

sql-server-2008

gradle

debugging

tkinter

listview

delphi

jpa

asynchronous

pdf

web-scraping

haskell

jsp

ssl

amazon-s3

google-cloud-platform

jenkins

testing

xamarin

wcf

npm

batch-file

generics

ionic-framework

network-programming

unix

recursion

google-app-engine

mongoose

visual-studio-2010

.net-core

android-fragments

assembly

animation

next.js

math

session

svg

hadoop

intellij-idea

curl

django-models

join

rust

laravel-5

winapi

url

heroku

http-redirect

tomcat

google-cloud-firestore

inheritance

webpack

keras

image-processing

gcc

asp.net-mvc-4

logging

web

dom

swiftui

matrix

pyspark

actionscript-3

button

post

optimization

firebase-realtime-database

jquery-ui

iis

cocoa

xpath

d3.js

javafx

firefox

internet-explorer

xslt

caching

select

asp.net-mvc-3

opengl

events

asp.net-web-api

plot

dplyr

magento

encryption

search

stored-procedures

amazon-ec2

ruby-on-rails-4

memory

audio

canvas

multidimensional-array

jsf

random

vector

cookies

redux

input

facebook-graph-api

flash

xamarin.forms

indexing

arraylist

ipad

cocoa-touch

data-structures

video

apache-kafka

model-view-controller

serialization

jdbc

woocommerce

azure-devops

routes

razor

awk

servlets

mod-rewrite

beautifulsoup

docker-compose

excel-formula

filter

iframe

aws-lambda

design-patterns

text

django-rest-framework

visual-c++

cakephp

mobile

android-intent

react-hooks

struct

methods

groovy

mvvm

ssh

lambda

checkbox

google-chrome-extension

ecmascript-6

time

grails

installation

sharepoint

cmake

shiny

spring-security

jakarta-ee

android-recyclerview

plsql

core-data

types

meteor

android-activity

sed

websocket

bootstrap-4

activerecord

graph

replace

scikit-learn

file-upload

group-by

vim

junit

boost

deep-learning

import

sass

memory-management

error-handling

async-await

dynamic

eloquent

soap

silverlight

dependency-injection

charts

layout

apache-spark-sql

deployment

browser

gridview

svn

while-loop

google-bigquery

vuejs2

ffmpeg

dll

highcharts

view

foreach

plugins

makefile

c#-4.0

redis

reporting-services

jupyter-notebook

merge

server

unicode

https

reflection

google-maps-api-3

twitter

oauth-2.0

extjs

pytorch

axios

terminal

pip

split

cmd

mysqli

django-views

encoding

automation

database-design

netbeans

collections

hash

build

data-binding

ember.js

tcp

sqlalchemy

pdo

apache-flex

concurrency

entity-framework-core

command-line

spring-data-jpa

printing

react-redux

java-8

jestjs

service

html-table

lua

neo4j

ansible

material-ui

parameters

module

enums

visual-studio-2012

flexbox

promise

outlook

webview

firebase-authentication

web-applications

uwp

jquery-mobile

utf-8

datatable

python-requests

parallel-processing

drop-down-menu

colors

scroll

hive

scipy

tfs

count

syntax

ms-word

twitter-bootstrap-3

ssis

google-analytics

fonts

three.js

powerbi

rxjs

constructor

graphql

file-io

paypal

discord

cassandra

socket.io

graphics

compiler-errors

gwt

react-router

nlp

solr

url-rewriting

backbone.js

memory-leaks

datatables

oauth

datagridview

terraform

drupal

oracle11g

zend-framework

neural-network

knockout.js

triggers

django-forms

interface

google-api

angular-material

casting

jmeter

linked-list

path

proxy

timer

django-templates

arduino

orm

directory

visual-studio-2015

parse-platform

windows-phone-7

cron

push-notification

conditional-statements

primefaces

functional-programming

pagination

model

jar

xamarin.android

hyperlink

uiview

gitlab

visual-studio-2013

vbscript

google-cloud-functions

azure-active-directory

jwt

download

swift3

sql-server-2005

configuration

process

pygame

rspec

properties

combobox

callback

windows-phone-8

linux-kernel

safari

permissions

scrapy

raspberry-pi

scripting

emacs

clojure

x86

scope

io

compilation

mongodb-query

expo

nhibernate

responsive-design

angularjs-directive

request

azure-functions

bluetooth

3d

dns

binding

reference

architecture

discord.js

playframework

version-control

pyqt

doctrine-orm

package

get

pycharm

sql-server-2012

rubygems

f#

autocomplete

openssl

datepicker

kendo-ui

tree

jackson

controller

yii

nested

grep

xamarin.ios

static

dockerfile

statistics

transactions

datagrid

null

active-directory

uiviewcontroller

webforms

phpmyadmin

discord.py

notifications

sas

computer-vision

duplicates

mocking

youtube

nullpointerexception

yaml

menu

sum

bitmap

electron

asp.net-mvc-5

blazor

time-series

visual-studio-2008

yii2

jsf-2

css-selectors

stl

android-listview

floating-point

cryptography

ant

stream

hashmap

character-encoding

msbuild

sdk

asp.net-core-mvc

google-drive-api

selenium-chromedriver

jboss

joomla

cors

navigation

devise

anaconda

background

camera

multiprocessing

pyqt5

binary

cuda

frontend

linq-to-sql

iterator

mariadb

onclick

plotly

ios7

rabbitmq

android-jetpack-compose

android-asynctask

microsoft-graph-api

tabs

laravel-4

insert

uicollectionview

amazon-dynamodb

environment-variables

linker

console

xsd

coldfusion

upload

continuous-integration

ftp

textview

opengl-es

vuejs3

operating-system

mockito

localization

macros

formatting

xml-parsing

json.net

kivy

type-conversion

data.table

timestamp

calendar

integer

segmentation-fault

android-ndk

drag-and-drop

prolog

char

crash

jasmine

automated-tests

dependencies

geometry

android-gradle-plugin

firebase-cloud-messaging

itext

header

fortran

sprite-kit

mfc

attributes

nuxt.js

nosql

format

azure-pipelines

nestjs

odoo

db2

jquery-plugins

jenkins-pipeline

leaflet

event-handling

postman

flutter-layout

julia

annotations

keyboard

textbox

arm

visual-studio-2017

gulp

libgdx

stripe-payments

xampp

synchronization

crystal-reports

timezone

dom-events

azure-web-app-service

swagger

uikit

android-emulator

wso2

sequelize.js

namespaces

aggregation-framework

uiscrollview

jvm

google-sheets-formula

chart.js

com

subprocess

geolocation

webdriver

centos

html5-canvas

snowflake-cloud-data-platform

widget

garbage-collection

dialog

numbers

concatenation

sql-update

qml

set

windows-10

tuples

smtp

mapreduce

java-stream

ionic2

rotation

modal-dialog

spring-data

android-edittext

http-headers

doctrine

nuget

radio-button

grid

sonarqube

lucene

xmlhttprequest

internationalization

listbox

initialization

components

switch-statement

google-play

apache-camel

boolean

serial-port

ldap

ios5

youtube-api

return

gdb

latex

pivot

eclipse-plugin

tags

frameworks

containers

github-actions

dataset

asp-classic

foreign-keys

label

subquery

copy

uinavigationcontroller

c++17

delegates

google-cloud-storage

migration

struts2

base64

protractor

find

sql-server-2008-r2

queue

embedded

uibutton

arguments

composer-php

append

jaxb

zip

stack

cucumber

autolayout

ide

entity-framework-6

popup

iteration

airflow

windows-7

r-markdown

tailwind-css

ssl-certificate

vb6

gmail

hover

jqgrid

g++

udp

Next You’ll be prompted to create an account to view your personalized homepage.

Home

Questions

Tags

Discussions
Labs

Chat

Users

Companies

Collectives

Communities for your favorite technologies. Explore all Collectives

Teams

Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

Try Teams for free
Explore Teams

Teams

Ask questions, find answers and collaborate at work with Stack Overflow for Teams.
Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Hang on, you can't upvote just yet.

You'll need to complete a few actions and gain 15 reputation points
before being able to upvote. Upvoting indicates when questions and answers are useful. What's reputation and how do I get it?

Instead, you can save this post to reference later.

Save this post for later Not now

Making ESP32 WiFi/Bluetooth work together

Ask Question

Asked
4 years, 2 months ago

Modified
11 months ago

Viewed
32k times

This question shows research effort; it is useful and clear

7

Save this question.

Show activity on this post.

I'm creating a App that involves Bluetooth and WiFi. I firstly connect the Phone to the Bluetooth and pass the WiFi ssid and password through it. Then after receiving the ssid and the password I attempt to connect it to the WiFi. I manage to store the ssid and password into a char array.

After sending the data from Bluetooth, and the ESP32 making the connection with the WiFi, the Bluetooth gets disconnected. I can't connect the Bluetooth again because WiFi is connected, since I control certain statements from the code via Bluetooth.read(), I will need to allow the connection to coexist between WiFi and Bluetooth.

The project consist on SPIFFS (Flash memory saving). The WiFi ssid and password are passed from Bluetooth firstly, then, I make the connection from the Bluetooth data received into a char array, so I can connect it to the internet later on.

I thought firstly on adding a callback that alerts when the device is attempting to connect, but couldn't find in the documentation any code that was able to do so. I have a callback function that tells me when the device connects and disconnects.

I searched up and found something about Menuconfig but I couldn't find where it was located.

This is what I was reading from: https://www.espressif.com/sites/default/files/documentation/ESP32_FAQs__EN.pdf

5.3.2.
How do ESP32 Bluetooth and Wi-Fi coexist?
In the menuconfig menu, there is a special option called “Software controls WiFi/
Bluetooth coexistence”, which is used to control the ESP32's Bluetooth and Wi-Fi
coexistence using software, thus balancing the coexistence requirement for controlling
the RF module by both the Wi-Fi and Bluetooth modules. Please note that if Option
“Software controls WiFi/Bluetooth coexistence” is enabled, the BLE scan
interval shall not exceed 0x100 slots (about 160 ms).

I couldn't find where menuconfig was located.

I'm using the ```BluetoothSerial.h`` library

This is a piece of the code:

// ------------------------------ Inicialização do loop ------------------------------ //
void loop() {
// Preparando String para enviar ao usuario
line_one_length = line_one.length();
line_two_length = line_two.length();
line_three_length = line_three.length();

char receive_line_one[line_one_length], receive_line_two[line_two_length], receive_line_three[line_three_length];
char receive_wifi_ssid[line_one_length], receive_wifi_pass[line_two_length];

String deletar;

file = SPIFFS.open("/wifi.txt");

// ------------------------------ Ve se o usuario digitou a palavra deletar ------------------------------ //
if (SerialBT.available()){
while (SerialBT.available()) {
insert_chars = SerialBT.read();
deletar = String(deletar + insert_chars);
}
deletar.trim();
}

// ------------------------------ Conexão ao WiFi ------------------------------ //
if (line_one != "" and wifi_state == 0 and receive_wifi_ssid != ""){
line_one.toCharArray(receive_wifi_ssid, line_one_length);
line_two.toCharArray(receive_wifi_pass, line_two_length);
delay(100);
WiFi.begin(receive_wifi_ssid, receive_wifi_pass);
Serial.println("Conectando ao WiFi...");
while (WiFi.status() != WL_CONNECTED)
{
Serial.print(".");
delay(1000);
}
Serial.println("\nConectado ao WiFi");
wifi_state = 1;
}

Serial.print("Estado: ");
Serial.println(connection_state);

// ------------------------------ Vê se a conteudo dentro do FILE ------------------------------ //
if (file.size() > 0) {
if (deletar == "deletar"){
delete_file_info();
wifi_ssid = "";
wifi_password = "";
database_info = "";
line_one = "";
line_two = "";
line_three = "";
wifi_state = 0;
Serial.println("Arquivo deletado com sucesso");
return;
}
read_file_info();
all_lines();
}else{
if (wifi_ssid == "" and connection_state == 0 and line_one == ""){
Serial.print("File size: ");
Serial.print(file.size());
Serial.println(", O valor dentro da string é nulo, nada será adicionado ao arquivo");
delay(1000);
}else if (connection_state == 1 and line_one == ""){
// Chamando a função para armazenar os dados do usuario dentro do FILE
bluetooth_while_loop();
}
}

file.close();
delay(3000);

What I needed was to be able to make a connection between WiFi and Bluetooth simultaneously.

arduino

esp32

arduino-esp8266

arduino-c++

Share

Share a link to this question

Copy linkCC BY-SA 4.0

Follow

Follow this question to receive notifications

asked Jan 8, 2021 at 21:06

Nilton Schumacher FNilton Schumacher F

1,18033 gold badges1818 silver badges5858 bronze badges

1

I'm a bit late on the scene, but doesn't ESP32 automatically support both BT and WiFi at the same time, switching between the two on the fly as necessary? It is called "RF Coexistence", and can be found here docs.espressif.com/projects/esp-idf/en/stable/esp32/api-guides/… and here docs.espressif.com/projects/esp-faq/en/latest/… .

– Edin Fifić

Commented
Dec 22, 2024 at 5:11

Add a comment
|

Report this ad

3 Answers
3

Sorted by:

Reset to default

Highest score (default)

Trending (recent votes count more)

Date modified (newest first)

Date created (oldest first)

This answer is useful

5

Save this answer.

Show activity on this post.

The menuconfig is here. The code for software WiFi/BL coexistence is here. And the related issue is here. Because WiFi and Bluetooth use the same antenna, i wouldn't recommend doing WiFi/BL coexistence altogether. Instead, you may use WiFi.setMode(WiFi_AP_STA) to instantiate SoftAP mode and STA mode simultaneously.
Try the code below to instantiate both softAP and STA mode:

#include <WiFi.h>

void setup(){
WiFi.setMode(WIFI_AP_STA);
WiFi.begin("my-sta-ssid", "my-sta-pass");
WiFi.softAP("my-ap-ssid", "my-ap-pass");
}

void loop(){}

You can create simple WebServer to do "runtime configuration" things.

Share

Share a link to this answer

Copy linkCC BY-SA 4.0

Follow

Follow this answer to receive notifications

answered Jan 9, 2021 at 4:27

Wachid SusiloWachid Susilo

65655 silver badges1212 bronze badges

2

I need to be able to use Bluetooth and WiFi, but the point is, when I attempt to realize a Bluetooth connection with the ESP, I would need to disconnect the WiFi (When attempting to connect the Bluetooth), and after sending the data from Bluetooth I could disconnect the Bluetooth so the WiFi can take control of the antenna. I don't think that softAP would solve my problem since I don't need a access point. Maybe STA can solve the problem, but I'm not sure...

– Nilton Schumacher F

Commented
Jan 11, 2021 at 4:22

1

I had a similar problem. Using WiFi to find get some clients and then sharing a BT-UUID so that only the selected client had access to the ESP device. I now use 2 ESPs: one with WiFi and one with BT connected via serial interface. Maybe this could be a solution for you too.

– Adriano

Commented
Jan 11, 2021 at 13:46

Add a comment
|

This answer is useful

0

Save this answer.

Show activity on this post.

Well.. Your question remains, but your use case though.. Seems a lot like BluFi.

The BluFi for ESP32 is a Wi-Fi network configuration function via Bluetooth channel. It provides a secure protocol to pass Wi-Fi configuration and credentials to ESP32. Using this information, ESP32 can then connect to an AP or establish a SoftAP.

Fragmenting, data encryption, and checksum verification in the BluFi layer are the key elements of this process.

Share

Share a link to this answer

Copy linkCC BY-SA 4.0

Follow

Follow this answer to receive notifications

answered Feb 13, 2023 at 13:03

ArjanWArjanW

44344 silver badges1919 bronze badges

Add a comment
|

This answer is useful

0

Save this answer.

Show activity on this post.

Esp32 has own solution for configuring WiFi via Ble app Espressif

https://docs.espressif.com/projects/esp-idf/en/stable/esp32/api-reference/provisioning/wifi_provisioning.html

Share

Share a link to this answer

Copy linkCC BY-SA 4.0

Follow

Follow this answer to receive notifications

answered Apr 10, 2024 at 6:02

Karel FundaKarel Funda

2933 bronze badges

2

Please give more details, what is the solution without needing to follow your link?

– mozway

Commented
Apr 10, 2024 at 8:36

Could you edit your answer to include the key points from the link ? If the link goes stale, it's difficult for people with the same issue to read up on it.

– KeyboardCat

Commented
Apr 11, 2024 at 12:17

Add a comment
|

Your Answer

Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid …

Asking for help, clarification, or responding to other answers.

Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved

Draft discarded

Sign up or log in

Sign up using Google

Sign up using Email and Password

Submit

Post as a guest

Name

Email

Required, but never shown

Post Your Answer

Discard

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

arduino

esp32

arduino-esp8266

arduino-c++

See similar questions with these tags.

The Overflow Blog

“The power of the humble embedding”

Featured on Meta

Policy: Generative AI (e.g., ChatGPT) is banned

19 people chatting

Linked

8

acquire a semaphore for the esp32 antenna (bluetooth/wifi dualmode)

Related

0

ESP32: Error when trying to connect to Web server via Wifi while Bluetooth is on: bcn_timout, alloc fail

1

ESP32 to ESP32 AP/client WiFi connection problem

-1

ESP32 to ESP32 WiFi Server/Client Problem

1

ESP32 iPhone Bluetooth, just a general question

3

WiFi.h with esp32

2

ESP32 using BLE and WiFi alternately

2

How to use Bluetooth with ESP32 & NodeMCU in Lua

4

Android + ESP32 send data over bluetooth (BLE)

0

BLE using ESP 32

0

Bluetooth reboots ESP32 when connecting

Hot Network Questions

Which tradition invented the term "Reverend" for their clergy?

Relevance of genetic algorithms in modern research

Is there a German word for "life" as in "life in the universe"?

What are some common conventions in quantum computing?

Is there a name for the following argument that observing (P & Q) implies there is evidence of (P implies Q)?

Dissertation data dilemma: 2 X 2 between subjects ANOVA significant interaction yet no main effects. How do I interpret this?

Is the camcorder in Severance based on a real-life model?

How to write a protagonist like Joseph K from The Trial, and still make the story compelling?

What is "fighting" for purposes of Charm Person / Monster spells?

Can warlock use 2 attacks with eldritch blast at lvl 8

Water cycle without sun on an Earth-like planet?

Can Elemental Cleaver, Mighty Impel, and Tavern Brawler be used in conjuction?

What does "dikaiosynen" mean in Romans 10:10?

Best way to publish an open-access text book

What answers for the issue of textiles might a village of tiny 5 inch people find?

6 month rule when flying back home

How to display duplicate lines with different IDS

What does "200 nanoseconds of simulation" mean?

Installation help on very old style Ortlieb handlebar mount

Bech32 error detection and correction reference implementation

Why do sonic booms happen at speeds significantly faster than the speed of sound?

Frame of discrete curve

Round Cut diamond 3D

Determinant in latex

Question feed

Subscribe to RSS

Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

Stack Overflow

Questions

Help

Chat

Products

Teams

Advertising

Talent

Company

About

Press

Work Here

Legal

Privacy Policy

Terms of Service

Contact Us

Cookie Settings

Cookie Policy

Stack Exchange Network

Technology

Culture & recreation

Life & arts

Science

Professional

Business

API

Data

Blog

Facebook

Twitter

LinkedIn

Instagram

Site design / logo © 2025 Stack Exchange Inc;
user contributions licensed under
CC BY-SA
.
rev 2025.3.26.24455