# bridge

## Gateway

A Raspberry PI 3 Model B was used as gateway.

**Hotspot for the Raspberry PI**

A hotspot has to be configured so that no other networks are involved and the gateway is the MQTT-broker at the same time. The broker is receiving the data of the sensor.

The following picture is showing the instruction for the Raspberry PI's configuration of the hotspot:

![](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHgUN0FpKxTuT7H90rv%2Fuploads%2F59r92iCJN80aIr1RO0O5%2Ffile.png?alt=media)

**MQTT for the Raspberry PI**

A MQTT-broker is a good tool to collect the sensor's data and forward it to other applications. MQTT is very suitable for these tasks because it is a simple protocol which was designed for sensor-applications.

In our case we decided to use Mosquitto. The installation is just one command on the terminal of the Raspberry PI:

![](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHgUN0FpKxTuT7H90rv%2Fuploads%2FtP5grNFcpl63MdkRzhAd%2Ffile.png?alt=media)

The Mosquitto-server should already be running and can be tested like this:

![](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHgUN0FpKxTuT7H90rv%2Fuploads%2Fixdnvhc2bzdFEVYZMnQT%2Ffile.png?alt=media)

Now the subscriber should display the message "Hello Word, Mosquitto" on the display.

## Bridge (ESP8266)

**MQTT for the ESP8266**

[PubSubClient](https://github.com/knolleary/pubsubclient) is a client based on Arduino, which gives us the possibility to send and retrieve messages to a specific topic.

### **Installation of MQTT for the Arduino IDE**

Download the folder under <https://github.com/knolleary/pubsubclient> and include the library in Arduino. Then you will get the possibility to install it in the Librarymanager.

![](https://firebasestorage.googleapis.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LHgUN0FpKxTuT7H90rv%2Fuploads%2FFRbzk4OrKQpuJ3zC82W8%2Ffile.png?alt=media)

**WIFI-Manager for the ESP 8266**

Throughout the Wifi-Manager you can create an own hotspot and configure each WLAN, so that this module can also be configured by the user himself.

**Installation of the Wifi-Manager for Arduino DIE**

The library for the Wifi-Manager can be found under <https://github.com/tzapu/WiFiManager>. Download this folder and include it in the Arduino libraries just like the installation of MQTT: *Sketch* -> *Include library* -> *Manage libraries...* .
