• 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

How to know and/or Set the wifi channel on an ESP32 ?

Q&A Forum › How to know and/or Set the wifi channel on an ESP32 ?
0 Vote Up Vote Down
paulfjujo asked 1 month ago

hello,
if ESP32 can see the WIFI LANs  around it ( ie: with Wifiscan application ) ..thet means  EPS32 receiving…. is OK
but if no way to connect it  to my Wifi Lan (with other applications  like Webserver,   websocket …etc …,)
is it possible that problem is due to a bad Channel number … so can’t reach my wifi lan
my Wifi LAN  channel is 11.
wifiscan result

Start your code here

rst:0x1 (POWERON_RESET),boot:0x17 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0030,len:1184
load:0x40078000,len:12776
load:0x40080400,len:3032
entry 0x400805e4
WIFISCAN version : 19-02-2023
Hardware : ESP32 <Bleu> VROMM-32 DEVKITV1 30 pins
Aduino IDE V 1.8.19
Set WiFi to STAtion
PORT OPEN 115200
Communication with MCU..Got answer! Communication with MCU established.
AutoDetect firmware…
Can’t autodetect firmware, because proper answer not received (may be unknown firmware).
Please, reset module or continue.
can start
scan done
3 networks found
1: ON_AIR2022 (-67)*
2: DIRECT-K8-BRAVIA (-73)*
3: sainmo4958 (-94)*
scan start
scan done
2 networks found
1: ON_AIR2022 (-68)*
2: DIRECT-K8-BRAVIA (-72)*

---------------------------------------
i can now confirm : probleme is channel number 
whis another application on ESP32
https://1drv.ms/u/s!AgSdoVts608TiTm0yfpFv7kpb4xv?e=VZjFhA
i get with a Android wifi scanner

Appli Android Wifi Man Liste Wifi
On AIR2022 canal 11 -62 db CH11 2432-2472 ( My WifiLAN)
DIRECT-K8-BRAVIA canal 11 -74db (TV)
et aussi :
ESP_8DC995 canal 1 -47db 
MAC adress : 08:3A:F2:8D:C9:95 <- ESP32 bleu !!
CH1 : 2402-2442 Mhz

so,now y question is:
How to change this channel number on ESP32?
( i don't want to change the channel on  my personnal WLAN (freebox config)

3 Answers
0 Vote Up Vote Down
Sara Santos Staff answered 1 month ago

Hi.
I think you need the following two lines:

wifi_promiscuous_enable(1);
wifi_set_channel(channel);

In which CHANNEL is the new wi-fi channel you want to set.
Let me know if this helps.
Regards,
Sara

0 Vote Up Vote Down
paulfjujo answered 1 month ago

hello Sara,
Sorry, this doesn’t work .. i get compile error , commande not reconnized
i tested this
change value in
C:\Users\Paul\AppData\Local\Arduino15\packages\esp32\hardware\esp32\2.0.2\libraries\WiFi\src\WiFiGeneric.h
WiFiGeneric.h
bool initiateFTM(uint8_t frm_count=16, uint16_t burst_period=2, uint8_t channel=11, const uint8_t * mac=NULL);
channel value was 1, changed to 11 but no effect ..
My ESP32 is seeing as ESP_8DC9595 Channel 1 as WIFI LAN

what is also strange because at compile, Chip is ESP32-D0WDQ6 (revision 1) Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse, Coding Scheme None Crystal is 40MHz MAC: 08:3a:f2:8d:c9:94
ESP name ended with 95 instead of 94
The channel change  in the code *.h , has NO effect

i think the solution is not so far … but where ?

0 Vote Up Vote Down
Sara Santos Staff answered 1 month ago

I’m sorry. I copied the wrong instructions.
You need to include this:

#include <esp_wifi.h>

Then, use the following after setting the WiFi mode

WiFi.printDiag(Serial); // Uncomment to verify channel number before
esp_wifi_set_promiscuous(true);
esp_wifi_set_channel(REPLACE_WITH_CHANNEL_NUMBER, WIFI_SECOND_CHAN_NONE);
esp_wifi_set_promiscuous(false);
WiFi.printDiag(Serial); // Uncomment to verify channel change after

Let me know if this helps.
 
We used that snippet in this project and it worked fine.
 
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] SMART HOME with RPi, ESP32, and ESP8266 (version 1.2) March 8, 2023
  • [eBook Updated] ESP32-CAM Projects (version 1.3) January 7, 2023

You must be logged in to view this content.

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

Copyright © 2013-2023 · 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.