Interfacing GPS location module with Bolt

I am making a project in which I have interfaced arduino,gps module,Boltiot. As a part of my project I want to send GPS location through Boltiot in an SMS. I have earlier sent the sensor data using boltiot as a SMS ,but I am not getting how to send GPS location through BOLTIOT.As i have interfaced GPS module with arduino and bolt iot with arduino.Can anyone help me in this??

@shivamishra97, Can you please share what you have done till now?
@vinayak.joshi Please help her out.

Hi @shivamishra97:

Please use the following library to write your code for interfacing Arduino with BoltIoT

Go through the example codes available via the library to understand how to setup the Arduino to respond to a command from the Bolt.

Then in your python code, use the serialWrite command from the BoltIoT python library, to send the command to the Arduino, and then use the serialRead command from the BoltIoT python library to get the response from the Arduino.

You can code your Arduino to send the GPS location as the response. This will allow you to pull the GPS data into your python code, and then send an SMS with the GPS data.

Till now I had just done the interfacing command. And as a part of my training I had earlier sent an SMS through boltiot but at that time the input device was a sensor( integer value). So i was trying to make some changes in it.But the only output i am getting is a msg stating “Sent from Twilio account command time out”. So i think something is wrong with the program.But still I will try steps given by @vinayak.joshi . I’ll keep you updated. Thank you

@shoeb.ahmed @vinayak.joshi I had installed the library.However in the examples using pushdata command we will send the data to the cloud.But how will i send the data through sms. Should i use the same Vm workstation Program which I had earlier used.Or is there any other way? Also I have connected Gps with arduino using RX tx pins of gps and 3,4 digital pin of arduino.So what pin number should I pass In Pushdatacommand? inorder to send the gps data?

temp(sms) @vinayak.joshi @shoeb.ahmed this is the screenshot of the Vmworkstation UBUNTU programming I had earlier did to send Sensor value in the SMS.

Hi @shivamishra97,[

When I said examples, I meant the examples that get populated in File>Examples>BoltIoT-Arduino-Helper in your Arduino IDE.
You will need to go through the code for the “CommandHandler” example.

Since you have the GPS device connected to the tx and rx pins of the Arduino, you will have to use 2 other pins of the Arduino to interface the Bolt WiFi module. These can be any two digital IO pins of the Arduino.

The readme gives an example of how you can use pins 3 and 4 to interface the Bolt, but you can use any of the Arduino pins for this, for example The following are totally valid

boltiot.begin(7,10);

boltiot.begin(6,5);

boltiot.begin(10,11);

Also in your python code, you will have to use the “serialWrite” and “serialRead” functions instead of the ‘analogRead’ function and you should be able to get the gps data from the Arduino.

@vinayak.joshi Thank You for your response.I am not able to understand the working of “commandhandler” as there is “getanalogdata” as well as “getdigitaldata” .Also I am only connecting GPS & BOLTIOT to the arduino,so is there any need for analogdata or digitaldata?Can you please explain me the working of the example so that I can implement it according to my project? Or it would be a great help if you send me a sample code stating only the important data(parameters,functions),so that it becomes easy for me to program it.Please help!!

@vinayak.josarduinoprgrm !
@vinayak.joshi I have shared the screenshot of arduino program and pythoncode that i wrote according to my understanding. please check it out.Also I have connected BOLTIOT to Rx Tx pin of arduino and GPS i have connected to tx-pin 4 and Rx -pin 6 of arduino.

pythoncode

Hi @shivamishra97,

The commandhandeller is an example code that explains how to use the library to implement a system to read all analog pins of the of the Arduino, and the required digital pins of the Arduino via the Bolt Cloud API.

Your system does not require the getAnalogData and getDigitalData functions.

You will need to write a function named getGPSData, which will do all the work required to retrieve the GPS data from your GPS module, print the GPS data into a String, and then return the string.

Also, as per my understanding, you are using the Hardware serial port of your Arduino to communicate with the GPS module, as such you cannot use it to communicate with the Bolt WiFi module.

For your python code, you will want to try the following

mybolt.serialWrite("Command")
response = mybolt.serialRead() 

Instead of

response = mybolt.serialRead() 

Remember to replace the String “Command” with the string that you used in your Arduino code as follows

bltiot.setCommandString("Command", getGPSData);

arduinoprgrm1 @vinayak.joshi I have attached the screenshot of the arduino code . I have made the changes according to my understanding.But still I am not getting the output,so please go through the code and help.

@vinayak.joshi here is the Pythoncode of the BoltIot ,in this i am getting an error in serialRead line saying “argument Missing”.

Hi,

In your code, for the function getGPSData, you are not returning the GPS location via the return string.

Add the following lines in the if(gps.location.isValid()) loop

returnString = "" + gps.location.lat() + "," + gps.location.lng() + "\n";

Hi,

Apologies for the error in the earlier code.

Use serialRead in the following manner, and the issue will go away.

mybolt.serialRead('10')

@vinayak.joshi I tried the commands that you sent.However I am getting an error in the program,I have attached the program so please go through it.

Text requesting personal information has been moderated.

@shivamishra97 : It seems I will need to replicate your code on my end.

Could you share your code for Arduino here, in text format.
If I have to implement your code right now, I will have to type out everything myself, and there may be a situation that I may not copy your code perfectly.

@vinayak.joshi Program:

    #include <TinyGPS++.h>
    #include <SoftwareSerial.h>
    #include <BoltIoT-Arduino-Helper.h>
    #ifndef API_KEY #define API_KEY   "fbe2f047-797b-4f1a-af28-879f2daf4d46 "
    #endif #ifndef DEVICE_ID
    #define DEVICE_ID "BOLT8879197 " #endif
    static const int RXPin = 0, TXPin = 1;static const uint32_t GPSBaud = 9600;
    TinyGPSPlus gps;SoftwareSerial ss(RXPin, TXPin);
    String getGPSData(String *data)
      { String returnString="";
        while (ss.available() > 0)
        if (gps.encode(ss.read()))
        { 
      if (gps.location.isValid())
      {
         
        Serial.print(gps.location.lat(), 6);
        Serial.print(F(" "));
        Serial.print(gps.location.lng(), 6);
        returnString = "" + gps.location.lat() + "," + gps.location.lng() + "\n";
      }
      else
      {
        Serial.print(F("INVALID"));
      }
      Serial.println();
    }
      return returnString;
      }
    void setup(){
    	boltiot.begin(7,10);
      Serial.begin(9600);ss.begin(GPSBaud);
      boltiot.setCommandString("GetGPSData",getGPSData);
    	}
    void loop(){
    	boltiot.handleCommand();
      }

Hi @shivamishra97,

Please make the following change in the code line that I had shared with you earlier.

returnString = "" + String(gps.location.lat()) + "," + String(gps.location.lng()) + "\n";

I was able to compile the code at my end.

Unfortunately, I do not have a GPS with which I could test out the code.

Do try out this solution.

I made the changes in the arduino code and it compiled successfully,thank you for that.However when i made the changes in the python code i am still getting an error.I have attached the photo of the program,please go through it .Also is there any other easier way in which I can program my Boltiot module,like now I am using Vmworkstation in which i use ubuntu virtual machine and then i code in python language.So is there any other way in which a beginner like me can program the boltiot module? Please help me through this…