Skip to content

rassweiler/pi-networked-counter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pi-networked-counter

Network attached counter using Pi5, python, pyqt6, and sqlite

Assembly Assembly IO Assembly Rear Assembly Opened Sensor Assembly Sensor Assembly 2 Sensor Assembly Opened

Dev Setup (Linux)

  • clone repository:
git clone https://github.com/rassweiler/pi-networked-counter.git && cd pi-networked-counter
  • Setup python environment:
python3 -m venv venv

source venv/bin/activate

pip3 install gpiozero lgpio msal msal_extensions python-dotenv pygobject
  • Install optional packages:
sudo apt install qtcreator sqlitebrowser

Device Setup (Pi5+)

Base Version Part List

Stacklight Version Part List

Optional Parts

Pi Software

  • Update system
sudo apt update && sudo apt upgrade
  • Install packages
sudo apt install < .packages
  • Disable sudo NOPASSWD:
sudo nano /etc/sudoers.d/010_pi-nopasswd

remove NOPASSWD:
  • Enable sudo logging:
sudo visudo

Insert:

Defaults    logfile=/var/log/sudo
  • Harden ssh config:
sudo nano /etc/ssh/sshd_config

PermitRootLogin prohibit-password
MaxAuthTries 5
MaxSessions 3
MaxStartups 3:90:15
PasswordAuthentication no
  • Harden ssh keys:
echo -e "# Restrict key exchange, cipher, and MAC algorithms, as per sshaudit.com\n# hardening guide.\n KexAlgorithms sntrup761x25519-sha512,sntrup761x25519-sha512@openssh.com,curve25519-sha256,curve25519-sha256@libssh.org,gss-curve25519-sha256-,diffie-hellman-group16-sha512,gss-group16-sha512-,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha256\n\nCiphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-gcm@openssh.com,aes128-ctr\n\nMACs hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,umac-128-etm@openssh.com\n\nHostKeyAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-256-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256\n\nRequiredRSASize 3072\n\nCASignatureAlgorithms sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512,rsa-sha2-256\n\nGSSAPIKexAlgorithms gss-curve25519-sha256-,gss-group16-sha512-\n\nHostbasedAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256\n\nPubkeyAcceptedAlgorithms sk-ssh-ed25519-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,sk-ssh-ed25519@openssh.com,ssh-ed25519,rsa-sha2-512-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256-cert-v01@openssh.com,rsa-sha2-256\n\n" > /etc/ssh/sshd_config.d/ssh-audit_hardening.conf
  • Remove avahi:
sudo systemctl stop avahi-daemon && sudo systemctl disable avahi-daemon

sudo apt purge avahi-daemon -y
  • Remove CUPS:
sudo systemctl stop cups && sudo systemctl disable cups

sudo apt purge cups -y 
  • PI configure Set the locale to UTF-8

  • Setup keyring for sharepoint integration Run seahorse and make sure there is a default keystore

  • clone repository to PI:

git clone https://github.com/rassweiler/pi-networked-counter.git && cd pi-networked-counter
  • Copy the desktop file to autostart the app:
sudo cp objectcounter.desktop /etc/xdg/autostart/objectcounter.desktop
  • Add panel icon
cp objectcounter.desktop ~/.local/share/applications/

Then restart the system to get the app in the menu under other, then right click the app and select add to taskbar

  • Setup startup IO for push button
echo "dtoverlay=gpio-poweroff,gpiopin=25,active_low" >> /boot/firmware/config.txt

Sharepoint Setup (Optional)

  • Add to the .settup.toml file your sharepoint access details:
[sharepoint]
authority = "https://login.microsoftonline.com/{AID}"
client = "{CID}"
scopes = 'User.ReadBasic.All Files.ReadWrite Sites.ReadWrite.All'
endpoint = "https://graph.microsoft.com/v1.0/me" 
  • run the get_token.sh script once to initialise your sharepoint token, it should provide a link and a key to login using a browser.

Print Parts

  • Print out the Front case section (Should contain the screen brackets as well)
  • Print out the Rear case section
  • Print out the Sensor case sections
  • Print any required brackets/stands

Prepare Sensors

  • Connect both power wires together from the IR emitter and receiver
  • Connect both ground wires together from the IR emitter and receiver
  • Solder the M12 AMP Connector Male to the sensors following the pinout below

Sensor Pinout To Cable

  • Pin 1 (Brown): 3.3V
  • Pin 2 (White): Unused
  • Pin 3 (Blue): Emitter signal (Yellow)
  • Pin 4 (Black): Ground
  • Pin 5 (Gray): Unused Connector Pinout

Lightstack Pinout

  • Cable Brown: 12V
  • Cable Green: Green LED
  • Cable Yellow: Yellow LED
  • Cable Red: Red LED

Pi5 Wiring

  • Pin 1 (3.3V): To infeed sensor pin 1
  • Pin 2 (5V): To Display pin 5 (5V)
  • Pin 6 (GND): To Display pin 1 (GND)
  • Pin 9 (GND): To infeed sensor pin 4
  • Pin 11: To infeed sensor pin 3
  • Pin 13: To stack light green wire
  • Pin 14 (GND): To outfeed sensor pin 4
  • Pin 15: To stack light yellow wire
  • Pin 16: To outfeed sensor pin 3
  • Pin 17: (3.3V): To outfeed sensor pin 1
  • Pin 18: To stack light red wire
  • Pin 22: To power led +
  • Pin 25 (GND): To dev board for ground
  • Pin 30 (GND): To power led -

Assembly Schematic

The Pi5 board is not entirely accurate, the J2 and J8 pins are proper however. Schematic

About

3d printed counter using Pi5, python, pyqt6, and sqlite that can export to folders or sharepoint

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors