Skip to main content

Raspberry Pi

This repository is home to a proof of concept (PoC) that demonstrates the interaction between a Raspberry Pi device and the peaq network through the use of Decentralized Identifiers (DIDs). Below are comprehensive steps to guide you in setting up your Raspberry Pi for this PoC.

Prerequisites

  • A Raspberry Pi device with Pi OS installed. If Pi OS is not installed, follow the official guide to install Pi OS on your device.

Setup Instructions

Install Node Version Manager (NVM):

NVM is a version manager for Node.js, designed to be installed per-user, and invoked per-shell. Execute the following command to install NVM:

curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash

Source BashRC:

To ensure NVM is available in your current session, source the bashrc file with the following command:

source ~/.bashrc

Verify NVM Installation:

Confirm that NVM has been installed correctly by checking its version with this command:

nvm -v

Install Node.js:

Now install Node.js version 18.12.1 using NVM with the following command:

nvm install 18.12.1

Verify Node.js Installation:

Confirm that Node.js has been installed correctly by checking its version with this command:

node -v

Install Nginx:

Nginx is a web server which can also be used as a reverse proxy, load balancer, and HTTP cache. Install nginx by following the instructions in this tutorial.

Verify Nginx Installation:

Confirm that Nginx has been installed correctly by checking its version with this command:

nginx -v

Clone Repository:

Clone this repository onto your Raspberry Pi and navigate to the project directory with the following commands:

git clone https://github.com/peaqnetwork/peaq-did-raspberry-pi-poc
cd peaq-did-raspberry-pi-poc

Install Dependencies:

Install all the necessary project dependencies using npm (Node Package Manager) with this command:

npm install

Install PM2:

PM2 is a production process manager for Node.js applications with a built-in load balancer.

Install PM2 globally using the following command:

npm install pm2@latest -g

Start Application:

Start the application using PM2 with this command:

pm2 start index.js

Setup PM2 Startup Script:

To ensure your application starts on system boot, execute the following command to set up a PM2 startup script:

pm2 startup

Save PM2 Configuration:

Save the current PM2 configuration with this command:

pm2 save

Check DID through PM2 Log:

Verify the DID generation by checking the PM2 log with this command:

pm2 log

Code Structure

  • constants.js: This file houses constant values which are used across various files in the project.

  • generate-did.js: This script is dedicated to generating Decentralized Identifiers (DIDs).

  • index.js: The entry point of the application where the main logic resides.

  • Other utility and configuration files: These files aid in the setup and operation of the PoC, ensuring smooth interaction with the peaq network.

Contributing

We welcome contributions! Feel free to fork this repository, submit issues, or open pull requests if you discover any improvements or bug fixes. Your input is invaluable in refining this PoC and enhancing its functionality.