/RPi_TasbihDigital

Digital tasbih counter using Raspberry Pi, Flask & SQLite database

Primary LanguagePython

simplinnovation

Raspberry Pi Digital Tasbih Counter

📋 Project Summary

Klik gambar berikut untuk melihat video demo:

Video

Tasbih digital berbasis Raspberry Pi dengan fitur: 1) menghitung jumlah tasbih layaknya digital tasbih komersil, 2) data hasil hitung tersimpan di database SQLite dan 3) monitor rekapitulasi total tasbih harian dengan mengakses IP address Raspberry Pi (via Flask server). Hardware: Raspberry Pi Zero W (Wireless), touch sensor dan 1.3 inch OLED display (SH1106). Software: diprogram dengan Python 3, package GPIO & Luma.OLED, Flask server dan database SQLite.


📋 Project Tutorial

This project is built on Raspberry Pi Zero W (Wireless) with Raspbian OS (Buster) and Python 3.x (I'm using 3.8). So make sure you've installed Python 3.x also git to clone this project from my github.

  • 0. Tools & Materials

    • Raspberry Pi Zero Wireless (you can use any type of mini PC) which has been installed Raspbian OS (or any compatible OS).
    • 1.3" OLED display SH1106 (or any OLED module such as 0.96" SSD1306)
    • Touch sensor
    • Some jumper wires & a breadboard

  • 1. Clone this project

    Clone this project from my github repo. Download here or clone it from your terminal (make sure you've installed git on your Pi):

    $ git clone https://github.com/LintangWisesa/RPi_TasbihDigital.git
    
    $ cd RPi_TasbihDigital

  • 2. Database (SQLite) Preparation

    Install SQLite on your Pi:

    $ sudo apt-get install sqlite3

    I've included the database on this repo, named tasbih.db. If you wanna make this project easier, simply just use my database and go to the next step. But if you want to make your own, follow these following step.

    • Open SQLite shell with worked database named tasbih.db:

      $ sqlite3 tasbih.db
    • Create tasbihcount table with columns: id, tasbih and tanggal:

      sqlite> create table tasbihcount (
                  id integer primary key autoincrement,
                  tasbih int,
                  tanggal date default CURRENT_DATE
              );
      
      sqlite> .tables
      
      sqlite> .fullschema
    • Optional: check your database/table by inserting an initial data.

      sqlite> insert into tasbihcount (tasbih) values (1);
      
      sqlite> select tanggal, sum(tasbih) from tasbihcount group by tanggal;
    • Exit from SQLite shell:

      sqlite> .quit

  • 3. Raspberry Pi (GPIO & apps) Preparation

    In this project I used 1.3" OLED display, also I'll create a Flask server application. So we need install several packages needed, especially Luma.OLED & Flask library:

    $ sudo apt install python3-dev python3-pip libfreetype6-dev libjpeg-dev build-essential libopenjp2-7 libtiff5
    
    $ sudo pip3 install luma.oled

    Connect 1.3" OLED display & touch sensor to Raspberry Pi, follow basic diagram/image below:

    -- image will be here --


  • 4. Run tasbih_device.py

    Execute tasbih_device.py:

    $ python3 tasbih_device.py

    Your OLED display will show a title text Tasbih Digital, and you're ready to go! Try to touch its sensor, the tasbih counter will add +1 value every touch detected.


  • 5. Run tasbih_app.py

    You can also monitor the daily recapitulation of the numbers of tasbih. Simply check your IP address, then find your Pi's. Insert your Pi's IP on tasbih_app.py.

    $ sudo nano tasbih_app.py

    Insert your IP on this line.

    if __name__ == '__main__':
        app.run(
            debug = True,
            host = 'XXX.XXX.XX.XX' # your IP address
        )

    Then execute tasbih_app.py:

    $ python3 tasbih_app.py

    Now you can check your tasbih status by requesting to its IP, port 5000 from any gadget that you have. For example from your smartphone, go to its browser then type XXX.XXX.XX.XX:YYYY. It will show a daily recapitulation table of the numbers of tasbih. Enjoy!


Lintang Wisesa 💌 lintangwisesa@ymail.com

Facebook | Twitter | Youtube | LinkedIn | :octocat: GitHub | Hackster