The ESP 1 Channel Gateway

Version: 1.1.0 First version
date: April 12, 2016

(c) Maarten Westenberg (mw12554@hotmail.com)

 

Introduction

After building the first 1-channel Gateway based on a raspberry with a RFM95 transceiver I asked myself whether it would be possible to make an even cheaper 1-channel gateway. If we would be satisfied with WiFi network support only, then the ESP8266 mcu would be a good candidate for such a gateway.

Now most of us know that the ESP8266 is a difficult animal to play with. As the ESP8266 divides its time between the IDE program and its internal WiFi support system, we will get watchdog reset problems really soon if we do not allow the background processes to deal with WiFi on a very regular basis.

The project source code is found on the Things4U github page as well.

Limitations

A full-function gateway is capable of simultaneously receive several LoRa packets with various spreading factors on random channels. The 1-channel gateway does not have the performance to do that. It is sort of compatible with the LoRa data format sent by sensors but it does not implement the rest of the LoRa specs and therefore is not compliant.
The 1-channel gateway has the following limitations compared to its bigger brother:

  1. 1-channel only: So 1 out of every 8 message on average is received. If you do not have any other gateways in production I advise you to use channel 0 for this purpose.
  2. Works with one Spreading Factor mode only (SF7 is activated by default at the moment).

Building

As you can see on the picture above, the whole thing fits on a very small board. And as there are even less connections necessary as for the loRa node, this DIY project could be ready in a matter of hours. These are the steps:

 

I did not yet find a nice box to put the gateway in, but that will probably not last very long.

Pin Out

The pin out of the two devices on the gateway board are as follows:

The pin-out of the ESP8266 is as follows (note: There are differences in pin-out between the various ESP8266 devices)

 

Connections

Connections need to be made as follows:

RFM95 pin   ESP8266 pin
3.3V VCC 3.3V
GND   GND
MISO   D6 GPIO12/MISO
MOSI   D7 GPIO13/MOSI
SCK   D5 GPIO14/CLK
NSS   D8 GPIO15/CS
RESET   *nc
DIO0   D1, GPIO5
     

* The reset pin does not have to be connected so it seems. It is only used at setup to read the chip identification

As you can see, both reset and GPIO0 of the ESP8266 are not used. Not connecting the last one makes the ESP8266 gateway more stable and the behavior between flash and normal mode is the same.

Software

The software is currently still under development. Several additions have been made to the RaspberryPI version in order to make this ESP version more reliable and workable. However, there are still some functions that can be included such as setting the SSID and password dynamically (The ESP will act as an access point so that your PC can connect to it, and set SSID and Password).

DNS

The ESP libraries support DNS hostnames out of the box. As apparently DNS functions are hard on the mcu, and may cause crashes and watchdog resets, I have decided to only once get the IP address of the LoRa router and from that moment on use that IP address in the program.

Clock

The clock function is implemented using NTP. As soon as we have an IP connection we try to connect to a timeserver to get the current time. This way we know how long the unit is operational since we last powered it on, and can we time things if necessary.

Webserver

As the ESP8266 is not a Linux machine, so it has no local persistent storage (disk), at least not out of the box. It also lacks the possibility to make a SSH connection as you can with a RaspberryPI for example. Still we would like to know how the device is doing, and how long it is operating without any problems. The latter is easy to measure if we look at the time that the gateway is operational. If that time is after the moment we plugged the gateway in, it probably suffered from a Watchdog reset and has restarted since.

Although watchdogs are not OK, they are an integral part of the ESP8266 design. The chip will reset in a very short amount of time so in principle we would not lose too many incoming packets (if any). However, since we will loose statistics data and probably the channel and WIFI setting as well if we make that dynamically, it would be better if we would not have ANY watchdog resets.

Over the last week, both gateways have been running fine without any resets. So I had to add a date field in the webserver as well, since "started on Friday" would not give enough information at all.

I built following webserver to view statistics and control debug level, channel assignment (future) etc. You can easily invoke the webserver at the IP address of the Gateway as follows: http://<IP Address of Gateway>:8080. The output looks like this. The interface also allows some setting of debug levels and statistics. More to come..

Todo:

Costs

So what does it cost to build this LoRa gateway (all prices in $, amount in Euros is a little lower).

Number Item Price/Piece
     
1 ESP8266 Wemos D1 Mini 3.50
1 Power Adapter with mini usb 5.00 (older)
1 RFM95 transceiver board 8.00
1 ESP8266 adapter board to get RFM95 to 2.54 mm pin spacing (sold per 10)

0.23

1 Piece of glassfiber perf board (sold per 10) 0.44
1 Antenna for 868MHz (sold per 10 for 17.60$) 1.76
1 SMA board connector (sold per 20) 0.16
0.5 meter UTP wire for hookup (stranded is best) 0.00
     
  Total including power supply) 19.10
  Just the Gateway 14.10

 

Links

The following links contain useful information for this project.

 

Questions

I think we all ask the same questions:

Notes

There are some things to remember however: