Compare commits

..

No commits in common. "7ccf7cc39575806da240362081cf2b2d35f0cbf9" and "cc521dcd43bba13e22196944e9b118c250fe4bd2" have entirely different histories.

5 changed files with 26 additions and 139 deletions

View File

@ -1,4 +1,4 @@
update=20/06/2021 21:17:52 update=29/12/2020 12:11:38
version=1 version=1
last_client=kicad last_client=kicad
[general] [general]
@ -34,7 +34,7 @@ LibDir=
[schematic_editor] [schematic_editor]
version=1 version=1
PageLayoutDescrFile= PageLayoutDescrFile=
PlotDirectoryName=D:/Users/Think/Programmation/Arduino/ESP8266_dual_NRF24l01_gateway/schematic/ PlotDirectoryName=
SubpartIdSeparator=0 SubpartIdSeparator=0
SubpartFirstId=65 SubpartFirstId=65
NetFmtName= NetFmtName=

View File

@ -697,11 +697,11 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
6700 3300 6800 3300 6700 3300 6800 3300
Wire Wire Line Wire Wire Line
6800 3300 6800 2850 6800 3300 6800 2100
Wire Wire Line Wire Wire Line
6800 2100 6900 2100 6800 2100 6900 2100
Wire Wire Line Wire Wire Line
6700 3400 7600 3400 6700 3400 8900 3400
Wire Wire Line Wire Wire Line
8900 3400 8900 2100 8900 3400 8900 2100
Wire Wire Line Wire Wire Line
@ -802,13 +802,13 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
5050 3700 5250 3700 5050 3700 5250 3700
Text Notes 850 7300 0 79 ~ 0 Text Notes 850 7300 0 79 ~ 0
ESP_GPIO_10 can only be used in DIO mode /!\\n ESP_GPIO_10 can only bes used in DIO mode /!\\n
$Comp $Comp
L Device:R R8 L Device:R R8
U 1 1 607ED4ED U 1 1 607ED4ED
P 5550 4100 P 5550 4100
F 0 "R8" V 5650 4100 50 0000 C CNN F 0 "R8" V 5650 4050 50 0000 C CNN
F 1 "6.8k" V 5550 4100 50 0000 C CNN F 1 "1k" V 5650 4150 50 0000 C CNN
F 2 "" V 5480 4100 50 0001 C CNN F 2 "" V 5480 4100 50 0001 C CNN
F 3 "~" H 5550 4100 50 0001 C CNN F 3 "~" H 5550 4100 50 0001 C CNN
1 5550 4100 1 5550 4100
@ -832,32 +832,4 @@ Wire Wire Line
Connection ~ 4700 3400 Connection ~ 4700 3400
Wire Wire Line Wire Wire Line
4700 3400 5700 3400 4700 3400 5700 3400
$Comp
L Device:R R16
U 1 1 60CE6C50
P 7750 3400
F 0 "R16" V 7850 3400 50 0000 C CNN
F 1 "6.8k" V 7750 3400 50 0000 C CNN
F 2 "" V 7680 3400 50 0001 C CNN
F 3 "~" H 7750 3400 50 0001 C CNN
1 7750 3400
0 1 1 0
$EndComp
Wire Wire Line
7900 3400 8900 3400
$Comp
L Device:R R15
U 1 1 60CE8759
P 6800 2700
F 0 "R15" H 6900 2700 50 0000 C CNN
F 1 "6.8k" V 6800 2700 50 0000 C CNN
F 2 "" V 6730 2700 50 0001 C CNN
F 3 "~" H 6800 2700 50 0001 C CNN
1 6800 2700
-1 0 0 1
$EndComp
Wire Wire Line
6800 2550 6800 2100
Text Notes 850 7000 0 79 ~ 0
/!\ R8 must be changed to a lower value like \n100 Ohm if using the nodemcu dev board instead of a bare bone ESP-12F
$EndSCHEMATC $EndSCHEMATC

View File

@ -4,7 +4,7 @@ EELAYER END
$Descr A4 11693 8268 $Descr A4 11693 8268
encoding utf-8 encoding utf-8
Sheet 1 1 Sheet 1 1
Title "ESP8266 Dual NRF24L01 Gateway" Title "ESP8266_dual_NRF24l01_gateway"
Date "2020-12-29" Date "2020-12-29"
Rev "1.0" Rev "1.0"
Comp "www.web-directories.tk" Comp "www.web-directories.tk"
@ -697,11 +697,11 @@ Wire Wire Line
Wire Wire Line Wire Wire Line
6700 3300 6800 3300 6700 3300 6800 3300
Wire Wire Line Wire Wire Line
6800 3300 6800 2850 6800 3300 6800 2100
Wire Wire Line Wire Wire Line
6800 2100 6900 2100 6800 2100 6900 2100
Wire Wire Line Wire Wire Line
6700 3400 7600 3400 6700 3400 8900 3400
Wire Wire Line Wire Wire Line
8900 3400 8900 2100 8900 3400 8900 2100
Wire Wire Line Wire Wire Line
@ -807,8 +807,8 @@ $Comp
L Device:R R8 L Device:R R8
U 1 1 607ED4ED U 1 1 607ED4ED
P 5550 4100 P 5550 4100
F 0 "R8" V 5650 4100 50 0000 C CNN F 0 "R8" V 5650 4050 50 0000 C CNN
F 1 "6.8k" V 5550 4100 50 0000 C CNN F 1 "1k" V 5650 4150 50 0000 C CNN
F 2 "" V 5480 4100 50 0001 C CNN F 2 "" V 5480 4100 50 0001 C CNN
F 3 "~" H 5550 4100 50 0001 C CNN F 3 "~" H 5550 4100 50 0001 C CNN
1 5550 4100 1 5550 4100
@ -832,30 +832,4 @@ Wire Wire Line
Connection ~ 4700 3400 Connection ~ 4700 3400
Wire Wire Line Wire Wire Line
4700 3400 5700 3400 4700 3400 5700 3400
$Comp
L Device:R R?
U 1 1 60CE6C50
P 7750 3400
F 0 "R?" V 7850 3400 50 0000 C CNN
F 1 "6.8k" V 7750 3400 50 0000 C CNN
F 2 "" V 7680 3400 50 0001 C CNN
F 3 "~" H 7750 3400 50 0001 C CNN
1 7750 3400
0 1 1 0
$EndComp
Wire Wire Line
7900 3400 8900 3400
$Comp
L Device:R R?
U 1 1 60CE8759
P 6800 2700
F 0 "R?" H 6900 2700 50 0000 C CNN
F 1 "6.8k" V 6800 2700 50 0000 C CNN
F 2 "" V 6730 2700 50 0001 C CNN
F 3 "~" H 6800 2700 50 0001 C CNN
1 6800 2700
-1 0 0 1
$EndComp
Wire Wire Line
6800 2550 6800 2100
$EndSCHEMATC $EndSCHEMATC

