This Raspberry Pi prepaid energy monitor takes a photo of the amount of money you have left and emails it to you at a predefined time via a cronjob.
- Raspberry Pi (any)
- Raspberry Pi camera module (any)
- Enabled camera module. Run:
sudo raspi-configto enable, then reboot - Raspberry Pi Wi-Fi Dongle (if using a Raspberry Pi < 3)
- raspistill
- ssmtp
- mailutils
- mpack
Clone to the ~/powerpi directory on your Raspberry Pi
git clone git@github.com:n8kowald/powerpi.git ~/powerpisudo apt-get install ssmtp
sudo apt-get install mailutilsEdit your SSMTP config
sudo vim /etc/ssmtp/ssmtp.confAdd or update the following settings
root=postmaster
mailhub=smtp.gmail.com:587
rewriteDomain=gmail.com
FromLineOverride=YES
UseSTARTTLS=YES
# Replace with your Gmail username
AuthUser=user@gmail.com
# Allow less secure apps to access your account: https://support.google.com/accounts/answer/6010255
# Replace with your application specific password: https://support.google.com/mail/answer/185833
AuthPass=echo "This is the body" | mail -s "Subject" user@gmail.comSSMTP docs (including how to secure it): https://wiki.archlinux.org/index.php/SSMTP
sudo apt-get install mpacksudo chmod +x ~/powerpi/powerpi.shEdit your crontab by typing crontab -e and paste the following command
# Run daily at 20:00 - change the time here: http://crontab-generator.org
0 20 * * * /home/pi/powerpi/powerpi.sh >/dev/null 2>/dev/null- Edit
~/powerpi/powerpi.shand replaceRECIPIENTS="user@gmail.com"with your email address - Play with the settings passed to 'raspistill' to get the best photo for YOUR light conditions
raspistill --exposure night --vflip --hflip --width 650 --height 450 --timeout 7000 --brightness 57 --sharpness 75 --output "${DIR}${FILENAME}"See the full list of options by typing raspistill
Run this script by typing 'powerpi', or change the alias name.
# Edit your ~/.bashrc
vim ~/.bashrc
# Paste the following to run the script on demand
alias powerpi='sh /home/pi/powerpi/powerpi.sh'