- 3D printer with filament
- Solder iron / solder
- Small cutting plier
- Hot glue gun (or other fixation tools)
- Small screwdriver
See the shopping list an up-to-date overview:
In the construction of the gateway you have a few options in the features you like to add:
- Either an active or passive gateway (with or without sensors on the gateway).
- Lora gateway or just an active sensor (with or without lorawan concentrator shield).
- With or without camera module for bug tracking or other camera applications.
In the instructions below we describe the most commong optional parts (without camera and without sensors). But note that you can easily leave out the lorawan concentrator as well if you already have gateways on site.
Be carefull about the screws nearby the Raspberry Pi. Don't overtighten the screws and if you notice it being to close to the electronics we advice you to shim the parts a bit or to use a smaller screw.
Check the github page for the latest STL files: Gateway STL files
- 1x GATEWAY_Main_Housing
- 1x GATEWAY_Backcover
- 1x Sensor_extension
- 1x Sensor_Housing
- 1x Sensor_Backcover
- 1x Camera_Housing
- 1x Camera_Backcover
- PETG preffered (for durability against the heat of the gateway)
- No supports needed
- Infill not necessary
- 0.2 layer height
- 3 outside perimeters (for strength and durability)
- 1x Raspberry Pi
- 1x Micro SD card.
- Make sure the SD card is flashed with the Raspberry Pi operation system (Raspberry Pi OS(32-bit) with desktop).
- Insert your micro SD card into the Raspberry Pi.
Follow the link below to find more detailed instructions how to flash and prepare your micro SD card. Raspberry installation instructions
Since the air dust sensor works on 5V supply and the raspberry pi only works on 3.3V we need to include a voltage devider in the cable using two resistors.
- 1x Seeed air dust sensor
- 2x resistor (3.3 KΩ) (orange, orange, red)
- 1x Grove hat
- 2x shrink sleeves
- Cut the red wire up to the connector.
- Cut the yellow wire at a distance of 3 cm from the connector.
- Cut the black wire at a distance of 2 cm from the connector.
- Strip the end of each wire.
- Put a small shrink sleeve over the yellow cable.
- Put a large shrink sleeve over the yellow and black cable.
- Solder the two resistors in series with the yellow cable of the connector in between.
- Solder the other yellow cable on the side of the sensor to one of the resistors.
- Slide the small sleeve over the solder connection of the yellow wire with one resistor end still exposed and heat shrink the small sleeve.
- Solder the black wires back together with the still exposed resistor leads in between.
- Slide the large sleeve over the solder connection and the small sleeve and heat shrink the large sleeve.
- Solder the red cable to the 5V pins (pin 2 and 4) on the Grove hat board (see the top view picture).
- 1x Grove hat board
- 1x Seeed air dust sensor
- 4x female-male spacers
- 4x female-female spacers
- 4x nut
- Mount the female-male spacers through the mounting holes of the grove hat board
- Screw the nuts on the female-male spacers and tighten it. (to provide extra space for the cables to bend)
- Screw the female-female spacers on top of the nuts and tighten everything.
- Lay the red 5V cable of the airdust sensor along the inside of the spacer (see last picture).
- > The assembly stack from step 6
- 1x Raspberry PiModel 3 B+
- 1x Camera cable
- 2x grove connection cables
- 1x Long M2.5 screw from the Grove hat bag
Camera cable:
- Lift the latch of the cable connecter on the Raspberry Pi (see picture one - red rectangle). Be careful, fragile!
- Insert the camera cable in the connector of the Raspberry Pi with the blue side facing the usb plugs.
- When the cable is in the right place. Push the latch back into place so the cable connection is secured.
- Feed the camera cable trough the provided hole into the grove board. (see picture of the grove board top view - red rectangle)
- Align the board with the pin connections on the side.
- Push it al the way down to make a stack.
- To secure the stack, mount the screw in the hole next to the audio connection of the raspberry pi. (see picture top view)
- The first stack is complete!
Air dust sensor:
- Connect the connector of the air dust sensor to pin D16 of the Grove hat board. ( see picture of the grove board top view - purple rectangle )
I2C connectors:
- Connect the two grove connection cables to the I2C connectors of the the Grove hat board. Preferably use the connectors that are close to the camera cable. This makes it easier to use the HDMI port afterwards. ( see picture of the grove board top view - blue rectangle )
- > The assembly stack from step 6
- 1x Gateway_body 3D print
- 1x M3 x 12
- 3x Long M2.5 screws from the Grove hat bag
- Check if the micro SD card is inserted into the Raspberry Pi.
- Insert the air dust sensor in the 3D print housing and secure it with the M3 screw.
- Before we insert the stack. Guide the camera cable and the two I2C grove connection cables through the bottom slot in the housing.
- Insert the Pi stack into the housing.
- Push the cables down on the side so they don't get in the way.
- Make sure that no wires are in front of the Micro USB and the HDMI connection.
- Secure the stack with three M2.5 screws through the big holes in the front.
- > The assembly from step 7
- 1x Dragino LoRa shield
- 4x Short M2.5 screws from the Lora Concentrator bag
- Pre install the antenna to the Dragino LoRa shield. (don't fully tighten yet!)
- Insert the Dragino LoRa shield on top of the grove hat board. Align the pins and push it all the way down.
- Secure the board with the four M2.5 screws.
- > The assembly from step 8
- 1x Gateway_backcover
- 2x M3 x 12 screws
- Slide the inserts of the backcover into the housing and push it down.
- Fixated the backcover with two M3 screws.
- > The assembly from step 9
- 1x Peripherals: screen (HDMI) / keyboard / mouse
- 1x Micro usb power supply (5.1V 2.5A)
- Connect the Raspberry to a screen with a HDMI cable.
- Connect a mouse, keyboard to the USB connector.
- Plug in the power usb cable to the Raspberry Pi last.
- It should start booting up now.
In these instructions we chose to use a display connected at all times during setup. You can also choose to connect trough SSH, but then you do not get to see all the visual information that often helps you along the way.
- You will see the setup screen. Follow the setup screen instructions.
- Choose your county / network / keyboard setting
- At the end it will search for updates and install them.
- Please be patient, this can take a few minutes.
- Open a terminal on the Raspberry Pi.
- Type in >
ifconfig wlan0:
- You can see the ether address of the Pi. (ex: b5:23:eb:fc:55:d4)
- Write this down because you will need it when setting up the gateway in TTN.
For more detail setup information about the Dragino PG1301, check their user manual (page 7): Dragino PG1301 user manual
The things network provide a set of open tools and a global, open network to build your next IoT application at low cost, featuring maximum security and ready to scale. https://www.thethingsnetwork.org/
If you already have an account you can skip this step.
- Sign up at The Things Network and make an account
- Follow the instruction on the TTN website.
- After Sign up log in to your account
- Go to your console. You will find it in the dropdown menu of your profile (see picture)
- In the console on TTN, click on Gateway.
- Click on register gateway in the upper right corner to at a new gateway device. (see picture - red square)
- Check the box of "I'm using the legacy packet forwarder". (see picture - green square)
- Fill in the gateway EUI by using the ether address from the Pi. Convert your address like this example
b5:23:eb:fc:55:d4
=>B523EBFC55D4FFFF
(see picture - green rectangle) The "FFFF" gets added to make it a 8 byte unique EUI. - Choose your Frequency plan ( ex: Europe - 868MHz for Europe)
- Choose your router ( ex: ttn-router-eu for Europe)
- Point your location on the map. (optional)
- Check the right box, indoor or outdoor.
- On the bottom of the page click on the button Register Gateway
In the terminal type in > sudo raspi-config
- Select Interface options
- Select and enable SPI
- Select and enable Camera
- Select and enable I2C
- In the terminal type in >
wget http://www.dragino.com/downloads/downloads/LoRa_Gateway/PG1301/software/lorapktfwd.deb
- This will download the packet forwarder from Dragino Server to RPI.
- In the terminal type in >
sudo dpkg -i lorapktfwd.deb
- After installation, go to
/etc/lora-gateway/
and open local_conf.json - In between the curly brackets add this section below:
"gateway_ID": "B523EBFC55D4FFFF", "server_address": "router.eu.thethings.network", "serv_port_up": 1700, "serv_port_down": 1700
- Make sure to place the correct structure with , after each line and no , at the last line.
- " " around all text values and none around the numbers.
- Change the gateway_ID to the gateway_ID you used to setup the gateway in the TTN. (with the "FFFF")
- Save the document.
- In the terminal type >
sudo systemctl stop lorapktfwd sudo systemctl start lorapktfwd sudo systemctl enable lorapktfwd
- This restarts the package forwarder and makes sure the forwarder starts with Raspberry Pi.
- Now your LoRa gateway is active.
- You should see the status update to "connected" within a few minutes on TTN.
- Check if you have python 3 on your Raspberry Pi. In the terminal type => python3
- If you don't have python 3, follow this install instructions:
- type =>
sudo apt update
- type =>
sudo apt upgrade
- type =>
sudo apt install python3 idle3
- Now you should have python 3. Please check again with the 1. first step.
- Activate camera / I2C / SPI: (you might have done this already in the LoRa setup)
- In the terminal type =>
sudo raspi-config
- Go to Interfacing Options.
- Enable camera
- Enable I2C
- Enable SPI
- Go to Interfacing Options.
- Install following libraries: (type these commands in the terminal)
sudo apt-get update sudo apt-get upgrade sudo apt-get install libatlas-base-dev pip3 install numpy pip3 install opencv-python pip3 install scikit-image pip3 install schedule pip3 install getmac pip3 install adafruit-circuitpython-bme680 pip3 install adafruit-circuitpython-tsl2561 pip3 install RPI.GPIO
- Before running the final code we have to focus our camera unit.
- In a command line window type:
from picamera import PiCamera from time import sleep camera = PiCamera() camera.start_preview() sleep(20) camera.stop_preview()
- This provides you a live preview of the camera.
- Focus the camera by rotating it's lens.
- After 20sec the preview stops, but you can re-run the code as much as needed.
- Download the python script
mumo.py
from github: Gateway python code - Place the code on your desktop.
- Open a terminal and type >
sudo nano /etc/xdg/lxsession/LXDE-pi/autostart
- Copy this line on to the bottom off the file >
@lxterminal -e python3 /home/pi/Desktop/mumo.py
- Save the file and close it.
- Now the script will automatically start at restart.
- Open the code.
- Change to your URL endpoint.
- This is where to send the data on your backend server.
- This data goes straight to the dashboard and not trough TTN.
- > The assembly from step 9
- 1x Sensor_body
- 1x Sensor_cap
- 1x Digital light sensor (small sensor)
- 1x BME680 sensor (long sensor)
- 4x M2 x 5 screws
- 4x M3 x 12 screws
- Insert the two I2C grove connection cables through the hole of the sensor_cap.
- Connect the BME680 sensor and the digital light sensor to the I2C grove connection cable.
- Insert the BME680 sensor and the digital light sensor into the sensor_body part and secure it with four M2x5 screws. You will have to bend the cable to fit the sensors into place, so be careful!
- Slide the sensor_cap on top of the sensor body to close it.
- Fixated the cap to the body with two M3 screws.
- Attach the sensor add-on assembly to the front of the gateway with two M3 screws. (see picture - Red circle)
- The grove cables are probably too long. Push them inside the sensor housing.
- > The assembly from step 10
- 1x Camera module (with M2.5 screws)
- 1x Camera_body
- 1x Camera_cap
- 4x M3 x 12 screws
- Place the camera and one light attachment into the camera_cap housing and secure it with the four M2.5 screws from the camera module.
- To insert the camera cable we must lift the black plastic holder from the connection.
- Insert the camera cable with the blue surface facing the camera. (see pictures)
- Slide the camera_body on top of the assembly
- Fixated the camera_cap with two M3 screws to the camera_body.
- Mount the camera add on assembly to the bottom off the gateway housing with two M3 screws (see picture - Red circle) Push the protruding cable into the housing.
- > The assembly from step 11
- 1x Trap_Frame
- 1x bug trap paper - sticky paper
- 2x M3 x 12 screws
- Place the Trap_Frame part on top of the camera housing. The trap has some space for the power usb cable of the gateway, therefore check the pictures for the correct orientation.
- Fixate with two M3 screws on the left and right side of the camera housing.
- Insert your (60 x 75) mm bug paper into the slot of the trap. There are two slots, in the front and back direction. It depends how you will position the gateway.
- The power usb cable can be weaved between the open structure of the trap part.
We have two screw slots on which the gateway can be hung.
And also have cable ties grooves, so you can easily attach the gateway to anything.
The gateway is modular so that the sensors and camera can be mounted in different orientations. You can also create your own components and add them to the setup.