CAN bus possible

All ESP8266 boards running MicroPython.
Official boards are the Adafruit Huzzah and Feather boards.
Target audience: MicroPython users with an ESP8266 board.
slush
Posts: 3
Joined: Mon Apr 11, 2016 3:44 pm

CAN bus possible

Post by slush » Fri Apr 15, 2016 11:33 pm

Hi,

there's CAN bus in Micropython for STM chips, but I didn't find any resources about CAN bus support on ESP8266. Is it just missing yet or not possible for any reason?

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: CAN bus possible

Post by dhylands » Sat Apr 16, 2016 3:43 am

I don't think that the ESP8266 has native CAN support.

I think you'd need to hook up a SPI-CAN bus (perhaps using something like the MCP2515).

Dino
Posts: 1
Joined: Thu May 25, 2017 8:38 pm

Re: CAN bus possible

Post by Dino » Thu May 25, 2017 8:42 pm

Hello,
I need some help with CAN bus to be connect to ESP-12F. any approach or schematic example.

Thank you

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: CAN bus possible

Post by dhylands » Fri May 26, 2017 5:24 pm

The ESP doesn't have CAN support biuiltin, so you'll need an external CAN Controller chip which you'd then communicate with over SPI (tyupically).

An example of a CAN controller chip is the MCP2515: http://www.microchip.com/wwwproducts/en/en010406 You'd then need to write a driver on the ESP which talks to the CAN controller.

Don't confuse the CAN Controller with a CAN transceiver (like the MCP2551).

In the case of the STM32F4 seriess (like the pyboard) the CAN controller is builtin to the microcontroller, and only a transceiver is needed. With the ESP, you need both a controller and a transceiver.

User avatar
TravisT
Posts: 72
Joined: Sun Feb 23, 2014 2:31 pm
Location: Portland, OR
Contact:

Re: CAN bus possible

Post by TravisT » Wed May 31, 2017 5:39 am

Hello Dino,

As Dave said, it is good to be aware of the 2 components to implementing CAN bus. I usually hear them called the CAN peripheral, which ideally is built into the microcontroller, and the transceiver, which is rarely part of the microcontroller. The peripheral is for dealing with the protocol and managing messages, while the transceiver is for the physical/electrical interface.

The Microchip MCP2515 and MCP2551 are great because they are some of the most heavily documented SPI based CAN interface chips. I would also recommend Microchips all in one solution (both peripheral and transceiver in a single chip) MCP25625. Mikroe has a dev board which can help you with the hardware side.
http://www.microchip.com/wwwproducts/en/MCP25625
https://shop.mikroe.com/click/interface/mcp25625

I hope that helps
_______________
Travis Travelstead

x79133000
Posts: 2
Joined: Fri Sep 13, 2019 2:50 am

Re: CAN bus possible

Post by x79133000 » Sun Sep 15, 2019 4:38 am

Is there any sample code for Micropython + MCP2515 CAN communication?
Any libraries available?

Thanks

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: CAN bus possible

Post by jimmo » Sun Sep 15, 2019 12:38 pm

x79133000 wrote:
Sun Sep 15, 2019 4:38 am
Is there any sample code for Micropython + MCP2515 CAN communication?
Any libraries available?
Which board are you using?

Any of the STM32 boards (e.g. Pyboard or STM32 Nucleo or Discovery) with CAN support will have the library built-in, see http://docs.micropython.org/en/latest/l ... b.CAN.html

Then you can use just a transceiver (e.g. MCP2551) rather than an external controller like the MCP2515.

x79133000
Posts: 2
Joined: Fri Sep 13, 2019 2:50 am

Re: CAN bus possible

Post by x79133000 » Sat Sep 21, 2019 9:43 pm

jimmo,

Thank you for the reply. I am using ESP32 which also does have internal CAN controller hardware but it looks like there is not enough resources available to use it yet, or at least I couldn't find any. That's why I have to use an external SPI CAN controller chip.

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: CAN bus possible

Post by jimmo » Sun Sep 22, 2019 2:25 am

Yeah, "CAN" is an unfortunately difficult term to search for. It's come up a lot in this forum and on the github issues.

It's not a question of resources, it's just that nobody has written a Python wrapper for it for ESP32 yet. It's well supported by ESP-IDF, and a Python wrapper wouldn't be too complicated. See https://docs.espressif.com/projects/esp ... s/can.html

This might be easier than writing a driver for an external controller chip. (Unless you need FDCAN support, which the ESP32 can't do)

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: CAN bus possible

Post by jimmo » Sun Sep 22, 2019 2:40 am

Perhaps an added incentive :) viewtopic.php?f=15&t=6984

Post Reply