-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error sending the data #1
Comments
Can you send me receiver code which you changed ?
Also make sure to use rechargeable battery only if you are powering through
battery .
On Mon, 8 Aug 2022 at 8:09 AM, Francis ***@***.***> wrote:
Hello,
thanks for this firmware this helps to understand a little more about
espnow
I program the transmitter and receiver on tw esp32 dev
I copy the Mac from receiver into the FW for tranmitter (by the way I add
now receiver MAC on Receiver FW in setup such to avoid having to run the
GetMac before then flash the receiver FW)
Receiver is rebooting every second obviously no receiving)
Transmitter loop on "Error sending the data"
Any idea about what can be the pb ? I try with 2 other Dev board with same
result
—
Reply to this email directly, view it on GitHub
<#1>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASDSL56DLRN2IODK54WTYTDVYD2HXANCNFSM5544PWRQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
--
Thanks And Regards,
Ujwal Nandanwar
9920996698
|
#include <esp_now.h>
#include <WiFi.h>
#include <ESP32Servo.h>
#define SIGNAL_TIMEOUT 1000 // This is signal timeout in milli seconds. We
will reset the data if no signal
unsigned long lastRecvTime = 0;
struct PacketData
{
byte lxAxisValue;
byte lyAxisValue;
byte rxAxisValue;
byte ryAxisValue;
byte switch1Value;
byte switch2Value;
byte switch3Value;
byte switch4Value;
byte switch5Value;
byte switch6Value;
byte switch7Value;
byte switch8Value;
};
PacketData receiverData;
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
int led1 = 15;
int led2 = 16;
int led3 = 17;
int led4 = 18;
int led5 = 19;
int led6 = 21;
int led7 = 22;
int led8 = 23;
//Assign default input received values
void setInputDefaultValues()
{
// The middle position for joystick. (254/2=127)
receiverData.lxAxisValue = 127;
receiverData.lyAxisValue = 127;
receiverData.rxAxisValue = 127;
receiverData.ryAxisValue = 127;
receiverData.switch1Value = LOW;
receiverData.switch2Value = LOW;
receiverData.switch3Value = LOW;
receiverData.switch4Value = LOW;
receiverData.switch5Value = LOW;
receiverData.switch6Value = LOW;
receiverData.switch7Value = LOW;
receiverData.switch8Value = LOW;
}
void mapAndWriteValues()
{
servo1.write(map(receiverData.lxAxisValue, 0, 254, 0, 180));
servo2.write(map(receiverData.lyAxisValue, 0, 254, 0, 180));
servo3.write(map(receiverData.rxAxisValue, 0, 254, 0, 180));
servo4.write(map(receiverData.ryAxisValue, 0, 254, 0, 180));
digitalWrite(led1, receiverData.switch1Value);
digitalWrite(led2, receiverData.switch2Value);
digitalWrite(led3, receiverData.switch3Value);
digitalWrite(led4, receiverData.switch4Value);
digitalWrite(led5, receiverData.switch5Value);
digitalWrite(led6, receiverData.switch6Value);
digitalWrite(led7, receiverData.switch7Value);
digitalWrite(led8, receiverData.switch8Value);
}
// callback function that will be executed when data is received
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len)
{
if (len == 0)
{
return;
}
memcpy(&receiverData, incomingData, sizeof(receiverData));
mapAndWriteValues();
lastRecvTime = millis();
}
void setUpPinModes()
{
servo1.attach(27);
servo2.attach(26);
servo3.attach(25);
servo4.attach(33);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
setInputDefaultValues();
mapAndWriteValues();
}
void setup()
{
setUpPinModes();
Serial.begin(115200);
WiFi.mode(WIFI_STA);
* Serial.print("MAC :"); Serial.println(WiFi.macAddress());*
// Init ESP-NOW
if (esp_now_init() != ESP_OK)
{
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_register_recv_cb(OnDataRecv);
}
void loop()
{
//Check Signal lost.
unsigned long now = millis();
if ( now - lastRecvTime > SIGNAL_TIMEOUT )
{
setInputDefaultValues();
mapAndWriteValues();
Serial.println("No signal");
}
}
Le lun. 8 août 2022 à 23:10, Ujwal Nandanwar ***@***.***> a
écrit :
… Can you send me receiver code which you changed ?
Also make sure to use rechargeable battery only if you are powering through
battery .
On Mon, 8 Aug 2022 at 8:09 AM, Francis ***@***.***> wrote:
> Hello,
>
> thanks for this firmware this helps to understand a little more about
> espnow
> I program the transmitter and receiver on tw esp32 dev
> I copy the Mac from receiver into the FW for tranmitter (by the way I add
> now receiver MAC on Receiver FW in setup such to avoid having to run the
> GetMac before then flash the receiver FW)
> Receiver is rebooting every second obviously no receiving)
> Transmitter loop on "Error sending the data"
>
> Any idea about what can be the pb ? I try with 2 other Dev board with
same
> result
>
> —
> Reply to this email directly, view it on GitHub
> <#1>, or
> unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ASDSL56DLRN2IODK54WTYTDVYD2HXANCNFSM5544PWRQ
>
> .
> You are receiving this because you are subscribed to this thread.Message
> ID: ***@***.***>
>
--
Thanks And Regards,
Ujwal Nandanwar
9920996698
—
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABX7RKWPDDLZZT64LQ64MPLVYEPNJANCNFSM5544PWRQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Francis RIQUET
|
I try firmware TX from
https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/
now the receiver is stable
but if I use your FW I still have error for transmission....
When I quickly compare your FW I didn't notice so much difference
Can it it because I didn't connect any pot or button on the ESP32 ?
Le lun. 8 août 2022 à 23:43, francis riquet ***@***.***> a écrit :
… #include <esp_now.h>
#include <WiFi.h>
#include <ESP32Servo.h>
#define SIGNAL_TIMEOUT 1000 // This is signal timeout in milli seconds.
We will reset the data if no signal
unsigned long lastRecvTime = 0;
struct PacketData
{
byte lxAxisValue;
byte lyAxisValue;
byte rxAxisValue;
byte ryAxisValue;
byte switch1Value;
byte switch2Value;
byte switch3Value;
byte switch4Value;
byte switch5Value;
byte switch6Value;
byte switch7Value;
byte switch8Value;
};
PacketData receiverData;
Servo servo1;
Servo servo2;
Servo servo3;
Servo servo4;
int led1 = 15;
int led2 = 16;
int led3 = 17;
int led4 = 18;
int led5 = 19;
int led6 = 21;
int led7 = 22;
int led8 = 23;
//Assign default input received values
void setInputDefaultValues()
{
// The middle position for joystick. (254/2=127)
receiverData.lxAxisValue = 127;
receiverData.lyAxisValue = 127;
receiverData.rxAxisValue = 127;
receiverData.ryAxisValue = 127;
receiverData.switch1Value = LOW;
receiverData.switch2Value = LOW;
receiverData.switch3Value = LOW;
receiverData.switch4Value = LOW;
receiverData.switch5Value = LOW;
receiverData.switch6Value = LOW;
receiverData.switch7Value = LOW;
receiverData.switch8Value = LOW;
}
void mapAndWriteValues()
{
servo1.write(map(receiverData.lxAxisValue, 0, 254, 0, 180));
servo2.write(map(receiverData.lyAxisValue, 0, 254, 0, 180));
servo3.write(map(receiverData.rxAxisValue, 0, 254, 0, 180));
servo4.write(map(receiverData.ryAxisValue, 0, 254, 0, 180));
digitalWrite(led1, receiverData.switch1Value);
digitalWrite(led2, receiverData.switch2Value);
digitalWrite(led3, receiverData.switch3Value);
digitalWrite(led4, receiverData.switch4Value);
digitalWrite(led5, receiverData.switch5Value);
digitalWrite(led6, receiverData.switch6Value);
digitalWrite(led7, receiverData.switch7Value);
digitalWrite(led8, receiverData.switch8Value);
}
// callback function that will be executed when data is received
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len)
{
if (len == 0)
{
return;
}
memcpy(&receiverData, incomingData, sizeof(receiverData));
mapAndWriteValues();
lastRecvTime = millis();
}
void setUpPinModes()
{
servo1.attach(27);
servo2.attach(26);
servo3.attach(25);
servo4.attach(33);
pinMode(led1, OUTPUT);
pinMode(led2, OUTPUT);
pinMode(led3, OUTPUT);
pinMode(led4, OUTPUT);
pinMode(led5, OUTPUT);
pinMode(led6, OUTPUT);
pinMode(led7, OUTPUT);
pinMode(led8, OUTPUT);
setInputDefaultValues();
mapAndWriteValues();
}
void setup()
{
setUpPinModes();
Serial.begin(115200);
WiFi.mode(WIFI_STA);
* Serial.print("MAC :"); Serial.println(WiFi.macAddress());*
// Init ESP-NOW
if (esp_now_init() != ESP_OK)
{
Serial.println("Error initializing ESP-NOW");
return;
}
esp_now_register_recv_cb(OnDataRecv);
}
void loop()
{
//Check Signal lost.
unsigned long now = millis();
if ( now - lastRecvTime > SIGNAL_TIMEOUT )
{
setInputDefaultValues();
mapAndWriteValues();
Serial.println("No signal");
}
}
Le lun. 8 août 2022 à 23:10, Ujwal Nandanwar ***@***.***> a
écrit :
> Can you send me receiver code which you changed ?
> Also make sure to use rechargeable battery only if you are powering
> through
> battery .
>
>
> On Mon, 8 Aug 2022 at 8:09 AM, Francis ***@***.***> wrote:
>
> > Hello,
> >
> > thanks for this firmware this helps to understand a little more about
> > espnow
> > I program the transmitter and receiver on tw esp32 dev
> > I copy the Mac from receiver into the FW for tranmitter (by the way I
> add
> > now receiver MAC on Receiver FW in setup such to avoid having to run the
> > GetMac before then flash the receiver FW)
> > Receiver is rebooting every second obviously no receiving)
> > Transmitter loop on "Error sending the data"
> >
> > Any idea about what can be the pb ? I try with 2 other Dev board with
> same
> > result
> >
> > —
> > Reply to this email directly, view it on GitHub
> > <#1>, or
> > unsubscribe
> > <
> https://github.com/notifications/unsubscribe-auth/ASDSL56DLRN2IODK54WTYTDVYD2HXANCNFSM5544PWRQ
> >
> > .
> > You are receiving this because you are subscribed to this thread.Message
> > ID: ***@***.***>
> >
> --
> Thanks And Regards,
>
> Ujwal Nandanwar
> 9920996698
>
> —
> Reply to this email directly, view it on GitHub
> <#1 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/ABX7RKWPDDLZZT64LQ64MPLVYEPNJANCNFSM5544PWRQ>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
--
Francis RIQUET
--
Francis RIQUET
|
My code should work as well .
Can you try the exact steps which I followed in video ?
Just use 2 esp32 boards and upload code. Make sure to set the Mac address
in transmitter code. And see if you are receiving data at receiver esp32.
Also the delay I used in transmitter is 50 milliseconds.
In random nerd tutorial he used 2 seconds which is too much .
Upload the print values receiver code and see if you receive data .
Follow the video properly and slowly .
If you get errors at transmitter sometimes , then May be it’s because of 50
milliseconds delay. But that’s fine. You can try increasing the delay but
your project will be slow .
On Mon, 8 Aug 2022 at 11:48 AM, Francis ***@***.***> wrote:
I try firmware TX from
https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/
now the receiver is stable
but if I use your FW I still have error for transmission....
When I quickly compare your FW I didn't notice so much difference
Can it it because I didn't connect any pot or button on the ESP32 ?
Le lun. 8 août 2022 à 23:43, francis riquet ***@***.***> a écrit :
> #include <esp_now.h>
> #include <WiFi.h>
> #include <ESP32Servo.h>
>
> #define SIGNAL_TIMEOUT 1000 // This is signal timeout in milli seconds.
> We will reset the data if no signal
>
> unsigned long lastRecvTime = 0;
>
> struct PacketData
> {
> byte lxAxisValue;
> byte lyAxisValue;
> byte rxAxisValue;
> byte ryAxisValue;
>
> byte switch1Value;
> byte switch2Value;
> byte switch3Value;
> byte switch4Value;
> byte switch5Value;
> byte switch6Value;
> byte switch7Value;
> byte switch8Value;
>
> };
> PacketData receiverData;
>
> Servo servo1;
> Servo servo2;
> Servo servo3;
> Servo servo4;
>
> int led1 = 15;
> int led2 = 16;
> int led3 = 17;
> int led4 = 18;
> int led5 = 19;
> int led6 = 21;
> int led7 = 22;
> int led8 = 23;
>
> //Assign default input received values
> void setInputDefaultValues()
> {
> // The middle position for joystick. (254/2=127)
> receiverData.lxAxisValue = 127;
> receiverData.lyAxisValue = 127;
> receiverData.rxAxisValue = 127;
> receiverData.ryAxisValue = 127;
>
> receiverData.switch1Value = LOW;
> receiverData.switch2Value = LOW;
> receiverData.switch3Value = LOW;
> receiverData.switch4Value = LOW;
>
> receiverData.switch5Value = LOW;
> receiverData.switch6Value = LOW;
> receiverData.switch7Value = LOW;
> receiverData.switch8Value = LOW;
> }
>
> void mapAndWriteValues()
> {
> servo1.write(map(receiverData.lxAxisValue, 0, 254, 0, 180));
> servo2.write(map(receiverData.lyAxisValue, 0, 254, 0, 180));
> servo3.write(map(receiverData.rxAxisValue, 0, 254, 0, 180));
> servo4.write(map(receiverData.ryAxisValue, 0, 254, 0, 180));
>
> digitalWrite(led1, receiverData.switch1Value);
> digitalWrite(led2, receiverData.switch2Value);
> digitalWrite(led3, receiverData.switch3Value);
> digitalWrite(led4, receiverData.switch4Value);
>
> digitalWrite(led5, receiverData.switch5Value);
> digitalWrite(led6, receiverData.switch6Value);
> digitalWrite(led7, receiverData.switch7Value);
> digitalWrite(led8, receiverData.switch8Value);
> }
>
> // callback function that will be executed when data is received
> void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int
len)
> {
> if (len == 0)
> {
> return;
> }
> memcpy(&receiverData, incomingData, sizeof(receiverData));
> mapAndWriteValues();
> lastRecvTime = millis();
> }
>
> void setUpPinModes()
> {
> servo1.attach(27);
> servo2.attach(26);
> servo3.attach(25);
> servo4.attach(33);
>
> pinMode(led1, OUTPUT);
> pinMode(led2, OUTPUT);
> pinMode(led3, OUTPUT);
> pinMode(led4, OUTPUT);
>
> pinMode(led5, OUTPUT);
> pinMode(led6, OUTPUT);
> pinMode(led7, OUTPUT);
> pinMode(led8, OUTPUT);
>
> setInputDefaultValues();
> mapAndWriteValues();
> }
>
> void setup()
> {
> setUpPinModes();
>
> Serial.begin(115200);
> WiFi.mode(WIFI_STA);
>
> * Serial.print("MAC :"); Serial.println(WiFi.macAddress());*
>
> // Init ESP-NOW
> if (esp_now_init() != ESP_OK)
> {
> Serial.println("Error initializing ESP-NOW");
> return;
> }
>
> esp_now_register_recv_cb(OnDataRecv);
> }
>
>
>
> void loop()
> {
> //Check Signal lost.
> unsigned long now = millis();
> if ( now - lastRecvTime > SIGNAL_TIMEOUT )
> {
> setInputDefaultValues();
> mapAndWriteValues();
> Serial.println("No signal");
> }
> }
>
> Le lun. 8 août 2022 à 23:10, Ujwal Nandanwar ***@***.***> a
> écrit :
>
>> Can you send me receiver code which you changed ?
>> Also make sure to use rechargeable battery only if you are powering
>> through
>> battery .
>>
>>
>> On Mon, 8 Aug 2022 at 8:09 AM, Francis ***@***.***> wrote:
>>
>> > Hello,
>> >
>> > thanks for this firmware this helps to understand a little more about
>> > espnow
>> > I program the transmitter and receiver on tw esp32 dev
>> > I copy the Mac from receiver into the FW for tranmitter (by the way I
>> add
>> > now receiver MAC on Receiver FW in setup such to avoid having to run
the
>> > GetMac before then flash the receiver FW)
>> > Receiver is rebooting every second obviously no receiving)
>> > Transmitter loop on "Error sending the data"
>> >
>> > Any idea about what can be the pb ? I try with 2 other Dev board with
>> same
>> > result
>> >
>> > —
>> > Reply to this email directly, view it on GitHub
>> > <#1>,
or
>> > unsubscribe
>> > <
>>
https://github.com/notifications/unsubscribe-auth/ASDSL56DLRN2IODK54WTYTDVYD2HXANCNFSM5544PWRQ
>> >
>> > .
>> > You are receiving this because you are subscribed to this
thread.Message
>> > ID: ***@***.***>
>> >
>> --
>> Thanks And Regards,
>>
>> Ujwal Nandanwar
>> 9920996698
>>
>> —
>> Reply to this email directly, view it on GitHub
>> <
#1 (comment)
>,
>> or unsubscribe
>> <
https://github.com/notifications/unsubscribe-auth/ABX7RKWPDDLZZT64LQ64MPLVYEPNJANCNFSM5544PWRQ
>
>> .
>> You are receiving this because you authored the thread.Message ID:
>> ***@***.***>
>>
>
>
> --
> Francis RIQUET
>
--
Francis RIQUET
—
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASDSL56PZLPMRT24KZD52UDVYET4BANCNFSM5544PWRQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Thanks And Regards,
Ujwal Nandanwar
9920996698
|
now this Tx firmware work good /* Permission is hereby granted, free of charge, to any person obtaining a copy The above copyright notice and this permission notice shall be included in all #include <esp_now.h> // REPLACE WITH YOUR RECEIVER MAC Address byte switch1Value; // Create a struct_message called myData esp_now_peer_info_t peerInfo; //*********************************************************************************************************************************** if (reverse) // Set device as a Wi-Fi Station // Init ESP-NOW // Once ESPNow is successfully Init, we will register for Send CB to // Register peer // Add peer esp_err_t result = esp_now_send(receiverMacAddress, (uint8_t *) &myData, sizeof(myData)); |
Awesome 👏🏻
On Tue, 9 Aug 2022 at 1:27 AM, Francis ***@***.***> wrote:
now this Tx firmware work good
/*
Francis RIQUET for SmartElectronic
Permission is hereby granted, free of charge, to any person obtaining a
copy
of this software and associated documentation files.
The above copyright notice and this permission notice shall be included in
all
copies or substantial portions of the Software.
*/
#include <esp_now.h>
#include <WiFi.h>
// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t receiverMacAddress[] = {0xC8, 0xF0, 0x9E, 0x2F, 0x7F, 0x80};
//uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
// Structure to send data
// Must match the receiver structure
typedef struct struct_message {
byte lxAxisValue;
byte lyAxisValue;
byte rxAxisValue;
byte ryAxisValue;
byte switch1Value;
byte switch2Value;
byte switch3Value;
byte switch4Value;
byte switch5Value;
byte switch6Value;
byte switch7Value;
byte switch8Value;
} struct_message;
// Create a struct_message called myData
struct_message myData;
esp_now_peer_info_t peerInfo;
//***********************************************************************************************************************************
//***********************************************************************************************************************************
//This function is used to map 0-4095 joystick value to 0-254. hence 127
is the center value which we send.
//It also adjust the deadband in joystick.
//Jotstick values range from 0-4095. But its center value is not always
2047. It is little different.
//So we need to add some deadband to center value. in our case 1800-2200.
Any value in this deadband range is mapped to center 127.
int mapAndAdjustJoystickDeadBandValues(int value, bool reverse)
{
if (value >= 2200)
{
value = map(value, 2200, 4095, 127, 254);
}
else if (value <= 1800)
{
value = (value == 0 ? 0 : map(value, 1800, 0, 127, 0));
}
else
{
value = 127;
}
if (reverse)
{
value = 254 - value;
}
Serial.println(value);
return value;
}
//***********************************************************************************************************************************
//***********************************************************************************************************************************
// callback when data is sent
void OnDataSent(const uint8_t
*mac_addr, esp_now_send_status_t status) { Serial.print("\r\nLast Packet
Send Status:\t"); Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery
Success" : "Delivery Fail"); } //*
**********************************************************************************************************************************
//***********************************************************************************************************************************
void setup() {
// Init Serial Monitor
Serial.begin(115200);
// Set device as a Wi-Fi Station
WiFi.mode(WIFI_STA);
// Init ESP-NOW
if (esp_now_init() != ESP_OK) {
Serial.println("Error initializing ESP-NOW");
return;
}
// Once ESPNow is successfully Init, we will register for Send CB to
// get the status of Trasnmitted packet
esp_now_register_send_cb(OnDataSent);
// Register peer
memcpy(peerInfo.peer_addr, receiverMacAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
// Add peer
if (esp_now_add_peer(&peerInfo) != ESP_OK){
Serial.println("Failed to add peer");
return;
}
}
//***********************************************************************************************************************************
//***********************************************************************************************************************************
void loop() {
// Set values to send
myData.lxAxisValue = mapAndAdjustJoystickDeadBandValues(analogRead(32),
false);
myData.lxAxisValue = mapAndAdjustJoystickDeadBandValues(analogRead(32),
false);
myData.lyAxisValue = mapAndAdjustJoystickDeadBandValues(analogRead(33),
false);
myData.rxAxisValue = mapAndAdjustJoystickDeadBandValues(analogRead(34),
false);
myData.switch1Value = !digitalRead(15);
myData.switch3Value = !digitalRead(17);
myData.switch5Value = !digitalRead(19);
myData.switch6Value = !digitalRead(21);
myData.switch7Value = !digitalRead(22);
myData.switch8Value = !digitalRead(23);
esp_err_t result = esp_now_send(receiverMacAddress, (uint8_t *) &myData,
sizeof(myData));
if (result == ESP_OK)
{
Serial.println("Sent with success");
}
else
{
Serial.println("Error sending the data");
}
delay(50);
}
—
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ASDSL5Y6IXSHLFYRBS62KTLVYHT5VANCNFSM5544PWRQ>
.
You are receiving this because you commented.Message ID:
***@***.***>
--
Thanks And Regards,
Ujwal Nandanwar
9920996698
|
Ok, I will check.
the problem is on the transmitter side when trying to send data and gives
the error message "Error sending the data"
I will compare and explore slowly to try to find where is PB
Le lun. 8 août 2022 à 23:59, Ujwal Nandanwar ***@***.***> a
écrit :
… My code should work as well .
Can you try the exact steps which I followed in video ?
Just use 2 esp32 boards and upload code. Make sure to set the Mac address
in transmitter code. And see if you are receiving data at receiver esp32.
Also the delay I used in transmitter is 50 milliseconds.
In random nerd tutorial he used 2 seconds which is too much .
Upload the print values receiver code and see if you receive data .
Follow the video properly and slowly .
If you get errors at transmitter sometimes , then May be it’s because of 50
milliseconds delay. But that’s fine. You can try increasing the delay but
your project will be slow .
On Mon, 8 Aug 2022 at 11:48 AM, Francis ***@***.***> wrote:
> I try firmware TX from
> https://randomnerdtutorials.com/esp-now-esp32-arduino-ide/
> now the receiver is stable
> but if I use your FW I still have error for transmission....
> When I quickly compare your FW I didn't notice so much difference
> Can it it because I didn't connect any pot or button on the ESP32 ?
>
> Le lun. 8 août 2022 à 23:43, francis riquet ***@***.***> a écrit :
>
> > #include <esp_now.h>
> > #include <WiFi.h>
> > #include <ESP32Servo.h>
> >
> > #define SIGNAL_TIMEOUT 1000 // This is signal timeout in milli seconds.
> > We will reset the data if no signal
> >
> > unsigned long lastRecvTime = 0;
> >
> > struct PacketData
> > {
> > byte lxAxisValue;
> > byte lyAxisValue;
> > byte rxAxisValue;
> > byte ryAxisValue;
> >
> > byte switch1Value;
> > byte switch2Value;
> > byte switch3Value;
> > byte switch4Value;
> > byte switch5Value;
> > byte switch6Value;
> > byte switch7Value;
> > byte switch8Value;
> >
> > };
> > PacketData receiverData;
> >
> > Servo servo1;
> > Servo servo2;
> > Servo servo3;
> > Servo servo4;
> >
> > int led1 = 15;
> > int led2 = 16;
> > int led3 = 17;
> > int led4 = 18;
> > int led5 = 19;
> > int led6 = 21;
> > int led7 = 22;
> > int led8 = 23;
> >
> > //Assign default input received values
> > void setInputDefaultValues()
> > {
> > // The middle position for joystick. (254/2=127)
> > receiverData.lxAxisValue = 127;
> > receiverData.lyAxisValue = 127;
> > receiverData.rxAxisValue = 127;
> > receiverData.ryAxisValue = 127;
> >
> > receiverData.switch1Value = LOW;
> > receiverData.switch2Value = LOW;
> > receiverData.switch3Value = LOW;
> > receiverData.switch4Value = LOW;
> >
> > receiverData.switch5Value = LOW;
> > receiverData.switch6Value = LOW;
> > receiverData.switch7Value = LOW;
> > receiverData.switch8Value = LOW;
> > }
> >
> > void mapAndWriteValues()
> > {
> > servo1.write(map(receiverData.lxAxisValue, 0, 254, 0, 180));
> > servo2.write(map(receiverData.lyAxisValue, 0, 254, 0, 180));
> > servo3.write(map(receiverData.rxAxisValue, 0, 254, 0, 180));
> > servo4.write(map(receiverData.ryAxisValue, 0, 254, 0, 180));
> >
> > digitalWrite(led1, receiverData.switch1Value);
> > digitalWrite(led2, receiverData.switch2Value);
> > digitalWrite(led3, receiverData.switch3Value);
> > digitalWrite(led4, receiverData.switch4Value);
> >
> > digitalWrite(led5, receiverData.switch5Value);
> > digitalWrite(led6, receiverData.switch6Value);
> > digitalWrite(led7, receiverData.switch7Value);
> > digitalWrite(led8, receiverData.switch8Value);
> > }
> >
> > // callback function that will be executed when data is received
> > void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int
> len)
> > {
> > if (len == 0)
> > {
> > return;
> > }
> > memcpy(&receiverData, incomingData, sizeof(receiverData));
> > mapAndWriteValues();
> > lastRecvTime = millis();
> > }
> >
> > void setUpPinModes()
> > {
> > servo1.attach(27);
> > servo2.attach(26);
> > servo3.attach(25);
> > servo4.attach(33);
> >
> > pinMode(led1, OUTPUT);
> > pinMode(led2, OUTPUT);
> > pinMode(led3, OUTPUT);
> > pinMode(led4, OUTPUT);
> >
> > pinMode(led5, OUTPUT);
> > pinMode(led6, OUTPUT);
> > pinMode(led7, OUTPUT);
> > pinMode(led8, OUTPUT);
> >
> > setInputDefaultValues();
> > mapAndWriteValues();
> > }
> >
> > void setup()
> > {
> > setUpPinModes();
> >
> > Serial.begin(115200);
> > WiFi.mode(WIFI_STA);
> >
> > * Serial.print("MAC :"); Serial.println(WiFi.macAddress());*
> >
> > // Init ESP-NOW
> > if (esp_now_init() != ESP_OK)
> > {
> > Serial.println("Error initializing ESP-NOW");
> > return;
> > }
> >
> > esp_now_register_recv_cb(OnDataRecv);
> > }
> >
> >
> >
> > void loop()
> > {
> > //Check Signal lost.
> > unsigned long now = millis();
> > if ( now - lastRecvTime > SIGNAL_TIMEOUT )
> > {
> > setInputDefaultValues();
> > mapAndWriteValues();
> > Serial.println("No signal");
> > }
> > }
> >
> > Le lun. 8 août 2022 à 23:10, Ujwal Nandanwar ***@***.***> a
> > écrit :
> >
> >> Can you send me receiver code which you changed ?
> >> Also make sure to use rechargeable battery only if you are powering
> >> through
> >> battery .
> >>
> >>
> >> On Mon, 8 Aug 2022 at 8:09 AM, Francis ***@***.***> wrote:
> >>
> >> > Hello,
> >> >
> >> > thanks for this firmware this helps to understand a little more
about
> >> > espnow
> >> > I program the transmitter and receiver on tw esp32 dev
> >> > I copy the Mac from receiver into the FW for tranmitter (by the way
I
> >> add
> >> > now receiver MAC on Receiver FW in setup such to avoid having to run
> the
> >> > GetMac before then flash the receiver FW)
> >> > Receiver is rebooting every second obviously no receiving)
> >> > Transmitter loop on "Error sending the data"
> >> >
> >> > Any idea about what can be the pb ? I try with 2 other Dev board
with
> >> same
> >> > result
> >> >
> >> > —
> >> > Reply to this email directly, view it on GitHub
> >> > <#1
>,
> or
> >> > unsubscribe
> >> > <
> >>
>
https://github.com/notifications/unsubscribe-auth/ASDSL56DLRN2IODK54WTYTDVYD2HXANCNFSM5544PWRQ
> >> >
> >> > .
> >> > You are receiving this because you are subscribed to this
> thread.Message
> >> > ID: ***@***.***>
> >> >
> >> --
> >> Thanks And Regards,
> >>
> >> Ujwal Nandanwar
> >> 9920996698
> >>
> >> —
> >> Reply to this email directly, view it on GitHub
> >> <
>
#1 (comment)
> >,
> >> or unsubscribe
> >> <
>
https://github.com/notifications/unsubscribe-auth/ABX7RKWPDDLZZT64LQ64MPLVYEPNJANCNFSM5544PWRQ
> >
> >> .
> >> You are receiving this because you authored the thread.Message ID:
> >> ***@***.***>
> >>
> >
> >
> > --
> > Francis RIQUET
> >
>
>
> --
> Francis RIQUET
>
> —
> Reply to this email directly, view it on GitHub
> <
#1 (comment)
>,
> or unsubscribe
> <
https://github.com/notifications/unsubscribe-auth/ASDSL56PZLPMRT24KZD52UDVYET4BANCNFSM5544PWRQ
>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
--
Thanks And Regards,
Ujwal Nandanwar
9920996698
—
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABX7RKXMEO3U7C5YEOTMJR3VYEVH5ANCNFSM5544PWRQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
--
Francis RIQUET
|
Hello,
thanks for this firmware this helps to understand a little more about espnow
I program the transmitter and receiver on tw esp32 dev
I copy the Mac from receiver into the FW for tranmitter (by the way I add now receiver MAC on Receiver FW in setup such to avoid having to run the GetMac before then flash the receiver FW)
Receiver is rebooting every second obviously no receiving)
Transmitter loop on "Error sending the data"
Any idea about what can be the pb ? I try with 2 other Dev board with same result
SCROLLING SERIAL MONITOR IFOUND OUT THIS :
20:34:28.022 -> Succes: Initialized ESP-NOW
20:34:28.022 -> E (334) ESPNOW: Peer interface is invalid
20:34:28.022 -> Failed to add peer
The text was updated successfully, but these errors were encountered: