BLYNK
HOME       📲 GETTING STARTED       📗 DOCS       ❓HELP CENTER       👉 SKETCH BUILDER

Need help with blynk and other loop function combining together


#1

Hello I kind of in a pinch here, I am doing a project about a car alarm system which sends messages when the vibration sensor triggers. My problem is that I got an error about this:

Arduino: 1.8.4 (Windows 10), Board: "Arduino Uno WiFi"

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_3'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_5'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

libraries\SoftwareSerial\SoftwareSerial.cpp.o (symbol from plugin): In function `SoftwareSerial::read()':

(.text+0x0): multiple definition of `__vector_4'

libraries\GSM\GSM3SoftSerial.cpp.o (symbol from plugin):(.text+0x0): first defined here

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino Uno WiFi.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Here is my code :

#include <GSM.h>
#define PINNUMBER XXXX


// gsm and gps...
GSM gsmAccess(true); // this call is to access to the data of the sim from the arduino to the phone.
GSM_SMS sms; // to call in to the phone from the arduino to the phone.e.g its like the use of  write() or attach() in terms of servo.
char remoteNumber[20]= "xxxxxxx"; //Phone number
char txtMsg[80]="message here"; 
 int vib=4; // for the vibration sensor which is connected to the digital pin 8 of the arduino
 void sendSMS();//function call for the SMS
//the gsm and gps...
 

#define BLYNK_USE_DIRECT_CONNECT
#define BLYNK_PRINT BT
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <Blynk.h>
#include <BlynkSimpleSerialBLE.h>


//for the servo and bluetooth.......
char authtok[] = "xxxxxxxxx"; //blynk auth tok
#include<SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial BT(10, 11); // RX, TX bluetooth
Servo door;//open and close
#define servopin 9
void opens();
 void closes();
 //void noconnect();
//for the blynks......




BLYNK_WRITE(V6) // loop code for the virtual push button of the app to move the servo
{
  int key = param.asInt(); // use to read the logic values of the button thats use in blynk

  if (key == 0)
  {
    closes();
    Serial.println(key);
    Serial.println("Close");
    
  }
  else if( key == 1)
  {
    opens();
    Serial.println(key);
    Serial.println("Open");
  }

}


void setup()
{
  Serial.begin(9600);

  BT.begin(9600);
  Blynk.begin(BT, authtok);
  Serial.println(BT);
  door.attach(servopin);//servo pin
  door.write(closes);// setup the servo to 0 degrees at start 
  opens();
  closes();
 
  pinMode(vib,INPUT);
  Serial.println("Car theft message");
  // boolean call to use act as a state if the gsm is connected to the sim
  boolean notConnected = true;// if the gsm is not connected to the sim which is stated as 'true'

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected) //its still finding connection
  {
    //number 0874267530
    if(gsmAccess.begin(PINNUMBER)==GSM_READY) // an if statement is use to tell the gsm to make a connection to the sim using the sim pin.
      notConnected = false;
      //sendSMS();
    else 
    {
      Serial.println("Not connected");
      delay(500);
    }
  }
  Serial.println("GSM initialized");
  sendSMS();
}

void loop()
{
  

      int al;
    
    //alarm sets in
      al = digitalRead(vib);
      if(al==1)      
      {    
         
         
          //Turn on Alarm here
            
            digitalWrite(vib,HIGH);
            Serial.println(al);
         
          
            sendSMS();
            delay(1000);
           
      }
      //alarm is not active
      else if(al==0)
      {
          digitalWrite(vib,LOW);  
          Serial.println(al);
      }
  Blynk.run();
}

void opens() //function to move the servot to 90 degrees
{
  door.write(90);
}

void closes() //function to move the servo to 0 degrees
{
  door.write(0);
}


void sendSMS()
{
  
  Serial.print("Message to mobile number: ");
  Serial.println(remoteNumber);

  // sms text
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);
  delay(500);
 

  //  this is where it will begin its process of connecting to the phone.
  sms.beginSMS(remoteNumber); // this will initiate connecting to the sim
  sms.print(txtMsg); //the message that has to be sent to the phone.
  sms.endSMS(); // Ends the process
  Serial.println("\nCOMPLETE!\n");
   
}

#2

Lots of inconsistencies here… You need to make sure you have the correct Blynk libraries (and whatever is needed for that ‘other’ sketch ) for your device and communications method… e.g. BLE, GSM or WiFi?


#3

