# Electric Imp/RN2903 to ESP32/RFM95W

**URL:** <https://www.thethingsnetwork.org/forum/t/electric-imp-rn2903-to-esp32-rfm95w/25255>\
**Category:** \[obsolete\] SCPF\
**Created:** [April 21, 2019, 9:18pm UTC](https://www.thethingsnetwork.org/forum/t/electric-imp-rn2903-to-esp32-rfm95w/25255 "2019-04-21T21:18:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fbraswell](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/fbraswell/32/23964_2.png) [@fbraswell](https://www.thethingsnetwork.org/forum/u/fbraswell)\
**Post date:** [April 21, 2019, 9:18pm UTC](https://www.thethingsnetwork.org/forum/t/electric-imp-rn2903-to-esp32-rfm95w/25255/1 "2019-04-21T21:18:40Z")

</div>

Trying to simulate following Arduino code which uses LMIC Library  
in order to communicate with an ESP32 and RFM95W HopeRF chip gateway  
as described at [https://www.sparkfun.com/products/15006](https://www.sparkfun.com/products/15006)  
This is for US 915 MHz

There are two code excerpts below. The first is the ESP32/RFM95W Arduino code used to communicate with its corresponding EPS32/RFM95W LoRaWAN gateway. The ESP32/RFM95W device and gateway were able to communicate with TTN.

The second block of code is my attempt to set up an RN2903 chip connected to an Electric Imp ([www.electricimp.com](http://www.electricimp.com)) to communicate with the EPS32/RFM95W gateway.

Communication is established with the RN2903 and Electric Imp, and I can monitor the “ok” responses from the commands. Is it possible for the RN2903 to communicate with the RFM95W gateway? Am I missing something in the setup? Any insight would be appreciated.

* * *

**// LMIC init used for node**

os\_init();  
// Reset the MAC state. Session and pending data transfers will be discarded.  
LMIC\_reset();  
// Set static session parameters. Instead of dynamically establishing a session  
// by joining the network, precomputed session parameters are be provided.  
uint8\_t appskey[sizeof(APPSKEY)];  
uint8\_t nwkskey[sizeof(NWKSKEY)];  
memcpy\_P(appskey, APPSKEY, sizeof(APPSKEY));  
memcpy\_P(nwkskey, NWKSKEY, sizeof(NWKSKEY));  
LMIC\_setSession (0x1, DEVADDR, nwkskey, appskey);

// slip to CFG\_us915 below  
#if defined(CFG\_eu868) // EU channel setup  
// Set up the channel used by the Things Network and compatible with  
// our gateway.  
// Setting up channels should happen after LMIC\_setSession, as that  
// configures the minimal channel set.  
LMIC\_setupChannel(0, 868100000, DR\_RANGE\_MAP(DR\_SF12, DR\_SF7), BAND\_CENTI); // g-band

#elif defined(CFG\_us915) // US channel setup  
// Instead of using selectSubBand, which will cycle through a sub-band of 8  
// channels. We’ll configure the device to only use one frequency.  
// First disable all sub-bands  
for (int b = 0; b \< 8; ++b) {  
LMIC\_disableSubBand(b);  
}  
// Then enable the channel(s) you want to use  
LMIC\_enableChannel(8); // 903.9 MHz  
LMIC\_enableChannel(17);  
#endif  
// Disable link check validation  
LMIC\_setLinkCheckMode(0);  
// TTN uses SF9 for its RX2 window.  
LMIC.dn2Dr = DR\_SF9;  
// Set data rate and transmit power for uplink (note: txpow seems to be ignored by the library)  
LMIC\_setDrTxpow(DR\_SF8, 14);  
// Start job – Transmit a message on begin  
do\_send(&sendjob);

* * *

**// Initialization commands sent from Electric Imp to RN2903**  
// trying to simulate the LMIC code above

// Excerpt below is representative of actual code to show the  
// RN2903 commands

“mac reset”,  
format("%s nwkskey %s", MAC\_SET, NWKSKEY),  
format("%s appskey %s", MAC\_SET, APPSKEY),  
format("%s devaddr %s", MAC\_SET, DEVADDR),  
“mac set ar off”,  
“mac set pwridx 5”,  
“mac set dr 4”,  
“mac save”,  
“mac join abp”,  
“mac pause”

// add “mac set ch status on/off” commands  
// turn off all but channels 8 and 17  
for (local i = 0; i \< 72; i++) {  
local str = format("mac set ch status %i ", i);  
local onoff = “off”;  
if(i == 8 || i == 17) onoff = “on”;  
str += onoff; // add onoff to mac command  
initCommands.push(str); // add command  
}

initCommands.push(“mac set linkchk 0”); // disable link check validation  
initCommands.push(“radio set sf sf9”); // spreading factor 9  
initCommands.push(“mac set dr 2”); // set data rate  
initCommands.push(“radio set pwr 14”); // power level  
initCommands.push(“mac resume”);

// list of init commands are now executed

* * *

**// Later Transmit commands sent from Electric Imp to RN2903**  
LoRaSend(MAC\_PAUSE);  
LoRaSend(“radio tx 48656c6C6F”); // send “Hello”  
LoRaSend(“mac resume”);

* * *

**Response from RN2903**  
receive message: mac\_tx\_ok

---

<div class="post-metadata">

**Author:** ![bluejedi](https://www.thethingsnetwork.org/forum/user_avatar/www.thethingsnetwork.org/bluejedi/32/44639_2.png) [@bluejedi](https://www.thethingsnetwork.org/forum/u/bluejedi)\
**Post date:** [July 10, 2021, 11:17am UTC](https://www.thethingsnetwork.org/forum/t/electric-imp-rn2903-to-esp32-rfm95w/25255/2 "2021-07-10T11:17:03Z")

</div>


