Is it possible to use ESP-NOW and conenct to a WiFi network

hassan1551
Posts: 2
Joined: Mon Aug 10, 2020 12:17 pm

Is it possible to use ESP-NOW and conenct to a WiFi network

Postby hassan1551 » Tue Apr 27, 2021 10:29 pm

I would like to ask some about something that did not work out for me. I am using PlatformIO. I have been trying to use one ESP32 to communicate with an ESP8266 using ESP-NOW and report back to a Wifi network that the ESP32 will connect to. This is a code that only initializes the ESP-NOW, without connecting to a Wifi network on the ESP32 board, it worked fine for me while communicating with the ESP8266:
  1. void setup() {
  2.  Serial.begin(9600);
  3.  WiFi.mode(WIFI_STA);
  4.  
  5.  // Get Mac Add
  6.  Serial.print("Mac Address: ");
  7.  Serial.println(WiFi.macAddress());
  8.  
  9.  // Initializing the ESP-NOW
  10.  if (esp_now_init() != 0) {
  11.    Serial.println("Problem during ESP-NOW init");
  12.    return;
  13.  }
  14.  esp_now_register_recv_cb(onDataReceiver);
  15.  esp_now_register_send_cb(onSent);
  16.  esp_now_peer_info_t* peer = new esp_now_peer_info_t;
  17.  memcpy(peer->peer_addr, slaveAddr, 6);
  18.  peer->channel = 4;
  19.  peer->encrypt = false;peer->ifidx = ESP_IF_WIFI_STA;
  20.  esp_now_add_peer(peer);
  21.  esp_now_send(slave1, dataToSend, sizeof(dataToSend));
  22. }
Now, if I want it to connect to a network, I place the following line right before the "esp_now_init()", after adding this line, it successfully connects to the network, but the ESP-NOW stops sending nor receiving any messages :
  1. WiFi.begin(networkSSID, networkPassword)
Here are my questions, is it even possible to connect to a Wifi network and use ESP-NOW at the same time? if it is possible, how can I get it to work? I am thankful for this forum and your hard work in it.


hassan1551
Posts: 2
Joined: Mon Aug 10, 2020 12:17 pm

Re: Is it possible to use ESP-NOW and conenct to a WiFi network

Postby hassan1551 » Wed Apr 28, 2021 10:24 pm

It worked, but this is not what I need, I need to connect to a network, not create one and at the same time using the ESP-NOW

michikite
Posts: 16
Joined: Thu Oct 22, 2020 1:35 am

Re: Is it possible to use ESP-NOW and conenct to a WiFi network

Postby michikite » Thu Apr 29, 2021 1:23 am

are you on the same wifi channel for esp-now and normal wifi?
I have not tried it myself, but I think that is a requirement. Then it should work.

impishbynature
Posts: 4
Joined: Thu May 20, 2021 7:14 am

Re: Is it possible to use ESP-NOW and conenct to a WiFi network

Postby impishbynature » Thu May 20, 2021 7:26 am

My experience is that practical connection is diminished , a lot.

I now use two devices as standard, one for ESP-NOW and the other for TCP and link them by the serial TX/RX so they are each dedicated to one type of networking, makes a huge difference and is much cheaper if your time is worth anything.

Who is online

Users browsing this forum: brocliath and 111 guests