Salmandabbakuti / botanix-spiderhack

Home Page:https://botanix-spiderhack.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Raspi Controller

Raspi Controller is a Raspberry Pi-based IoT project designed for home automation with botanix(Bitcoin Blockchain) integration. The project allows users to control home devices securely and efficiently using blockchain technology, ensuring trust, security, and authentication among IoT devices.

Raspi Controller leverages the power of Raspberry Pi's GPIO pins to control home devices while integrating blockchain technology for enhanced security and trust among connected devices. The project includes a smart contract system that stores and updates pin statuses with access control by the owner. When authorized users update pin statuses, the contract emits events with the respective pin number and status. A Python listener then detects these events and updates the Raspberry Pi pins accordingly, simulating device control in a secure and decentralized manner.

Architecture

botanix-iot-drawio

Getting Started

Prerequisites

Steps

This project consists of three main components:

1. Compiling and Deploying Contract

Copy .env.example to .env and fill in the required environment variables.

  1. Install required dependencies
npm install
  1. Compile the contract
npx hardhat compile
  1. Set Private Key to hardhat config variables (For deploying contract to network. Make sure you dont use your primary account)
npx hardhat vars set PRIVATE_KEY
  1. Deploy the contract
npx hardhat run scripts/deploy.ts --network <network>

2. Starting Client

Copy client/.env.example to client/.env and fill in the deployed contract address and other required environment variables.

  1. Install required dependencies
cd client

npm install
  1. Start the client
npm run dev
  1. Navigate to http://localhost:3000 in your browser to see the client. Connect your wallet and start using the app.

  2. Register Device with the contract by clicking the "+ Device" button in the client interface.

  3. Load the control panel with registered device Id by entering device Id and click on arrow button.

usage_screen

3. Setup Contract Event Listener and Rasp Pi GPIO Simulator

Copy .env.example to .env and fill in the contract address and RPC URL.

  1. Install required dependencies
pip install -r requirements.txt
  1. Run the event listener
python listener.py
  1. Enter the registered device Id in previous step when prompted.

listener_prompt

Usage

  1. Connect your wallet to the client interface and register a device with the contract.

  2. Load the control panel with registered device Id by entering device Id and click on arrow icon.

  3. Start the event listener in new terminal and enter the registered device Id when prompted.

  4. Use the client interface to turn pins on or off.

  5. The event listener will listen for choosen device events in the contract and simulate/update the GPIO pins on the Raspberry Pi.

usage_screen

listener_prompt

Demo

Screen1

Built With

  • Botanix Labs - Botanix Labs aims to establish a fully decentralized EVM-equivalent Layer 2 on Bitcoin, combining the security of Bitcoin's Proof-of-Work with a Proof-of-Stake consensus model using Spiderchain
  • Hardhat - Ethereum development environment for compiling, testing, deploying, and interacting with smart contracts
  • Solidity - Ethereum's smart contract programming language
  • Web3.py - Python library for interacting with Ethereum blockchain
  • GPIO Simulator - Python library for simulating GPIO pins
  • RPi.GPIO - Python library for accessing GPIO pins on Raspberry Pi
  • React + Vite - Frontend development environment for building fast and modern web apps

Safety

This is experimental software and subject to change over time.

This is a proof of concept and is not ready for production use. It is not audited and has not been tested for security. Use at your own risk. I do not give any warranties and will not be liable for any loss incurred through any use of this codebase.

License

This project is licensed under the MIT License - see the LICENSE file for details

About

https://botanix-spiderhack.vercel.app

License:MIT License


Languages

Language:JavaScript 65.3%Language:Python 11.8%Language:Solidity 9.6%Language:CSS 6.9%Language:TypeScript 4.8%Language:HTML 1.6%