Arduino with torque sensor connection for E-Bike

Hi,
I am building a project on controlling an E-bike speed based on the user's pedal force. For this I have decided to use a Thun series torque sensor and an Arduino as a controller to decide when and how much power to send to the motors after analysing input from the Torque sensor and IMU sensors. I have seen the datasheet of the Thun T13 torque sensor which shows 6 pins with power, torque and rotation pins - uploaded the datasheet
Torque Speed Sensor(1).pdf (303.6 KB)

My questions are:

  1. What are the connections to link an Arduino with the torque sensor? Any datasheet or manual would be helpful as I have scourged the internet but found no guide. Could I directly connect the pins to the Arduino and get the readings?
  2. Would any additional circuitry be required to measure the torque?

Thanks for your time,

Best Regards,
Shashank

There are many sizes of Arduino boards (link), and almost as many power requirements, capabilities. Are you making a BLDC controller in a roomy box, or limited space?

Keep going with your project, I just want to add that you might take a look at the current market for ideas... Bafang and Bosch have very good names (if not best) in e-bike motor/controller pairs. Their controllers are ready for connecting to the torque sensor you linked (but for the interface cable - usually YLS, but the field is fast moving, and what worked this month might be legacy next). That's all I have.

The datasheet for the sensor clearly says the torque output is analog and varies from about 0v to 5v, with 2.5v offset at 0 torque.

Most simply, try analogRead with a 5v Arduino.

Mind the sensor needs at least 6v.

If analogRead doesn't give consistent results, it's probably because the output is not ratiometric. There's a solution to that, but you may not need it.

1 Like

Hi, I tried analogRead but it doesn't give any output as expected. I have connected the torque signal from the torque sensor to an analog pin of the ESP32 and done analogRead but I get a constant value (read from serial monitor) even after turning the torque sensor. Do I need to change the voltage from the sensor? Please let me know any alternative options. Thanks for your time

Do you have the ground (0v) connected to both devices (each other)?

In addition to the good question in post #5:

  • what voltage are you powering the torque sensor with?

  • with the torque sensor powered and not connected to the ESP32, what voltage does your DMM read at the sensor signal pin relative to the power supply ground under the following three conditions: no torque on the sensor, the full rated torque one direction (say, clockwise), the full rated torque the other direction (counter-clockwise)?

  • the ESP32 is not a 5v Arduino (see post #3). If you use this sensor with the ESP32, you must apply the torque so that the output does not exceed 3.3v. If, as it seems, your torque can be applied in one direction only, then apply it so that the output voltage decreases relative to the no-load voltage (that way, it will stay in the safe range, between 0v and 2.5v).

  • the ESP32 ADC is not very good (search terms: ESP32 ADC non-linear). If you need to correct for that, you will need to calibrate at a fair number of torques.

@apf1979 Yes, GND are connected together.
Here is the setup with an RPS set at 12V:

RPS- positive to torque sensor positive power pin and GND of RPS to torque sensor GND and also to ESP32 GND. Then took the torque sensor signal and set it on the ESP32 ADC pin where I read the signal with analogRead. (tried with ESP32 pins 2, 4, 34, and 36. All have same result - > 0 with no change after giving torque)

Do I need to treat the signal as a PWM pulse and try reading the data with pulseIn(pin,HIGH);?
-> I tried this and was getting 0 everytime

Here is the weird reading I get on DMM with different conditions:
No torque on sensor : 3.3V
applying torque clockwise and anticlockwise : 3.3V
So no change in the voltage from signal with movement. I have no idea what the protocol would be after this test. Could it be a defect of the sensor or anything wrong from my side?

I tried connecting it to a USB logic analyser as well and got no change in the voltage reading as well
I am not sure whether the connections I did are proper with the logic analyser, but I connected the power supply from the RPS as usual to the torque sensor power pins and took the GND from torque sensor and connected it to the GND of the logic analyser. The torque signal from the sensor connected to channel 1 of the logic analyser. Result == No change or pulses viewed

I have attached a snippet of the torque sensor datasheet which clearly shows signal voltage should vary from 1.5V to 3.3 V, but the voltage I'm getting at all pins of the torque sensor are 3.3V (Except power pin which I'm getting 12V as expected)

Well, I see you edited your first post to change the datasheet link, so my previous comments no longer make sense.

If, in fact, the currently linked datasheet is applicable, then you should indeed be getting 1.5v (no load) to 3.3v (full load) on the analog torque output pin. So maybe it is defective.

Could there be anything else I'm missing? Would you recommend any other tests or methods to get the data from the torque sensor?

Only to be sure you are using the white pin as the output.

Yes, white pin and also tried green pin (rotation signal).

It doesn't say what pins 3 and 5 are used for. Maybe they're electrically isolated or need to be energized somehow??? On your DMM what do you get between 4 and 3 or 4 and 5?

Torque sensors need force. Spinning (cadence) will not produce an output.

He did. Output stayed at 3.3 with torque in either direction.

Okay. Thank you.

Since all pins have 3.3V, the potential difference is 0V between any 2 pins

Is MCLR a reset signal?
Is CLD an enable?

The ESP32 ADC has quite a few limitations. You should read this:
https://docs.espressif.com/projects/arduino-esp32/en/latest/api/adc.html

Shashank, have you contacted the manufacturer for additional installation details? Do you have a large value resistor(s) you could use to connect either/both pins to ground?

Yes, I've contacted the manufacturer but no luck. Once they said it's using UART15384 bps protocol (completely opposite to what datasheet says) then they said they'll look further into it when asked more into detail.