{"id":19442994,"url":"https://github.com/syncom/twitimg-rpi","last_synced_at":"2026-05-17T07:39:38.750Z","repository":{"id":145815056,"uuid":"53308642","full_name":"syncom/twitimg-rpi","owner":"syncom","description":"A simple tool turns a Raspberry Pi (RPi) into a security monitoring system.","archived":false,"fork":false,"pushed_at":"2023-05-01T00:53:56.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-07T22:13:15.991Z","etag":null,"topics":["motion-detection","raspberry-pi","twitter-bot"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/syncom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-03-07T08:28:30.000Z","updated_at":"2023-05-01T00:53:52.000Z","dependencies_parsed_at":null,"dependency_job_id":"c60001ca-66af-4c75-8e65-2856d40b73d9","html_url":"https://github.com/syncom/twitimg-rpi","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syncom%2Ftwitimg-rpi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syncom%2Ftwitimg-rpi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syncom%2Ftwitimg-rpi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/syncom%2Ftwitimg-rpi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/syncom","download_url":"https://codeload.github.com/syncom/twitimg-rpi/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240627067,"owners_count":19831592,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["motion-detection","raspberry-pi","twitter-bot"],"created_at":"2024-11-10T15:41:39.555Z","updated_at":"2026-05-17T07:39:38.744Z","avatar_url":"https://github.com/syncom.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# twitimg-rpi\n\nA simple tool turns a Raspberry Pi (RPi) into a security monitoring system.\n\n# What are needed\n\n- A Raspberry Pi (version 1-3) Model B (needs Internet connectivity) running\n  Raspberry Pi OS Lite (32-bit)\n- A camera module (any of these sould work:\n  \u003chttps://www.raspberrypi.com/documentation/accessories/camera.html\u003e)\n- imagemagick (for image conversion on the RPi), libssl-dev, build-essential,\n  python-imaging, libffi-dev\n- Python 2.7: twython, pyOpenSSL, ndg-httpsclient, pyasn1, PIL\n- A Twitter account (for multimedia storage and accessibility)\n\n## Tweet a time-lapse GIF every 20 minutes\n\nUsage:\n\n1. Install the camera module on the RPi. Install the `rpicam-apps` package and\n   other dependencies\n\n   ```bash\n   sudo apt update\n   sudo apt install rpicam-apps imagemagick git vim \\\n     python3-dev python3-setuptools libjpeg-dev\n   ```\n\n   Clone this repo to `/home/pi/twitimg-rpi`, and set up Python virtual\n   environment\n\n   ```bash\n   cd /home/pi\n   git clone https://github.com/syncom/twitimg-rpi.git\n   ```\n\n\n2. Create a Twitter app and obtain the API Key, API Secret, Access Token, and\n   Access Token Secret for the app. This can be done by following the\n   instructions at:\n   \u003chttp://www.instructables.com/id/Raspberry-Pi-Twitterbot/?ALLSTEPS\u003e. After\n   April 2023, if you start seeing API authentication errors, and a message like\n   \"This app has violated Twitter rules and policies\" on the Twitter app setting\n   page, sign up for the Free tier of \"[Twitter API\n   v2](https://developer.x.com/en/portal/products)\" (at no cost), and clicked\n   button \"downgrade to free\"; this resolved the auth issue\n   ([reference](https://twittercommunity.com/t/this-app-has-violated-twitter-rules-and-policies/191204/10)).\n\n   One also needs to create a \"project\" in the [X developer\n   portal](https://developer.x.com/en/portal/dashboard), and add this Twitter\n   app to it. Otherwise, one might encounter the following error message (as of\n   20250624):\n\n   ```text\n    When authenticating requests to the Twitter API v2 endpoints, you must use\n    keys and tokens from a Twitter developer App that is attached to a Project.\n    You can create a project via the developer portal.\n   ```\n\n3. Override the corresponding strings in the file '.auth' with appropriate\n   Twitter app API access token strings obtained in the last step.\n\n4. Because we are going to write and delete a lot of files, in order to prevent\n   the SD card from wearing out, create a ramdisk (of size 25M bytes) to store\n   image files created during the process.\n\n   ```bash\n   mkdir /mnt/ramdisk\n   mount -t tmpfs -o size=25m tmpfs /mnt/ramdisk\n   ```\n\n   To make the ramdisk persist over reboots, add the following lines to\n   `/etc/fstab`:\n\n   ```text\n   # ramdisk for camera capture (added 20160306)\n   tmpfs       /mnt/ramdisk tmpfs   nodev,nosuid,noexec,nodiratime,size=25m   0 0\n   ```\n\n5. Create a cron job to take a still picture from the RPi camera module every 1\n   minute. Do `crontab -e` and add the following:\n\n   ```text\n   # take still picture every 1 minute\n   * * * * * /home/pi/bin/twitimg-rpi/camera_raspistill.sh 2\u003e\u00261\n   ```\n\n   Create a cron job to upload an animated GIF image combined from the still\n   images taken in the past 20 minutes. Do `crontab -e` and add the following:\n\n   ```text\n   # upload image every 20 minutes\n   0,20,40 * * * * /home/pi/bin/twitimg-rpi/twitimg-run.sh\n   ```\n\n   Because currently Twitter only allows uploading of an animated GIF of maximum\n   size of 5M bytes, this setting works well for me. You may want to tweak the\n   frequencies of taking still pictures and uploading according to your\n   situation.\n\n6. Connect the RPi to the Internet, and watch the stream of videos from your\n   Twitter timeline.\n\n7. (Optional) To turn off the LED red light in the camera module when taking\n   pictures, edit the file `/boot/config.txt` to add / change the following line:\n\n   ```text\n   disable_camera_led=1\n   ```\n\n## Tweet a JPEG image upon motion detection\n\nUsage:\n\n1. Follow the same steps 1-3 as above to install the camera module and set up\n   the twitter account.\n\n2. Create another ramdisk of size 80M bytes to store motion-detected image\n   files.\n\n   ```bash\n   mkdir /mnt/ramdisk_motion\n   mount -t tmpfs -o size=80M tmpfs /mnt/ramdisk_motion \n   ```\n\n   To make the ramdisk persist over reboots, add the following lines to\n   `/etc/fstab`:\n\n   ```text\n   # ramdisk for camera capture (added 20170309)\n   tmpfs       /mnt/ramdisk_motion tmpfs   nodev,nosuid,noexec,nodiratime,size=80m   0 0\n   ```\n\n3. Run `twitimg-motion-run.sh`.\n\n4. (Optional) To run the program upon system boot, create a cron job:\n\n   ```bash\n   crontab -e\n   ```\n\n   And add the following lines (and redirect stdout and stderr output to a file)\n\n   ```text\n   # Upon reboot\n   @reboot stdbuf -oL -eL /home/pi/bin/twitimg-rpi/twitimg-motion-run.sh \u003e /home/pi/bin/twitimg-rpi/twitimg.log 2\u003e\u00261\n   ```\n\n   In the above line, we use `stdbuf -oL -eL` tool in the `coreutils` package to\n   set line buffering for stdout and stderr, so that log messages are written to\n   the log file immediately. (If you wish to completely turn off buffering for\n   stdout and stderr, use the `-o0 -e0` options.)\n\n5. (Optional) Reboot the RPI nightly.\n\n   ```bash\n   sudo crontab -e\n   ```\n\n   Add the following lines\n\n   ```text\n   # reboot at 00:05 every day\n   0  0 * * * /sbin/shutdown -r +5 \n   ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncom%2Ftwitimg-rpi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsyncom%2Ftwitimg-rpi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsyncom%2Ftwitimg-rpi/lists"}