ElectricMotorcycleForum.com

  • November 26, 2024, 12:53:55 PM
  • Welcome, Guest
Please login or register.

Login with username, password and session length
Advanced search  

News:

Electric Motorcycle Forum is live!

Pages: [1] 2

Author Topic: FXE smarter charger  (Read 1258 times)

ttshaw1

  • Newbie
  • *
  • Posts: 6
    • View Profile
FXE smarter charger
« on: September 26, 2023, 08:42:42 AM »

I bought a 2022 FXE in early August with about 500 miles on it. It's been great, but I've found charging to be a bit inconvenient. To keep the battery healthy, I want to let the bike cool off before charging it, and I want to keep the battery at low charge. My commute uses about 35% of the battery, so if I was to charge it every day I'd have to get home, let the bike cool off, go out and plug it in, then come back and unplug it about three and a half hours later. That's a lot of trips out to my shed when I'd rather be in the AC or sleeping.

I put together a circuit that should help make my life easier. It's an ESP32C3 microcontroller with WiFi, a relay, and a USB brick to give me a 5V supply, plus a button and a couple of indicator LEDs. I cut up a 120V cable and ran it through the relay, which is only closed when the microcontroller switches it closed.The ESP hosts a webpage that I connect to and tell it a delay time, to let my bike cool off, and a charge time. So for example, I get home, immediately plug in my bike, and either hit the button for 2 hour cool-off delay and 3.5 hours charge, or fire up a web browser and put in numbers I like better. Then the microcontroller switches the relay on at the appropriate time and off again later.

Links to pics of box exterior and interior:



It's a very simple device, and I'm completely saved by the fact that the bike has an onboard charger that does all the actual thinking. If my device fails, the bike charges to 100% but nothing catastrophic happens, assuming my box doesn't burn my shed down. I'm still working on the code as I want to make the web interface more friendly. I'll upload to Gitlab when it's done, but I can share in advance if anyone's dying of curiosity. The circuit was simple enough that it was all done mentally, so no schematic to share. But I'm happy to answer any questions. Anyway, I'd recommend spinning a PCB if anyone decides to recreate this. The wiring turned out to be enough of a pain that it's worth the $15. 

I realized after finishing it that I probably could have bought an off-the-shelf wifi-controlled outlet and set up a Raspberry Pi to host a web server and boss the outlet around. But then I wouldn't have had the button and LEDs. Not sure yet how much they'll affect the convenience of using this thing.

Total cost was around $20. Total time to build this was about 35 hours, which is about 1400 trips to the shed... so this will pay for itself in around two years  ;D But what's more important is that I had fun. And the skills I learned messing with the ESP do actually seem like they'll be useful.

The next thing I want is to actually know the bike's charge percentage. That way I can stop charging at some target percentage, rather than a guess based on time. I think the Bluetooth interface and the CAN bus should be able to report charge percentage, but I don't know if they work while the bike is turned off and charging. Anyone know? If they don't work, how hard would it be to modify the bike and get them to be on in that mode (bike off but charging)? The alternative is to sense the current at 120V and from there try to estimate the charge, but that's a last resort. If anyone knows what sort of accuracy I could expect doing that, I'm interested in that information as well.
« Last Edit: September 26, 2023, 08:52:05 AM by ttshaw1 »
Logged

TheRan

  • Hero Member
  • *****
  • Posts: 1634
    • View Profile
Re: FXE smarter charger
« Reply #1 on: September 26, 2023, 04:47:26 PM »

Probably not totally necessary unless you're putting your bike on charge right after an extended 70mph highway journey (2 hours to cool down is definitely overkill), but a neat project. A more useful feature of it would be setting it to charge when electricity is cheapest.

