Author Topic: Getting an ebike motor controller to talk to my smartphone  (Read 9510 times)

superserge

  • Member
  • ***
  • Posts: 1
Getting an ebike motor controller to talk to my smartphone
« on: September 08, 2019, 02:12:29 am »
Hi there,

I recently bought a DIY ebike kit from ebay. It comes with a motor controller and a dinky LCD screen for showing you your speed, distance, battery remaining, etc.

I'd like to replace the LCD screen with a smartphone so that I can write a little app for it that will also incorporate GPS.

Unfortunately, I have no idea where to start in terms of connecting the motor controller wire to my smartphone's microusb.

What I've tried and found out so far:

Somebody has already figured out the protocol between the motor controller and the lcd, and it's quite straightforward. If the connection between the controller and my phone existed, I would know what to do from there.
I've tried searching for variations of "create custom usb wire", "create custom usb device", "convert usb to another wire" but i've only been able to find irrelevant things like order forms for custom-branded flash drives.
I've learned a little bit about how the (original) usb wire and spec works, but have a very shallow understanding. Basically, power, ground, and data, with data being transmitted over 2 twisted wires in order to help reduce noise.

What I still don't know:

The controller has 5 pins that attach to the lcd. 4 of them are the same as the usb, but there's also a VB- pin and I have not been able to figure out what that means. You can see the diagram here: https://images-na.ssl-images-amazon.com/images/I/51kBrfSeXlL._SL1000_.jpg
The document describing the protocol between the controller and the lcd mentioned "9600 baud". I know that that's the bitrate, but I'm not sure if that's something that I have to handle in the hardware or in software.
There are other wires that I might also want to tell my smartphone about. If I have multiple different wires providing data, how would I put them all together in the same usb wire?

My background:

15 years writing software professionally, but rarely at a low level.
Very shallow understanding of electronics and circuits. I could tell you about kirchoff's laws, but would not be able to build a multimeter without considereable effort.

Really appreciate any help that anybody might offer!

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: Getting an ebike motor controller to talk to my smartphone
« Reply #1 on: September 08, 2019, 02:54:55 pm »
9600 baud means that the interface is asynchronous serial.

https://www.microcontrollertips.com/asynchronous-serial-communication-explained-including-ttl-uart-rs232/

To communicate with a phone's USB port, you would need:

A USB/serial converter to translate between the serial and USB voltages and protocols.

These are widely available. It looks like you want one with TTL/CMOS/5V voltages, not RS-232.

https://www.ftdichip.com/Products/Cables/USBTTLSerial.htm

Driver support in your phone for communicating with a USB serial/COM-port device, and an app of some type to do the communicating. A web search found this, assuming Android, I have no experience with it:

https://github.com/mik3y/usb-serial-for-android

The VB line is likely power. You will need to find out what is the function of the Control line.