{"id":13801573,"url":"https://github.com/przemobe/micropy-ENC28J60","last_synced_at":"2025-05-13T11:31:23.516Z","repository":{"id":93467974,"uuid":"441773541","full_name":"przemobe/micropy-ENC28J60","owner":"przemobe","description":"ENC28J60 Ethernet chip driver for MicroPython (RP2)","archived":false,"fork":false,"pushed_at":"2024-01-14T23:54:47.000Z","size":77,"stargazers_count":24,"open_issues_count":2,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-12T14:12:11.478Z","etag":null,"topics":["enc28j60","ethernet","micropython","rp2040"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/przemobe.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}},"created_at":"2021-12-25T23:10:49.000Z","updated_at":"2025-04-30T07:59:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"e664db5b-d79e-42ab-be77-82cafd249c8a","html_url":"https://github.com/przemobe/micropy-ENC28J60","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemobe%2Fmicropy-ENC28J60","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemobe%2Fmicropy-ENC28J60/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemobe%2Fmicropy-ENC28J60/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/przemobe%2Fmicropy-ENC28J60/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/przemobe","download_url":"https://codeload.github.com/przemobe/micropy-ENC28J60/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253932885,"owners_count":21986470,"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":["enc28j60","ethernet","micropython","rp2040"],"created_at":"2024-08-04T00:01:24.542Z","updated_at":"2025-05-13T11:31:23.467Z","avatar_url":"https://github.com/przemobe.png","language":"Python","funding_links":[],"categories":["Libraries"],"sub_categories":["Communications"],"readme":"# micropy-ENC28J60\nENC28J60 Ethernet chip driver for MicroPython v1.17 (RP2)\n\n## Rationale\nENC28J60 is a popular and cheap module for DIY projects.\nAt the moment, however, there is no driver for the MicroPython environment.\nThe Python implementation seems easy for further improvements and self adaptation.\n\n## Installation\nCopy enc28j60.py to your board into /enc28j60 directory.\n\n## Wiring\nWiring requires pins for SPI: SCK, MISO, MOSI and ChipSelect and optionally Interrupt.\nExample wiring that uses SPI1 bus (any SPI bus can be used):\n\n| ENC28J60 Module | RP2040 Board | Notes |\n| :-------------: |:-------------:| ---- |\n| VCC | 3V3 | requires up to 180 mA |\n| GND | GND | |\n| SCK | GP10 | SPI1 SCK |\n| SI | GP11 | SPI1 MOSI/TX |\n| SO | GP8 | SPI1 MISO/RX |\n| CS | GP13 | SPI1 CSn |\n| INT | GP15 | Optional |\n\n## To do\n - interrupt handler\n\n\n## Example code\n\n### Packet transmission\nExample of packet transmission to broadcast ethernet address:\n\n```python\nfrom machine import Pin, SPI\nfrom enc28j60 import enc28j60\n\nspi1 = SPI(1, baudrate=10000000, sck=Pin(10), mosi=Pin(11), miso=Pin(8))\neth = enc28j60.ENC28J60(spi1, Pin(13))\neth.init()\n\nsrcMac = eth.getMacAddr()\ntgtMac = bytearray([0xFF,0xFF,0xFF,0xFF,0xFF,0xFF])\npayLoad = bytearray(64)\npktType = bytearray([(len(payLoad) \u003e\u003e 8) \u0026 0xFF, len(payLoad) \u0026 0xFF])\n\neth.SendPacket([tgtMac, srcMac, pktType, payLoad])\n```\n\n### Packet reception\nExample of packet reception:\n\n```python\nfrom machine import Pin, SPI\nfrom enc28j60 import enc28j60\n\nspi1 = SPI(1, baudrate=10000000, sck=Pin(10), mosi=Pin(11), miso=Pin(8))\neth = enc28j60.ENC28J60(spi1, Pin(13))\neth.init()\n\nprint(\"myMac:\", \":\".join(\"{:02x}\".format(c) for c in eth.getMacAddr()))\nprint(\"ENC28J60 revision ID: 0x{:02x}\".format(eth.GetRevId()))\n\nrxBuf = bytearray(enc28j60.ENC28J60_ETH_RX_BUFFER_SIZE)\n\nwhile eth.GetRxPacketCnt():\n    rxLen = eth.ReceivePacket(rxBuf)\n    print('rxLen:', rxLen, 'srcMac:', \":\".join(\"{:02x}\".format(c) for c in rxBuf[6:12]))\n```\n\n### IPv4 simple suite for polling mode\n\nPlease refer to examples/Ntw.py file for details.\n\nThe file contains roughly written procedures for handling IP protocols in polling mode:\n- IPv4 for not fragmented packets only, single static IP address\n- ARP for IPv4 over Ethernet, simple ARP table\n- ICMPv4: rx Echo Request and tx Echo Response\n- UDPv4: rx and tx\n- Simple UDP Echo server\n\nMicroPython v1.17 for Raspberry Pi Pico does not include socket library.\nIt also does not allow to run more than 2 threads at the time.\nIt is hard to mimic network sockets in such environment. So polling mode seems reasonable solution.\n\n```python\nfrom machine import Pin\nfrom machine import SPI\nimport Ntw\n\nif __name__ == '__main__':\n    # Create network\n    nicSpi = SPI(1, baudrate=10000000, sck=Pin(10), mosi=Pin(11), miso=Pin(8))\n    nicCsPin = Pin(13)\n    ntw = Ntw.Ntw(nicSpi, nicCsPin)\n\n    # Create UDP Echo server\n    udpecho = Ntw.Udp4EchoServer(ntw)\n\n    # Bind UDP Echo server to UDP port 7\n    ntw.registerUdp4Callback(7, udpecho)\n\n    # main loop\n    while True:\n        # Receive and process packets\n        ntw.rxAllPkt()\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprzemobe%2Fmicropy-ENC28J60","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprzemobe%2Fmicropy-ENC28J60","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprzemobe%2Fmicropy-ENC28J60/lists"}