Single-Channel ESP-based Gateway

I’ve been looking into running a single-channel gateway with the Wemos D1R1 I’ve got lying around. I’ve actually managed to get it to compile too!

Link to repository: https://github.com/b00bl1k/ESP-1ch-Gateway-v5.0/tree/fix-downlink

Note that it’s actually a 3rd party pull request branch and not the master branch itself, as I coudn’t get the master branch to compile. After a great deal of fiddling, I got this up:

I will, of course, show how I did this in more detail at the next hardware meetup after I’ve cleaned up my code (and removed my personal information).

It claims that it talks to TTN by default, and I’ve configured it to use channel 0 (868.1MHz).

Testing a Client

Next, to test it out I tried using this example: https://github.com/mcci-catena/arduino-lmic/blob/master/examples/ttn-otaa/ttn-otaa.ino

…with a tiny adjustment. Before the os_init(); call I’m doing this:

#define CHANNEL  0

for (uint8_t i = 0; i < 9; i++) {
	if (i != CHANNEL) {
		LMIC_disableChannel(i);
	}
}

Unfortunately, it doesn’t appear to work. I get the following output:

Starting
Packet queued
203: EV_JOINING
448: EV_TXSTART
428708: EV_TXSTART
939220: EV_TXSTART
1356359: EV_TXSTART
1772850: EV_TXSTART
2203851: EV_TXSTART
3226779: EV_TXSTART
FAILURE 
/absolute/path/to/MCCI_LoRaWAN_LMIC_library/src/lmic/radio.c:746

Interestingly, I don’t get EV_TXCOMPLETE, and neither does the gateway pick anything up either.

Thoughts? I’ll bring everything to the hardware meetup next week.

Update: I’ve been having a bit of trouble with it. I’m going to bring it (and all my other bits & pieces) along to the next Hardware Meetup.

Here are the things I have:

  • Dragino: 1 x Arduino Uno with 1 x Dragino LoRa Shield and a ‘proper antenna’ (which belongs to University, but I’m using it for my project)
  • Gateway: 1 x Wemos D1 R2 with 1 x RFM95 with a 1/4 wave antenna cut from a piece of wire
  • Greenhouse: 1 x Arduino Uno with 1 x RFM95 + a ‘proper antenna’ connected via a level shifter

I’ve given each of these nicknames according to what their function is to make the following section easier to understand.

Things I know:

  • Greenhouse and Dragino can both send and receive basic messages without issue.
  • When receiving basic messages, continuous receive mode must be used - or it doesn’t work.
  • Gateway can send and receive basic messages without issue too, but to receive the library I’m using requires a small tweak.
  • When Gateway runs the new ESP-based gateway code, it only picks up every 5th-13th message. This was tested by sending simple test messages with Dragino, and putting Greenhouse into listening mode.
  • Disabling CAD and enabling SPI Mutex don’t help Gateway to receive more messages.
  • Changing the ESP speed from 80 to 160 in the setting does appear to boost the catch rate of messages, but testing this is challenging.
  • When Greenhouse or Dragino run an LMIC OTAA example code (with some additional tweaks to ensure it functions correctly for single channel gateways), I see either 1 EV_TXSTART or the same EV_TXSTART loop documented above.
  • Trying to enable the debug logging in LMIC has no effect, and doesn’t enlighten me as to what frequency it’s actually transmitting on.
  • Gateway doesn’t appear to pick up the OTAA messages from Greenhouse or Dragino, but this is probably just bad luck - since I tested this when also sending simple test messages every 5 seconds.

Things I don’t know:

  • Whether Dragino would pick up an OTAA join message in ‘receive simple messages mode’ if Greenhouse was flashed with the LMIC code.
  • Whether I should buy a ‘real antenna’ for Gateway.