projekte:arduino_projekte:lora:rangetest
Dies ist eine alte Version des Dokuments!
pt1000 tx
Übersicht
Ein kleiner Rangetest. Es wird einfach die Entfernung zum Target übertragen.
Bei static const double target_lat = 53.000000, target_lon = 8.000000; bitte die eigenen Koordinaten eingeben. Unter static const uint32_t GPSBaud = 9600; bitte je nach GPS die Baudrate anpassen.
Links
Bitte die Librarys von hier installieren!, hier habe ich auch den Original Code her:Simple_temp https://github.com/CongducPham/LowCostLoRaGw
Material
Folgendes wird benötigt:
- PT1000
- 1000Ohm Widerstand
- Arduino
- SX1278 (Oder SX1276)
Aufbau
Spannungsteiler: AREF → 1000Ohm A0 → PT1000→ GND Also ein 1:2 Spannungsteiler Oder von pin 8 → 1000Ohm ….. Für Low Power, der Sensor wird beim nicht gebrauch abgeschaltet.
Code
- PT1000_TX.ino
/* temperature sensor on analog 8 to test the LoRa gateway extended version with AES and custom Carrier Sense features Copyright (C) 2016 Congduc Pham, University of Pau, France This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with the program. If not, see <http://www.gnu.org/licenses/>. ***************************************************************************** last update: Nov. 26th by C. Pham */ #include <TinyGPS++.h> #include <SoftwareSerial.h> /* 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). */ static const int RXPin = 4, TXPin = 3; static const uint32_t GPSBaud = 9600; // The TinyGPS++ object TinyGPSPlus gps; // The serial connection to the GPS device SoftwareSerial ss(RXPin, TXPin); #include <SPI.h> // Include the SX1272 #include "SX1272.h" #define DEFAULT_DEST_ADDR 1 int e; void setup() { int e; Serial.begin(38400); ss.begin(GPSBaud); // Power ON the module sx1272.ON(); // Set transmission mode and print the result e = sx1272.setMode(4); sx1272._enableCarrierSense = true; e = sx1272.setChannel(CH_00_433); sx1272._needPABOOST = true; e = sx1272.setPowerDBM(14); e = sx1272.setNodeAddress(8); delay(500); Serial.println("Setup ready"); } uint32_t distancetoTarget = 0; void loop(void) { while (ss.available()) gps.encode(ss.read()); //sx1272.CarrierSense(); sx1272.setPacketType(PKT_TYPE_DATA); if (gps.location.isValid()) { static const double target_lat = 53.000000, target_lon = 8.000000; distancetoTarget = (unsigned long)TinyGPSPlus::distanceBetween( gps.location.lat(), gps.location.lng(), target_lat, target_lon); //printInt(distanceKmToLondon, gps.location.isValid(), 9); Serial.println(distancetoTarget); char disbuffer [33]; uint8_t message[100]; itoa (distancetoTarget, disbuffer, 10); int r_size=sprintf((char*)message, disbuffer); e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, disbuffer, r_size,1000); } else { e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, "No GPS"); Serial.println("No GPS Fix"); } delay(1000); }
projekte/arduino_projekte/lora/rangetest.1490123146.txt.gz · Zuletzt geändert: 2022-11-17 22:34 (Externe Bearbeitung)