If you key the bike on you can connect to it via bluetooth and then as long as it's plugged in and charging the connection will remain if the bike is keyed off. I don't think the bluetooth is turned on just from plugging the bike in, at least I've never managed to get it connected without keying on first. The official app shows the charge percentage as well as other stats (cell balance, charging watts and amps into the battery, estimated time to completion). There's also the Metrics for Zero Motorcycles app although it's intended more for use while riding, looking through the options it can show battery voltage but I don't see anything else that would be useful for charging (there is battery current but I assume that's only output, maybe it goes negative when charging).
Logged

Specter

  • Hero Member
  • *****
  • Posts: 1757
    • View Profile
Re: FXE smarter charger
« Reply #2 on: September 27, 2023, 08:53:01 PM »

Why not just get a 5  dollar timer?  Plug the bike into that and come 10 o clock, or whenever the 3 hour cool down is done, or electricity is cheapest etc, it turns on and charges your bike for you.  No other gadgets needed.

Aaron
Logged

ttshaw1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: FXE smarter charger
« Reply #3 on: September 27, 2023, 11:09:48 PM »

Why not just get a 5  dollar timer?
I don't know that you can get one for $5 that'll let you program a one-off delay and on time. But yeah, that's essentially the functionality I have right now, except that I also can mess around with it over wifi and press one button to get a reasonable day-to-day charge. My hope is to get more functionality by talking to the bike so I can e.g. monitor the state of charge from inside.

If you key the bike on you can connect to it via bluetooth and then as long as it's plugged in and charging the connection will remain if the bike is keyed off. I don't think the bluetooth is turned on just from plugging the bike in, at least I've never managed to get it connected without keying on first.
I was thinking about that, but I don't think any data I could get is worth leaving my key in the bike overnight. Seems like the risk of theft would go way up.

Do you know if the CAN bus stays on? I'm hoping the BMS is talking to the mainboard all the time. The manual says there's a clock on the dash (though I don't have it displayed), so there's a clock running somewhere even when they key is out. Hopefully it's on the mainboard. And the BMS must be on while it's charging. So there's a chance they'll be talking to each other, or if not, that I can interrogate them. I may need to dig through the wiring diagram...
Logged

TheRan

  • Hero Member
  • *****
  • Posts: 1634
    • View Profile
Re: FXE smarter charger
« Reply #4 on: September 28, 2023, 01:32:10 AM »

Of course, I didn't think about you needing to leave the key in as the bike wouldn't start charging for a while.

The dash has its own coin cell battery to keep the clock running.
Logged

Motoproponent

  • Full Member
  • ***
  • Posts: 203
    • View Profile
Re: FXE smarter charger
« Reply #5 on: September 28, 2023, 11:38:33 PM »

What about a smart switch.

My wife plugs her Zero into one in the garage.

"Alexa, turn on the Zero for 4 hours at eleven PM"

It comes on after the time of use power rates come down. She can tell it to charge for whatever number of hours gets it close to the SOC she's looking for. They were 15$ for a 4 pack. Plus the app will tell you current draw so you can get an accurate idea of how many KWH you got in that time frame. Don't need the key for level 1 charging. easy peasy and "reprogramming" it is as easy as telling it something different.
Logged
"Life is a deathbound train"

2024 Energica Experia
@motoproponent on Youtube

ttshaw1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: FXE smarter charger
« Reply #6 on: October 03, 2023, 09:25:40 AM »

Definitely sounds like that's a good solution. It's not for me as I like to avoid bringing corporate-controlled stuff into my home (Windows, cloud-based services, Alexa, etc.). But it's certainly more cost-effective than what I did.

For whatever reason, my utility doesn't vary their rates by time. That's a good call, though, and I'll delay til off-peak hours just to be a good citizen.

I finally got around to adding some labels to the bar graph of charging/delay progress. Screenshots of the web interface are attached. There's probably not too much more I want to add to the website. But I started looking at a 2016 wiring diagram and it seems like there's no feasible way to get CAN signals out while it's charging without putting the key in. MBB2 runs the OBD connector, and it's not powered unless the motor controller wants to power it. At that point any messing around gets too close to bricking my bike. I have to take off the seat soon anyway, so I'll probably stick a scope on the OBD connector while I'm at it and make sure there's no signal.

Now I'm thinking about measuring the power going to the charger to approximate the SOC. Turns out you can get a current sense IC that sits on the neutral line and outputs a neat analog signal to tell you the current... very little practical benefit, but it'd be fun!
Logged

NoMoreIdeas

  • Full Member
  • ***
  • Posts: 139
    • View Profile
Re: FXE smarter charger
« Reply #7 on: October 04, 2023, 02:58:53 AM »

Cool little project! You might check out the sonoff S31s, they are just ran with an esp8266 and can be easily flashed with esphome and integrated into home assistant, and give voltage and current readings. Then you can control it however you want through home assistant.

I built a little esp8266 that reads the battery soc and temp info from that obd2 port via a cheap can controller, I cant remember if I tried pulling data from it while the bike was off or not but I might try it out again. Theres no power on that obd2 port either, so it would be harder to put a permanent microcontroller on the bike to send info back to anything.

Charging while the battery is warm isnt really a big deal, the bike will terminate the charge if it gets too hot. Storing at proper SOC though makes much more sense and that would help with timed charging. 
« Last Edit: October 04, 2023, 08:21:15 PM by NoMoreIdeas »
Logged

staples

  • Full Member
  • ***
  • Posts: 163
    • View Profile
Re: FXE smarter charger
« Reply #8 on: October 04, 2023, 09:44:57 AM »

I haven't tried the CAN bus, but the serial connection definitely shuts down when there is no power. My microcontroller just talks to the bike via the serial interface, and home assistant polls data from it when connected to the Wi-Fi.
I permanently mounted my microcontroller to my FXS with a small battery bank. It that lasts a couple days. I wired in a USB charger to the accessory power which kicks on when the bike is charging or the bike is on. And in both those situations I can ask the bike for all the stats I want through the serial interface.
Logged

Motoproponent

  • Full Member
  • ***
  • Posts: 203
    • View Profile
Re: FXE smarter charger
« Reply #9 on: October 05, 2023, 09:46:09 PM »

You might check out the sonoff S31s, they are just ran with an esp8266 and can be easily flashed with esphome and integrated into home assistant, and give voltage and current readings.

At first I thought you were having a stroke and that was the result of your face hitting the keyboard when you repeatedly lost consciousness, but then I googled it all and discovered those were all actual words.

who knew?
Logged
"Life is a deathbound train"

2024 Energica Experia
@motoproponent on Youtube

ttshaw1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: FXE smarter charger
« Reply #10 on: October 07, 2023, 01:56:22 AM »

accessory power which kicks on when the bike is charging or the bike is on. And in both those situations I can ask the bike for all the stats I want through the serial interface.

Great call, I didn't think to check the serial interface. That's exactly what I want. Do you have a post or repository or anything talking about the project?
Logged

ttshaw1

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: FXE smarter charger
« Reply #11 on: October 16, 2023, 05:03:14 AM »

Following up on the serial interface, I realized that there's enough information in https://zeromanual.com/wiki/MBB_Console to get me started. I found an ESP32 library (https://github.com/AlphaLima/ESP32-Serial-Bridge) that will let me use the serial interface over WiFi. So my plan for today was to open up the bike, make sure I can get power from the OBDII connector at least when the bike is on or charging, and maybe test out talking to the mainboard.

But I wasn't able to find the OBDII connector. The wiki (https://zeromanual.com/wiki/OBD-II_Port_Location) says the connector's on the left side of the battery. I can see on my frame the two screw holes where the connector should be mounted
, but there's no trace of it. I took a bunch of pictures, closed my bike up, and have been doing more reading. I've seen some conversations saying there are two ports, one being under the seat with a red or orange cap, and one being down next to the controller behind the rubber gap filler. Is the red/orange-capped one under the seat this?
I'll take the seat back off this week and take a second look, but if anyone knows you might be able to save me some trouble.

Apparently the second connector was added recently with an always-on 12V pin to meet EU regulations. Anyone know which is which? And any advice on how to find the second one? I took a quick look around behind the gap filler but couldn't see anything.
Logged

Curt

  • Hero Member
  • *****
  • Posts: 670
    • View Profile
Re: FXE smarter charger
« Reply #12 on: October 16, 2023, 06:56:49 AM »

Now I'm thinking about measuring the power going to the charger to approximate the SOC. Turns out you can get a current sense IC that sits on the neutral line and outputs a neat analog signal to tell you the current... very little practical benefit, but it'd be fun!

Yes, if the current draw is indicative of SOC, you could come up with the curve of SOC vs. current, and set your thingamabob to stop charging at the specified SOC. That would be something a smart switch or timer couldn't do.

Around these parts, there is no longer much difference between peak and off-peak rates.
Logged

Specter

  • Hero Member
  • *****
  • Posts: 1757
    • View Profile
Re: FXE smarter charger
« Reply #13 on: October 16, 2023, 07:54:08 AM »

Don't rely on the current going to the charger as a super reliable soc of charge indicator.  Many things can  bias that.  Unless you make a table that you have verified is accurate for YOUR bike, at XX temperature etc, there really is not much you can use to call an accurate standard IMO.

A chargers efficiency will change with charge rate as well, and no they are NOT linear.

Aaron
Logged

ESokoloff

  • Hero Member
  • *****
  • Posts: 724
    • View Profile
Re: FXE smarter charger
« Reply #14 on: October 16, 2023, 08:47:49 AM »

Wow, I got lucky with my DSR with a 14.4 battery as it takes about 1 hr/ 10% SOC so it’s easy to twist a spring wound timer to the proper time to yield a 70% SOC   
The 4 hr timer as well as a fixed 3hr electronic timer and a dpdt configuration switch that are permanently mounted to the bike in a small project box giving me a 0-7hr or un-interrupted charge time.
The outlet of this box has a 90° plug that’s semi permanently plugged into the bike & the inlet has a 6’ 15amp outdoor plug that folds up & stored in the top frame hole when not in use.

I don’t worry about a cool down period as in my case I don’t think it’s an issue.
« Last Edit: October 16, 2023, 08:51:04 AM by ESokoloff »
Logged
Eric
2016 Zero DSR
Pages: [1] 2