The only connection im using is an HM-10 bluetooth and the antenova GSM shield. The arduino board I am using is the arduino uno wifi board I tried the ordinary uno board but its still to no avail. I have all the libraries in there . These codes on the bottom work if I try them in different sketches. I just want them to work in one sketch. What I want to do is that when the function void closes() is on the alarm is set to triggered and if the vibration sensor triggers its sends an sms message to my phone. And when its opens() the alarm is off.

Here is the code to move the servo 0 to 90 degrees using blynk:

#define BLYNK_USE_DIRECT_CONNECT
#define BLYNK_PRINT BT
#define BLYNK_PRINT Serial
#define BLYNK_DEBUG
#include <Blynk.h>
#include <BlynkSimpleSerialBLE.h>


//for the servo and bluetooth.......
char authtok[] = "xxxxxxx"; //blynk auth tok
#include<SoftwareSerial.h>
#include <Servo.h>
SoftwareSerial BT(10, 11); // RX, TX bluetooth
Servo door;//open and close
void opens();
 void closes();
//for the blynks......


void opens() //function to move the servot to 90 degrees
{
  door.write(90);
  
}

void closes() //function to move the servo to 0 degrees
{
  door.write(0);
}

BLYNK_WRITE(V6) // loop code for the virtual push button of the app to move the servo
{
  int key = param.asInt(); // use to read the logic values of the button thats use in blynk

  if (key == 0)
  {
    closes();
    Serial.println(key);
    
    Serial.println("Close");
  }
  else if( key == 1)
  {
    opens();
    Serial.println(key);
    Serial.println("Open");
  }

  
}
void setup()
{
  Serial.begin(9600);

  BT.begin(9600);
  Blynk.begin(BT, authtok);
  Serial.println(BT);
 
  door.attach(9);//servo pin
  door.write(0);// setup the servo to 0 degrees at start 

}

void loop()
{
   Blynk.run();
 
} 

Here is for the GSM and vibration sensor, when the sensor is triggered its sends an sms to the designated  phone number:
#include <GSM.h>
#define PINNUMBER 0000


// initialize the library instance
GSM gsmAccess(true); // this call is to access to the data of the sim from the arduino to the phone.
GSM_SMS sms; // to call in to the phone from the arduino to the phone.e.g its like the use of  write() or attach() in terms of servo.
char remoteNumber[20]= "0873319704"; //Phone number
char txtMsg[80]="Theft ALERT: Someone is trying to rob your car."; 
 int vib=4; // for the vibration sensor which is connected to the digital pin 8 of the arduino
 void sendSMS();//function call for the SMS



void setup() 
{
  Serial.begin(9600);
  
  pinMode(vib,INPUT);
  
  

  Serial.println("Car theft message");
  // boolean call to use act as a state if the gsm is connected to the sim
  boolean notConnected = true;// if the gsm is not connected to the sim which is stated as 'true'

  // Start GSM shield
  // If your SIM has PIN, pass it as a parameter of begin() in quotes
  while(notConnected) //its still finding connection
  {
    //number 0874267530
    if(gsmAccess.begin(PINNUMBER)==GSM_READY) // an if statement is use to tell the gsm to make a connection to the sim using the sim pin.
      notConnected = false;
      //sendSMS();
    else 
    {
      Serial.println("Not connected");
      delay(500);
    }
  }
  Serial.println("GSM initialized");
  sendSMS();
}
  
  


void loop() 
{
      int al;
    //alarm sets in
      al = digitalRead(vib);
      if(al==1)      
      {
          
          //Turn on Alarm here
          digitalWrite(vib,HIGH);
          Serial.println(al);
            
          
          sendSMS();
          delay(500);
      
         
      }
      //alarm is not active
      else if(al == 0)
      {
        digitalWrite(vib,LOW);  
        Serial.println(al);
    
      }
    }
  


void sendSMS()
{
  Serial.print("Message to mobile number: ");
  Serial.println(remoteNumber);

  // sms text
  Serial.println("SENDING");
  Serial.println();
  Serial.println("Message:");
  Serial.println(txtMsg);
  delay(500);
 
  //  this is where it will begin its process of connecting to the phone to send message.
  sms.beginSMS(remoteNumber); // this will initiate connecting to the sim
  sms.print(txtMsg); //the message that has to be sent to the phone.
  sms.endSMS(); // Ends the process
  Serial.println("\nCOMPLETE!\n");
  
}

#4

Blynk - FTFC


#5

So is there a way for me to use the void loop while using blynk?


#6

You must use a loop() in every sketch, Blynk or no Blynk.

See the excellent loop() in the PUSH DATA example.