Esp Now receiver problem

ahmedfotoh
Posts: 3
Joined: Tue Apr 25, 2023 9:16 am

Esp Now receiver problem

Postby ahmedfotoh » Tue Apr 25, 2023 9:20 am

Hi,
I'm using esp now(transmitter & receiver) to switch relays on/off ( relays on at LOW signal)
the problem is when power on receiver before, transmitter power on,
the output pins of receiver go LOW and relays switch on,
but it go HIGH when transmitter power on.
I need to set the output pins of receiver to HIGH by default (when power on)
and before the transmitter power on.
many thanks for helping.
the code of receiver

Code: Select all

#include <esp_now.h>
#include <WiFi.h>
#define LED_Pin1   4
#define LED_Pin2   12
typedef struct struct_message {
    int led1;
    int led2;
} struct_message ;
struct_message receive_Data; // Create a struct_message to receive data.
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
  memcpy(&receive_Data, incomingData, sizeof(receive_Data));
 digitalWrite(LED_Pin1, receive_Data.led1);
  digitalWrite(LED_Pin2, receive_Data.led2);
  Serial.print("Receive Data: ");
  Serial.println("<<<<<");
}
void setup(){
  Serial.begin(115200);
  pinMode(LED_Pin1, OUTPUT);
  pinMode(LED_Pin2, OUTPUT);
  WiFi.mode(WIFI_STA); //--> Set device as a Wi-Fi Station
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
  esp_now_register_recv_cb(OnDataRecv);
}
void loop()
{}

Who is online

Users browsing this forum: No registered users and 28 guests