Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ESP32 due code #7

Open
martiinezz opened this issue Jul 28, 2019 · 13 comments
Open

ESP32 due code #7

martiinezz opened this issue Jul 28, 2019 · 13 comments

Comments

@martiinezz
Copy link

Collin - great work with the code. My question is if you're going to port this code to the latest ESP32 based board?

Thanks.

@BobbyBleacher
Copy link

Is that why none of us can get this working? We've got a newer version of the board this was written for?

@collin80
Copy link
Owner

Well, I did in fact port it over to the ESP32 for a project but that project didn't actually end up open source so it isn't on here. But, rest assured, it can work on an ESP32. I think really the biggest change to compile on an ESP32 is that it has no USB based serial so all the status output needs to go to a normal serial port instead and the serial port to communicate with the BMS slaves is initialized differently.

Here's some quick advice for setting up the serial port to the tesla hardware:
HardwareSerial Serial2(1); //define second serial port for Tesla BMS board
Serial2.begin(BMS_BAUD, SERIAL_8N1, 4, 2); //rx pin is 4, tx pin is 2

Obviously BMS_BAUD should be one of the speeds, 612500 being a common one. There's a slightly faster one for newer Tesla hardware, 631578. I think we had better luck just using 631578 all the time. I don't think the ESP32 can quite generate that exact rate but it gets close enough.

So, no, I don't believe the ESP32 is available anywhere but really you just redirect all serial console output to Serial and all BMS traffic to Serial2 - initialized as above.

@BobbyBleacher
Copy link

I'm staring at this code trying to figure out how to make it do just that. I'm mostly unfamiliar with all of this, so most of what I'm trying results in failure to compile or something I don't even want to go try after it does compile because it simply doesn't make sense.

So the Due, which does have SerialUSB, needs to NOT use that and initialize two separate serials (looks like HardwareSerial doesn't need the initialization code you put there), and the Serial2.begin statement provided has two too many arguments.

What was this originally written for if not the Due?

@collin80
Copy link
Owner

No, the code as provided should have worked on the Due. That's what it was written for. I was talking about the ESP32. In order to compile for ESP32 you need the special serial init I posted and you can't use SerialUSB since ESP32 has no SerialUSB - Due does.

@BobbyBleacher
Copy link

BobbyBleacher commented Sep 17, 2019

Oh... Yes, it definitely doesn't work on the Due as noted in Niall's video. I'm getting the same results as him. LPG on the Tesla forums also had the same experience.

Is it possible we've got some sort of newer library that has changed... I'm running out of options trying to figure out why none of us can get this project or any of Tom debree's teensy projects to work, either.

Screenshot 2019-09-13 15 39 52

@collin80
Copy link
Owner

What is interesting about your picture is that you are getting the exact same bytes returning as you sent. That isn't really what it should be doing. The Tesla module should be catching the bytes that you send and be broadcasting but with changes. 7F is a broadcast and 0 if I remember correctly is used to number the modules automatically. It shouldn't be directly passing those bytes back. Something seems odd there. You should make sure you don't have a direct loop between TX and RX. Does your first tesla module in line have LEDs flashing on the board when it gets traffic? Near the bottom you should see flashing upon traffic. This can help to verify that it is receiving data bytes.

@BobbyBleacher
Copy link

The light on the BMB comes on only during power up, but that's it. If you're interested in troubleshooting (and I definitely am) we can chat elsewhere. I have Whatsapp, discord, slack, etc.

@CZal
Copy link

CZal commented Sep 17, 2019

Code works for me... I think there is an issue with your wiring to the modules....

Btw, Great work Colin...

@BobbyBleacher
Copy link

BobbyBleacher commented Sep 17, 2019

I finally got it to work, actually.

@martiinezz
Copy link
Author

@BobbyBleacher So what was your issue?

@twanek
Copy link

twanek commented Feb 19, 2021

hello!

thank you sharing this great work! i also would like to port this code to esp32. anyone can help me, where to start? unfortunately, i do not have a due, so i have to begin directly with the esp32...

best regards!

@collin80
Copy link
Owner

I gave the relevant advice up above. I don't know for sure what else you'd want to know. On the ESP32 your user facing output should be sent to Serial instead of SerialUSB and you need to initialize the second serial port that talks to the modules as I specified above. Other than that, both chips support Arduino so once you install the Arduino support for ESP32 you should only have to make those two changes and it should work.

@MohamedGaberZidan
Copy link

I gave the relevant advice up above. I don't know for sure what else you'd want to know. On the ESP32 your user facing output should be sent to Serial instead of SerialUSB and you need to initialize the second serial port that talks to the modules as I specified above. Other than that, both chips support Arduino so once you install the Arduino support for ESP32 you should only have to make those two changes and it should work.

Hello,
when I did this I had some problems with due wire library, could you tell me what I should do?. Thanks in advance.
best regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants