I've been following this tutorial and I've run into some weird problems. When my motor starts running, I get "Failed to read from DHT sensor" on my serial window, meaning that readHumidity() and readTemperature() functions are returning NaNs.
This only happens while the motor is running. Once I stop the motor even momentarily, the DHT sensor starts working again.
Does anyone know why this is happening? I'm using a genuine UNO and a RHT03 sensor and some 5.9V motor (TD599839).
-
try to add a 100nF ceramic capacitor between the motor terminals.Ikbel– Ikbel2015年11月13日 10:22:22 +00:00Commented Nov 13, 2015 at 10:22
-
1And a flyback diode across the terminals, too - every little helps. On a different note, you are using a resistor with that LED, yes? I'll overlook the fact that it's the wrong way round in the schematic!CharlieHanson– CharlieHanson2015年11月13日 11:51:49 +00:00Commented Nov 13, 2015 at 11:51
-
What is that capacitor doing there? Slow start?Gerben– Gerben2015年11月13日 14:11:12 +00:00Commented Nov 13, 2015 at 14:11
-
First make sure that your motor has its own run back to ground - you must avoid motor current passing through the Arduino's ground. Next, filtering your PWM is a bad idea - at a minimum it is inefficient. You do not want to have your transistor "part way on" as that leads to conversion of power to heat in the transistor. Instead, you want the transistor to only ever be fully on or off, applying full voltage to the motor at variable duty cycle. The inductance of the motor will cause some limitation of current, but the mechanical inertia of the rotor will accomplish the rest of the averaging.Chris Stratton– Chris Stratton2015年11月14日 17:30:42 +00:00Commented Nov 14, 2015 at 17:30
-
Remove 10k resistor and use 1k instead. Or, just connect directly to Analog A0 pin. And modify your code. This may help you. Also consider GND to be 0V. Not below 1V instead while motor is working.Bay– Bay2015年11月14日 22:48:48 +00:00Commented Nov 14, 2015 at 22:48
1 Answer 1
The problem may be electrical noise from the motor, or you may have a wiring problem (an incorrect or intermittent connection).
Kira San’s comment "try to add a 100nF ceramic capacitor between the motor terminals" is directed toward suppressing electrical motor noise. As brushes make or break connections on a motor's commutator, arcs and sparks can occur. The capacitor will limit voltage rate of change thus suppressing some of that electrical noise.
CharlieHanson's comment (add a flyback diode across the motor terminals) is partly related to noise suppression but mostly to suppressing high voltage excursion that occurs when you shut off motor power. While the motor is running, the magnetic field in it stores 1⁄2 L i2 joules of power. When current stops suddenly, those joules of power convert to a high voltage spike. A flyback diode acts as a near-short to absorb that spike. The cathode (cross-bar) of the flyback diode attaches to the high side of the motor voltage, as shown in the circuit diagram of the project you linked to on electroschematics.com.
Re "you are using a resistor with that LED, yes? I'll overlook the fact that it's the wrong way round in the schematic!", if the LED is wired backwards as shown in your drawing, it won't turn on – which is a good thing, because without a resistor (say 300-3000 Ω) in series with the LED, enough current may flow to damage the Uno or the LED. Turn the LED around on the schematic (and on your wiring setup if you didn't already), and add a series resistor.
Edit: A comment says, "Don't have a diode either :S Will an LED work instead?". LEDs typically have rather low reverse-voltage ratings – 4 to 5 volts. You could put two or three in series and if they don't burn up you're ok for this experiment. But in production, don't depend on LEDs as flyback diodes except where it doesn't matter what happens.
- Gerben's comment, "What is that capacitor doing there? Slow start?" refers to the 100 μF capacitor shown between transistor base and emitter. In conjunction with the 1KΩ resistor from D4, that gives RC=0.1 second, so the transistor will take an appreciable amount of time to turn on. This has a couple of consequences: PWM control may be less effective (at low duty cycles, PWM depends on short, high-current pulses, to overcome stiction etc) and the transistor will run hotter. If it's a big power transistor, ok. If it's a small switching transistor intended for full-on or full-off, no.
Edit: A comment refers to a fan speed controlled temperature page at electroschematics.com. That page shows a BD139 power transistor, and says the 100 μF capacitor between transistor base and emitter eliminates some motor noise. Thus it falls into the "big power transistor, ok" category. Well, more or less ok. A heat sink may be needed on the transistor and the capacitor probably doesn't need to be that big; eg try 10 μF instead of 100.
- An ordinary 9V battery easily supplies a dozen milliamps, but current draw larger than that quickly depletes it. See eg 9V Alkaline tests at powerstream.com and my answer to a previous question, Using Arduino Micro With 12V Buzzer that's somewhat related. The motor shown (TD599839) is rated at 35 mA at 5.9 V no-load, so will draw say 50 mA no-load from a 9V battery and will try to draw several times that if loaded; ie it will overstress an ordinary 9V battery. In brief: Use a wall-wart or equivalent, or a big battery, rather than a small 9V battery when running motors.
-
3. Sorry about that, didn't see that its backward in the schematic. I'm actually not using that LED in the actual project anyway, just playing around in fritzing. Thanks for pointing that out though. 4. I'm actually following another tutorial to control the motor speed -> electroschematics.com/9540/…. Apparently its an RC filter to smooth out noise from the PWM. 5. Would it help if I changed the motor completely? Bought a less powerful one intended for hobbyists? Because the shop I bought the components from wasn't well stocked.cybergla– cybergla2015年11月14日 08:15:31 +00:00Commented Nov 14, 2015 at 8:15
-
1. 2. -> I'll try those out, but I don't have the necessary materials. 1. -> I only have 100uF capacitors, will those work? 2 -> Don't have a diode either :S Will an LED work instead? (or is that a totally crazy idea?)cybergla– cybergla2015年11月14日 08:23:02 +00:00Commented Nov 14, 2015 at 8:23
-
@cybergla, see editsJames Waldby - jwpat7– James Waldby - jwpat72015年11月14日 17:09:52 +00:00Commented Nov 14, 2015 at 17:09
-
In the long run if you are going to be in electronics I would suggest you learn how to draw schematics. KiCad is free and one of the better schematic capture programs available. It runs on most platforms. It will not be an overnight learning experience but there are lots of tutorials on line for it. If later you want to do simulation you will probably have to do a schematic anyway.Gil– Gil2021年01月31日 07:07:14 +00:00Commented Jan 31, 2021 at 7:07
Explore related questions
See similar questions with these tags.