mirror of
https://github.com/timmbogner/Farm-Data-Relay-System
synced 2024-11-08 13:10:29 +00:00
Delete Sensors/GPS_8266 directory
This commit is contained in:
parent
10514e2885
commit
5a38515593
@ -1,7 +0,0 @@
|
||||
|
||||
typedef struct DataReading {
|
||||
float d;
|
||||
uint16_t id;
|
||||
uint8_t t;
|
||||
|
||||
} DataReading;
|
@ -1,89 +0,0 @@
|
||||
// FARM DATA RELAY SYSTEM
|
||||
//
|
||||
// BMP280 SENSOR MODULE
|
||||
//
|
||||
// Developed by Timm Bogner (bogner1@gmail.com) for Sola Gratia Farm in Urbana, Illinois, USA.
|
||||
// Each sensor is assigned a two-byte identifier along with a one-byte sensor type
|
||||
//
|
||||
|
||||
#define TERM_MAC 0x00 //Terminal MAC
|
||||
#define SLEEPYTIME 15 //Time to sleep in seconds
|
||||
#define TEMP_ID 1 //Unique ID (0 - 255) for each data reading
|
||||
|
||||
|
||||
#define BASE_LAT
|
||||
#define BASE_LON
|
||||
#include <SoftwareSerial.h>
|
||||
|
||||
#include <ESP8266WiFi.h>
|
||||
#include <espnow.h>
|
||||
#include <TinyGPS++.h>
|
||||
#include "DataReading.h"
|
||||
|
||||
static const int RXPin = D5, TXPin = D6;
|
||||
SoftwareSerial ss(RXPin, TXPin);
|
||||
static const uint32_t GPSBaud = 9600;
|
||||
|
||||
TinyGPSPlus gps;
|
||||
unsigned int delay_time = 0;
|
||||
|
||||
uint8_t broadcastAddress[] = {0xAA, 0xBB, 0xCC, 0xDD, 0xEE, TERM_MAC};
|
||||
int wait_time = 0;
|
||||
|
||||
void OnDataSent(uint8_t *mac_addr, uint8_t sendStatus) {
|
||||
Serial.print("Last Packet Send Status: ");
|
||||
if (sendStatus == 0) {
|
||||
Serial.println("Delivery success");
|
||||
}
|
||||
else {
|
||||
Serial.println("Delivery fail");
|
||||
}
|
||||
}
|
||||
|
||||
void sendPing() {
|
||||
DataReading myLat;
|
||||
myLat.d = gps.location.lat();
|
||||
myLat.t = 20;
|
||||
myLat.id = 0;
|
||||
Serial.println(gps.location.lat());
|
||||
DataReading myLon;
|
||||
myLon.d = gps.location.lng();
|
||||
myLon.t = 21;
|
||||
myLon.id = 1;
|
||||
|
||||
DataReading myDist;
|
||||
myDist.d = TinyGPSPlus::distanceBetween(gps.location.lat(), gps.location.lng(), BASE_LAT, BASE_LON);
|
||||
myDist.t = 23;
|
||||
myDist.id = 2;
|
||||
DataReading myData[3];
|
||||
myData[0] = myLat;
|
||||
myData[1] = myLon;
|
||||
myData[2] = myDist;
|
||||
esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
|
||||
}
|
||||
|
||||
void setup() {
|
||||
ss.begin(GPSBaud);
|
||||
|
||||
Serial.begin(9600);
|
||||
if (esp_now_init() != 0) {
|
||||
return;
|
||||
}
|
||||
esp_now_set_self_role(ESP_NOW_ROLE_COMBO);
|
||||
esp_now_register_send_cb(OnDataSent);
|
||||
// Register peer
|
||||
esp_now_add_peer(broadcastAddress, ESP_NOW_ROLE_COMBO, 0, NULL, 0);
|
||||
Serial.println("GPS init");
|
||||
}
|
||||
|
||||
void loop() {
|
||||
while (ss.available() > 0)
|
||||
if (gps.encode(ss.read()))
|
||||
{
|
||||
// sendPing();
|
||||
}
|
||||
if (millis() > delay_time) {
|
||||
delay_time = millis() + (SLEEPYTIME * 1000);
|
||||
sendPing();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user