Skip to content
This repository has been archived by the owner on Mar 7, 2023. It is now read-only.
/ DigitalBatteryLog Public archive

Uses a raspberry Pi with touchscreen display to log in/out batteries. This information will be stored to a local mongoDB database and upon a wifi connection, it will be synced with google sheets.

Notifications You must be signed in to change notification settings

frc-862/DigitalBatteryLog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Digital Battery Sign-out Sheet

Log battery sign-outs with the battery number, time signed out/in, and battery stats (rint and state of charge) before and after use, all with kiosk mode chromium running on xserver.

Hardware

  1. Raspberry Pi 2/3 with internet access
  2. Sunfounder 7" touchscreen display

Node Dependencies

  • mongoose
  • node-cron
  • google-apis
  • dotenv

Setup

Note: These instructions are specifically for Ubuntu server 20.04.4LTS (64bit ARM64). For help on installing this operating system, please click here.

Warning: You MUST install the 64 bit version (ARM64 architecture) of Ubuntu server.

First clone the repository via HTTP

git clone https://github.com/Mikecerc/DigitalBatteryLog.git

An installer script is currently planned, however setup at this point is manual. The steps to installing all the software needed is as follows:

  1. Install all the node dependencies with the following command:
    npm i
  2. follow the steps located here to install mongoDB version 4.4 for Ubuntu 20.04 LTS:
  3. Add the following to your ~/.bash_profile(create one if it does not exist):
source ~/.profile
if [[ -z $DISPLAY ]] && [[ $(/dev/tty) = /dev/tty1 ]]; do
cd DigitalBatteryLog/
git pull
node . &
startx -- --nocursor
fi
  1. Add the following to your ~/.xinitrc (create one if it does not exist):
chromium-browser --kiosk http://localhost:3000 --disable-infobars --start-maximized --window-position=0,0 --window-size=480,640
  1. Install Xorg and chromium with the following:
    sudo apt-get install xserver-xorg x11-server-utils xinit
    sudo apt-get install -y chromium-browser
  1. create a .env file in the repository folder with the following content:
syncInterval=[time in minutes that you want to scan db for updates]
sheetURL=[full url of the google sheet you are updating]
databaseAddress=mongodb://localhost:27017/batteryLogs
scopes=[\"https://www.googleapis.com/auth/spreadsheets\"]

Next, you must create an app via Google Cloud Platform in order to use the Google Sheets API. Follow the steps below to successfully setup the application, Oauth2 and Google Sheets API

  1. Using internet explorer, navigate to the Google Cloud Platform

  2. agree to the terms of service and continue onto the master dashboard.

  3. click on IAM & Admin
    img

  4. Click "create a project"
    img

  5. Create a new Project by giving the project a name. Proceed by clicking create.
    img

  6. Return Back to the master dashboard of Google Cloud Platform

  7. While on the dashboard, navigate to the APIs & Services tab and select Library.
    img

  8. In the search bar, search "Google Sheets API"
    img

  9. Click on the result. It should be the only result.
    img

  10. Click enable to enable the Google Sheets API.
    img

  11. Next we will have to create credentials. On the top of the page you are now at, you should see a button labeled CREATE CREDENTIALS. Click it.
    img img

  12. You should now see a prompt labeled Which API are you using? Select User Data and then click next.
    img

  13. In the next section, name the app something you would recognize (Digital Battery Log) and enter the email address you are using in boxes labeled User support email and Email addresses. You do not need to submit an App logo. Click save and continue when done.

  14. You should now be prompted with a section labeled Scopes. Click Add and Remove scopes. Navigate to the last page of the scopes menu and find the scope: .../auth/spreadsheets. Hit the check box next to it and scroll to the bottom of the page. click the update button.
    img img

  15. At the bottom of the scopes page, click SAVE AND CONTINUE.

  16. You should now see a tab labeled OAuth Client ID. Under the Application type dropdown, select Desktop app. Give the client a name you will remember. Click Create.
    img

  17. The final tab should be labeled Credentials. Click the download button. Move the JSON file you downloaded into [REPOSITORY-FOLDER]/config/auth and rename the file to credentials.json.

  18. Return to the API & Services Tab and navigate to the OAuth consent screen tab.
    img

  19. Scroll down until you see the section labeled Test Users. Click the Add Users Button
    img

  20. add the email you will be using to edit your sheets

WARNING: The email address you enter MUST have edit permissions on the Google Sheets you are editing.

  1. You may now close your internet explorer browser.

  2. In order to use the Google Sheets API, you need an access token. To generate an access token, run the following command in the main folder of the repository:

node run getToken

About

Uses a raspberry Pi with touchscreen display to log in/out batteries. This information will be stored to a local mongoDB database and upon a wifi connection, it will be synced with google sheets.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •