Like the case? Get it from balenalabs' inkyshot repo
Have questions? Feel free to open a new discussion in this repo
- Send an
email...text message... Discord message to update the message on the inky phat- Ran into some trouble with different mail servers having different ways of handling message bodies. The Discord bot is cleaner, more stable, and more practical as it can be accessed on iOS, Android, Windows, Linux, MacOS, Chrome OS, etc.
- Weather status icon
- Temperature (in Fahrenheit) from OpenWeatherMap API (RIP DarkSky)
- Date in the bottom right corner
- Can send a message up to 4 lines long
- Makes one call to the IpInfo API (unless the device is moved to a different network)
- Logging of errors saved in
log.txt
for easy debugging though sftp if the device suddenly stops working- Log will include:
- Incorrect / invalid email credentials
- Incorrect / invalid API key
- Missing email or password in
config.json
- Missing API key in
config.json
- Missing
config.json
- Log will include:
- Discord commands:
!reboot
- Restarts the Raspberry Pi!shutdown
- Turns off the Raspberry Piany text here
- Sends a message. Usage:Hello!
will showHello!
on the display
- Raspberry Pi Zero W with pre-soldered headers ($14)
- Break-away 2x20-pin GPIO headers ($0.95)
- Power supply and cable - 5V 2.5A ($8.25)
- Pimoroni Inky pHat ($25)
- 8GB microSD card ($5.50)
- 3D printed case (free stl; about $5 to print)
- Micro USB to DIP adapter ($4.50)
- Soldering gun ($12) (for the headers and USB DIP adapter)
- Above link includes the necessary items:
- Flux paste
- Solder wire
- Above link includes the necessary items:
- ~22 AWG wire ($5) (or salvage from something lying around)
- Download Raspberry Pi OS Lite
- Flash image to SD card with Raspberry Pi imager. While this is happening...
- Download wpa_supplicant.conf and ssh
- Modify wpa_supplicant.conf to include your wifi credentials
- Safely remove and reinsert the microSD card you just flashed
- Put YOUR modified version of
wpa_supplicant.conf
andssh
directly onto the root directory of the microSD card - Insert microSD, boot up the Pi, and SSH into it
- Download the necessary files through
curl https://get.pimoroni.com/inky | bash
- Enable SPI and I2C. To do this, run
sudo raspi-config
, scroll to Interface Options, and enable them.- While in
raspi-config
, change the time zone (unless you live in the UK). SelectLocalisation Options
>Timezone
.
- While in
- Run
sudo apt-get update
andsudo apt-get upgrade
- This will take a while - Run
python3 -m pip install --upgrade pip
andpython3 -m pip install --upgrade Pillow
andpython3 -m pip install discord
- Run
cd ~
andgit clone https://github.com/corey-schneider/inky-phat-messenger.git
andcd inky-phat-messenger
- Create a new (free) account with OpenWeatherMap.org.
- Sign in, click your name in the top right, click
My API keys
and copy the Key to config/config.json
- Sign in, click your name in the top right, click
- Create Discord bot:
- Create a Discord account or sign in to your existing account
- Create a new server, name it whatever you'd like
- You may want to create a server icon - there is a Raspberry Pi icon that can be found here
- Head to https://discord.com/developers/applications
- Click
New Application
in the top right and name itinky
(or whatever you'd like) - Click
Bot
on the left column and thenReset Token
on the right - Copy your
TOKEN
and be sure not to share it with anyone. Paste it inconfig/config.json
underdiscord > token
- You may also enter your discord handle there too. Be sure to include your hash tag and numbers. This will act as a whitelist, only messages from
discord > allowed_user
will change the message on the inky phat, but you may also leave it blank to allow anyone in the server to change the message
- You may also enter your discord handle there too. Be sure to include your hash tag and numbers. This will act as a whitelist, only messages from
- Still in the
Bot
section, scroll down to the Privileged Gateway Intents section. Enable the following 3 toggles:PRESENCE INTENT
SERVER MEMBERS INTENT
MESSAGE CONTENT INTENT
- Click
OAuth2
in the left column. Select the dropdownURL Generator
, checkbot
under theSCOPES
section. UnderBOT PERMISSIONS
, checkSend Messages
,Manage Messages
,Read Message History
- You should now see a link at the bottom of
SCOPES
ending with&scope=bot
- visit this link. It should ask which server you'd like to attach the bot to - select the server made in the 2nd step
- After testing to make sure everything is working, we need to make sure
discordbot.py
runs on startup anddisplay.py
runs every hour to update the weather- Run
crontab -e
. Type1
if prompted to select an editor - At the bottom of the file, enter these two lines:
@reboot sleep 30; cd /home/pi/inky-phat-messenger && python3 /home/pi/inky-phat-messenger/discordbot.py
@hourly cd /home/pi/inky-phat-messenger && python3 /home/pi/inky-phat-messenger/display.py
- hit
ctrl o
, enter, thenctrl x
- Run
If you need help, feel free to open a new discussion in this repo.
- If you see an error saying
File "/home/pi/.local/lib/python3.7/site-packages/PIL/Image.py", line 109, in <module>
or something aboutfrom . import _imaging as core
...- Run
sudo rm -rf /home/pi/.local/lib/python3.7/site-packages/PIL/
. If the error persists, notice the directory - you may seepython3.8
or similar - change therm -rf
command to the version seen in your error.
- Run
- If the Discord bot is showing as offline on the Discord server...
- Check the connection of the raspberry pi - make sure you can ssh into it
- Make sure the token is correct and placed in
config/config.json
- Check the
log.txt
for an error message from discordbot
- If the Discord bot is not responding, the bot is likely offline and needs to be restarted
- If the Discord bot is saying you're not authorized, make sure you entered your name correctly in
config/config.json
. It should look similar to this:"allowed_user": "tester#1234"
. Reminder that this is NOT the bot's name; it is YOUR personal account's name
- Use PIL to create a mockup image of the display and have the bot send it over Discord
- Clean up code in
display.py
- Separate code into methods and classes
- Weather can be its own class
- Integrate
bottom_frame_info
better- If false, move text lower or allow for longer messages
- Vertical align text
- Remove print alongside logger
- Change sys.exit(message) to (0)
- Separate code into methods and classes
- Fix logger
- Should print
- Add more commands to Discord bot
- font size
- font style
- get IP / location / weather information
- enable / disable bottom frame
- !help command to show all commands
- Have error messages routed to Discord bot
- Set up optional alerts to recipient on Discord bot
- Enter the recipient's Discord handle and alert them when a new message arrives on the inky display
- Add more weather icons
- Hopefully remove the ugly bump too
- Climacons are really nice
- Finer detailed weather
- Have discord bot be aware of length of message and reject a message that will overflow off the screen
paragraph = textwrap.wrap(message, width=24)
24 cuts off, may need to lower to 23 - do some testing- Create method for saving to json
- "Send your first message via discord" doesn't save to configuration file
- Add automatic wifi and automate the setup
- IpInfo - Turns IP addresses into latitude and longitude coordinates
- OpenWeatherMap - Weather API
- weather-phat.py - Code pieces and icons from the weather application sample
- balenalabs/inkyshot - 3D printed case files
Ethereum: 0xbb5f5d978acbde2ec79736cc5398768a35665d42