SN65HVD230 to ESP32 Devkit v1

Hi folks. I am using the IDE to program an ESP32 Devkit V1 and using it to communicate with a CAN bus via the SN65HVD230 transceiver board. I was initially advised to use DIO4 and DIO5 as the CRX and CTX pins respectively. This was a project by another user on GitHub.

The issue is that no CAN data is being sent, I have checked with my Pcan analyser but nothing gets across. Next I have to retrieve my oscilloscope from a friend to check the ESP32 is sending data to the DIO5 pin, but can anyone here confirm the ESP32 Devkit V1 can use any chosen DIO pins for CAN purposes? Or does it have to be specific pins? On a few sites I see DIO 21 and 22 mentioned, so can try that tomorrow.

I read on the Espressif site that this device has a CAN controller built in, but the pinout shows no dedicated CAN pins so I'm unsure whether this is true of all Devkit V1s. And if it is true, is it enough to write the data to any chosen pin of DIO and it will work, provided of course that the CAN library is used and defined?

This project worked for the creator with the same hardware but I am finding a few people who have built it encountered the same issue, and no one reported a solution yet.

Hoping someone here can shed some light on this.

@l-tech

Your two or more topics on the same or similar subject have been merged.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Apologies, I had posted on a few forums and forgot I had done so here already.

HI, @l-tech
Welcome to the forum.

Can you please tell us your electronics, programming, arduino, hardware experience?

Can you please post your code?

Have you tried some simple code to check your ESP32 I/O?

Can you please post a link to the GitHub article?

Can we please have a circuit diagram?
An image of a hand drawn schematic will be fine, include ALL power supplies, component names and pin labels.

I know this is a lot, but you have the project in front of you, we don't.

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

Hi Tom, no problem.

Firstly, thank you for a kind reply.

The question really centres on whether the Devkit V1 has a CAN controller, which Library works and why this one doesn't on some boards but does on others. I set the question late at night and maybe made it confusing to others.

I am an electronics engineer, currently automation engineer in a large global company. 40 years in the game, on the tools, commissioning, debug, panel build, PLC coding and desktop apps in VB then .NET - new to Arduino though, and to ESP32 / MCUs (a recent hobby I picked up) - also raw at C++ though trying to learn, coming from VB.NET it is different to say the least but I am 20% there already and catching up.

The project is this one: GitHub - morcibacsi/PSAWifiDisplayControl: A simple WiFi portal to control the display in your Peugeot or Citroen if you remove the factory installed head unit

The ESP32 does not send any data / pulses to any pins, so the schematic is not really an issue, I will post the intended one here but even without the CAN transceiver board connected, the ESP32 is not behaving as expected. (edit: no upload picture controls)

https://github.com/morcibacsi/PSAWifiDisplayControl/raw/master/images/schema.jpg

I have put my DSO (Tektronix scope) on the pins used in the "#define pins" routine, and nothing. Selected different pins, same result. I am now suspecting the CAN library used in the project is not working on my ESP32 board. I can access the WIFI AP the board creates, that part works. The project compiles with no issues, it just does not write data to any pin.

The project was intended for PlatformIO but can be used on Arduino IDE (I prefer that) and is a blank .ino file which loads the libraries required at compile time. So to see the code, please see the GitHub link as there is no code to post here from the Arduino IDE file. I have ensured the libraries used are declared and installed in the IDE libraries.

Really looking to see what others have found when using the internal CAN controller on the ESP32 especially the Devkit V1, which CAN library does it need, also confusingly I now read that Espressif have renamed CAN in their world to TWAI (?)

I intend when I get home to put a test project together to switch the DIO pins (digital_write I guess) and see what happens, oddly some DIO pins are always at 3.3v and others are always at 0v, which I find odd too, I would expect all DIO to be either pulled-up or pulled-down until used, it seems the ESP32 does it differently. I'm used to PLCs where the DIOs only go high (or low) when told to.

I tried another CAN bus example for the ESP32 and still nothing happens. I am beginning to think I have a faulty unit. This one came stuck in some white foam (not ESD safe type) and it may have been damaged by handling, due to the seller not taking precautions over ESD.

I've ordered a replacement ESP32 from a different seller, and a replacement CAN transceiver just in case it actually works.

Final update on this problem for others who may follow. I got it working.

I bought a Waveshare CAN transceiver and it works perfectly with the ESP32. Here are some tips you need to know:

  1. The SJA1000 CAN controller in the ESP32 cannot be used without a CAN transceiver connected and working, as the level on the RX pin makes it think the bus is busy, so it will not even try to transmit - therefor you cannot test the signals using a scope etc. No working CAN transceiver = no working ESP32 CAN controller. (I know it can't be used for real CAN data without a transceiver but I mean you cannot even test the code and see if the data pins on the ESP32 are working for this purpose without the actual transceiver hooked up every time).

  2. Choose the pins carefully as used in the code for the CanTx and CanRx pins / functions, all pins on the ESP32 which are GPIO technically work but in practice, not so much. 31,32 are good as are 21,22 - read the documentation on your particular device as some need to be high or low at boot time, and the ESP32 will not start correctly or refuse to flash if they are not correct, and so the CAN transceiver could and will interfere with this if you use pins allocated thus by Espressif.

  3. On some later implementations of the ESP32 the CAN speed is half of what it is selected in the code, there is a software bit which needs to be set to counteract this (by design) : https://github.com/espressif/esp-idf/commit/03d5742e110d2d5a8fbdf60ad9fcf894d3f98eb5 - this is so you can set a much lower CAN speed than was possible, if required, by adding a divide_by_2 prescaler.

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.