Go Down

Topic: Servo shaking while using a GSM shield (Read 2075 times) previous topic - next topic

janvier123

Apr 08, 2015, 04:43 pm Last Edit: Apr 08, 2015, 07:47 pm by janvier123
Hi,

Ive noticed that the SERVO starts shaking at random, its constant
It does not matter what PIN i use

Setup is: Arduino Uno, GSM shield 2.0, servo
The basic idea is to send an SMS to the arduino, and that moves the servo to turn on a button

Here is the code
Code: [Select]
#include <Servo.h>
#include <GSM.h>
GSM gsmAccess;
GSM_SMS sms;
Servo myServo;

void setup()
{
  // initialize serial communications and wait for port to open:
  Serial.begin(9600);
  Serial.println("Booting GSM Shield");
 
  boolean notConnected = true;
 
  // Start GSM connection
  while (notConnected)
  {
    if (gsmAccess.begin() == GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }
  Serial.println("Waiting for messages");
  myServo.attach(8);
  myServo.write(0);
}

void loop()
{
  char c;
  char smsData[80];
  byte smsIndex = 0;
  char txtMsg[200];
  char remoteNum[20] = "+vvvvvvvvvvvv";
 
  // If there are any SMSs available()
  if (sms.available())
  {
    Serial.println("Message received");
    // Read message bytes and print them
    while (c = sms.read())
    {
        smsData[smsIndex++] = c;
        smsData[smsIndex] = '\0'; // Keep string NULL terminated
    }
   
 

    if (strcmp(smsData, "H") == 0)
    {
        char txtMsg[200] = "OK, I will now turn <ON> the PC!"; 
        Serial.print(txtMsg);
       
        myServo.write(90);
        delay (1000);
        myServo.write(0);
       
    }
    sms.flush();
  }
}


Code is a bit messy :(
Thx in advance

jremington

The power supply is inadequate. The servo and the GSM module each require 1 or more amperes. Both should be powered from a separate supply and neither can be powered from the 5V Arduino output.

Be sure to connect the grounds together!

janvier123

its strange, i did a test before using the USB power and changed the SERVO with an LED
It worked perfecly, but once i add the servo library, then things go nuts
Even now when i use the servo lib, and use an LED as output, the led starts flickering ....

jremington

USB power is limited to 500 mA. You need a 5V, 2 ampere power supply.

janvier123

#4
Apr 08, 2015, 07:32 pm Last Edit: Apr 08, 2015, 07:45 pm by janvier123
Ok, ive connected a LACIE power supply

12vDC - 2A
5vDC - 2A

Same results, as soon as the LOOP begins, the servo goes bananas ;)

View it in action => http://youtu.be/Ev0Cb3SD7r0

jremington

Can you post a wiring diagram showing all the connections? Don't waste your time with Fritzing, even hand drawn is much better.

janvier123

As requested: http://prntscr.com/6rh5ko

Its just a stacked gsm shield on a arduino and the servo connections directly connected to the POWER and DIGITAL pins

JimboZA

You need to power the servo from the external supply, not through the Arduino 5V, which is what the diagram shows. On the other hand in the video it looks like the servo is powered externally?.... but the grounds don't seem to be connected. The servo power -ve must be hooked up to the Arduino ground, else the Arduino 5V on the signal wire means nothing to the servo.
Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

janvier123

In  the video the servo is hooked up to an external power supply, in the diagram its not.
However, iam getting the same results with or without external power

Ill remake the project again

JimboZA

In  the video the servo is hooked up to an external power supply,
But are the grounds all hooked up? The servo -ve, servo power -ve and Arduino GND must be joined as in the attached.

Johannesburg hams call me: ZS6JMB on Highveld rep 145.7875 (-600 & 88.5 tone)
Dr Perry Cox: "Help me to help you, help me to help you...."
Your answer may already be here: https://forum.arduino.cc/index.php?topic=384198.0

janvier123

#10
Apr 09, 2015, 08:58 am Last Edit: Apr 09, 2015, 09:00 am by janvier123
I think ive broke my servo, while re-creating the project ive reversed the V5 and GND
doesnt want to do anything now, even without my GSM shield

It is broke and get a new one ? or .. ?


TESTED USING MY OWN SKETCH

Code: [Select]

#include <Servo.h>
int pos;
Servo myservo;


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  myservo.attach(9);
  myservo.write(0);
}

void loop() {
  // put your main code here, to run repeatedly:
  pos = analogRead(A0) / 5.68;
  myservo.write((byte)pos);
  Serial.println((byte)pos);
}

MarkT

The power supply is inadequate. The servo and the GSM module each require 1 or more amperes. Both should be powered from a separate supply and neither can be powered from the 5V Arduino output.

Be sure to connect the grounds together!
GSM probably needs 2A peak, but its average will be about 1/8th of that
so a multimeter will not show you whats happening.  I suspect your 2A supply is
barely adequate for the GSM shield alone...  Check the datasheets or use an
oscilloscope on the supply rail to see better what's actually happening.

In general don't skimp on power supplies - if you measure/calculate a circuit
needs 1.0A, say, then use a supply of 1.5A or more.
[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

Go Up