Interfacing GPS location module with Bolt


#5

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


#6

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


#7

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.


#8

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


#9

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


#10


#11

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);

#12

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


#13

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


#14

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";


#15

Hi,

Apologies for the error in the earlier code.

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

mybolt.serialRead('10')


#16

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


#17

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


#18

@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();
      }

#19

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.


#21

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…


GPS tracker using Bolt IoT
#22

@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().


#23

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


#24

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.


#25

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 :