I'm working on a project where I want to control a small motor using the voltage generated by an electrochemical cell. The setup involves reading the voltage of the cell with an Arduino and using that information to adjust the motor's speed through a PWM signal. However, I'm encountering some issues, and I would greatly appreciate any help or suggestions to get everything working.
What I'm trying to do:
I have a small electrochemical cell (which generates a voltage between 0 and 2V) connected to an analog input pin of the Arduino.
I want to use the voltage from the cell to control the speed of a DC motor. The motor is connected to a motor driver (e.g., L298N), and I’m using PWM to control the motor speed.
The idea is that the motor's speed should vary according to the voltage read from the electrochemical cell.
What works:
The Arduino can read the voltage from the electrochemical cell.
The motor moves when I apply a voltage from an external power supply, but the motor doesn't respond to the voltage from the electrochemical cell.
What I’ve tried:
I’ve mapped the voltage from the cell to a PWM value using the map() function in the code.
I’ve tried connecting the electrochemical cell directly to the Arduino analog pin and using an external power supply to power the motor.
Issues:
The motor only responds to the external power supply voltage, not the voltage from the electrochemical cell.
I’m not sure if I need to use a transistor or other components to properly control the motor with the cell’s voltage.
I’m not sure how to ensure that the cell's voltage correctly influences the motor's speed.
The electrochemical cell is connected to the Arduino analog input pin (A0).
The motor is connected to a motor driver (L298N), with the motor driver powered by an external supply.
The motor driver is controlled via PWM from the Arduino.
Do I need a transistor to control the motor using the PWM signal from the Arduino?
How can I make sure that the voltage from the cell properly adjusts the motor speed instead of just using the external power supply?
Is there any other component or circuit that I might need to implement for this to work?
Any advice or ideas would be really helpful. Thanks in advance for your support!
One: read the sensor voltage directly as you have. Scale it however. Print it anf verify you are reading the sensor.
Two: learn how to control a DC motor via PWM analogWrite*() from 0 to full speed.
This might be worth the time:
Conceptually a no-brainer. In practice, you've run across a few "real world" fact. Mainly here is the sad truth that motors take real power, which can not be provided by the sensor, nor the PWM signal. In effect, your external circuitry will be an amplifier of sorts, vastly increasing the current available.
The source of power for any motor must not be tapping 5 volts from the Arduino board. You need an external battery or power supply.
Which Arduino? Do you have the + (positive) cell electrode connected to the analog input pin and the other electrode connected to GND? What values do you get from:
Please tell us which Arduino you are using. None of the Arduinos read a voltage. They compare the test voltage to a standard and report how close the test voltage is to the standard voltage.
The standard voltage can be set to external or to internal standards in order to give more or less range of comparison numbers.
Please be more accurate in describing the actual voltages from your test cell. Then you can decide what voltage standard you wish to use in order to make your project more responsive to different voltages.
When you mention electro chemical cell I assume battery. What is your motor current? What is your cell current capability? Also if you are using the cell to power your motor you can't use a L298 for the task as the old L298 will drop just about all of your applied 2.0 volts. This is why newer H Bridge modules use MOSFETs rather than plain BJT transistors.