Samo Penic
2022-03-27 b08ee12060d3cfa52b00e1710b3cc49a8f4ab820
commit | author | age
b08ee1 1 /* There was a help from these two pages:
SP 2 https://forum.arduino.cc/t/connect-nrf24l01-to-esp32/678710/4
3 https://electropeak.com/learn/wireless-communication-w-arduino-and-nrf24l01/
4 */
5
6 #include <RF24_config.h>
7 #include <nRF24L01.h>
8 #include <RF24.h>
9 #include <printf.h>
10
c6fcd5 11 #include<WiFi.h>
SP 12
b08ee1 13 #define IN_TRIGGER 17
SP 14 #define OUT_TRIGGER 16
c6fcd5 15
b08ee1 16
SP 17 RF24 radio(22, 21); // CE, CSN
18
19 const byte address[6] = {'R','E','C','V', '1'};
20 char dataToSend[4] = "TRG";
c6fcd5 21
SP 22 void IRAM_ATTR isr() {
23     digitalWrite(OUT_TRIGGER, HIGH);
b08ee1 24     radio.write( &dataToSend, sizeof(dataToSend) );
c6fcd5 25     delay(1);
SP 26     digitalWrite(OUT_TRIGGER,LOW);
27 }
b08ee1 28
SP 29
c6fcd5 30
SP 31 void setup() {
32   // put your setup code here, to run once:
33   
34   WiFi.mode(WIFI_OFF);
35   btStop();
36
b08ee1 37
SP 38   radio.begin();
39   radio.openWritingPipe(address);
40   radio.setPALevel(RF24_PA_MIN);
41   //radio.setDataRate( RF24_250KBPS );
42
c6fcd5 43   pinMode(IN_TRIGGER, INPUT_PULLUP);
SP 44   pinMode(OUT_TRIGGER, OUTPUT);
45   attachInterrupt(IN_TRIGGER, isr, RISING);
b08ee1 46   
c6fcd5 47
SP 48 }
49
50 void loop() {
51   // put your main code here, to run repeatedly:
52
53 }