×
IoT platform 
About us 
Media 
Documentation 
Courses 
Downloads 
Forum 
DIY 
Wazihub 
What's on this Page:

How to develop a WaziApp

WaziApps are possible with WaziGate V2, which will be published officially soon.

This course guides you to step through development of a simple app running on the Wazigate platform. What you will learn:

  • How do WaziApps work?: You will learn about the structure of the WaziGate and how to utilize docker containers for your applications
  • Preparing the RPI for development of WaziApps: You will setup the Wazigate Firmware, install the IDE and communicate to the WaziGate through SSH and FTP
  • Develop a WaziApp in Python, GoLang and Javascript: You will learn how to install and run apps on the WaziGate, how to make APIs for your app and how to create docker image for your App.

Prerequisites

You need to be familiar with:

  • Raspberry PI
  • A general knowledge of sensor nodes (e.g. Arduino, ESP, etc)
  • Docker container concept
  • A basic knowledge of programming (in either Python, Go or Javascript)

You will need the following Hardware:

  • A Raspberry pi
  • An SD Card (at least 8GB)
  • Internet Connection

Level: Intermediate


How do WaziApps work?

Wazigate uses a microservice architecture to manage its Apps. This architecture allows each application to operate independently in isolation which makes the development and maintenance much simpler than a monolithic architecture.

Useful links:


Preparing the development environment

Setup Wazigate Firmware

In this section we learn how to set up our development environment. We need to flash a Raspberry pi with Wazigate Firmware, configure it, install the required tools and finally prepare our PC.

In order to flash the Raspberry pi, we go to waziup.io/downloads and download the latest SD card image. We use Etcher tool to flash the downloaded image on the SD card. After flashing is done, we insert the SD card into the raspberry pi and turn it on.


Setup communication channels

When we boot a Raspberry pi with Wazigate Firmware for the first time, it goes to WiFi access point mode by default. We can either connect to the pi through the access point or use an Ethernet cable to reach the pi. Using Ethernet is recommended for development as it is more reliable. You can either wire it like this to your local router:

router connection
router connection

Or you can just connect the cable directly to your PC. In this case, remember to share your Ethernet connection in the PC networking settings in order to allow the PI to connect to your PC as a client.

If you want to communicate to your pi through WiFi, here is how to configure your Wazigate to connect to your local WiFi connection. On our PC we should see a wireless network that starts with WAZIGATE. Connect to it, the default password is loragateway .

When the pi is in WiFi access point mode, the default IP address is: 192.168.200.1


Find the Wazigate’s IP address

When we connect our pi through Ethernet or WiFi, we need to find its IP address to be able to work with it. One of the tools that helps us to find the IP address of our pi is Angry IP Scanner.


Alternatively, we can use Nmap to find the IP address. It is initially developed for Unix, but now you can install it on windows machines as well. On Debian based machines you can install it this way:

sudo apt-get install nmap

Here is how to use it to find the IP address of the pi:


IDE installation

You can use any IDE that suits you for developping WaziApps. Here I show what I use and how I upload my code to the pi. I use Visual Studio Code which is multi-platform and has tons of extensions.


Install FTP on Wazigate

FTP comes handy when we want to copy files to/from our pi.

We can install it easily by running the following code in the terminal of the pi:

sudo apt-get install -y pure-ftpd
sudo groupadd ftpgroup
sudo usermod -a -G ftpgroup $USER
sudo chown -R $USER:ftpgroup "$PWD"
sudo pure-pw useradd upload -u $USER -g ftpgroup -d "$PWD" -m <<EOF
loragateway
loragateway
EOF
sudo pure-pw mkdb
sudo service pure-ftpd restart

A Wazigate Application in Python

Install and run the Python sample App


Make a “Hello world” API

  • Default password: loragateway
  • The App folder: ~/waziup-gateway/apps/waziup/hello-world-python/
  • Change the ownership: sudo chown pi -R .
  • Start the container: docker-compose up -d
  • Shell into the container: sudo docker exec -it <container_name> sh
  • Start the App inside the container: python /root/src/main.py

Make APIs to handle POST/PUT/DELETE requests

  • Start the container: docker-compose up -d
  • Shell into the container: sudo docker exec -it <container_name> bash
  • Start the App inside the container: python /root/src/main.py

Configure “docker-compose.yml” file


Configure “package.json” file


Package and build the docker image for the Python App

  • Build our app: docker-compose build

Push the App image to the docker hub

The used commands:

docker login
docker push <the_full_image_name_with_tag>

How the update mechanism works in WaziGate


A Wazigate Application in GoLang

Install and run the Go sample App


Make a “Hello world” API

  • Default password: loragateway
  • The App folder: ~/waziup-gateway/apps/waziup/hello-world-go/
  • Change the ownership: sudo chown pi -R .
  • Start the container: docker-compose up -d
  • Shell into the container: sudo docker exec -it <container_name> sh
  • Build and start the App inside the container: go build -o start . && ./start

Make APIs to handle POST/PUT/DELETE requests

  • Start the container: docker-compose up -d
  • Shell into the container: sudo docker exec -it <container_name> sh
  • Build and start the App inside the container: go build -o start . && ./start

Tip: Wazigate-system is actually a WaziApp that is written in Go Lang and its UI is based on REACT.

Please check out its repository to see real-world examples: https://github.com/Waziup/wazigate-system


Configure “docker-compose.yml” file


Configure “package.json” file


Package and build the docker image for the GoLang App

Build our app: docker-compose build


Push the App image to the docker hub

The used commands:

docker login
docker push <the_full_image_name_with_tag>

How the update mechanism works in WaziGate


A Wazigate Application in Javascript

Install and run the Javascript sample App


Make a GET Request API call

  • Default password: loragateway
  • The App folder: ~/waziup-gateway/apps/waziup/hello-world-js/
  • Change the ownership: sudo chown pi -R .
  • Start the container: docker-compose up -d
  • API lists:

Call an API on the Edge to list all registered devices on Wazigate

  • Default password: loragateway
  • The App folder: ~/waziup-gateway/apps/waziup/hello-world-js/
  • Change the ownership: sudo chown pi -R .
  • Start the container: docker-compose up -d
  • API lists:

Notes: You can also make your WaziApp entirely based on other popular Javascript libraries like REACT as the UI of the Wazigate-System and Wazigate-Edge are made with REACT. Please check out the Waziup-JS library that we use ourselves, it makes the life easier: https://www.npmjs.com/package/waziup-js

Configure “docker-compose.yml” file


Configure “package.json” file


Package and build the docker image for the App

Build our app: docker-compose build


Push the App image to the docker hub

The used commands:

docker login
docker push <the_full_image_name_with_tag>

How the update mechanism works in WaziGate