{"id":16167133,"url":"https://github.com/ethymoney/pi-neopixel-http-api-controller","last_synced_at":"2026-05-18T15:33:59.920Z","repository":{"id":207444499,"uuid":"713218117","full_name":"EthyMoney/pi-neopixel-http-api-controller","owner":"EthyMoney","description":"A simple addressable LED strip control program for Raspberry Pi that takes control commands over a HTTP REST API.","archived":false,"fork":false,"pushed_at":"2025-08-01T20:41:45.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-01T21:46:41.831Z","etag":null,"topics":["addressable-leds","led","neopixel","python","raspberry-pi","raspberrypi","rest-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EthyMoney.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,"zenodo":null}},"created_at":"2023-11-02T04:22:16.000Z","updated_at":"2025-08-01T20:41:48.000Z","dependencies_parsed_at":null,"dependency_job_id":"dc1645b3-1bd4-4b7a-8001-04f48567ba4b","html_url":"https://github.com/EthyMoney/pi-neopixel-http-api-controller","commit_stats":{"total_commits":13,"total_committers":1,"mean_commits":13.0,"dds":0.0,"last_synced_commit":"b406acfd4a2992ed216359be7743e8ab73930768"},"previous_names":["ethymoney/pi-led-controller"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/EthyMoney/pi-neopixel-http-api-controller","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EthyMoney%2Fpi-neopixel-http-api-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EthyMoney%2Fpi-neopixel-http-api-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EthyMoney%2Fpi-neopixel-http-api-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EthyMoney%2Fpi-neopixel-http-api-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EthyMoney","download_url":"https://codeload.github.com/EthyMoney/pi-neopixel-http-api-controller/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EthyMoney%2Fpi-neopixel-http-api-controller/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33182906,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-18T09:27:30.708Z","status":"ssl_error","status_checked_at":"2026-05-18T09:27:28.300Z","response_time":71,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["addressable-leds","led","neopixel","python","raspberry-pi","raspberrypi","rest-api"],"created_at":"2024-10-10T03:06:23.535Z","updated_at":"2026-05-18T15:33:59.915Z","avatar_url":"https://github.com/EthyMoney.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Pi LED Controller Web API\n\nThis is a Python program for the Raspberry Pi that allows you to control a strip of WS2812B (NeoPixel) addressable LEDs using a REST API. Any Raspberry Pi model will work, I like to use the Pi Zero W because it's cheap, small, and has built-in WiFi. The processing requirements for this program are very low, so even the weak Pi Zero W can handle it just fine, but installing things will take a little more patience :)\n\n## Installation\n\nFollow these steps to install the necessary packages and libraries:\n\n```bash\nsudo apt update\nsudo apt upgrade\nsudo apt install python3-pip git\n```\n\nSet up your Python virtual environment, see [here](https://learn.adafruit.com/circuitpython-on-raspberrypi-linux/installing-circuitpython-on-raspberry-pi#setup-virtual-environment-3157129) to see how\n\nOnce it's set up, install the Python dependencies:\n\n```bash\nsudo pip3 install flask adafruit-circuitpython-neopixel rpi_ws281x\n```\n\nClone the repository to your Raspberry Pi:\n\n```bash\ngit clone https://github.com/EthyMoney/pi-neopixel-http-api-controller.git\n```\n\n## Configuration\n\nYou need to open the `main.py` file and set the `NUM_PIXELS` variable to the count of leds in your strip. You can also change the GPIO pin that the data pin of the strip is connected to by changing the `DATA_PIN` variable. This needs to be a hardware PWM pin like GPIO 12, GPIO 13, GPIO 18, GPIO 19. The default is GPIO pin 18, which is represented in the code as `board.D18`. You can find a list of GPIO pin numbers [HERE](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio-pins) and see the pinout diagram [HERE](https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#gpio).\n\n## Hardware Setup\n\nConnect the data pin of the LED strip to GPIO pin 18 on the Raspberry Pi (default), or whatever you changed it to. Connect the ground pin of the LED strip to any ground pin on the Raspberry Pi **AND** the ground of the power supply. Yes, the strip should have a common ground with the Pi and power supply, you will have issues if you don't do this. Connect the power pin of the LED strip to a power supply of correct voltage for your strip, this is typically either 5v, 12v or 24v. Make sure your power supply has enough current to power your strip. Assuming 12v, you typically need 1 amp per meter of strip as a very general rule of thumb. For example, a 5 meter 12v strip would need a 5 amp 12v power supply.\n\n## Running the Program\n\nYou can run the program directly with Python:\n  \n```bash\nsudo python3 main.py\n```\n\n**NOTE:** If you are using an older pi (like a pi 1), you may get an error on startup related to the revision code not being supported. This is because the GPIO library in use does not support the \"old style\" revision codes. You can get around this running with a specified \"new style\" reperesentation of the revision code as RPI_LGPIO_REVISION, like this for example: `sudo python3 RPI_LGPIO_REVISION=\"800012\" main.py`\n\nFor running with pm2, add this option to the `process.json` file under the `cwd` entry:\n\n```json\n\"env\": {\n  \"RPI_LGPIO_REVISION\": \"800012\"\n},\n```\n\nFor example:\n\n```json\n{\n  \"apps\": [\n    {\n      \"name\": \"rest-led-controller\",\n      \"script\": \"main.py\",\n      \"interpreter\": \"python3\",\n      \"cwd\": \"/path/to/your/project/directory\",\n      \"env\": {\n        \"RPI_LGPIO_REVISION\": \"800012\"\n      },\n      \"exec_mode\": \"fork\",\n      \"wait_ready\": true,\n      \"autorestart\": true,\n      \"max_restarts\": 10\n    }\n  ]\n}\n```\n\nFor more info about this, see [here](https://rpi-lgpio.readthedocs.io/en/latest/differences.html#pi-revision)\n\n## Running with PM2 (Recommended)\n\nPM2 is a process manager for Node.js applications. The repository includes a PM2 process definition json file, which allows you to run the app as a background process and automatically start it on boot.\n\nFirst, edit the `process.json` file to replace the path to the `main.py` file with the path to your copy of the repository on your pi. Also edit as above if you need the special `RPI_LGPIO_REVISION` environment variable for an old pi.\n\nThen, install node.js and PM2:\n\n```bash\nsudo apt update \u0026\u0026 sudo apt install npm -y \u0026\u0026 sudo npm install pm2 -g\n```\n\nNote that you may need to manually install a newer version of node.js if you are on a 32-bit pi/os. See [this guide](https://www.instructables.com/Install-Nodejs-and-Npm-on-Raspberry-Pi) and download builds for your pi from the [unofficial builds project](https://unofficial-builds.nodejs.org) \n\nNow, start the app with PM2, save the process list, and set to start on boot:\n\n```bash\nsudo pm2 start process.json\nsudo pm2 save\nsudo pm2 startup\n```\n\n## API Endpoints\n\nThe program runs a web server on port 5000 hosting a REST API and set of endpoints for controlling the connected LED strip. The base API URL is `http://\u003cyour-pi-ip-address\u003e:5000/`. Here are the available endpoints:\n\n- `/set_color`: Sets the color of the LED strip.\n  - Method: `POST`\n  - Request body: `{\"color\": [255, 0, 0]}` (for red)\n\n- `/turn_off`: Turns off the LED strip.\n  - Method: `POST`\n  - Request body: None\n\n- `/rainbow_wave`: Starts a rainbow wave effect.\n  - Method: `POST`\n  - Request body: `{\"speed\": 50}` (optional speed parameter, 0-100%, default 50%)\n\n- `/alternating_colors`: Alternates between the specified colors.\n  - Method: `POST`\n  - Request body: `{\"color1\": [255, 0, 0], \"color2\": [0, 255, 0], \"speed\": 50}` (optional speed parameter, 0-100%, default 50%)\n\n- `/set_brightness`: Sets the brightness of the LED strip.\n  - Method: `POST`\n  - Request body: `{\"brightness\": 100}` (for 100% brightness)\n\n- `/color_loop`: Loops through the specified colors.\n  - Method: `POST`\n  - Request body: `{\"colors\": [[255, 0, 0], [0, 255, 0], [0, 0, 255]], \"speed\": 50}` (optional speed parameter, 0-100%, default 50%)\n\n- `/pulse_effect`: Starts a pulse effect with the specified color.\n  - Method: `POST`\n  - Request body: `{\"color\": [255, 0, 0], \"speed\": 50}` (optional speed parameter, 0-100%, default 50%)\n\n- `/help`: Returns a list of available endpoints and their usage (basically what you are looking at right now)\n  - Method: `GET`\n  - Request body: None\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethymoney%2Fpi-neopixel-http-api-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fethymoney%2Fpi-neopixel-http-api-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fethymoney%2Fpi-neopixel-http-api-controller/lists"}