|
Post by papa on Oct 27, 2021 19:26:38 GMT
Adding an RFM95 Radio Network, Installed on ESP32 & Arduino Compatibles, Interacting with OpenHAB via MQTT MessagingMuch can already be accomplished with previous Gateways & Nodes published on this forum. Threads on RFM69 radio Gateways & Nodes provide ways to gather sensor data & control appliances. A WiFi ESP32 RFM69 radio Gateway was recently added. Threads on WiFi ESPxxxx Nodes provide ways to control appliances & gather camera data without needing a separate Gateway. Now I'm documenting an RFM 95 radio network which may be used alongside or instead of the above mentioned nodes & gateways. We should be able to use all of them without interference. All can interact with openHAB via MQTT messaging. Advantages of an RFM95 Network
|
|
|
Post by papa on Oct 27, 2021 19:29:33 GMT
Advantages of an RFM95 NetworkFor the RFM95 Gateway, I'm using an ESP32 WiFi board which has more program memory & should be easier to obtain than the Ethernet Shields we used with the first RFM69 Gateways. Typically, RFM 69 radios communicate somewhat longer distances than WiFi does. RFM 95 radios are supposed to communicate even farther than RFM 69. At Adafruit, see this: RFM 69 radios have a range of approx. 500 meters line of sight with tuned uni-directional antennas. Depending on obstructions, frequency, antenna and power output, you will get lower ranges - especially if you are not line of sight. At Adafruit, also see this: The RFM 9x radios have a range of up to 2 km line of sight with tuned uni-directional antennas. Depending on obstructions, frequency, antenna and power output, you will get lower ranges - especially if you are not line of sight. So this RFM95 network may allow us to communicate with one or more nodes where WiFi or RFM69 communication has been problematic.
|
|
|
Post by papa on Oct 27, 2021 19:43:21 GMT
Another Advantage
This RFM95 Network uses the same messaging structure as our forum's RFM69 nodes. With some hardware tweaks, the forum's RFM69 node projects should readily adapt to this RFM95 network.
Caution: RFM69 Gateway/nodes (even at the same frequency) cannot communicate with RFM95 Gateway/nodes. The two types of radio communicate differently.
Let's get started on building the minimum units for this network.
Next, Parts for an Initial RFM95 Network of Gateway & One Bare Bones Node
|
|
|
Post by papa on Oct 27, 2021 20:30:47 GMT
What Is Needed for an RFM95 NetworkDetermine the radio frequency Allowed in Your Region & Its Antenna Length:Your Gateway & nodes must have the same frequency RFM95 radios. We're expected to use the frequency that's available for our region. I adapted the following from Table 1 at this site. It gives appropriate regions for the frequencies. Antenna sizes (1/4 wave) may be close but a little different from other tables: Available Unlicensed Frequency Bands Frequency Antenna length Regions433 MHz 173 mm Europe, Asia, Australia, U.S. (limited) 868 MHz 78 mm Europe only 915 MHz 82 mm U.S. and Australia (& Canada ??) Other research says, a 1/4 wave ANT or ANA (antenna) wire for 868 or 915 MHz can be about 3 inches (80mm), about 6.5 inches (165 mm) for 433MHz. You can make an antenna from regular wire or buy one. This page shows a 433MHz antenna that is somewhat coiled & somewhat straight. In the following posts, use the above info to get the correct RFM95 radio frequencies & cut the proper length of wire for radio's antennas. Parts & Hardware Continue Below
|
|
|
Post by papa on Oct 28, 2021 20:56:54 GMT
What Is Needed for an RFM95 Network Overview
The Gateway & nodes will each need a USB cable to help connect them to the Arduino IDE computer (for programming & serial output) & power (via USB or 5 volt DC adapter). ESP32 & Arduino boards may have a Micro USB connectors to receive the USB cable.
For the Gateway, we need an adequately configured ESP32 board with an RFM95 radio.
For each node, we need an Arduino compatible board with an RFM95 radio. I usually call them "Arduinos."
ESP32+RFM95 & Arduino+RFM95 can be achieved in a variety of ways. Posts below will discuss at least some of them.
Disclaimers: I've only made a RFM95 Gateway by my installing an RFM95 radio onto a Sparkfun ESP32 Thing. I've only made a RFM95 node by my installing an RFM95 radio onto a Buno Uno Arduino compatible. What I say about other ESP32 & Arduino compatibles is based on research, but you may need to work out more using schematics & your own experience.
Next, RFM95 Radios, Factory Installed or Not
|
|
|
Post by papa on Oct 28, 2021 21:45:55 GMT
Boards with Factory Installed RFM95 Radios Introduction & Gateway Possibilities
Introductory notes about RFM95 radio names: The radio/transceiver may be called "LoRa." Also my understanding is that RFM9x radio modules are the same except for the electronic parts that tune them to their frequency. I usually just call them "RFM95 radios (or transceivers)." Disclaimer about boards with factory-installed RFM95 radios. I have used none of the ESP32 boards that might work for an RFM95 Gateway. I have used none of the Arduino compatible boards that might work for an RFM95 node. (In my RFM 69 network, I have successfully used an Anarduino Miniwireless board with an installed RFM 69 radio.) Factory installation takes care of connecting the radio to the ESP32. Solder holes on board edges are for other connections. You may solder to these holes or I recommend you install .1 inch (2.54mm) female headers in the holes & plug bared wire ends into the female headers. ESP32-RFM95 Boards That May Work as a GatewaySparkFun LoRa Gateway-1-Channel 868/915mhz Docs here & here especially. ESP32 add-on includes this in the Tools/Board list. Heltec Wireless Shell all 3 frequencies. Docs here & here especially. From ESP32 add-on may be able to use “Wireless Stick Lite” in the Tools/Board list. ESP32 LoRa 32, 868/915mhz, has OLED screen, has only male pins on the bottom. Docs here & here. At this location, search for "ESP32 IOT LoRa" & see an announced, but not yet ?? offered ESP32 with RFM95 radio (433 or 868 or 915mhz) already mounted. Pics show all ESP32 pins broken out, but I cannot yet tell if V-SPI pins are in standard locations. To find more, search for "ESP32 RFM95" or "ESP32 LoRa" See this post for installing the Arduino IDE add-on that you need for programming an ESP32 board. Next, Arduino-RFM95 Boards That May Work for a Node
|
|
|
Post by papa on Oct 29, 2021 21:58:37 GMT
For Nodes, Arduino Compatibles with Installed RFM9x RadiosGo here to order one kind of Moteinos & select your RFM9x radio frequency & headers. These Moteinos will need an FTDI to program them & a USB adapter to power them. Or go here to order another kind of Moteino with USB connector & select your RFM9x radio frequency & headers & correct USB cable.These Moteinos will NOT need an FTDI to program them. Moteino docs here. Or go here to order a MiniWireless board & select your RFM9x radio frequency. These devices will need an FTDI to program them & a USB adapter to power them. Headers would also be useful. MiniWireless docs here. Via this & the previous post, you could have a ESP32-RFM9x unit & an Arduino-RFM9x unit minimally needed for a RFM9x Gateway/Node network. Posts below give hints & links for getting installing the RFM9x radios yourself. Next, FTDI Device to Program Some Arduinos
|
|
|
Post by papa on Nov 1, 2021 19:58:53 GMT
FTDI Device to Program Some Arduinos Parts to Power Them Later
As noted in the last post, some Arduino compatibles need an FTDI device to connect for programming, power & serial output. The FTDI programmer must be able to function in 3.3 volts (much more will damage the Arduino or its RFM69 radio). I use this one. Others use this one. To connect to the Arduino IDE computer, the FTDI device will also need a USB cable probably with a male Mini connector. =================================== Also needed later to power the programmed Arduino for regular use: a 5 volt (2 Amp may be best) power adapter that accepts a USB cable
Two short dupont cables (red & black?) to connect the breakout board to the Arduino compatible. One end of each cable will be female for connecting to the breakout board's male header. Each cable's other end will be male or female depending on the Arduino's headers.
Depending on your need, at ebay, etc., search for 10cm female to female or female to male Dupont wires. Next, Getting RFM9x Radios
|
|
|
Post by papa on Nov 1, 2021 20:02:57 GMT
Getting RFM9x RadiosUnless you use above posts to get boards with pre-installed radios, you'll need at least two RFM9x radio transceivers. The following are some links to get you started with obtaining radios using your region's available frequency: 433mhz 868mhz 915mhzOn their edges, the radios have solder holes that are fairly close, but manageable. To some of those holes, you'll also need to solder about 10 short (2 +/- inches) 22 gauge wires (color-coded?). More on this below. Next, an ESP32 board for the Gateway
|
|
|
Post by papa on Nov 1, 2021 20:23:01 GMT
An ESP32 Board for the Gateway (RFM95 Radio Not Installed Yet)If you did not get a ESP32 board with a pre-installed RFM95 radio (see above), you need an ESP32 board that breaks out all pins, or at least power, gnd, VSPI pins, available pins for RFM95 reset & chip select connection, & ways to connect the ESP32 pins. I bought a Sparkfun ESP32 Thing & 2 sets of female headers that were each 20 sockets long. The ESP32 Thing has all pins broken out & has an USB connector for programming & Arduino IDE serial output. It uses the standard ESP32 pin arrangements including for the V-SPI pins: MOSI (pin 23), MISO (19), SCK (18), & CS (5). Similarly qualified boards (ESP32 Dev Module ??) should also work. << Members, click pic for larger view In the above pic ^^ I marked the pins I used for the RFM95 radio with red bracket or dot. Pins marked by the red bracket are already selected for SPI communication use by the ESP32 add-on (see next post). Those bracketed pins & the GND pin I selected line up nicely with how I wire the RFM95 radios. Pins I used for 2 add on LED indicators are marked with green dots. If the ESP32 board has a USB connector, we need a USB cable to connect the board to the Arduino IDE computer for programming & IDE Serial Monitor output. The Sparkfun ESP32 Thing needs a Micro USB cable. Next, Add-on to Prepare Arduino IDE for ESP32
|
|
|
Post by papa on Nov 1, 2021 20:35:14 GMT
What Is Needed for an ESP32_RFM95 Network Prepare Arduino IDE for ESP32
In preparation for programming an ESP32 board for a Gateway, install the needed ESP32 add-on In Arduino IDE, go to File\PreferencesIn the “Additional Board Manager URLs” near the bottom of Preferences, enter the URL below & click the OK button. If other URLs are in the box, end the list with a comma & then add the URL. OR click the nearby "page & shadow" icon & enter the URL on a separate line.
Go to Tools\Board\Boards Manager. In the box near the Boards Manager's top, search for ESP32 & press the install button for “ESP32 by Espressif Systems“ When the install finishes, you may close the Boards Manager. Installing that add-on gives us a Sparkfun ESP32 Thing option at IDE Tools/Board. The add on also lists the ESP32 Dev Module whose settings might work for other boards. Next, For Nodes, Arduino Compatibles
|
|
|
Post by papa on Nov 3, 2021 20:21:26 GMT
For Nodes, Arduino Compatibles (Radios NOT Pre-Installed)For nodes, an earlier post offered examples of Arduino compatibles that have pre-installed RFM95 radios. They have the advantages & disadvantages of being small. Being without USB connectors, they need add-on devices to program & power them. This post offers larger Arduino compatibles (Arduino Uno form factor) with USB connectors for programming & power. They & possible add-on shield boards give more room to work & make connections. We must use Arduinos that can operate at 3.3 volts so we don't damage the RFM95 radios that will be installed. I recommend BUONO UNO R3 Arduino compatibles which you can buy here. Though I don't have one, I believe a Seeeduino v4.2 will work. Buy here or elsewhere. I do NOT recommend a Massduino. Next, Prepare Wires for RFM95 Radios
|
|
|
Post by papa on Nov 4, 2021 18:53:22 GMT
Prepare Wires for RFM95 RadiosThis is for the ESP32 & Arduino Compatible boards that do NOT have pre-installed RFM95 radios. You need 22 gauge insulated wire. So I can color code & better see their connections, I have 7 colors of wire: red (3.3v), white (DIO0), blue (SCK), yellow (ANT), white, green, & black (GND). Cut four wires 1.5 inches long for GND (black), MISO, MOSI, & NSS. Cut three wires 1 5/8 inches long for 3.3v (red), SCK & Reset. Cut one wire 2.25 inches long for DIO0. From one end of all these wires, strip 1/2 inch of insulation (for the ESP32 & Arduino sockets). From the other end of all these wires, bare 3/8 inch of wire (to insert & solder in the RFM95 radio's solder holes). Unless you buy an antenna, also cut one wire at the length needed for your radios' frequency ( See this post above). For the home-made antenna , only bare 3/8 inch of wire on one end for soldering to the radio. After soldering, you may leave the antenna straight or wind it around a pencil into a coil. Both ways seem to work. For optimal communication, leave the antenna straight & perpendicular to the radio board. Next, Begin to Wire RFM95 Radios
|
|
|
Post by papa on Nov 4, 2021 20:17:33 GMT
Begin to Wire RFM95 RadiosWire Gateway & Arduino Node radios the same way & use bends in some wires to adjust length as needed. For me, the easiest way (as a whole) to start setting up & soldering the radio is to use an Arduino that is no longer working (spilled solder does not matter). On the MISO/MOSI side of the radio, insert the bared 1/2 inch of 6 wires into Arduino sockets on the D0-D13 side. Then insert the other end (3/8 inch) of the six wire in the correct RFM95 solder hole. Keep the radio board roughly parallel to the Arduino board. Carefully crimp the wire end to be soldered so it only touches itself & its solder hole & not another wire or solder hole. Check your work. The above should provide a fairly stable setup for soldering the first six wires. Using some solder flux?, solder the six wires to the radio. With magnification, make sure each wire is sufficiently soldered & no solder bridges between wires. Use the following table to make correct connections for the first six wires. The hardest part is inserting all bared ends into the RFM69 holes. If a wire is too long, use a bend to shorten it. Arduino |
| RFM95 | length (in)
| Color Code ? | D7 |
| Reset | 1 5/8 in
| blue? | D10 |
| NSS | 1.5 in
| yellow? | D11 |
| MOSI
| 1.5 in
| white?
| D12 |
| MISO
| 1.5 in
| green?
| D13 |
| SCK ^
| 1 5/8 in
| blue?
| Gnd #
|
| Gnd *
| 1.5 in
| black
|
*Notes: Use the RFM95 Gnd solder hole that is next to the RFM95 MISO hole. # Use the Arduino Gnd socket that is next to D13. ^ Caution while the other wires stay "in order" into the Arduino sockets, the SCK wire crosses over the MISO wire. Next, Install the Last 3 Wires onto the RFM95
|
|
|
Post by papa on Nov 4, 2021 20:32:10 GMT
Install the Last 3 Wires onto the RFM95 In the order of the following table, insert the bared .5 inch in the Arduino socket & the 3/8 inch into the RFM95 solder hole. Crimp the bared end carefully over the RFM95 hole & solder it there. Check your work. Arduino
| RFM95
| length (in)
| color code?
| 3v3
| 3.3 v | 1 5/8 in
| red
| DIO0
| D2
| 2.25 in
| white?
| no connection
| ANA | See above
| yellow? |
For more easily installing the radio later, carefully remove the RFM95 from the not working Arduino so wires & RFM95 retain their "shape." Remove wires from Arduino sockets in this order: 3.3v, DIO0, then the last 6 wires at the same time. Repeat the last post & this post so you have at least two wired radios. Next, Assemble ESP32 Gateway
|
|
|
Post by papa on Nov 5, 2021 20:46:39 GMT
Assemble ESP32 RFM95 Gateway ESP32 + Wired RFM95 Radio + LEDs
Assemble the Gateway using the following wiring diagram. If you wired the RFM95 as in the posts just above, the wires should be shaped (perhaps with a little bending) to be inserted into the proper ESP32 pin socket. On one side of the ESP32 & RFM95, start by inserting (at the same time) the RFM95's Reset-Gnd wires into their sockets. Then do the 3.3v wire & then DIO0. Check your work.
The diagram assumes standard ESP32 V-SPI pin assignments. The later Gateway sketch will use the two LEDs. Especially for when the Gateway will be disconnected from the Serial Monitor, one steady-burning LED will signal that WiFi/MQTT is connected. The flashing LED signals when radio communication is happening. For each LED, the originally shorter pin goes into an ESP32 ground. Via a 100 ohm resistor each originally longer pin goes into the ESP32 pin designated in the Gateway sketch. You may change the ESP32 pins for RFM95 Reset & for the LEDs, but you must also change the pin numbers in the Gateway sketch. Update, Nov. 11, 2021: The connection between ESP32 GPIO 15 & RFM95 Reset is NOT NEEDED so its use is disabled in sketches. << Members, click on pic for larger view. In this post, see a picture of the RFM 69 WiFi Gateway I built on a Sparkfun ESP32 Thing. This RFM 95 Gateway is the same except one more wire is added for the RFM95 Reset pin which again is probably optional Next, Assemble a Bare Bones Arduino RFM95 Node
|
|
|
Post by papa on Nov 5, 2021 21:43:18 GMT
Assemble a Bare Bones Arduino RFM95 Node << Building on a 3.3 volt Arduino compatible (with Arduino Uno form factor), follow this schematic to install the RFM95 radio wired as above. If you wired the RFM95 as in the posts just above, the wires should be shaped (perhaps with a little bending) to be inserted into the proper Arduino pin sockets. On one side of the Arduino & RFM95, start by inserting (at the same time) the RFM95's Reset-Gnd wires into their sockets. Then do the 3.3v wire & then DIO0. Check your work. If also changed in the sketch below, RFM95 Reset can be moved from Arduino D7 to D5, D6, D8, or D9 if available. For some nodes, such a move will be necessary.
Update, Nov. 11, 2021: The connection between Arduino D7 & RFM95 Reset is NOT NEEDED so its use is disabled in sketches.
For this node version, you only need the Arduino compatible (with power supply), connecting wires, & the RFM95 radio (obtained & prepared as above). Carefully following the labels in the schematic, bend & insert the RFM95 wires into their correct Arduino sockets. Next, For Programming Some Boards, Connect FTDI
|
|
|
Post by papa on Nov 6, 2021 19:06:39 GMT
For Programming Some Boards, Connect FTDIThis post is relevant only if your ESP32 or Arduino compatible does NOT contain a USB connector (by which the board can be programmed & powered & give Arduino IDE serial monitor output). This post above gives links for obtaining an FTDI programming device which must be able to function at 3.3 volts. When the time comes later to program & initially power these boards, connect them in this chain: Arduino IDE computer's USB port, USB cable, FTDI's USB connector, & then using dupont cables connect the FTDI pins to the ESP32 or Arduino as follows: ESP32 or Arduino to be connected to FTDI VCC 3V3 Rx Tx Tx Rx GND GND Next, Get Needed Code Libraries for Arduino IDE
|
|
|
Post by papa on Nov 6, 2021 21:30:19 GMT
Get Needed Code Libraries for Arduino IDE Download the RadioHead library here. & keep track of where you save it. Install the RadioHead library via the Arduino IDE menu: Sketch/Include Library/Add .Zip Library Get MQTT client library; At IDE/Tools/Manage Libraries, search for PubSubClient & install the Nick O'Leary version Members, download these two files & keep track of where you save them: encrypt.h (260 B) encrypt.cpp (1.08 KB) Next, Preparing to Test the RFM95 Radios
|
|
|
Post by papa on Nov 9, 2021 2:13:25 GMT
Preparing to Test the RFM95 Radios On ESP32 Server/GatewayFor programming the ESP32_RFM95 Gateway, the Arduino IDE needs to know where RFM95 pins are connected to the ESP32 pins. When you install the ESP32 add-on, it's best the Arduino IDE Tool/Board menu lists the board (& thus it knows the pin connections). If this is not the case, board documentation (especially pinouts or schematics) are helpful. User-installed RFM95 radios. In my "test radio" & Gateway sketches, I provide the necessary pin defines for the Sparkfun ESP32 Thing (& I believe the ESP32 Dev Module & other boards which follow its SPI pins standard). After the ESP32 add-on is installed, Tools/Board list knows the ESP32 Thing & its V-SPI pins. Arduino just needs to know how we've wired the rest of the RFM95. I've provided comments to help you know where you can change to other available pins. If you use my Gateway-RFM95 wiring for the ESP32 Thing & probably the ESP32 Dev Module, my sketches should work for these boards. I just updated this post on ESP32 boards with pre-installed radios to give links to board documentation & whether I found them on the ESP32 add-on Tools/Board list. Such documentation also helps when you install Gateway LEDs on available pins. Whether this device has a pre-installed or user-installed RFM95 radio, before you power it, be sure you have soldered the correct length of Antenna to the ANT solder hole on the board. See this post about antennas. Testing the RFM95 Radio on the ESP32 Server/Gateway
|
|
|
Post by papa on Nov 9, 2021 19:37:23 GMT
Testing the RFM95 Radio on the ESP32 Server/GatewayNow you're close to programming an ESP32 board with pre-installed or user-installed RFM95 radio. Without a matching Arduino Client/Node, this device will not do much but initialize the radio. This post includes a fairly simple server sketch that will receive a struct of data from a client (that sketch comes later). This sketch does not have things we need later for a gateway: WiFi & MQTT. It does include a #define you can UNcomment for encryption, but (at least at first), I recommend you leave that commented (//) & disabled. If your ESP32 board has a pre-installed radio AND your board is in the Arduino IDE Tools/Board menu, comment out #define User_Installed_RFM95. If you have Sparkfun ESP32 Thing (or probably ESP32 Dev Module or similar) AND wired the radio as in my schematic above, UNcomment #define User_Installed_RFM95. If you wired your RFM95 radio differently, adapt lines 16-18 accordingly. If possible in the Arduino IDE Tools/Board menu, select your ESP32 board's name. In the Tools menu select Partition Scheme: large APP. Connect your ESP32 board to your computer's USB port (via FTDI if necessary). In the Tools/Port menu select the computer port to which your board connected. R95_Struct_Server_B03_esp.ino (5.84 KB) << Members, download this sketch to your Arduino IDE sketch folder. Open the sketch in the Arduino IDE & customize as above in this post. When you want to try the encryption, copy the 2 encrypt files from this post into the subfolder where the IDE places this sketch. Upload the sketch to the ESP32 with RFM95 radio. Open the Arduino IDE serial monitor at 115200 baud. On the serial monitor screen, if you see "init failed" then check your work from this post. If you see "radio init succeeded," then so far, so good. No more serial Output will occur until the R95_Struct_Client sketch is successfully running.
Note: Again, this is not yet a gateway. That sketch comes later. This sketch programs a simple RFM95 server to test your radio.
Next, Preparing to Test the RFM95 Radio on the Arduino Client/Node
|
|
|
Post by papa on Nov 9, 2021 19:38:26 GMT
Repeated Disclaimers:
Again, I've only made a RFM95 Gateway by my installing an RFM95 radio onto a Sparkfun ESP32 Thing.
I've only made a RFM95 node by my installing an RFM95 radio onto a Buno Uno Arduino compatible with an Arduino Uno form factor.
What I say about other ESP32 & Arduino compatibles is based on some research & experience, but you may need to work out more using schematics & your own experience. Next, Preparing to Test the RFM95 Radio on the Arduino Client/Node
|
|
|
Post by papa on Nov 9, 2021 20:46:09 GMT
Preparing to Test the RFM95 Radio on the Arduino Client/NodeNow you're close to programming an Arduino compatible with pre-installed or user-installed RFM95 radio. Without a matching Arduino Gateway/Server, this device will not do much but initialize the radio. This post includes a fairly simple client sketch that will send a struct of data to a server which will reply to the client. This sketch does not have things we need later for a node. It does include a #define you can UNcomment for encryption, but (at least at first), I recommend you leave that commented (//) & disabled. The encryption #define line must be the same for server & client. If your Arduino compatible is thumbnail size & has a pre-installed radio, comment out #define Arduino_Uno_Form. If you have a user-installed radio on an Arduino Uno form factor (about 2 x 2.75 inches), UNcomment #define Arduino_Uno_Form. If you wired your RFM95 radio differently, adapt lines 33-35 accordingly. If you have a Moteino or Moteino USB, get its Arduino IDE add-on by using the instructions in the Programming & libraries section on this page. In the Arduino IDE Tools/Board menu, select a board name: For a Moteino, select Moteino AVR. For MiniWireless or Arduino Uno Form Factor, select Arduino Uno. Connect your board to your computer's USB port (via FTDI if necessary). In the Tools/Port menu select the computer port to which your board connected. R95_Struct_Client_B03.ino (4.52 KB) << Members, download this sketch to your Arduino IDE sketch folder. Open the sketch in the Arduino IDE & customize as above in this post. When you want to try the encryption, copy the 2 encrypt files from this post into the subfolder where the IDE places this sketch. Upload the customized sketch to the Arduino compatible with RFM95 radio.
Next, R95 Struct Server & Client, Expected Results
|
|
|
Post by papa on Nov 9, 2021 21:19:10 GMT
R95 Struct Server & Client, Expected ResultsAfter you upload the customized sketch to the Arduino compatible with RFM95 radio, open the Arduino IDE serial monitor at 115200 baud. On the serial monitor screen, if you see "init failed" then check your work from the above post. If you see "radio init succeeded," that's good. Connect the ESP32 R95 struct server to a computer USB port. In Arduino IDE's Tools/Port, select the ESP32 server's port. Open the Arduino IDE Serial monitor at 115200 baud. In the client's serial monitor, you want to repeatedly see: In the server's serial monitor, you want to repeatedly see something like: Unless you change the client sketch, the nodeID will always be 85 & the payload will be "Hello World." The other items are randomly generated within ranges. Note: Again, this is not yet a node. That sketch comes later. This sketch programs a simple RFM95 client to test your radio & simple communication between two devices with RFM95 radios. If this simple server-client interaction worked, this is great preparation for a RFM95 Gateway & Nodes.
Next, How Are You Doing So Far, Especially with Pre-Installed Radios?
|
|
|
Post by papa on Nov 10, 2021 14:11:12 GMT
How Are You Doing So Far, Especially with Pre-Installed Radios?
Again, I've only made a RFM95 Gateway by my installing an RFM95 radio onto a Sparkfun ESP32 Thing.
I've only made a RFM95 node by my installing an RFM95 radio onto a Buno Uno Arduino compatible with an Arduino Uno form factor.
What I say about other ESP32 & Arduino compatibles (with pre-installed radios) is based on some research & experience, but you may need to work out more using device schematics & your own experience. Update: The ESP32 & Arduino's connection with RFM95 Reset is probably optional. Who used ESP32s or Arduino compatibles with pre-installed RFM95 radios? Did what I provided above work for you? What adjustments did you need to make?
Next, Preparing to Program the ESP32-RFM95 Gateway
|
|
|
Post by papa on Nov 10, 2021 18:43:10 GMT
Preparing to Program the ESP32-RFM95 Gateway Install Mosquitto MQTT & Find Your Computer's IP Address
If you have successfully accomplished the above, you've done much of the challenging work of this project: You have an ESP32 & Arduino compatible with RFM95 radios, their software successfully initialized the radios, & the devices successfully communicated both directions. Now some other preparation. Install Mosquitto MQTT messaging: See here for guides to install Mosquitto on Windows or Linux. MQTT handles messaging between the Gateway & openHAB. In order to initialize, the Gateway sketch expects to connect with MQTT. See here for my notes on the Linux install of Mosquitto. See here for my notes on configuring Mosquitto 2 MQTT Broker in Linux. =============================================== Find the IP address of the computer that hosts Mosquitto MQTT. (The Gateway sketch needs it to know this.) See my notes here on doing this in Linux. For Windows, search for & open cmd. At the prompt, enter ipconfig ============================================ Be sure you have the code libraries from this post above. Next, the ESP32-RFM95 Gateway Programming
|
|
|
Post by papa on Nov 10, 2021 20:39:02 GMT
ESP32-RFM95 Gateway Programming & Customizing RF95_MQTT_GW_25.6.6_esp_pub.ino (29.68 KB) << Members, download this Gateway sketch & open it in Arduino IDE. Do NOT upload it until you customize as follows. Save your work as you go. In the sketch, find #define mqtt_server & between quote marks, give the IP address of your computer. Find 3 lines with #define RF95_FREQ & according to your radio's frequency, UNcomment (remove initial //) only one of the lines. If you want to use encryption, UNcomment #define SECRET. Also into the same folder as the Gateway sketch, copy the two encryp.x files from this post & see an additional change below. Find 4 lines starting with #define wifi_ & between the quote marks, give your WiFi credentials. If you want MQTT to require username & password, UNcomment #define MQTT_USER & #define MQTT_PASS & between the quote marks, give your MQTT credentials. Find #define User_Installed_RFM95. UNcomment for user-installed radio. Comment (start the line with //) for ESP32 with pre-installed radio. Find #define MQCON & #define R_LED. If you installed 2 indicator LEDs above, make sure you define the correct pins. If you did not install them, use -1 for pin numbers. If you installed the radio, find #define RFM95_CS & #define RFM95_INT (RFM95_RST is probably optional). Make sure the pin assignments are correct. Find ifdef NetworkOne. For byte ip, give an available IP address in your local network. If you're using encryption, change the encryptkey (16 elements separated by commas, each element starts with 0x. The given encryptkey is too easy to guess. If & when you add NetworkTwo or NetworkThree, complete byte ip & encryptkey as you did for NetworkOne. Next, Configure Arduino IDE & Upload Gateway Sketch
|
|
|
Post by papa on Nov 10, 2021 20:50:26 GMT
Configure Arduino IDE & Upload Gateway Sketch
With the Gateway sketch (last post) open in Arduino IDE & the Gateway device connected to your computer's USB, configure Arduino IDE as follows ...
In Arduino IDE Tools/Board menu, select ESP32 Arduino then (if possible) select the name of your board or a working equivalent. At the least, select ESP32 Dev Module.
Tools/Partition: Select one with "large App"
Tools/Core Debug: Select Verbose
Tools/Port: Select the port that the computer/Arduino IDE assigned to your ESP32.
Check your work. Upload the Gateway sketch to the ESP32.
Next, RFM95 Gateway, Expected Results
|
|
|
Post by papa on Nov 10, 2021 21:06:40 GMT
RFM95 Gateway, Expected Results (No Matching Node Yet)
Without a matching node yet, you'll see only a little on the Arduino IDE Serial Monitor. However, what you see so far are important steps.
With the ESP32 Gateway connected to computer's USB & the ESP32 Gateway's port selected in Arduino IDE Tools/Port, open the Serial Monitor & see something like the following:
If you installed the indicator LEDs, one LED will blink once as it connects with WiFi & then it will shine steady when it connects to MQTT. The other LED will not light until the Gateway is communicating with a node.
Sometimes the above steps take a little while. If it does not seem to be working, press the ESP32 reset button & move the ESP32 to help align it better with your WiFi router.
Ahead, Preparing to Program an RFM95 Node
|
|
|
Post by papa on Nov 11, 2021 16:59:05 GMT
Signal LEDs for ESP32 Boards with Pre-Installed Radios
As said above, the Gateway sketch uses two LEDs. Especially for when the Gateway will be disconnected from the Serial Monitor, one LED will blink once to signal that WiFi is connected & then will light steadily to indicate MQTT connected. The other LED will flash to signal when radio communication is happening with a node. For each LED, its originally shorter pin goes into an ESP32 ground. Via a 100 ohm resistor each originally longer pin goes into the ESP32 pin designated in the Gateway sketch. Before you solder the resistor to the LED's originally longer leg, shorten the leg & the resistor leg to make a good length for installing on the ESP32.
Where to attach the LEDs on the ESP32 board ...
My schematic/wiring diagram above & the downloaded Gateway sketch has the LEDs connected to ESP32 pins 12 & 16 & to conveniently located Gnd pins. You may change the pins for the LEDs, but you must also change the pin numbers in the Gateway sketch accordingly. Ahead, Programming & Customizing an RFM95 Node
|
|