Skip to content
This repository was archived by the owner on Mar 21, 2023. It is now read-only.

brobots-hub/meal-tracking

Repository files navigation

#brobots school meal tracking

GitHub release (latest by date) GitHub code size in bytes

This is a system running on Raspberry Pi that helps to record at what exact time each student has taken his meal. It uses personal RFID tags as user identifiers.

Hardware

  • Raspberry Pi 3B+
  • RDM6300 RFID Reader - 125kHz
  • RFID wrist tags - 125kHz

Software

  • Python as main project language
  • Google Sheets API as data storage
    • I'd personally use MySQL for these purposes, but all school data is stored in Google Sheets API - @andrewyazura
  • RDM6300 sensor library

Setup

Environment variables

  • ENVIRONMENT
    • DEVELOPMENT - app will use .env.dev
    • PRODUCTION - app will use .env

Configuration and authentication

  1. Create a new Google Cloud Platform (or use an existing one) project. Enable Google Sheets API and create a service account for this device. Read this manual on how to get it: Creating a service account. Next, download a JSON key for that service account.
  2. Create a Google Sheets document where your data will be stored.
    • Give your service account access to the document. Just copy email address of service
  3. Insert data into .env file
    • Copy example from .env.example
    • Set DOCUMENT_ID to ID of a document you created
    • Set SERVICE_ACCOUNT to a path to JSON key you downloaded

How to get service-account.json

Follow this steps:

  • Go to Credentials tab
  • Open Manage service accounts link
    • It's located near Service Accounts list
  • Find the service account you need.
  • Press Actions button (three dots) and choose Create key
  • Choose JSON and press Create

Google Sheets document setup

Copy this example: link.

If for some reason the link isn't working, here is how table looks:

IDs Users Records
1 user1 --- 1970/01/01 00:00:00
2 user2 --- 1970/01/01 00:00:00 1970/01/01 00:00:00
3 user3 ---
4 user4 --- 1970/01/01 00:00:00

New records are appended into user's row. Record only has date and time of the request.

Raspberry Pi setup

Serial / UART

Run sudo raspi-config. Select Interfacing Options / Serial then disable Serial console and enable Serial hardware. Now use /dev/serial0 in any code which accesses the Serial Port.

If given instructions didn't work, try using this tutorial: link.

System Service Unit

You can use mealtracker.service that is provided in the repostitory or write your own unit. If you're using the existing one, you have to:

  1. Enter path to your project in specified placed
  2. Enter name of the user you're going to use
    • On the Raspberry Pi it's most probably pi user.
  3. Copy the unit file to /etc/systemd/system/

Now the service is accessible over sudo systemctl command.

Remember to stop the service before using input.py

Usage

sudo systemctl start mealtracker.service - start the service

sudo systemctl stop mealtracker.service - stop the service

sudo systemctl status mealtracker.service - check status of the service

Custom Service

Here is a link to official Raspberry Pi documentation on writing services: link

About

System for tracking meals taken at school. Running on a Raspberry Pi

Topics

Resources

Stars

Watchers

Forks

Languages