I’ve got a 3A servo hooked up to D0 on my Photon. It’s powered by a 5V power supply that also supplies power to the Photon.
It used to work really well, but now, every time I run a servo command, the Photon reboots itself. The function, itself, makes a beep on a piezo buzzer on D1, then is supposed to run the servo. It just never makes it to the servo–it beeps and beeps like it should but then reboots.
I’ve heard breadboards don’t always like handling 3A. Is this a symptom that I fried my breadboard?
Oh yes. I change it all the time. At one point, I had too many variables and functions for it to compile, so I brought it back down to just its core tasks while I figure out how to streamline it. It’s just the core tasks now. I’ve looked over the code and I see no reason why it would cause a reboot.
I should describe what’s happened a little better:
It used to work great
I tested out a new piece of code while I was away that accidentally ran the servo for like 3 hours straight
I then brought all the code back to just the core functions
I tried running the servo like normal and it worked okay
Tried it again and it ran shorter than it should’ve
The fact that it used to work, you then changed something after which it doesn’t work anymore, makes me thing it’s the ‘something’ you changed that causes the issue.
This would suggest, that your offending code is in loop()after the moving-publish.
Try to find the offending instruction first and then see why this causes a reboot.
The code I used in that test was from the servo docs as Moors7 recommended. So the only thing in loop() was Particle.publish(), myservo.write() and delay()
Try the code without the servo attached.
Try the code with the servo attached, but the servo control statements commented.
Add one by one back (in an order so that the code still builds).
It is a little bit unusual to run the servo and the micro controller off the same power supply. I would guess you were in a rather lucky condition for it to work in the first place, and now a slightly changed sequence of current demands from the servo is momentarily depriving the photon. Its also possible that the power supply is slightly derated. I would beef up the capacitors across the power right at the photon itself - a couple of 100uF - , and move the servo connections off the breadboard. If that doesn’t work, try powering the servo - or the photon - from a battery pack. For the record a breadboard should have no problem with 3A, but make sure the photon is secure in the breadboard as a glitchy power connection would also be revealed by the current demand from the servo.
@humphreyg: Just did as you recommended. The photon no longer reboots, but the servo doesn’t move. I replaced it with a different, 1A servo, which worked fine. Think maybe the servo shorted out?