{"id":13801989,"url":"https://github.com/kevinkk525/micropython_arduino_control","last_synced_at":"2026-04-18T22:02:59.738Z","repository":{"id":97057506,"uuid":"179875022","full_name":"kevinkk525/micropython_arduino_control","owner":"kevinkk525","description":"Micropython library to control an arduino remotely. With corresponding arduino code.","archived":false,"fork":false,"pushed_at":"2020-07-20T02:49:57.000Z","size":13,"stargazers_count":0,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-22T12:33:28.160Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/kevinkk525.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}},"created_at":"2019-04-06T19:04:33.000Z","updated_at":"2019-04-07T09:40:05.000Z","dependencies_parsed_at":"2023-04-22T03:46:01.788Z","dependency_job_id":null,"html_url":"https://github.com/kevinkk525/micropython_arduino_control","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kevinkk525/micropython_arduino_control","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinkk525%2Fmicropython_arduino_control","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinkk525%2Fmicropython_arduino_control/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinkk525%2Fmicropython_arduino_control/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinkk525%2Fmicropython_arduino_control/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kevinkk525","download_url":"https://codeload.github.com/kevinkk525/micropython_arduino_control/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kevinkk525%2Fmicropython_arduino_control/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31986327,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-18T20:23:30.271Z","status":"ssl_error","status_checked_at":"2026-04-18T20:23:29.375Z","response_time":103,"last_error":"SSL_read: 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":[],"created_at":"2024-08-04T00:01:32.371Z","updated_at":"2026-04-18T22:02:59.715Z","avatar_url":"https://github.com/kevinkk525.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# Micropython Arduino Control\nMicropython library to control an Arduino using the 1-wire protocol.\n\n\nThis is a simple library to control your Arduinos pins from a micropython device using the 1-wire protocol.\nSupported commands are:\n- pinMode\n- digitalWrite\n- digitalRead\n- analogWrite\n- analogRead\n\n\nAll communication is secured with crc to prevent corruption and failed transmissions will be retransmitted by the host for a few times before raising an error.\n\nThe micropython library also provides ADC and Pin Objects compatible to the machine.ADC and machine.Pin objects so they can be used in any application.\nOnly word of caution: Sending a command takes ~15ms which can be too much for some applications.\n\n\n# Micropython side\n\n## Installation\n\nGenerally this library can be installed in different ways. In this Readme we will follow this:\n\nCopy the directory [arduinoGPIO](./arduinoGPIO) onto your device's internal storage.\nThis can be done using [rshell](https://github.com/dhylands/rshell).\n\n```\ngit clone https://github.com/kevinkk525/micropython_arduino_control\ncd micropython_arduino_control\nrshell -p /dev/ttyUSB0 \"cp -r arduinoGPIO /pyboard\"\n```\n\n## Usage ArduinoControl\n\nThe main module is [arduinoControl](./arduinoGPIO/arduinoControl.py). All features can be used with this module.\nEvery method will take the ROM of the device that should be controlled. \nThere are no features implemented that will be executed by all devices at the same time because every command will be confirmed by the client with an answer.\n\n```Python\nfrom arduinoGPIO.arduinoControl import ArduinoControl\nimport machine\nimport time\n\narduinoControl = ArduinoControl(machine.Pin(19)) # 19: pin number of the 1-wire connection\n\nroms=arduinoControl.scanSafely() # .scan() can be used too, this is just safer as it scans multiple times\navailable_digital_pins=arduinoControl.digitalPins(roms[0])\navailable_analog_pins=arduinoControl.analogPins(roms[0])\narduinoControl.digitalWrite(roms[0], 13, 1) # led on\ntime.sleep(2)\narduinoControl.digitalWrite(roms[0], 13, 0) # led off\n\n```\n\n## Usage Arduino Class\n\nThe arduino class is just a wrapper to remove the need to pass the ROM to each command and represents one Arduino device with a specific ROM.\n\n```Python\nfrom arduinoGPIO.arduinoControl import ArduinoControl\nfrom arduinoGPIO.arduino import Arduino\nimport machine\nimport time\n\narduinoControl = ArduinoControl(machine.Pin(19)) # 19: pin number of the 1-wire connection\nroms=arduinoControl.scanSafely() # .scan() can be used too, this is just safer as it scans multiple times\n\narduino = Arduino(arduinoControl, roms[0])\n\navailable_digital_pins=arduino.digitalPins()\navailable_analog_pins=arduino.analogPins()\narduino.digitalWrite(13, 1) # led on\ntime.sleep(2)\narduino.digitalWrite(13, 0) # led off\n```\n\n## Usage of Pin and ADC objects\n\nThe ArduinoControl class can create Pin and ADC objects as well as the Arduino Class. Only difference is that the Arduino Class doesn't need a ROM argument.\n\n```Python\nfrom arduinoGPIO.arduinoControl import ArduinoControl\nfrom arduinoGPIO.arduino import Arduino\nimport machine\nimport time\n\narduinoControl = ArduinoControl(machine.Pin(19)) # 19: pin number of the 1-wire connection\nroms=arduinoControl.scanSafely() # .scan() can be used too, this is just safer as it scans multiple times\n\narduino = Arduino(arduinoControl, roms[0])\n\nadc=arduino.ADC(0,vcc=3.3) # Analog pin 0. optional argument vcc used for calculating voltages\nprint(adc.read())\nprint(adc.readVoltage())\n\nled=arduinoControl.Pin(roms[0],13)\nled.on()\ntime.sleep(1)\nled.off()\n\n```\n\n\n# Arduino Side\n\n## Requirements\n\nHardware:\n\u003cbr\u003eI tested this with Atmega328 modules (Arduino Uno, Arduino Pro, ...) but every device capable of running the required libraries should work.\n\u003cbr\u003eThe library uses digital pin 2 for the 1-wire communication, which can be adapted in the Sketch of course.\n\nSoftware:\n\u003cbr\u003eThe only required external library is *OneWireHub* which can be found in the integrated Arduino IDE libraries.\n\n## Sketch\n\nThe Arduino Sketch is located in [ProjectArduinoControl.ino](./arduino_onewire_sketch/ProjectArduinoControl/ProjectArduinoControl.ino).\n\u003cbr\u003eThere you have to adapt the *UNIT_ID* to be unique in your 1-wire network for each device.\n\nThese are the first lines of the Sketch:\n\n```cpp\n#include \"OneWireHub.h\"\n#include \"Control.h\"\n\nconstexpr uint8_t pin_led {13};\nconstexpr uint8_t pin_onewire {2};\n\nauto hub = OneWireHub(pin_onewire);\n\n#define UNIT_ID 0x03 //change this to be unique for every device in your 1-wire network\n\nauto arduino = Control(Control::family_code, 0x00,0x00,0xB2,0x18,0xDA,UNIT_ID);\n```\n\n# Motivation\n\nI was faced with the situation of having to connect 16 simple analog sensors to my ESP32 running micropython.\nThese were all within a few meters from the device but would require me to run a lot of cables and still use an analog multiplexer and a multiplexer for the power supply lines as these devices are not supposed to be powered all the time.\nTherefore the easier solution was to have small, power efficient and cheap Arduinos do the sensor power toggling and reading.\nThis way I only need to run one cable with Vcc,Data and GND between all Arduinos and can reliably read all 16 sensors.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinkk525%2Fmicropython_arduino_control","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkevinkk525%2Fmicropython_arduino_control","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkevinkk525%2Fmicropython_arduino_control/lists"}