GPS and Servo Issue

Hi everyone,

So I’ve seen a lot of people having this problem and I can’t find a solution specific to my application that actually worked from the other forum posts.

My problem is using a GPS and servo motors at the same time. The other forums say something about using software serial GPS and servo motors together causes erratic impulses from the servo, I am having the same problem, even just by initialising a servo pin without sending it a location it goes back and forth. I used an oscilloscope to see the impulse that the servo was receiving and it was a square wave with duty cycle that increases and then decreases, just as the servo does.

I am using the “TinyGPS++” library to talk to the GY-NEO6MV2 GPS Module, FR0109 servo motors that are being independently powered from a battery and an Arduino UNO.

For this project I’m using a GPS to get data to then find the azimuth and solar altitude angles of the sun and then pointing my solar panel using the 2 servo motors.

Is there a way to switch the GPS on get the data, then switch the GPS off and then move the servo?

Please, if anyone has a solution that would be great or needs any other information let em know, I’ve been stuck on this for a couple of weeks 

Im using pins 2 and 3 for my GPS and pin for my servo motor.

GPS link - https://www.robotics.org.za/GY-NEO6MV2?search=gps%20for%20arduino

GPSwithArduino.ino (545 Bytes)

About 95% of the servo problems posted on this forum are power supply problems, so post a wiring diagram and the details of your servo power supply.

Did you connect the grounds?

Yea I'm 100% sure it's not that because when I comment out the GPS pins the servo works perfectly

Hi Zee9696,

In my experience it's more efficient to use a hardware serial port and uBlox's proprietary UBX protocol.

The UBX binary protocol uses fixed length data structures that are much easier for a microcontroller to decode and read, rather than the traditional way of parsing NMEA strings.

Using the UBX protocol is discussed on this Youtube video: https://www.youtube.com/watch?v=TwhCX0c8Xe0.

Is there a way to switch the GPS on get the data, then switch the GPS off and then move the servo?

The GPS can be switched to standby, but it's also possible just to get your sketch to simply ignore the incoming GPS data stream and drive the servos instead.

Post your code: I don't see any mention of servos in the one you did post.

Check this thread: servos and softwareserial - slipstick has an answer for you.

Thank you @MartinL! I watched the video and I had no idea you could do any of that! I will sit down this weekend and go through that video again to see if I am able to solve my problem!

Hi @wildbill, thank you for the input.

I commented out and removed all my servo code because the servo was pulsing erratically when I just assign the pin, so my first step was to be able to assign a pin without getting any erratic pulses.

I tried using "ServoTimer2.h" library and that also caused erratic pulses.

MartinL:
The GPS can be switched to standby, but it's also possible just to get your sketch to simply ignore the incoming GPS data stream and drive the servos instead.

Is the function in the Tiny GPS ++ library?

So I finally managed to fix my problem! I didn't understand what people were saying when they meant convert Software Serial to hardware serial until I came across this post which explained it step-by step and explained that the servo library and the software serial conflict.

https://forum.arduino.cc/index.php?topic=298198.0