{"id":14977944,"url":"https://github.com/lemariva/upyfocus","last_synced_at":"2026-03-02T12:06:36.762Z","repository":{"id":109048980,"uuid":"280903823","full_name":"lemariva/uPyFocus","owner":"lemariva","description":"Add autofocus to the 16 mm Telephoto Lens mounted on the Raspberry Pi HQ Camera (Firmware for the M5Stack)","archived":false,"fork":false,"pushed_at":"2020-12-31T16:55:05.000Z","size":33,"stargazers_count":13,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-01T12:44:10.121Z","etag":null,"topics":["autofocus-camera","m5stack","raspberry-pi-camera","raspberry-pi-hq-camera"],"latest_commit_sha":null,"homepage":"https://lemariva.com/blog/2020/12/raspberry-pi-hq-camera-autofocus-telephoto-lens","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/lemariva.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":"2020-07-19T16:18:59.000Z","updated_at":"2024-03-19T21:52:13.000Z","dependencies_parsed_at":null,"dependency_job_id":"5a7f7bb1-5536-4e4a-b059-cf1a919973a1","html_url":"https://github.com/lemariva/uPyFocus","commit_stats":{"total_commits":12,"total_committers":1,"mean_commits":12.0,"dds":0.0,"last_synced_commit":"a2d05729542f4f461954df4c6deee5214117718b"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyFocus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyFocus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyFocus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lemariva%2FuPyFocus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lemariva","download_url":"https://codeload.github.com/lemariva/uPyFocus/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238608351,"owners_count":19500364,"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":["autofocus-camera","m5stack","raspberry-pi-camera","raspberry-pi-hq-camera"],"created_at":"2024-09-24T13:56:35.146Z","updated_at":"2025-10-28T07:30:36.807Z","avatar_url":"https://github.com/lemariva.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Autofocus for the 16mm telephoto lens mounted on a Raspberry Pi HQ Camera.\nAs you may have already noticed, the Raspberry Pi HQ Camera lenses don't have any autofocus functionality. This project includes the hardware design, firmware and software to add autofocus functionality to those lenses. In this case, I use the 16mm telephoto lens.\nThe project is divided into two repositories. This repository includes the code of the M5Stack firmware whereas [lemariva/rPIFocus](https://github.com/lemariva/rPIFocus) includes the code for the Raspberry Pi, in which the Microservices application runs.\n\nA detailed article about the application can be found on [Raspberry Pi HQ Camera: Autofocus for the Telephoto Lens (JiJi)](https://lemariva.com/blog/2020/12/raspberry-pi-hq-camera-autofocus-telephoto-lens).\n\n## Video\n[![Autofocus for the Raspberry HQ Camera](https://img.youtube.com/vi/PrbyPmq_Z7Q/0.jpg)](https://www.youtube.com/watch?v=PrbyPmq_Z7Q)\n\n## Photo examples\n|          |          |          |          |\n|:--------:|:--------:|:--------:|:--------:|\n|\u003cimg src=\"https://lemariva.com/storage/app/uploads/public/5fe/c63/443/5fec63443a76c981023585.jpg\" alt=\"Focus Type: Box - Background focused\" width=\"300px\"\u003e|\u003cimg src=\"https://lemariva.com/storage/app/uploads/public/5fe/c63/392/5fec6339224b0320000410.jpg\" alt=\"Focus Type: Box - Nanoblock bird focused\" width=\"300px\"\u003e|\u003cimg src=\"https://lemariva.com/storage/app/uploads/public/5fe/c63/4ab/5fec634ab3092068212455.jpg\" alt=\"Focus Type: Box - Nanoblock bird focused. Diff. illum \u0026 cam. aperture\" width=\"300px\"\u003e|\u003cimg src=\"https://lemariva.com/storage/app/uploads/public/5fe/c63/3cd/5fec633cda6af591369087.jpg\" alt=\"Focus Type: Object detector - Teddy bear focused\" width=\"300px\"\u003e|\n|Focus Type: Box \u003cbr/\u003e Background focused (\u003ca href=\"https://lemariva.com/storage/app/media/blog_imgs/hqcamera/hq_camera_background_focused.jpg\"\u003edownload\u003c/a\u003e)|Focus Type: Box \u003cbr/\u003eNanoblock bird focused (\u003ca href=\"https://lemariva.com/storage/app/media/blog_imgs/hqcamera/hq_camera_nanoblock_bird_focused.jpg\"\u003edownload\u003c/a\u003e)|Focus Type: Box \u003cbr/\u003eNanoblock bird focused. \u003cbr/\u003e Diff. illum \u0026 cam. aperture (\u003ca href=\"https://lemariva.com/storage/app/media/blog_imgs/hqcamera/hq_camera_nanoblock_bird_focused_2.jpg\"\u003edownload\u003c/a\u003e)|Focus Type: Object detector  \u003cbr/\u003eTeddy bear focused (\u003ca href=\"https://lemariva.com/storage/app/media/blog_imgs/hqcamera/hq_camera_teddy_bear_focused.jpg\"\u003edownload\u003c/a\u003e)|\n\n## Simple PCB schematic\nInside the folder [`pcb`](https://github.com/lemariva/rPIFocus/tree/main/pcb), you'll find the board and schematic files (Eagle), to order your PCB. I also added the Gerber files that I used by \u003ca rel=\"noopener noreferrer\" href=\"https://jlcpcb.com/\"\u003ejlcpcb\u003c/a\u003e.\n\n## M5Stack Application\nThe M5Stack ATOM Matrix controls the motors and offers a RestAPI to receive the commands. The M5Stack application is programmed in MicroPython. If you haven't heard about MicroPython, you can check this tutorial: [Getting Started with MicroPython on ESP32, M5Stack, and ESP8266](https://lemariva.com/blog/2020/03/tutorial-getting-started-micropython-v20). MicroPython is a lean and efficient implementation of the Python 3 programming language that includes a small subset of the Python standard library and is optimized to run on microcontrollers and in \"constrained environments\".\nThe application is located [lemariva/uPyFocus](https://github.com/lemariva/uPyFocus). \n\nSo, follow these steps to upload the application to the M5Stack:\n1. Flash MicroPython to the M5Stack as described in [this tutorial](https://lemariva.com/blog/2020/03/tutorial-getting-started-micropython-v20).\n2. Clone the [lemariva/uPyFocus](https://github.com/lemariva/uPyFocus) repository:\n    ```sh\n    git clone https://github.com/lemariva/uPyFocus.git\n    ```\n3. Open the folder `uPyFocus` with \u003ca rel=\"noopener noreferrer\" href=\"https://code.visualstudio.com/\"\u003eVSCode\u003c/a\u003e and rename the `config.py.sample` to `config.py`. \n4. Open the file and add your Wi-Fi credentials in this section:\n    ```python\n    wifi = {\n        'ssid':'',\n        'password':''\n    }\n    ```\n    The M5Stack needs to connect to your Wi-Fi so that the Raspberry Pi (also connected to your Wi-Fi/LAN) can find it and sends the commands to control the steppers.\n5. Upload the application to the M5Stack.\n\nAfter uploading the code, the M5Stack resets and starts with the calibration routine. Take note of the IP that the M5Stack reports while connecting to your Wi-Fi. You'll need that to configure the Microservices Application on the Raspberry Pi.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fupyfocus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flemariva%2Fupyfocus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flemariva%2Fupyfocus/lists"}