# Adding PoE to a DIY RPi-based LoRaWAN gateway

> Background Currently, DIY LoRa gateways are the cheapest options for beginners who want to experiment with LoRaWAN technology. There are excellent instructions

- Type: Community update
- Community: [The Things Network Ulaanbaatar](https://www.thethingsnetwork.org/community/ulaanbaatar/)
- Author: Khash Jalsan
- Published: 2017-07-26
- Web page: https://www.thethingsnetwork.org/community/ulaanbaatar/post/adding-poe-to-a-diy-rpi-based-lorawan-gateway

### Background

Currently, DIY LoRa gateways are the cheapest options for beginners who want to experiment with LoRaWAN technology. There are excellent instructions on building a LoRa gateway using a Raspberry Pi (RPi) and a LoRa concentrator:

- [https://github.com/ttn-zh/ic880a-gateway/wiki](https://github.com/ttn-zh/ic880a-gateway/wiki)
- [https://www.rs-online.com/designspark/building-a-raspberry-pi-powered-lorawan-gateway](https://www.rs-online.com/designspark/building-a-raspberry-pi-powered-lorawan-gateway)

However, it is not easy to power a gateway at our outdoor deployment site since no power source is present nearby, and a long power cable would degrade the supply voltage. Since the gateway is connected to the Internet through Ethernet, PoE is a natural choice.

There are already plug-and-play [1](https://www.pi-supply.com/product/pi-poe-switch-hat-power-over-ethernet-for-raspberry-pi/), [2](https://www.adafruit.com/product/435) and DIY [3](http://www.instructables.com/id/PiPoE-powering-a-Raspberry-Pi-over-Ethernet/), [4](https://www.raspberrypi.org/forums/viewtopic.php?f=41&t=3059&start=25) solutions for powering RPi over Ethernet. But this project is conducted anyways because of its DIY nature.

### Modifying Raspberry Pi B+ for PoE

According to a [discussion](https://raspberrypi.stackexchange.com/questions/715/how-do-i-modify-my-raspberry-pi-to-be-powered-over-poe), RPi uses a MagJack which is not compatible with PoE standards. This resorts to the inevitably ultimate hack -- modifying the RPi MagJack.

Instead of [removing the MagJack](https://www.raspberrypi.org/forums/viewtopic.php?f=41&t=3059&start=25#p488918), a less involving (though less elegant) approach was to cut open the MagJack from the top (I used a soldering iron to cut the plastic, shame on me) and cut two unused connector (either two pins of 4, 5, 7, 8) traces from the MagJack circuit.
![Cut open MagJack of RPi B+](https://ttn-mongolia.github.io/images/post1-1-cut-open.jpg)

Afterwards, pin headers were soldered on those connectors.
![Pin headers are soldered](https://ttn-mongolia.github.io/images/post1-2-pin-headers.jpg)

As the resistance of a long cable can be significant, it is a common practice to power the device with a 12 or higher voltage and regulate to 5V using a DC-DC step-down converter. Instead of building one, I scavenged an unused car USB charger.
![Disassembled car charger](https://ttn-mongolia.github.io/images/post1-3-scavenge-car-charger.jpg)

Functional test. The output voltage of the car charger reads 4.874V, which may be a bit low for a nominal supply (5V) of RPi B+ and iC880A. But the devices are plugged to it and are functional.
![Test run](https://ttn-mongolia.github.io/images/post1-4-test-run.jpg)

Next, a 3-way RJ45 splitter was modified for our custom PoE by removing the unneeded pins from the corresponding connectors. The connector with two pins is for the 12V power supply. ![Modified Ethernet splitter](https://ttn-mongolia.github.io/images/post1-5-modifying-ethernet-splitter.jpg)

After putting everything together, "the gateway" looks like a gateway. ![Pin headers are soldered](https://ttn-mongolia.github.io/images/post1-6-fully-assmbled.jpg)

Finally, our DIY gateway is ready for the "experimental" deployment in Ulaanbaatar.
