Joshua
Junior Member
Posts: 75
|
Post by Joshua on Sept 20, 2021 13:09:10 GMT
Hello all,
I've been exploring the options for migrating the RFM Gateway from an Arduino with Ethernet to an ESP32. The purpose is to have a secure connect to remote nodes via Wi-Fi.
OpenMQTTGateway may offer a head start as they have enabled TLS and you have "The MQTT broker is configured for TLS and you have access to the CA certificate which was used to sign the MQTT broker certificate" built in their Advanced configuration of the gateway I've successfully compiled the RFM69 module on an ESP 32 board using these libraries and the ESP32 1.0.6 version board. I'm not sure how to connect the ESP32 and RFM together and what pins to configure in the .ino file.
Here are the steps I've taken so far.
- Open User_config.h and enable #define ZgatewayRFM69 "RFM69" //ESP8266, Arduino, ESP32 by uncommenting it.
- Configure config_RFM69.h to your RFM network settings and pin assignment
Here's my pin assignment
#elif defined(ESP32) # define RFM69_CS 1 // NSS # define RFM69_IRQ 15 // GPIO15/D8 DIO0 # define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) # define RFM69_RST 4 // GPIO02/D4 #else
Here's the pinout that I believe is correct
RFM Module
| ESP32
| ESP GPIO
| NSS
| D5
| IO5
| DIO0
| RX2
| IO16 IRQ
| DIO2
| D26 (may not be needed)
| IO26
| DIO15 SS
| IO5 (may not be needed)
|
| Reset
|
|
| SCK
| D18
| IO18
| MOSI
| D23
| IO23
| MISO
| D19
| IO19
| GND
| GND
| -
| 3V3
| 3v3
| -
|
Sorry to come back to the forum after a long absence with a hand out. However, any assistance would be helpful. The OpenMQTTGateway group hasn't tested the code with an ESP32.
|
|
|
Post by papa on Sept 20, 2021 21:59:15 GMT
Joshua, you're always welcome to the forum, especially when you bring new possibilities.
One more advantage I could foresee with your project: Since it connects to one's local network via WiFi & does not depend on locating near an Ethernet connection, it would allow for a gateway to be placed anywhere that has a good WiFi signal. This placement flexibility could help communicate with RFM69 nodes that are not connecting well to Ethernet gateways.
Some possible challenges For your project: 1) RFM69 radios need a lot of current or they reset. An ESP32 board pin might not supply enough power. Connecting RFM69's power pin to a separate 3.3 volts may be required.
BTW you don't say which ESP32 module you are using. 2) Unlike Arduino compatibles, different ESP32 board types have different pinouts for their functions. For the ESP32 camera boards, we have definition tables (in a .h header file) for each board type which list the pin number for each pin function that is needed. A similar .h header file may be needed for the ESP32 pins where RFM69 pins need to connect.
Please give more information: What have you tried so far & what were the results? Again, what ESP32 module are you using? Where have you looked online & what was helpful & not helpful?
|
|
Joshua
Junior Member
Posts: 75
|
Post by Joshua on Sept 21, 2021 12:03:56 GMT
The configuration in the first post is what I've tried, and it's not working. I'll give it a go with external 3.3 power. The board is an Esp32 DEV and I referenced the pin assignment and schematic from the TFT32 IoT Gateway. This is the only working RFM69/ESP32 config that I could find with the Vroom-32 Board.
|
|
|
Post by papa on Sept 21, 2021 19:28:08 GMT
Warning: I'm more a tinkerer & adapter than anything, not an expert, esp. on ESP32. I've stared at pinouts & wiring diagrams until I'm cross eyed. Except for the one questionable row, I believe you correctly recorded the TFT32 RFM69 connections in this table:
RFM69 Module
| ESP32
| ESP GPIO
| NSS
| D5
| IO5
| DIO0
| RX2 D16
| IO16 IRQ
| DIO2
| D26
| IO26
| DIO15 SS
| IO5 (may not be needed)
| papa: not sure where you got this
| Reset
| not connected
|
| SCK
| D18
| IO18
| MOSI
| D23
| IO23
| MISO
| D19
| IO19
| GND
| GND
| -
| 3V3
| 3v3
| -
|
I'm not sure you configured config_RFM69.h to match the above table. I believe the downloaded original version of config_RFM69.h reflects an ESP32 board whose GPIOs & Dxx did NOT match (used to be common). From your board's pinouts the GPIOs & Dxx DO MATCH (use the same numbers). Perhaps the following pin assignments will help.
So far I'm not sure how the Gateway code knows what ESP32 pins are connected to RFM69 radio's SCK, MOSI, & MISO.
Anyway, maybe see how the above pin assignments work.
Keep us posted on your results. If this project gets to working, we can probably adapt the forum's ESP32 node code to be a WiFi Gateway.
|
|
ragoth
Junior Member
Posts: 64
|
Post by ragoth on Sept 21, 2021 19:43:55 GMT
Hi, this is Ragoth after few years. You may try the same pin config that works with ESP32 and LoRa module. RFM module to ESP32 PINS: SCK --5 MISO --19 MOSI --27 SS/CS --18 RST --14 DI0/IRQ --26 I think it should work, give it a try and good luck:-)
papa: thanks, ragoth, for offering suggestions to solve this.
|
|
|
Post by papa on Sept 22, 2021 13:35:58 GMT
After more research, I believe I'm understanding more about some aspects of ESP32, namely SPI Master Driver. The first part of this vendor document helped. So an ESP32 board has 4 SPI peripherals (I'll call them systems of pins that can work together). Two SPI systems are available to users, VSPI & HSPI. On an ESP32 board pinout, we see pins which can have more than one function & some function labels start with VSPI & HSPI. Ending letters in the VSPI & HSPI labels help us know their particular function in that SPI system. Caution: We must look at each board's pinouts (Joshua's are here) for the pin function labels. They often differ from board to board. E.G. from the table below, see that Joshua's board's pin assignments must not be the same as the pin assignments that he/we tried to adapt from the TFT32 board above. Also according to this, any (available) pin can serve interrupts (IRQ). SPI Signal-RFM69
| VSPI labels
| Joshua GPIO
| HSPI labels
| Joshua GPIO
|
| SS/CS | VSPICS0
| 5
| HSPICS0 | 15 |
| MOSI
| VSPID | 23 | HSPID
| 13 |
| MISO
| VSPIQ | 19
| HSPIQ | 12
|
| SCLK | VSPICLK | 18
| HSPICLK | 14
|
| DIO0/IRQ
|
| any available pin
|
| any avail
|
|
If I'm correct, for boards with pin functions IDENTICAL TO JOSHUA'S, the above table gives 2 SETS of pins (VSPI or HSPI) for connecting to the RFM69 radio's SPI signals (left column). Again if I'm correct, in the config_RFM69.h file, after the line "#elif defined(ESP32)", the next line FOR JOSHUA'S BOARD would be "# define RFM69_CS 5 // (VSPI)" or "# define RFM69_CS 15 // (HSPI)" Apparently that "#define RFM69_CS" activates a whole SET of pins (VSPI or HSPI). E.G. for Joshua's board, if he did # define RFM69_CS 5, then he'd connect the RFM69 radio's MOSI pin to his ESP32 board's pin 23.
Again, the pins in the above table are only for boards with pin assignments identical to Joshua's. However, using your board's pinouts, you can look for the labels in my table's VSPI or HSPI columns & adapt to YOUR ESP32 board accordingly. Hope this helps with a WiFI MQTT Gateway. (I don't currently have hardware to test this.)
Caution 2: Fortunately, with Joshua's board, the pinout chart's GPIO pin numbers & the Dxx pin labels printed on the ESP32 board mostly agree (E.G. GPIO5 matches with D5 pin). That's not always true for other boards. My understanding is that if GPIOs & Dxx don't agree, we use the GPIO numbers.
|
|
|
Post by papa on Sept 24, 2021 2:24:18 GMT
More Hints for Connecting RFM69 Radios to ESP332 Boards like Joshua's
It turns out that Joshua's VSPI pins (see last post) are standard for the ESP32 core.
So for boards with VSPI pins like Joshua's, the following might work...
Wire RFM69 3.3v & GND pins to ESP32 board.
Pick an available ESP32 pin & wire that pin to RFM69's DIO0 IRQ pin. Edit that ESP32 pin number into the config_RFM69.h file
Also in the config_RFM69.h file, after the line "#elif defined(ESP32)", the next line FOR BOARDS LIKE JOSHUA'S would be ... # define RFM69_CS 5 // (VSPI)
Using the left 3 columns of the last post's table, wire from the RFM69 pins to the Joshua's ESP32 pins. (E.G. connect RFM69 MOSI to ESP32 pin 23, etc)
In Arduino IDE/Tools/Board, select ESP32 Dev Module board (That will define the standard ESP32 core pins, including the VSPI pins.)
Compile / upload.
|
|
Joshua
Junior Member
Posts: 75
|
Post by Joshua on Sept 25, 2021 2:38:54 GMT
Hey folks,
I'm open for suggestions. Thank you for all your help and time.
I'm sorry to say that I have not been able to get these radios talking. I have an end node with DHT11 enabled and talking to the Uno Gateway. I'm using the same radio from the working Uno on the ESP32. Here are the steps I've taken.
- Download fresh copy of OpenMQTTGateway 0.9.8 - Setup the library shared in this thread - Enable #define ZgatewayRFM69 in User_config.h - Configured the following in config_RFM69_h (VSPI)
const char PROGMEM ENCRYPTKEY[] = "69C8D1790EAFB287"; //not top secret:)#define NETWORKID 100 //the same on all nodes that talk to each other #define NODEID 1 #define FREQUENCY RF69_915MHZ #define IS_RFM69HCW true // set to 'true' if you are using an RFM69HCW module # define RFM69_CS 5 // NSS # define RFM69_IRQ 16 // GPIO15/D8 DIO0 # define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) # define RFM69_RST -1 // GPIO02/D4 << changed, needs to indicate "not connected" - I've also tried config_RFM69_h (HSPI)
# define RFM69_CS 15 // NSS # define RFM69_IRQ 16 // GPIO15/D8 DIO0 # define RFM69_IRQN digitalPinToInterrupt(RFM69_IRQ) # define RFM69_RST -1 // GPIO02/D4 << changed, needs to indicate "not connected"
- As well as reassigning RFM69_IRQ to 4
Here's another diagram that has the HSPI pinout as a reference.
|
|
|
Post by papa on Sept 25, 2021 2:53:58 GMT
Joshua,
In Arduino IDE/Tools/Board, did you select ESP32 Dev Module board (to define the standard ESP32 core pins, including the VSPI pins.)?
|
|
Joshua
Junior Member
Posts: 75
|
Post by Joshua on Sept 25, 2021 3:03:26 GMT
Yes. ESP32 Dev Module with Minimal SPIFFS partition scheme (as directed in OpenMQTTGateway)
|
|
|
Post by papa on Sept 25, 2021 11:10:57 GMT
Joshua,
What sketch did you upload to the end node?
For the Gateway, did you try wiring the radio's 3.3v pin to its own power supply?
|
|
|
Post by papa on Nov 4, 2021 17:54:34 GMT
RFM69 Gateway Migrated to an ESP32 Board In this thread, I document an RFM69 Gateway created using an ESP32 (WiFi). This post has an ESP32 Gateway sketch that adds MQTT username & password. Joshua, were you able to get your ESP32 Gateway working using OpenMQTTGateway?
|
|