Interfacing GPS location module with Bolt

@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…

@shivamishra97 The error is because you have not specified the data param of the mybolt.serialWrite() function.
I think the serialWrite() function takes some string data to be passed to the Bolt. The line should make use of response and not serialWrite().

Check your serialWrite function in send_sms section. You need to pass string parameter in the the serial write functions . For example :

mybolt.serialWrite('Hello')

Check the function details here https://github.com/Inventrom/bolt-api-python#uart-functions

Hi, So I am attempting to trace gps values from GPS module and transfer/manipulate the data,
This is what i have done so far:
1.Interfacing of GPS with successful
2.Tx and Rx of data from GPS to Arduino: Successful
3.Connected Tx and Rx of Arduino to Rx and Tx of Bolt: Successful
4. Trying to read serialData
This is what i was trying to write in python code:

while True:
	mybolt.serialWrite('getGPSData')
	response = mybolt.serialRead('Rx')
	print(response)

Output is:

"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"
"{\"value\": \"Invalid till value\", \"success\": \"0\"}"

Can you please suggest,which step did i do wrong??Please help.

serialRead() functions takes a positive integer as a string in the parameter. You have passed alphabet string in the serialRead that is incorrect. Please refer the code below.

from boltiot import Bolt
api_key = "ACXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
device_id  = "BOLT1234"
mybolt = Bolt(api_key, device_id)
response = mybolt.serialRead('10')

References :

Hi @shivamishra97
I’m doing my final year project which involves the same gps location sending via sms
Can you please share the complete code and hardware connections to me
It would be very helpful

Thanks for sharing the following information.It really helped us a lot.I want to include that I have been facing a severe problem of not being able to reset my GPS in my Android phone Samsung A20. I have followed out the guidelines as suggested by the garmin map updates free download 2019.
1.Firstly,opened Chrome.
2.Tapped on Settings (the 3 vertical dots on the top right)
3.Tapped on Site Settings.
4.Made sure possibly that settings for Location is set to “Ask First”
5.Tapped on Location.
6.Tapped on All Sites.
7.Scrolled down to ServeManager.
8.Tapped on Clear and Reset.
Suggest us if we have missed out on anything.