Controlling a 5V PWM controlled fan causing errors in my HC 04 ultrasonic senso

Controlling a 5V PWM controlled fan causing errors in my HC 04 ultrasonic sensor

Hi

First time posting to this forum for help.

I am building a project to control the height of a ping pong ball in a tube.

Ive designed this to be powered solely buy an Arduino Uno (I hope)

I have a 5v (180ma) PWM controlled fan
And a HC 04 ultrasonic sensor 5v (15ma)

My connections are as follows
Fan
Power is from the 5v & Gnd on the Uno power rail
Control is from the Digital rail PWM pin 3

Sensor HC 04
Power is from the other 5v & Gnd on the Uno power rail
Control from pins 7 & 8 for echo and trigger.

Control is through LinX (Makerhub add-on) to Labview

At this point my fan is running and lifting the ball and my sensor is reading back. All good

The issue I am noticing is that the sensor reading is becoming erratic and unsettled when the fan is running from 30% to full power on and this is going to have an effect on my control system.

My first thought is that the Arduino can't provide enough power. but it should be capable of 500 ma power and 40 ma per pin which I am well within.

Am I right in saying the PWM pin to control the fan uses almost no current and is only a voltage control between 0-5 Volts and that the power / current to run the fan is from the power rail.

Or is it the case I have this wrong and require a mosfet to control the fan. but if so I would nt have gotten the fan to run so far.

Any help is much appreciated

You shouldn't run the fan of the arduino 5V. Get a external 5V switchmode walwart or regulator
and power the fan with that. You probably have noise on your 5V line. Also add at least 470uF
electrolytic cap on the motor power .

Hi Raschemmel

Thank you for your reply.

Electronics is a little over my head so I don't under stand why I need a switching regulator. Would a suitable mosfet not do the job.

Can u still regulate the voltage to the fan with my PWM output from the Arduino through a switching regulator.

rgds

Electronics is a little over my head so I don’t under stand why I need a switching regulator. Would a suitable mosfet not do the job.

Can u still regulate the voltage to the fan with my PWM output from the Arduino through a switching regulator.

No, because it implies you intend to use the arduino 5V to power the mosfet and as already explained,
you can’t run motors off the arduino 5V because it induces noise in the microcontroller , causing errors.
You could use a 5V linear regulator (LM7805) if you don’t want to use a switching regulator.