A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By Jaison
#90641 Hello . Good afternoon. I would like to ask for help, I don't know much about programming, I would like to integrate an aprs.fi information sending program into your program, following the model of the program I received from an Italian amateur radio friend. Thank you very much in advance.
*
* This sketch sends data via HTTP GET requests to data.sparkfun.com service.
*
* You need to get streamId and privateKey at data.sparkfun.com and paste them
* below. Or just customize this script to talk to other HTTP servers.
*
*/
#include <Wire.h>
#include <ESP8266WiFi.h>
#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
// WiFi credentials.
const char* WIFI_SSID = "XXXXX";
const char* WIFI_PASS = "YYYYY";
Adafruit_BME280 bme; // I2C
float h, t, p, pin, dp;
char temperatureFString[6];
char dpString[6];
char humidityString[6];
char pressureString[7];
char pressureInchString[6];
char tmp_buffer[20];
const char* APRSisHost = "rotate.aprs2.net";
const uint16_t APRSPort = 14580;
//*************************************************
// local function
//*************************************************
void getWeather() {
h = bme.readHumidity();
t = bme.readTemperature();
t = t*1.8+32.0; // to Fahrenheit
dp = t-0.36*(100.0-h);
p = (bme.readPressure()/100.0F + 26.1) * 10;
pin = 0.02953*p;
dtostrf(t, 5, 1, temperatureFString);
dtostrf(h, 5, 1, humidityString);
dtostrf(p, 6, 1, pressureString);
dtostrf(pin, 5, 2, pressureInchString);
dtostrf(dp, 5, 1, dpString);
delay(100);
}
//*************************************************
void Connect_WIFI() {
// Connect to Wifi.
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(WIFI_SSID);
WiFi.begin(WIFI_SSID, WIFI_PASS);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
Serial.println("Connected!");
Serial.println("This device is now ready for use!");
}
//*************************************************
void APRS_WeatherReport() {
getWeather();
// We now create a URI for the request
//String DataPkt = "IW2ESL-11>APRS,WIDE2-1:=4607.93N/00934.85E_000/000g000t";
// CHANGE THIS INFORMATION WITH YOUR CALLSIGN AND YOUR GPS COORTINATES
String DataPkt = "IW2ESL-11>APRS,WIDE2-1:=4607.93N/00934.85E_000/000g000t";
snprintf(tmp_buffer, 4, "%03d", (int)(t));
DataPkt += tmp_buffer;
DataPkt += "h";
snprintf(tmp_buffer, 4, "%02d", (int)(h));
DataPkt += tmp_buffer;
DataPkt += "b";
snprintf(tmp_buffer, 6, "%05d", (int)(p));
DataPkt += tmp_buffer;
DataPkt += " ESP-8266 tx data test 014";
Serial.println(temperatureFString);
Serial.println(humidityString);
Serial.println(pressureString);
Serial.println("Sending Data: ");
Serial.println(DataPkt);
//while(true) ESP.wdtFeed();
Serial.print("connecting to ");
Serial.println(APRSisHost);
// Use WiFiClient class to create TCP connections
WiFiClient client;
if (!client.connect(APRSisHost, APRSPort)) {
Serial.println("connection failed");
return;
}
// CHANGE LOGIN STRING INFORMATION WITH YOUR CALLSIGN AND
// YOUR APR INTERNET PASSWORD (SEARCH TO FIND HOW TO HAVE ONE)
//String LoginPkt = "user IW2ESL pass 12345 vers esp8266_WX 0.0";
String LoginPkt = "user YOURCALLSIGN pass 12345 vers esp8266_WX 0.0";
Serial.println("Sending Login: ");
Serial.println(LoginPkt);
client.print(LoginPkt + "\r\n");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
while (true){ESP.wdtFeed();};
}
}
// Read all the lines of the reply from server and print them to Serial
int Verified=0;
while(client.available()){
String line = client.readStringUntil('\r');
if (line.indexOf("verified") > 0) {
Verified=1;
}
Serial.print(line);
}
if(Verified == 1)
Serial.println("Server verified OK");
Serial.println("Sending Data: ");
Serial.println(DataPkt);
// DO NOT SEND FOR TESTING
client.print(DataPkt + "\r\n");
if (client.connected()) {
Serial.println();
Serial.println("disconnecting.");
client.stop();
}
}
//*************************************************
void setup() {
Serial.begin(115200);
Serial.setTimeout(2000);
// Wait for serial to initialize.
while (!Serial) { }
Serial.println("Device Started");
Serial.println("-------------------------------------");
Serial.println("Running Deep Sleep Firmware!");
Serial.println("-------------------------------------");
Serial.println("Initialising I2C BME280 sensor ..");
Wire.begin(D2, D1); // SDA,SCL
Wire.setClock(100000);
if (!bme.begin()) {
Serial.println("Could not find a valid BME280 sensor, check wiring!");
while (1);
}
Connect_WIFI();
APRS_WeatherReport();
Serial.println("Going into deep sleep for 20 seconds");
ESP.deepSleep(350e6); // 350e6
}
//*************************************************
void loop() {
}