Arduino Leonardo A7 GPS/GPRS трекер

Akalchuk
Offline
Зарегистрирован: 29.01.2016

Добрый день Всем )

Прошу помощи с проектом!! Весь мозг уже себе сломал(

Идея следующая: Хочу собрать трекер с финкцией сбора координат и последуещией отправкой их на Blynk. 

Есть модуль Ai Thinker A7 и плата Arduino Leonardo. Rx и Tx из A7 заходят в Rx и Tx ардуины.

Gps контакт модуля заведен в 8 пин ардуины.

Не могу заставить одновременно работать и модуль и SoftwareSerial чтобы одновременно получать координаты и тут же слать их на сервер.

Надеюсь на вашу помощь)

Мой код:

#define TINY_GSM_MODEM_A7
#include <SoftwareSerial.h>
#include <TinyGsmClient.h>
#include <BlynkSimpleSIM800.h>
#include <TinyGPS++.h>
#include <SimpleTimer.h>
SimpleTimer timer;
WidgetMap myMap(V0);

const char auth[] = "###################";

// Your GPRS credentials
// Leave empty, if missing user or pass
const char apn[]  = "internet.mts.ru";
const char user[] = "";
const char pass[] = "";

int spd; //Variable  to store the speed
int sats;      //Variable to store no. of satellites response
String accur;     //accuracy
int alt;        //altitude
int hours;
int minutes;
unsigned int move_index; 

#define SerialAT Serial1

// or Software Serial on Uno, Nano
//#include <SoftwareSerial.h>
SoftwareSerial ss (8, 9); // RX, TX
TinyGPSPlus gps; 
TinyGsm modem(SerialAT);

void displayInfo()
{ 

  if (gps.location.isValid() ) 
  {
    
    float latitude = (gps.location.lat());     //Storing the Lat. and Lon. 
    float longitude = (gps.location.lng()); 
    Blynk.virtualWrite(V1, String(latitude, 6));   
    Blynk.virtualWrite(V2, String(longitude, 6));
  }
  Serial.println();
}

void Sent_serial() {
         // Sent serial data to Blynk terminal - Unlimited string readed
         String content = "";  //null string constant ( an empty string )
         char character;
         while(ss.available()) {
              character = ss.read();
              content.concat(character);  
         }
         if (content != "") {
              Blynk.virtualWrite (V11, content);
         }  
  }

void setup() {
  // put your setup code here, to run once:
Serial.begin(115200);
  delay(10);

  // Set GSM module baud rate
  SerialAT.begin(28200);
  delay(2000);
  ss.begin(9600);
  delay(2000);
  SerialAT.print("AT+GPS=1");
  delay(2000);

  // Restart takes quite some time
  // To skip it, call init() instead of restart()
  //Serial.println("Initializing modem...");
  modem.restart();

  String modemInfo = modem.getModemInfo();
  //Serial.print("Modem: ");
  Serial.println(modemInfo);
  delay(3000);
  
  Blynk.begin(auth, modem, apn, user, pass);
  timer.setInterval(500, Sent_serial);

}

void loop() {
  // put your main code here, to run repeatedly:
while (ss.available() > 0) 
    {
      if (gps.encode(ss.read()))  
        displayInfo();
  }
  Blynk.run();
  timer.run(); 
}

 

Akalchuk
Offline
Зарегистрирован: 29.01.2016

Примечательно то что  к серверу Blynk он цепляется и в инет выходит. Могу светодиодом помигать)

Но вот не могу парсить координаты с Gps модуля.

До этого реализовывал подобное с Esp8266 +VK16E + Мтс Модем. все бы ничего, но модем постоянно отваливался и стабильности не было никакой.

Ввыбрал Леонардо изза аппаратного Uart на борту, для одновременной обработки данных. 

DragonPC
Offline
Зарегистрирован: 21.04.2018

Комрад, победил проблему?