Get Started with DIY API

How this works#

  1. Choose a project idea
  2. Pick the components that you need
  3. Assemble the code and build
  4. Try it on container or run it on hardware

See Video Tutorial#

Learn from an example#

Step 1: Choose a project Idea#

Lets say my project Idea is

Project Idea: I want to unlock a door with Face recognition.

Step 2: Pick components#

info

Image is interactive, Click on the Image to see the components in detail.

Step 3: Get Environment#

You can code, build and deploy Shunya AIoT using

  1. Docker containers
  2. Shunya supported ARM (armv7 & armv8) Development boards
Try example on Docker Container

Requirements#

  1. Good Internet Connection
  2. Docker Installed on your system.

Steps are#

  1. Pull the Shunya OS docker image
  2. Run the docker container

  1. Pull shunya OS docker image, by running command in the terminal

    docker pull shunyaos/shunya-console-armv7:latest
  2. Run the docker container, by running command in the terminal

    docker run -it shunyaos/shunya-console-armv7:latest
  3. This will bring you to Terminal inside the docker container.

  4. Now you can download, build and run the code using inside the docker container.

Try example on Hardware

Requirements#

  1. Shunya OS supported Development board (RaspberryPi 4)
  2. Power supply for the board (5V 3A power supply for RaspberryPi 4)
  3. microSD card
  4. microSD card Reader
  5. Laptop/PC

Steps are :#

  1. First we load Shunya OS on your board.
  2. Boot up Shunya OS
Install Etcher#

Etcher allows you to Flash Shunya OS on the micro-SD card.

For Ubuntu 16.04#

Installing Etcher is Simple, download the executable file and Run.

  1. Download balenaEtcher for Linux.
  2. Extract the zip file.
  3. Run AppImage sudo ./balenaEtcher-xxx.AppImage

Flash Shunya OS#

  1. Download Shunya OS

  2. Extract Downloaded zip file, by Right clicking on the downloaded zip file and selecting "Extract Here".

  3. .img file in the extracted folder contains Shunya OS.

  4. Insert SD card with Card reader.

  5. Open Etcher program.

  6. Click Select Image.

  7. Select Shunya OS file shunya-{type}-image-{board-name}.img file.

    For example: shunya-console-image-raspberry4.img

    note
    • Shunya OS released in 2 variants

      • basic - Extremely Small footprint image use only for final deployment.
      • console - Full console only image use only for development.
    • At this stage it is recommended that you use console variant

  8. Your SDCard should be auto detected in Etcher.

  9. Click on Flash.

    install-shunya-os-gif
  10. Now Etcher will load the Shunya OS on your SD card.

  11. Now you can boot up the Shunya OS on your board.

Booting Up with Shunya OS#

  1. Insert the micro-SD card into the board.
  2. Connect peripherals like Keyboard, Mouse and HDMI monitor.
  3. Connect Power Supply.

The board should boot up with Shunya OS.

Login to Shunya#

Login with these credentials:

  • Username : shunya
  • Password : shunya
  1. This will bring you to Terminal inside the board.
  2. Now you can download, build and run the code using inside the board.

Step 4: Assemble code and Run#

  1. Start with an ready to use template for building with shunya stack

    git clone https://gitlab.iotiot.in/repo-public/examples.git
    cd examples/template
  2. Open the main.cpp in an text editor and modify as per your use case.

    Example main.cpp file:

    /* --- Standard Includes --- */
    #include <iostream>
    #include <cstdlib>
    #include <stdint.h>
    #include <time.h>
    #include <unistd.h>
    /* --- RapidJSON Includes --- */
    /* MANDATORY: Allows to parse Shunya AI binaries output */
    #include "rapidjson/document.h"
    #include "rapidjson/writer.h"
    #include "rapidjson/istreamwrapper.h"
    #include "rapidjson/stringbuffer.h"
    #include "rapidjson/ostreamwrapper.h"
    #include "rapidjson/filereadstream.h"
    #include "subprocess.hpp" /* MANDATORY: Allows to run Shunya AI binaries */
    #include "exutils.h" /* MANDATORY: Allows to parse Shunya AI binaries output */
    /* --- Shunya Interfaces Includes --- */
    #include <si/shunyaInterfaces.h> /* MANDATORY: Contains all IoT Functions */
    using namespace std;
    using namespace rapidjson;
    int main(void)
    {
    /* MANDATORY: Initializes the Shunya components */
    initLib();
    /* Write your code here */
    }
  3. For our example idea we would have to pick, these components

    1. Face Recognition
    2. Relay (for door Unlock)
    • Each of these components contain the steps to code.
    • Follow the steps and keep adding the code to the template above.
    • This should result in your idea getting implemented in code.
  4. Compiling and Running the code,

    # Run these commands in Shunya OS Terminal
    mkdir -p build
    cd buid
    cmake ../
    make
    # Once the code compiles then, runs the code
    sudo ./program-name