{"id":16239599,"url":"https://github.com/nopnop2002/esp-idf-can2socket","last_synced_at":"2025-08-23T17:42:31.695Z","repository":{"id":233223128,"uuid":"786312271","full_name":"nopnop2002/esp-idf-can2socket","owner":"nopnop2002","description":"CANbus to BSD-Socket bridge using esp32","archived":false,"fork":false,"pushed_at":"2024-07-27T00:59:52.000Z","size":64,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-17T09:05:26.720Z","etag":null,"topics":["can","can-bus","csv","esp-idf","esp32","json","socket","tcp","udp","xml"],"latest_commit_sha":null,"homepage":"","language":"C","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/nopnop2002.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":"2024-04-14T04:09:44.000Z","updated_at":"2024-07-27T00:59:56.000Z","dependencies_parsed_at":"2024-07-27T02:04:12.872Z","dependency_job_id":null,"html_url":"https://github.com/nopnop2002/esp-idf-can2socket","commit_stats":null,"previous_names":["nopnop2002/esp-idf-can2socket"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-can2socket","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-can2socket/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-can2socket/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nopnop2002%2Fesp-idf-can2socket/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nopnop2002","download_url":"https://codeload.github.com/nopnop2002/esp-idf-can2socket/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244463792,"owners_count":20456944,"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":["can","can-bus","csv","esp-idf","esp32","json","socket","tcp","udp","xml"],"created_at":"2024-10-10T13:44:16.755Z","updated_at":"2025-07-13T02:03:11.288Z","avatar_url":"https://github.com/nopnop2002.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# esp-idf-can2socket\nCANbus to BSD-Socket bridge using esp32.   \nIt's purpose is to be a bridge between a CAN-Bus and a BSD-Socket.    \nYou can use Python's rich library to visualize CAN data, perform statistical processing, and transfer it to other computers.   \nThis project does not include any visualization or statistical processing.   \nMany python visualization and statistical processing samples are available on the Internet.   \n\n# Software requirement\nESP-IDF V5.0 or later.   \nESP-IDF V4.4 release branch reached EOL in July 2024.   \nESP-IDF V5.1 is required when using ESP32-C6.   \n\n# Hardware requirements\n- SN65HVD23x CAN-BUS Transceiver   \nSN65HVD23x series has 230/231/232.   \nThey differ in standby/sleep mode functionality.   \nOther features are the same.   \n\n- Termination resistance   \nI used 150 ohms.   \n\n# Wireing   \n|SN65HVD23x||ESP32|ESP32-S2/S3|ESP32-C3/C6||\n|:-:|:-:|:-:|:-:|:-:|:-:|\n|D(CTX)|--|GPIO21|GPIO17|GPIO0|(*1)|\n|GND|--|GND|GND|GND||\n|Vcc|--|3.3V|3.3V|3.3V||\n|R(CRX)|--|GPIO22|GPIO18|GPIO1|(*1)|\n|Vref|--|N/C|N/C|N/C||\n|CANL|--||||To CAN Bus|\n|CANH|--||||To CAN Bus|\n|RS|--|GND|GND|GND|(*2)|\n\n(*1) You can change using menuconfig. But it may not work with other GPIOs.  \n\n(*2) N/C for SN65HVD232\n\n\n\n# Test Circuit   \n```\n   +-----------+   +-----------+   +-----------+ \n   | Atmega328 |   | Atmega328 |   |   ESP32   | \n   |           |   |           |   |           | \n   | Transmit  |   | Receive   |   | 21    22  | \n   +-----------+   +-----------+   +-----------+ \n     |       |      |        |       |       |   \n   +-----------+   +-----------+     |       |   \n   |           |   |           |     |       |   \n   |  MCP2515  |   |  MCP2515  |     |       |   \n   |           |   |           |     |       |   \n   +-----------+   +-----------+     |       |   \n     |      |        |      |        |       |   \n   +-----------+   +-----------+   +-----------+ \n   |           |   |           |   | D       R | \n   |  MCP2551  |   |  MCP2551  |   |   VP230   | \n   | H      L  |   | H      L  |   | H       L | \n   +-----------+   +-----------+   +-----------+ \n     |       |       |       |       |       |   \n     +--^^^--+       |       |       +--^^^--+\n     |   R1  |       |       |       |   R2  |   \n |---+-------|-------+-------|-------+-------|---| BackBorn H\n             |               |               |\n             |               |               |\n             |               |               |\n |-----------+---------------+---------------+---| BackBorn L\n\n      +--^^^--+:Terminaror register\n      R1:120 ohms\n      R2:150 ohms(Not working at 120 ohms)\n```\n\n![ESP32-CAN-3V3](https://github.com/nopnop2002/esp-idf-candump/assets/6020549/dec3744e-ede1-41c7-99b6-77ebfe916123)\n\n__NOTE__   \n3V CAN Trasnceviers like VP230 are fully interoperable with 5V CAN trasnceviers like MCP2551.   \nCheck [here](http://www.ti.com/lit/an/slla337/slla337.pdf).\n\n\n# Installation\n```\ngit clone https://github.com/nopnop2002/esp-idf-can2socket\ncd esp-idf-can2socket\nidf.py set-target {esp32/esp32s2/esp32s3/esp32c3/esp32c6}\nidf.py menuconfig\nidf.py flash\n```\n\n# Configuration\n\n![config-top](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/13737965-d52a-474c-a327-a35ccce04dc9)\n![config-app](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/a238e29e-85eb-42cb-bc54-9d64bc01a25a)\n\n## CAN Setting\n\n![config-can](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/93c94856-e930-47b3-ae66-936d05312baf)\n\n\n## WiFi Setting\n\n![config-wifi](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/5ff129d4-cd8e-4273-a9cf-7134c39fb84d)\n\n\n## Socket Setting   \nYou can select the output format.   \n\n![config-format-text](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/9b2ddbd2-7bd2-4626-80b7-72351df5edd1)\n![format-text](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/835de76f-562c-4b85-a23a-5748f9cb8a80)\n\n![config-format-json](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/1fb2da0f-721b-4590-9af9-df323c0440fb)\n![format-json](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/092f3f7b-44d4-474d-ab96-ab2ce6239954)\n\n![config-format-xml](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/6fc6d075-7656-4048-b619-7547541a59c3)\n![format-xml](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/36c95acd-bb1a-4168-b218-c12d0d100a80)\n\n![config-format-csv](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/1caefeb3-0349-4ed2-8c29-fa13d4e0c17f)\n![format-csv](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/dc26f63a-8f1c-4e87-98b6-f0f79d3e827a)\n\nYou can choose between TCP and UDP protocols.   \nESP32 acts as a TCP client or a UDP client.   \n![config-protocol-tcp](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/3e848d3a-8ba2-4f5e-a266-a7772aa7bc2c)\n\nTCP Host is specified by one of the following.\n- IP address   \n ```192.168.10.20```   \n- mDNS host name   \n ```tcp-server.local```   \n- Fully Qualified Domain Name   \n ```tcp-server.mydomain.com```\n\n\n![config-protocol-udp-1](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/6ef37579-663a-48df-98e5-7eb6fed81fa8)\n\nThere are the following four methods for specifying the UDP Address.   \n\n- Limited broadcast address   \n The address represented by 255.255.255.255, or \\\u003cbroadcast\\\u003e, cannot cross the router.   \n Both the sender and receiver must specify a Limited broadcast address.   \n\n- Directed broadcast address   \n It is possible to cross the router with an address that represents only the last octet as 255, such as 192.168.10.255.   \n Both the sender and receiver must specify the Directed broadcast address.   \n __Note that it is possible to pass through the router.__   \n\n- Multicast address   \n Data is sent to all PCs belonging to a specific group using a special address (224.0.0.0 to 239.255.255.255) called a multicast address.   \n I've never used it, so I don't know anything more.\n\n- Unicast address   \n It is possible to cross the router with an address that specifies all octets, such as 192.168.10.41.   \n Both the sender and receiver must specify the Unicast address.\n\n![config-protocol-udp-2](https://github.com/nopnop2002/esp-idf-can2socket/assets/6020549/a3995cae-3cc6-4111-9e14-7169239a3a40)\n\n# Python code\nIf you use the TCP protocol, you can use ```tcp-server.py``` to display the can data.   \nIf you use the UDP protocol, you can use ```udp-server.py``` to display the can data.   \n\n# Troubleshooting   \nThere is a module of SN65HVD230 like this.   \n![SN65HVD230-1](https://user-images.githubusercontent.com/6020549/80897499-4d204e00-8d34-11ea-80c9-3dc41b1addab.JPG)\n\nThere is a __120 ohms__ terminating resistor on the left side.   \n![SN65HVD230-22](https://user-images.githubusercontent.com/6020549/89281044-74185400-d684-11ea-9f55-830e0e9e6424.JPG)\n\nI have removed the terminating resistor.   \nAnd I used a external resistance of __150 ohms__.   \nA transmission fail is fixed.   \n![SN65HVD230-33](https://user-images.githubusercontent.com/6020549/89280710-f7857580-d683-11ea-9b36-12e36910e7d9.JPG)\n\nIf the transmission fails, these are the possible causes.   \n- There is no receiving app on CanBus.\n- The speed does not match the receiver.\n- There is no terminating resistor on the CanBus.\n- There are three terminating resistors on the CanBus.\n- The resistance value of the terminating resistor is incorrect.\n- Stub length in CAN bus is too long. See [here](https://e2e.ti.com/support/interface-group/interface/f/interface-forum/378932/iso1050-can-bus-stub-length).\n\n# Reference\nhttps://github.com/nopnop2002/esp-idf-candump\n\nhttps://github.com/nopnop2002/esp-idf-can2http\n\nhttps://github.com/nopnop2002/esp-idf-can2mqtt\n\nhttps://github.com/nopnop2002/esp-idf-can2usb\n\nhttps://github.com/nopnop2002/esp-idf-can2websocket\n\nhttps://github.com/nopnop2002/esp-idf-CANBus-Monitor\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-can2socket","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnopnop2002%2Fesp-idf-can2socket","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnopnop2002%2Fesp-idf-can2socket/lists"}