код проверенный координаты отправляет(http://gansta-paradise-forum.ru/GPS/map.html) ,остальное пока не проверял ,позже займусь
выводы :
дисплей : scl - d22, sda - d21
GPS: green -d15,blue -d13.
Код: Выбрать все
/*****************************************
* ESP32 GPS VKEL 9600 Bds
******************************************/
//#include <TimeLib.h>
///#include "math.h"
///#include <WiFi.h>
///#include <WiFiClient.h>
///#include <HTTPClient.h>
///#include <Wire.h>
#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "driver/adc.h"
#include "esp32-hal-ledc.h"
#include <Preferences.h>
int value = 0;
const char* streamId = "....................";
double privateKey ;
double privateKeyL ;
float privateKeyS ;
float privateKey30 ;
float privateKey60 ;
float privateKey100 ;
String Latitude;
String Longitude;
Preferences prefs;
Preferences prefsmem;
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "esp_task.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include <ArduinoOTA.h> // Библиотека для OTA-прошивки
#include <TimeLib.h>
#include "math.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <HTTPClient.h>
#include <Wire.h>
//wifii&server
#include <OneWire.h>
const char* ssid = "Gansta-Paradise.gps";
const char* password = "";
const char* host = "www.gansta-paradise-forum.ru";
int interval = 0;
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clockk[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
/*
This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
///unsigned char meteringTime = 0; // Время замера
///unsigned long startMillis = 0; // Начало отсчета
unsigned long startITOW = 0; // Начало отсчета из GPS
///unsigned long currentMillis = 0; // Текущее время
float speedKM = 0; //////скорость
char gpsSpeed[3]; // Буфер для строки с скоростью
int gpsSpeedKm = 0; // Скорость в км/ч
bool start = false; // Старт замера
long startMillis = 0; // Начало отсчета
long currentMillis = 0; // Текущее время
float meteringTime = 0; //
struct Metering
{
float accel30;
float accel60;
float accel100;
};
Metering metering;
int startzamer = 0;
#include <TinyGPS++.h>
TinyGPSPlus gps;
HardwareSerial Serial1(1);
void setup()
{
///// pinMode(D5, INPUT_PULLUP);
pinMode(32,INPUT_PULLUP);
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, 13, 15);
Serial.println();
Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"));
Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"));
Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------"));
lcd.init(); // initialize the lcd
lcd.backlight();
//lcd.createChar(0, bell);
//lcd.createChar(1, note);
lcd.createChar(2, clockk);
lcd.createChar(3, heart);
lcd.createChar(4, duck);
lcd.createChar(5, check);
lcd.createChar(6, cross);
lcd.createChar(7, retarrow);
lcd.home();
lcd.print("RAZGONOMETR...");
lcd.setCursor(0, 1);
lcd.printByte(3);
lcd.print("GANSTA-PARADISE");
delay(5000);
//displayKeyCodes();
lcd.clear();
}
void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
printInt(gps.location.age(), gps.location.isValid(), 5);
printDateTime(gps.date, gps.time);
printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.value()) : "*** ", 6);
lcd.home();
lcd.print(gps.location.lat(),5);
lcd.printByte(5);
lcd.print(gps.location.lng(),5);
lcd.setCursor(0, 1);
lcd.print(gps.speed.kmph());
lcd.printByte(4);
lcd.print("SPEED");
lcd.printByte(2);
lcd.print(interval);
delay(30);
speedKM = gps.speed.kmph();///////////////скорость..........вжжжжжж............
unsigned long distanceKmToLondon =
(unsigned long)TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON) / 1000;
printInt(distanceKmToLondon, gps.location.isValid(), 9);
double courseToLondon =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);
printFloat(courseToLondon, gps.location.isValid(), 7, 2);
const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);
printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);
printInt(gps.charsProcessed(), true, 6);
printInt(gps.sentencesWithFix(), true, 10);
printInt(gps.failedChecksum(), true, 9);
Serial.println();
smartDelay(1000);
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
interval++;
zamer();
if(digitalRead(32)==LOW){
lcd.clear();
startzamer++;
lcd.setCursor(0, 1);
lcd.print("STARTZAMER");
delay(10000);
lcd.setCursor(0, 0);
lcd.print("1");
delay(1000);
lcd.print("2");
delay(1000);
lcd.print("3-GO");
delay(1000);
////startrazgon();
}
/// Serial.println(interval);
if(interval>300&&gps.location.lat()>0){
/// delay(100);
sendtowebGPS();
delay(100);
interval = 0;
// lcd.init(); // initialize the lcd
// lcd.backlight();
// lcd.home();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("GPS-SEND");
delay(1000);
lcd.setCursor(0, 1);
///lcd.print( currentMillis);
lcd.print(gps.location.lat(),5);
lcd.printByte(5);
lcd.print(gps.location.lng(),5);
delay(10000);
lcd.clear();
}
////////////posl scob
if(interval==100){
lcd.clear();
}
if(interval==200){
lcd.clear();
}
if(interval==10){
lcd.clear();
}
if(interval==1){
lcd.clear();
}
///sendtowebGPS();
privateKey = gps.location.lat(),5;
privateKeyL=gps.location.lng(),5;
privateKeyS=gps.speed.kmph();
}
/////////////////////////////////////////////////END LOOP
// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (Serial1.available())
gps.encode(Serial1.read());
} while (millis() - start < ms);
}
static void printFloat(float val, bool valid, int len, int prec)
{
if (!valid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(' ');
}
smartDelay(0);
}
static void printInt(unsigned long val, bool valid, int len)
{
char sz[32] = "*****************";
if (valid)
sprintf(sz, "%ld", val);
sz[len] = 0;
for (int i=strlen(sz); i<len; ++i)
sz[i] = ' ';
if (len > 0)
sz[len-1] = ' ';
Serial.print(sz);
smartDelay(0);
}
static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
if (!d.isValid())
{
Serial.print(F("********** "));
}
else
{
char sz[32];
sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
Serial.print(sz);
}
if (!t.isValid())
{
Serial.print(F("******** "));
}
else
{
char sz[32];
sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
Serial.print(sz);
}
printInt(d.age(), d.isValid(), 5);
smartDelay(0);
}
static void printStr(const char *str, int len)
{
int slen = strlen(str);
for (int i=0; i<len; ++i)
Serial.print(i<slen ? str[i] : ' ');
smartDelay(0);
}
void zamer(){
// lcd.init(); // initialize the lcd
// lcd.backlight();
// lcd.home();
/// lcd.clear();
///lcd.setCursor(0, 0);
///lcd.print("ZAMER");
///delay(100);
///lcd.setCursor(0, 1);
///lcd.print( currentMillis);
//delay(100);
///delay(1000);
/// lcd.printByte(5);
currentMillis = millis();
gpsSpeedKm = gps.speed.kmph();
if (gpsSpeedKm > 0 ) {
// Если это был старт
if (!start) {
start = true;
startMillis = millis();
}
meteringTime = (float)(currentMillis - startMillis) / 1000; // Время замера
// Результаты замера
if (0.0 == metering.accel30 && gpsSpeedKm >= 30) {
metering.accel30 = meteringTime; // Разгон до 30км/ч
}
else if (0.0 == metering.accel60 && gpsSpeedKm >= 60) {
metering.accel60 = meteringTime; // Разгон до 60км/ч
}
else if (0.0 == metering.accel100 && gpsSpeedKm >= 100) {
metering.accel100 = meteringTime; // Разгон до 100км/ч
}
}
else if (start && 0 == gpsSpeedKm) { // Если остановились
start = false;
}
if ( startzamer > 0 &&meteringTime > 1 ) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ZAMER");
lcd.printByte(5);
lcd.print( metering.accel30);
lcd.printByte(5);
lcd.print( metering.accel60);
delay(100);
lcd.setCursor(0, 1);
lcd.print( metering.accel100);
delay(10000);
interval = 0;
startzamer = 0;
}
privateKey30 = metering.accel30 ;
privateKey60 = metering.accel60 ;
privateKey100 = metering.accel100 ;
}
///}
void sendtowebGPS(){
Serial.begin(115200);
delay(4000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
Serial.println(Latitude);
Serial.println(Latitude);
//// WiFiClient client;
delay(1000);
///HTTPClient client;
/// const char zuio = 546456;
///http.begin("http://www.gansta-paradise-forum.ru/gps.php?pak0=333"); //Specify the URL
/////http.begin("http://www.gansta-paradise-forum.ru");
///http.begin(response);
///http.POST("/gps.php?pak1=444POS");
////http.GET();
++value;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String url = "/gps.php?pak0=";
/// url += streamId;
/// url += "?private_key=";
Latitude = String(gps.location.lat(),5);
Longitude = String(gps.location.lng(),5);
url +=Latitude;
url += "&pak1=";
///url += gps.location.lng(),5;
url += Longitude;
url += "&pak2=";
url += privateKeyS;
url += "&pak3=";
url += privateKey30;
url += "&pak4=";
url += privateKey60;
url += "&pak5=";
url += privateKey100;
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while(client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
/// if (client.connect(host, 80))
/// {
/// client.print( "GET /gps.php?");
/// client.print( "/gps.php?");
/// client.print("pak0=");
/// client.print( gps.location.lat(),5);
/// client.print("&");
// client.print("&");
/// client.print("pak1=");
/// client.print( gps.location.lng(),5 );
/// client.print("&");
// client.print("&");
// client.print("pak2=");
// client.print( gps.speed.kmph() );
/// client.print("&");
/// client.print("&");
/// client.print("pak3=");
/// client.print( metering.accel30 );
/// client.print("&");
/// client.print("&");
// client.print("pak4=");
/// client.print( metering.accel60 );
/// client.print("&");
/// client.print("&");
/// client.print("pak5=");
/// client.print( metering.accel100 );
/// client.print("&");
// client.println( " HTTP/1.1");
/// client.print( "Host:" ); //////www.gansta-paradise.com
/// client.println(host);
/// client.println( "Connection: close" );
/// client.println();
/// client.println(); }
// else {
// If Arduino can't connect to the server (your computer or web page)
/// Serial.println("--> connection failed\n");
/// }
Serial.println("srabotalo-web-GPS");
///ESP.reset();
}
///////////////////памяти еще много есть где разгуляться ......//////////
пины могут на разных платах в разных местах быть ,суть не меняется ,главное номер!
со звуком звук на д12
Код: Выбрать все
/*****************************************
* ESP32 GPS VKEL 9600 Bds
******************************************/
//#include <TimeLib.h>
///#include "math.h"
///#include <WiFi.h>
///#include <WiFiClient.h>
///#include <HTTPClient.h>
///#include <Wire.h>
#include <stdio.h>;
#include <string.h>;
#include <stdlib.h>;
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "driver/gpio.h"
#include "driver/adc.h"
#include "esp32-hal-ledc.h"
#include <Preferences.h>
int value = 0;
const char* streamId = "....................";
double privateKey ;
double privateKeyL ;
float privateKeyS ;
float privateKey30 ;
float privateKey60 ;
float privateKey100 ;
String Latitude;
String Longitude;
/////////sound
int freq = 2000;
int channel = 0;
int resolution = 8;
Preferences prefs;
Preferences prefsmem;
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include "esp_err.h"
#include "esp_wifi.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "esp_task.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_log.h"
#include "sdkconfig.h"
#include <ArduinoOTA.h> // Библиотека для OTA-прошивки
#include <TimeLib.h>
#include "math.h"
#include <WiFi.h>
#include <WiFiClient.h>
#include <HTTPClient.h>
#include <Wire.h>
//wifii&server
#include <OneWire.h>
const char* ssid = "Gansta-Paradise.gps";
const char* password = "";
const char* host = "www.gansta-paradise-forum.ru";
int interval = 0;
#include <OneWire.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#if defined(ARDUINO) && ARDUINO >= 100
#define printByte(args) write(args);
#else
#define printByte(args) print(args,BYTE);
#endif
uint8_t bell[8] = {0x4,0xe,0xe,0xe,0x1f,0x0,0x4};
uint8_t note[8] = {0x2,0x3,0x2,0xe,0x1e,0xc,0x0};
uint8_t clockk[8] = {0x0,0xe,0x15,0x17,0x11,0xe,0x0};
uint8_t heart[8] = {0x0,0xa,0x1f,0x1f,0xe,0x4,0x0};
uint8_t duck[8] = {0x0,0xc,0x1d,0xf,0xf,0x6,0x0};
uint8_t check[8] = {0x0,0x1,0x3,0x16,0x1c,0x8,0x0};
uint8_t cross[8] = {0x0,0x1b,0xe,0x4,0xe,0x1b,0x0};
uint8_t retarrow[8] = { 0x1,0x1,0x5,0x9,0x1f,0x8,0x4};
LiquidCrystal_I2C lcd(0x3F,20,4); // set the LCD address to 0x27 for a 16 chars and 2 line display
/*
This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object.
It requires the use of SoftwareSerial, and assumes that you have a
4800-baud serial GPS device hooked up on pins 4(rx) and 3(tx).
*/
///unsigned char meteringTime = 0; // Время замера
///unsigned long startMillis = 0; // Начало отсчета
unsigned long startITOW = 0; // Начало отсчета из GPS
///unsigned long currentMillis = 0; // Текущее время
float speedKM = 0; //////скорость
char gpsSpeed[3]; // Буфер для строки с скоростью
int gpsSpeedKm = 0; // Скорость в км/ч
bool start = false; // Старт замера
long startMillis = 0; // Начало отсчета
long currentMillis = 0; // Текущее время
float meteringTime = 0; //
struct Metering
{
float accel30;
float accel60;
float accel100;
};
Metering metering;
int startzamer = 0;
#include <TinyGPS++.h>
TinyGPSPlus gps;
HardwareSerial Serial1(1);
void setup()
{
///// pinMode(D5, INPUT_PULLUP);
pinMode(32,INPUT_PULLUP);
pinMode(19,OUTPUT);
digitalWrite(19, LOW);
Serial.begin(115200);
Serial1.begin(9600, SERIAL_8N1, 13, 15);
Serial.println();
Serial.println(F("Sats HDOP Latitude Longitude Fix Date Time Date Alt Course Speed Card Distance Course Card Chars Sentences Checksum"));
Serial.println(F(" (deg) (deg) Age Age (m) --- from GPS ---- ---- to London ---- RX RX Fail"));
Serial.println(F("---------------------------------------------------------------------------------------------------------------------------------------"));
lcd.init(); // initialize the lcd
lcd.backlight();
//lcd.createChar(0, bell);
//lcd.createChar(1, note);
lcd.createChar(2, clockk);
lcd.createChar(3, heart);
lcd.createChar(4, duck);
lcd.createChar(5, check);
lcd.createChar(6, cross);
lcd.createChar(7, retarrow);
lcd.home();
lcd.print("RAZGONOMETR...");
lcd.setCursor(0, 1);
lcd.printByte(3);
lcd.print("GANSTA-PARADISE");
delay(5000);
//displayKeyCodes();
lcd.clear();
/////////////////sound
ledcSetup(channel, freq, resolution);
ledcAttachPin(12, channel);
}
void loop()
{
static const double LONDON_LAT = 51.508131, LONDON_LON = -0.128002;
printInt(gps.satellites.value(), gps.satellites.isValid(), 5);
printInt(gps.hdop.value(), gps.hdop.isValid(), 5);
printFloat(gps.location.lat(), gps.location.isValid(), 11, 6);
printFloat(gps.location.lng(), gps.location.isValid(), 12, 6);
printInt(gps.location.age(), gps.location.isValid(), 5);
printDateTime(gps.date, gps.time);
printFloat(gps.altitude.meters(), gps.altitude.isValid(), 7, 2);
printFloat(gps.course.deg(), gps.course.isValid(), 7, 2);
printFloat(gps.speed.kmph(), gps.speed.isValid(), 6, 2);
printStr(gps.course.isValid() ? TinyGPSPlus::cardinal(gps.course.value()) : "*** ", 6);
lcd.home();
lcd.print(gps.location.lat(),5);
lcd.printByte(5);
lcd.print(gps.location.lng(),5);
lcd.setCursor(0, 1);
lcd.print(gps.speed.kmph());
lcd.printByte(4);
lcd.print("SPEED");
lcd.printByte(2);
lcd.print(interval);
delay(30);
speedKM = gps.speed.kmph();///////////////скорость..........вжжжжжж............
unsigned long distanceKmToLondon =
(unsigned long)TinyGPSPlus::distanceBetween(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON) / 1000;
printInt(distanceKmToLondon, gps.location.isValid(), 9);
double courseToLondon =
TinyGPSPlus::courseTo(
gps.location.lat(),
gps.location.lng(),
LONDON_LAT,
LONDON_LON);
printFloat(courseToLondon, gps.location.isValid(), 7, 2);
const char *cardinalToLondon = TinyGPSPlus::cardinal(courseToLondon);
printStr(gps.location.isValid() ? cardinalToLondon : "*** ", 6);
printInt(gps.charsProcessed(), true, 6);
printInt(gps.sentencesWithFix(), true, 10);
printInt(gps.failedChecksum(), true, 9);
Serial.println();
smartDelay(1000);
if (millis() > 5000 && gps.charsProcessed() < 10)
Serial.println(F("No GPS data received: check wiring"));
interval++;
zamer();
if(digitalRead(32)==LOW){
lcd.clear();
startzamer++;
lcd.setCursor(0, 1);
lcd.print("STARTZAMER");
delay(10000);
lcd.setCursor(0, 0);
lcd.print("1");
delay(1000);
lcd.print("2");
delay(1000);
lcd.print("3-GO");
delay(1000);
startsound();
}
/// Serial.println(interval);
if(interval>300&&gps.location.lat()>0){
/// delay(100);
sendtowebGPS();
delay(100);
interval = 0;
// lcd.init(); // initialize the lcd
// lcd.backlight();
// lcd.home();
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("GPS-SEND");
delay(1000);
lcd.setCursor(0, 1);
///lcd.print( currentMillis);
lcd.print(gps.location.lat(),5);
lcd.printByte(5);
lcd.print(gps.location.lng(),5);
delay(10000);
lcd.clear();
}
////////////posl scob
if(interval==100){
lcd.clear();
}
if(interval==200){
lcd.clear();
}
if(interval==10){
lcd.clear();
}
if(interval==1){
lcd.clear();
}
///sendtowebGPS();
privateKey = gps.location.lat(),5;
privateKeyL=gps.location.lng(),5;
privateKeyS=gps.speed.kmph();
}
/////////////////////////////////////////////////END LOOP
// This custom version of delay() ensures that the gps object
// is being "fed".
static void smartDelay(unsigned long ms)
{
unsigned long start = millis();
do
{
while (Serial1.available())
gps.encode(Serial1.read());
} while (millis() - start < ms);
}
static void printFloat(float val, bool valid, int len, int prec)
{
if (!valid)
{
while (len-- > 1)
Serial.print('*');
Serial.print(' ');
}
else
{
Serial.print(val, prec);
int vi = abs((int)val);
int flen = prec + (val < 0.0 ? 2 : 1); // . and -
flen += vi >= 1000 ? 4 : vi >= 100 ? 3 : vi >= 10 ? 2 : 1;
for (int i=flen; i<len; ++i)
Serial.print(' ');
}
smartDelay(0);
}
static void printInt(unsigned long val, bool valid, int len)
{
char sz[32] = "*****************";
if (valid)
sprintf(sz, "%ld", val);
sz[len] = 0;
for (int i=strlen(sz); i<len; ++i)
sz[i] = ' ';
if (len > 0)
sz[len-1] = ' ';
Serial.print(sz);
smartDelay(0);
}
static void printDateTime(TinyGPSDate &d, TinyGPSTime &t)
{
if (!d.isValid())
{
Serial.print(F("********** "));
}
else
{
char sz[32];
sprintf(sz, "%02d/%02d/%02d ", d.month(), d.day(), d.year());
Serial.print(sz);
}
if (!t.isValid())
{
Serial.print(F("******** "));
}
else
{
char sz[32];
sprintf(sz, "%02d:%02d:%02d ", t.hour(), t.minute(), t.second());
Serial.print(sz);
}
printInt(d.age(), d.isValid(), 5);
smartDelay(0);
}
static void printStr(const char *str, int len)
{
int slen = strlen(str);
for (int i=0; i<len; ++i)
Serial.print(i<slen ? str[i] : ' ');
smartDelay(0);
}
void zamer(){
// lcd.init(); // initialize the lcd
// lcd.backlight();
// lcd.home();
/// lcd.clear();
///lcd.setCursor(0, 0);
///lcd.print("ZAMER");
///delay(100);
///lcd.setCursor(0, 1);
///lcd.print( currentMillis);
//delay(100);
///delay(1000);
/// lcd.printByte(5);
currentMillis = millis();
gpsSpeedKm = gps.speed.kmph();
if (gpsSpeedKm > 0 ) {
// Если это был старт
if (!start) {
start = true;
startMillis = millis();
}
meteringTime = (float)(currentMillis - startMillis) / 1000; // Время замера
// Результаты замера
if (0.0 == metering.accel30 && gpsSpeedKm >= 30) {
metering.accel30 = meteringTime; // Разгон до 30км/ч
}
else if (0.0 == metering.accel60 && gpsSpeedKm >= 60) {
metering.accel60 = meteringTime; // Разгон до 60км/ч
}
else if (0.0 == metering.accel100 && gpsSpeedKm >= 100) {
metering.accel100 = meteringTime; // Разгон до 100км/ч
}
}
else if (start && 0 == gpsSpeedKm) { // Если остановились
start = false;
}
if ( startzamer > 0 &&meteringTime > 1 ) {
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("ZAMER");
lcd.printByte(5);
lcd.print( metering.accel30);
lcd.printByte(5);
lcd.print( metering.accel60);
delay(100);
lcd.setCursor(0, 1);
lcd.print( metering.accel100);
delay(10000);
interval = 0;
startzamer = 0;
}
privateKey30 = metering.accel30 ;
privateKey60 = metering.accel60 ;
privateKey100 = metering.accel100 ;
}
///}
void sendtowebGPS(){
Serial.begin(115200);
delay(4000);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(1000);
Serial.println("Connecting to WiFi..");
}
Serial.println("Connected to the WiFi network");
Serial.println(Latitude);
Serial.println(Latitude);
//// WiFiClient client;
delay(1000);
///HTTPClient client;
/// const char zuio = 546456;
///http.begin("http://www.gansta-paradise-forum.ru/gps.php?pak0=333"); //Specify the URL
/////http.begin("http://www.gansta-paradise-forum.ru");
///http.begin(response);
///http.POST("/gps.php?pak1=444POS");
////http.GET();
++value;
Serial.print("connecting to ");
Serial.println(host);
// Use WiFiClient class to create TCP connections
WiFiClient client;
const int httpPort = 80;
if (!client.connect(host, httpPort)) {
Serial.println("connection failed");
return;
}
// We now create a URI for the request
String url = "/gps.php?pak0=";
/// url += streamId;
/// url += "?private_key=";
Latitude = String(gps.location.lat(),5);
Longitude = String(gps.location.lng(),5);
url +=Latitude;
url += "&pak1=";
///url += gps.location.lng(),5;
url += Longitude;
url += "&pak2=";
url += privateKeyS;
url += "&pak3=";
url += privateKey30;
url += "&pak4=";
url += privateKey60;
url += "&pak5=";
url += privateKey100;
Serial.print("Requesting URL: ");
Serial.println(url);
// This will send the request to the server
client.print(String("GET ") + url + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
// Read all the lines of the reply from server and print them to Serial
while(client.available()) {
String line = client.readStringUntil('\r');
Serial.print(line);
}
Serial.println();
Serial.println("closing connection");
/// if (client.connect(host, 80))
/// {
/// client.print( "GET /gps.php?");
/// client.print( "/gps.php?");
/// client.print("pak0=");
/// client.print( gps.location.lat(),5);
/// client.print("&");
// client.print("&");
/// client.print("pak1=");
/// client.print( gps.location.lng(),5 );
/// client.print("&");
// client.print("&");
// client.print("pak2=");
// client.print( gps.speed.kmph() );
/// client.print("&");
/// client.print("&");
/// client.print("pak3=");
/// client.print( metering.accel30 );
/// client.print("&");
/// client.print("&");
// client.print("pak4=");
/// client.print( metering.accel60 );
/// client.print("&");
/// client.print("&");
/// client.print("pak5=");
/// client.print( metering.accel100 );
/// client.print("&");
// client.println( " HTTP/1.1");
/// client.print( "Host:" ); //////www.gansta-paradise.com
/// client.println(host);
/// client.println( "Connection: close" );
/// client.println();
/// client.println(); }
// else {
// If Arduino can't connect to the server (your computer or web page)
/// Serial.println("--> connection failed\n");
/// }
Serial.println("srabotalo-web-GPS");
///ESP.reset();
}
void startsound() {
ledcWrite(channel, 125);
for (int freq = 255; freq < 1500; freq = freq + 250){
Serial.println(freq);
ledcWriteTone(channel, freq);
delay(1000);
}
ledcWrite(channel, 1500);
delay(500);
ledcWrite(channel, 0);
delay(500);
ledcWrite(channel, 1500);
delay(500);
ledcWrite(channel, 0);
delay(500);
ledcWrite(channel, 1500);
delay(500);
ledcWrite(channel, 0);
delay(500);
ledcWrite(channel, 1500);
delay(1500);
ledcWrite(channel, 0);
}
///////////////////памяти еще много есть где разгуляться ......//////////