trigger multiple ESP32 via (local) ethernet

kainer
Posts: 1
Joined: Wed Dec 11, 2019 11:03 am

trigger multiple ESP32 via (local) ethernet

Postby kainer » Wed Dec 11, 2019 11:14 am

Dear Forum,

after getting a little familiar with programming with Arduino, I'm at a point where I can't get any further. I am using an ESP32-POE-ISO. As part of the project, I want to synchronously read several sensors using the I2C protocol. Since several ESP32s are used, I need a method to synchronize them as accurately as possible. For this I use a local NTP server on a Raspberry (connected via Ethernet). Currently I get a jitter of max. +/-100 microseconds. I also tried a UDP broadcast, but the result is similar.
Do any of you have an idea for a method to improve this value (->smaller jitter)? Maybee causing an interrupt via UDP?

Thanks in advance,

Kainer
  1. #include <WiFi.h>
  2. #include <ETH.h>
  3. #include "time.h"
  4.  
  5. TaskHandle_t Task1;
  6. time_t new_t, old_t;
  7. void codeForTask1(void * parameter)
  8. {
  9.   const long  gmtOffset_sec = 3600;
  10.   const int   daylightOffset_sec = 3600;
  11. //  time_t new_tl, old_tl;  
  12.   for(;;){
  13.     delay(1000);
  14.     configTime(gmtOffset_sec, daylightOffset_sec, "192.168.1.2");                          
  15.   }
  16. }
  17. void setup()
  18. {
  19.     Serial.begin(115200);
  20.     Serial.println("Start .......");
  21.     pinMode(5, OUTPUT);      // set the LED pin mode
  22.     ETH.begin();
  23.     ETH.config(IPAddress(192, 168, 1, 66),IPAddress(192, 168, 1, 255),IPAddress(255, 255, 255, 0));
  24.     delay(100);
  25.     xTaskCreatePinnedToCore(codeForTask1,"Task_1",10000,NULL,1,&Task1,0);
  26.     old_t=0;
  27. }
  28.  
  29. void loop(){
  30.     time(&new_t);
  31.     if(difftime(new_t,old_t)!=0)
  32.       {
  33.         pinMode(5, INPUT);      // set the LED pin mode
  34.         delayMicroseconds(100);
  35.         old_t=new_t;  
  36.       }
  37.   pinMode(5, OUTPUT);
  38. }
  39.  
  40.  

Who is online

Users browsing this forum: No registered users and 52 guests