Hello, I am working on a project, but when I send the data I receive from the sensors on 2 devices to the receiving card with ESP Now, a zero value is inserted in between. The 1st card sends the value 10, the 2nd card sends 25, the receiving card writes 10 on the screen for the first 1 second, then it returns to 0 and this continues continuously. It repeats, the same happens to the sender with the value 25, but when only one device is active, that is, when 10 senders are working and 25 senders are off, the receiver receives this value of 10 without any problems, there is no zero in between. How can I solve this, I would be glad if you can help me.
transmitter1 code
#include "esp_now.h"
#include "WiFi.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "MAX30100_PulseOximeter.h"
// EKRAN TANIMLAMA
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define REPORTING_PERIOD_MS 2500
//NABIZ SENSÖRÜ TANIMLAMA
PulseOximeter pox;
uint32_t tsLastReport = 0;
int deger1,deger2;
//nabız algılandığında
void onBeatDetected()
{
Serial.println("Nabız Algılandı.");
}
uint8_t broadcastAddress[] = {0xF4, 0x12, 0xFA, 0xDF, 0x73, 0x6C}; // ALICI kartın MAC adresi
typedef struct struct_message {
int nabiz;
int spo;
int nabiziki;
int spoiki;
} struct_message;
struct_message myData;
esp_now_peer_info_t peerInfo;
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
//Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Veri gönderme başarılı" : "Veri gönderme başarısız");
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("ESP-NOW başlatılamadı");
return;
}
esp_now_register_send_cb(OnDataSent);
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Eşleşme başarısız");
return;
}
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop() {
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
deger1=int(pox.getHeartRate());
deger2=int(pox.getSpO2());
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
display.print("Nabiz:");
display.setTextSize(1);
display.setCursor(0,20);
display.print("SPO2:");
display.setTextSize(2);
display.setCursor(70,0);
display.print(int(pox.getHeartRate()));
display.setTextSize(1);
display.setCursor(35,20);
display.print(int(pox.getSpO2()));
display.display();
myData.nabiz=deger1;
myData.spo=deger2;
Serial.print(deger1);
Serial.println(" Nabiz Değeri 1");
Serial.print(deger2);
Serial.println(" Spo2 Değeri 1");
tsLastReport = millis();
}
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
}
transmitter2 code
#include "esp_now.h"
#include "WiFi.h"
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include "MAX30100_PulseOximeter.h"
// EKRAN TANIMLAMA
#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 32 // OLED display height, in pixels
#define OLED_RESET -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3C ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define REPORTING_PERIOD_MS 2500
//NABIZ SENSÖRÜ TANIMLAMA
PulseOximeter pox;
uint32_t tsLastReport = 0;
int deger1,deger2;
//nabız algılandığında
void onBeatDetected()
{
Serial.println("Nabız Algılandı.");
}
uint8_t broadcastAddress[] = {0xF4, 0x12, 0xFA, 0xDF, 0x73, 0x6C}; // ALICI kartın MAC adresi
typedef struct struct_message {
int nabiz;
int spo;
int nabiziki;
int spoiki;
} struct_message;
struct_message myData;
esp_now_peer_info_t peerInfo;
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
//Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Veri gönderme başarılı" : "Veri gönderme başarısız");
}
void setup() {
Serial.begin(115200);
WiFi.mode(WIFI_STA);
if (esp_now_init() != ESP_OK) {
Serial.println("ESP-NOW başlatılamadı");
return;
}
esp_now_register_send_cb(OnDataSent);
memcpy(peerInfo.peer_addr, broadcastAddress, 6);
peerInfo.channel = 0;
peerInfo.encrypt = false;
if (esp_now_add_peer(&peerInfo) != ESP_OK) {
Serial.println("Eşleşme başarısız");
return;
}
if(!display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
Serial.println(F("SSD1306 allocation failed"));
for(;;); // Don't proceed, loop forever
}
if (!pox.begin()) {
Serial.println("FAILED");
for(;;);
} else {
Serial.println("SUCCESS");
}
pox.setOnBeatDetectedCallback(onBeatDetected);
}
void loop() {
pox.update();
if (millis() - tsLastReport > REPORTING_PERIOD_MS) {
deger1=int(pox.getHeartRate());
deger2=int(pox.getSpO2());
display.clearDisplay();
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(0,0);
display.print("Nabiz:");
display.setTextSize(1);
display.setCursor(0,20);
display.print("SPO2:");
display.setTextSize(2);
display.setCursor(70,0);
display.print(int(pox.getHeartRate()));
display.setTextSize(1);
display.setCursor(35,20);
display.print(int(pox.getSpO2()));
display.display();
myData.nabiziki=deger1;
myData.spoiki=deger2;
Serial.print(deger1);
Serial.println(" Nabiz Değeri 1");
Serial.print(deger2);
Serial.println(" Spo2 Değeri 1");
tsLastReport = millis();
}
esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
}
receiving code
#include "WiFi.h"
#include "esp_now.h"
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
const uint8_t kalp[] PROGMEM = {
// 'kalp', 35x35px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60,
0x01, 0xc0, 0x00, 0x03, 0xfc, 0x07, 0xf0, 0x00, 0x07, 0xff, 0x0f, 0xfc, 0x00, 0x0f, 0xff, 0x3f,
0xfe, 0x00, 0x0f, 0xff, 0xff, 0xfe, 0x00, 0x1f, 0xff, 0xff, 0xff, 0x00, 0x1f, 0xff, 0xff, 0xff,
0x00, 0x1f, 0xfb, 0xfb, 0xff, 0x00, 0x1f, 0xf3, 0xf9, 0xff, 0x00, 0x1f, 0xf3, 0xf9, 0xff, 0x00,
0x0f, 0xf1, 0xb1, 0xfe, 0x00, 0x0f, 0xf5, 0x94, 0xfe, 0x00, 0x07, 0xe5, 0x96, 0xfc, 0x00, 0x00,
0x0d, 0x86, 0x00, 0x00, 0x01, 0xfc, 0x2f, 0xf0, 0x00, 0x00, 0xfe, 0x7f, 0xe0, 0x00, 0x00, 0x7e,
0x7f, 0xc0, 0x00, 0x00, 0x3e, 0x7f, 0x80, 0x00, 0x00, 0x1f, 0xff, 0x00, 0x00, 0x00, 0x0f, 0xfe,
0x00, 0x00, 0x00, 0x07, 0xfc, 0x00, 0x00, 0x00, 0x03, 0xf8, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x00,
0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
typedef struct struct_message {
int nabiz;
int spo;
int nabiziki;
int spoiki;
} struct_message;
struct_message myData;
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
memcpy(&myData, incomingData, sizeof(myData));
//neopixelWrite(RGBLED, 100, 0, 0); // Burada neopixel kontrolü yapılıyor
display.clearDisplay();
//display.drawBitmap(50, 15, kalp, 35, 35, 1);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(10, 10);
display.print(myData.nabiz);
display.setTextSize(2);
display.setCursor(10, 40);
display.print(myData.spo);
display.setTextSize(2);
display.setTextColor(SSD1306_WHITE);
display.setCursor(45, 10);
display.print(myData.nabiziki);
display.setTextSize(2);
display.setCursor(45, 40);
display.print(myData.spoiki);
display.display();
Serial.println("Nabiz2 ");
Serial.print(myData.nabiz);
Serial.print("spo2 ");
Serial.print(myData.spo);
Serial.print(" ");
Serial.print("Nabiz2 ");
Serial.print(myData.nabiziki);
Serial.print("spo2 ");
Serial.print(myData.spoiki);
}
void setup() {
Serial.begin(115200);
pinMode(LED_BUILTIN, OUTPUT);
WiFi.mode(WIFI_STA);
// OLED ekranı başlatma
if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C)) {
Serial.println(F("SSD1306 ekranı başlatılamadı"));
for(;;);
}
if (esp_now_init() != ESP_OK) {
Serial.println("ESP-NOW başlatılamadı");
return;
}
esp_now_register_recv_cb(OnDataRecv);
}
void loop() {
// main loop kodu buraya gelebilir
}
card i use
DENEYAP MINI V2 2PCS TRANSMITTER CARDS
DENEYAP 1A V2 1 RECEIVER CARD