HarringayMakerSpace / ESP-Now

ESP-Now Examples
300 stars 48 forks source link

Reverse channel possible? #10

Open SensorsIot opened 6 years ago

SensorsIot commented 6 years ago

I have a remote control to transmit commands to a tank using ESP_Now. I want also to include a "telemetry channel which sends data from the tank to the remote control but was not successful. Did you try this?

torntrousers commented 6 years ago

Sorry for the slow reply. I've just tried and it seems to work. For example, the receive callback function gets the mac address of the sender and adding an esp_now_send inside the receive callback does send data back to the sender:

  esp_now_register_recv_cb([](uint8_t *mac, uint8_t *data, uint8_t len) {

    Serial.print("$$"); // $$ just an indicator that this line is a received ESP-Now message
    Serial.write(mac, 6); // mac address of remote ESP-Now device
    Serial.write(len);
    Serial.write(data, len); 

    esp_now_send(mac, data, len); 
  });
}

And if the sender has registered a receive callback then it succesfully receives the data.

Is that the sort of thing you tried?