|
@ -233,6 +233,7 @@ void sendESPNOW() { |
|
|
|
|
|
|
|
|
WiFi.forceSleepWake(); |
|
|
WiFi.forceSleepWake(); |
|
|
delay(1); // yield();
|
|
|
delay(1); // yield();
|
|
|
|
|
|
digitalWrite(LED_BUILTIN, LOW); |
|
|
WiFi.persistent(false); // don't load and save credentials to flash
|
|
|
WiFi.persistent(false); // don't load and save credentials to flash
|
|
|
WiFi.mode(WIFI_STA); |
|
|
WiFi.mode(WIFI_STA); |
|
|
if (esp_now_init()==0) { |
|
|
if (esp_now_init()==0) { |
|
@ -241,7 +242,8 @@ void sendESPNOW() { |
|
|
esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0); |
|
|
esp_now_add_peer(remoteMac, ESP_NOW_ROLE_SLAVE, WIFI_CHANNEL, NULL, 0); |
|
|
u8 bs[sizeof(sd)]; |
|
|
u8 bs[sizeof(sd)]; |
|
|
memcpy(bs, &sd, sizeof(sd)); |
|
|
memcpy(bs, &sd, sizeof(sd)); |
|
|
esp_now_send(NULL, bs, sizeof(sd)); // max ESP_NOW_MAX_DATA_LEN
|
|
|
for (int i=0; i<20; i++) |
|
|
|
|
|
esp_now_send(NULL, bs, sizeof(sd)); // max ESP_NOW_MAX_DATA_LEN
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
Serial.println("error configuring ESP NOW"); |
|
|
Serial.println("error configuring ESP NOW"); |
|
@ -253,6 +255,7 @@ void sendESPNOW() { |
|
|
WiFi.mode(WIFI_OFF); |
|
|
WiFi.mode(WIFI_OFF); |
|
|
WiFi.forceSleepBegin(); |
|
|
WiFi.forceSleepBegin(); |
|
|
delay(1); // yield();
|
|
|
delay(1); // yield();
|
|
|
|
|
|
digitalWrite(LED_BUILTIN, HIGH); |
|
|
Serial.printf("sendESPNOW() took %d ms\n", millis()-espnowmillis); |
|
|
Serial.printf("sendESPNOW() took %d ms\n", millis()-espnowmillis); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -264,6 +267,9 @@ void ICACHE_RAM_ATTR ISR_geiger_impulse() { |
|
|
void setup() { |
|
|
void setup() { |
|
|
Serial.begin(115200); |
|
|
Serial.begin(115200); |
|
|
|
|
|
|
|
|
|
|
|
pinMode(LED_BUILTIN, OUTPUT); |
|
|
|
|
|
digitalWrite(LED_BUILTIN, HIGH); // turn OFF board led
|
|
|
|
|
|
|
|
|
sds.begin(SDS_TX, SDS_RX); |
|
|
sds.begin(SDS_TX, SDS_RX); |
|
|
sds.mode_mon_300(); |
|
|
sds.mode_mon_300(); |
|
|
|
|
|
|
|
@ -276,6 +282,8 @@ void setup() { |
|
|
|
|
|
|
|
|
pinMode(GEIGER_PIN, INPUT); |
|
|
pinMode(GEIGER_PIN, INPUT); |
|
|
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING); |
|
|
attachInterrupt(digitalPinToInterrupt(GEIGER_PIN), ISR_geiger_impulse, FALLING); |
|
|
|
|
|
|
|
|
|
|
|
Serial.println("ready."); Serial.flush(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
void loop() { |
|
|
void loop() { |
|
|