Git Product home page Git Product logo

cwgtk's Introduction

IoT Toolkit for Coworking Spaces

Requirements

  • Raspberry Pi Model 3B+
  • Speaker pHAT
  • Adafruit PN532 RFID/NFC Shield (v1.3+)
  • SparkFun FT231X Breakout

Hardware

  1. On Adafruit Adafrauit PN532 RFID/NFC Shield, make sure SEL0 is closed (solder bridge) and SEL1 is open. This will switch PN532 in UART mode.

  2. Connect signals between Adafrauit PN532 RFID/NFC Shield and SparkFun FT231X Breakout in the following way:

    RFID/NFC Shield FT231X Breakout
    5V VCC
    GND GND
    Analog in 4 RX
    Analog in 5 TX

Software

Basic Installation

  1. Prepare Raspberry Pi with MicroSD card and Raspbian on it.

    Use balenaEtcher to flash the Raspbian image.

  2. Put empty file ssh to the boot partition of the SD card to enable SSH access.

  3. Insert the MicroSD card to Raspberry Pi and connect the power adapter.

  4. SSH to your Raspberry Pi:

    ssh pi@<ip-address>
    
  5. Change default password:

    passwd
    
  6. Set correct locales:

    echo "en_US.UTF-8 UTF-8" | sudo tee /etc/locale.gen
    sudo locale-gen
    echo "LC_ALL=en_US.UTF-8" | sudo tee /etc/default/locale
    
  7. Logout and SSH back to Raspberry Pi with the new password:

    logout
    ssh pi@<ip-address>
    
  8. Set correct timezone:

    sudo dpkg-reconfigure tzdata
    
  9. Change default hostname to cwgtk:

    sudo hostnamectl set-hostname cwgtk
    
  10. Overwrite raspberry to cwgtk in /etc/hosts:

    sudo nano /etc/hosts
    
  11. Reboot system and SSH back to Raspberry Pi:

    sudo reboot
    ssh pi@<ip-address>
    
  12. Upgrade system packages:

    sudo apt update
    sudo apt upgrade
    
  13. Reboot system and SSH back to Raspberry Pi:

    sudo reboot
    ssh pi@<ip-address>
    
  14. Install common tools:

    sudo apt install git mc tmux vim
    
  15. Select default editor /bin/nano:

    select-editor
    

Setup Coffee Log

  1. Install NFC library:

    sudo apt install libnfc-dev libnfc5
    
  2. Edit linbnfc.conf file:

    sudo nano /etc/nfc/libnfc.conf
    
  3. Uncomment and edit the following lines:

    device.name = "pn532_uart"
    device.connstring = "pn532_uart:/dev/ttyUSB0"
    
  4. Download cwgtk:

    git clone https://github.com/hubpav/cwgtk.git
    
  5. Build tagcat:

    cd ~/cwgtk/tagcat
    make
    
  6. Install support for Python 3 virtual environments:

    sudo apt install python3-venv
    
  7. Install required Python 3 packages:

    cd ~/cwgtk/coffeelog
    python3 -m venv env
    source env/bin/activate
    pip3 install -r requirements.txt
    
  8. Fix dependency issue with Python 3.7:

    pip3 install 'grpcio==1.23.0' --force-reinstall
    
  9. Install /home/pi/cwgtk.json file with Google API credentials.

  10. Install mpg123:

    sudo apt install mpg123
    

Background Service

  1. Edit coffeelog.service file:

    sudo nano /etc/systemd/system/coffeelog.service
    
  2. Insert this content:

    [Unit]
    Description=CWGTK - Coffee Log Service
    After=network.target
    StartLimitIntervalSec=0
    
    [Service]
    Type=simple
    User=pi
    ExecStart=/home/pi/cwgtk/coffeelog/run.sh
    Restart=always
    RestartSec=1
    
    [Install]
    WantedBy=multi-user.target
    
  3. Start and enable the service:

    sudo systemctl start coffeelog.service
    sudo systemctl enable coffeelog.service
    

Loudspeaker Setup - Speaker pHAT

Run this command:

curl -sS https://get.pimoroni.com/speakerphat | bash

Answer N when asked about full install:

Do you wish to perform a full install? [y/N] N

When asked about reboot, answer y:

Would you like to reboot now? [y/N] y

Loudspeaker Setup - USB

  1. Edit alsa.conf file:

    sudo nano /usr/share/alsa/alsa.conf
    
  2. Update these two parameters to index 1:

    defaults.ctl.card 1
    defaults.pcm.card 1
    
  3. Create this configuration file:

    sudo nano /etc/asound.conf
    
  4. Insert this content:

    pcm.!default  {
      type hw card 1
    }
    
    ctl.!default {
      type hw card 1
    }
    

Install SQLite Webserver

The following procedure will configure phpLiteAdmin with the SQLite database.

  1. Change default phpLiteAdmin password:

    nano /home/pi/cwgtk/phpliteadmin/phpliteadmin.config.php
    
  2. Install required packages:

    sudo apt install lighttpd php-cgi php-cli php-mbstring php-sqlite3
    
  3. Configure webserver:

    sudo lighty-enable-mod fastcgi
    sudo lighty-enable-mod fastcgi-php
    sudo service lighttpd force-reload
    
  4. Create symlinks to phpLiteAdmin:

    cd /var/www/html
    sudo ln -s /home/pi/cwgtk/phpliteadmin/phpliteadmin.config.php
    sudo ln -s /home/pi/cwgtk/phpliteadmin/phpliteadmin.php index.php
    
  5. Open Raspberry Pi IP address in your browser - you should see a login page.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

Authors

License

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.