View File

@ -30,28 +30,16 @@ RF24 NRF_1(NRF_1_CE, NRF_1_CS);
RF24 NRF_2(NRF_2_CE, NRF_2_CS); RF24 NRF_2(NRF_2_CE, NRF_2_CS);
PCF8574 PCF(0x20); PCF8574 PCF(0x20);
const uint8_t ADDR[] = "WEST1", ADDR2[] = "ABCDE"; const uint8_t ADDR[] = "WEST1";
uint64_t timeStamp(0), recvSlot(0), packetTimeout(0); uint64_t timeStamp(0), recvSlot(0), packetTimeout(0);
uint32_t freeMem(0); uint32_t freeMem(0);
uint16_t biggestContigMemBlock(0); uint16_t biggestContigMemBlock(0);
uint8_t frag(0); uint8_t frag(0);
volatile boolean IRQFlag(false);
IRAM_ATTR void NRFIRQsHandler(void *p)
{
Serial.println("NRF IRQs detected !");
*(boolean *)p = true;
}
void setup() { void setup() {
//We do not need to read on the serial bus //We do not need to read on the serial bus
delay(1000);
Serial.println("\nSetup begin");
Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY); Serial.begin(115200, SERIAL_8N1, SERIAL_TX_ONLY);
//We set the RXD0 as a GPIO Serial.println("Setup begin");
pinMode(D9, FUNCTION_3);
pinMode(D9, INPUT);
attachInterruptArg(D9,&(NRFIRQsHandler), (void *)&IRQFlag, FALLING);
//To prevent wear and tear on the flash mem //To prevent wear and tear on the flash mem
WiFi.persistent(false); WiFi.persistent(false);
WiFi.disconnect(true); WiFi.disconnect(true);
@ -94,69 +82,22 @@ void setup() {
Serial.println("End setup"); Serial.println("End setup");
} }
void loop() void loop() {
{ // put your main code here, to run repeatedly:
if(millis() - recvSlot > RECV_CHECK) if(millis() - recvSlot > RECV_CHECK)
{ {
//We check if we got and IRQ from one, both NRFs if(NRF_1.available()) //Then we read the incoming data
if(IRQFlag)
{ {
bool tx_ok, tx_fail, rx_ready;
//We read the PCFs IO to check which NRF raised the IRQ :
if(!PCF.digitalRead(PCF8574::P1)) //IRQs are active low
{
Serial.printf("NRF 1 triggered the IRQs\n Checking why :\n");
NRF_1.whatHappened(tx_ok, tx_fail, rx_ready);
if(tx_ok)
{
Serial.println("NRF 1 TX_OK");
}
if(tx_fail)
{
Serial.println("NRF 1 TX_FAIL");
}
if(rx_ready)
{
Serial.printf("NRF 1 Received %u bytes with sig(%s) : \n",NRF_1.getPayloadSize(), NRF_1.testRPD()?"good":"bad");
NRF_1.read(&p, sizeof(p)); NRF_1.read(&p, sizeof(p));
Serial.printf("NRF 1 Received : \n");
debugStruct(&p); debugStruct(&p);
} }
} if(NRF_2.available()) //Then we read the incoming data
if(!PCF.digitalRead(PCF8574::P0)) //IRQs are active low
{ {
Serial.printf("NRF 2 triggered the IRQs\n Checking why :\n");
NRF_2.whatHappened(tx_ok, tx_fail, rx_ready);
if(tx_ok)
{
Serial.println("NRF 2 TX_OK");
}
if(tx_fail)
{
Serial.println("NRF 2 TX_FAIL");
}
if(rx_ready)
{
Serial.printf("NRF 2 Received %u bytes with sig(%s) : \n",NRF_2.getPayloadSize(), NRF_2.testRPD()?"good":"bad");
NRF_2.read(&p, sizeof(p)); NRF_2.read(&p, sizeof(p));
Serial.printf("NRF 2 Received : \n");
debugStruct(&p); debugStruct(&p);
} }
}
//We check if the RX fifo the NRFs are full
//If yes, it means we have a big problem since packets can be thrown away without notice
//Could be due to missed IRQs (very bad)
if(NRF_1.rxFifoFull())
{
Serial.println("NRF 1 FIFO FULL !!!!!!!!!!!!");
NRF_1.flush_rx();
}
if(NRF_2.rxFifoFull())
{
Serial.println("NRF 2 FIFO FULL !!!!!!!!!!!!");
NRF_2.flush_rx();
}
IRQFlag = false;
}
recvSlot = millis(); recvSlot = millis();
} }