projekte:arduino_projekte:lora:rangetest
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
Beide Seiten der vorigen RevisionVorhergehende ÜberarbeitungNächste Überarbeitung | Vorhergehende Überarbeitung | ||
projekte:arduino_projekte:lora:rangetest [2017-03-21 20:06] – gamecompiler | projekte:arduino_projekte:lora:rangetest [2021-03-27 09:57] (aktuell) – gelöscht gamecompiler | ||
---|---|---|---|
Zeile 1: | Zeile 1: | ||
- | ====== Lora Rangetest 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!, | ||
- | https:// | ||
- | |||
- | http:// | ||
- | |||
- | http:// | ||
- | |||
- | ===== Material ===== | ||
- | |||
- | Folgendes wird benötigt: | ||
- | * Arduino | ||
- | * GPS | ||
- | * Arduino | ||
- | * SX1278 (Oder SX1276) | ||
- | |||
- | |||
- | ===== Code ===== | ||
- | |||
- | <file lang=" | ||
- | /* | ||
- | 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. | ||
- | GNU General Public License for more details. | ||
- | |||
- | You should have received a copy of the GNU General Public License | ||
- | along with the program. | ||
- | |||
- | | ||
- | last update: Nov. 26th by C. Pham | ||
- | */ | ||
- | |||
- | #include < | ||
- | #include < | ||
- | /* | ||
- | This sample code demonstrates the normal use of a TinyGPS++ (TinyGPSPlus) object. | ||
- | It requires the use of SoftwareSerial, | ||
- | | ||
- | */ | ||
- | 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 < | ||
- | // Include the SX1272 | ||
- | #include " | ||
- | |||
- | #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(" | ||
- | } | ||
- | uint32_t distancetoTarget = 0; | ||
- | void loop(void) | ||
- | { | ||
- | while (ss.available()) | ||
- | gps.encode(ss.read()); | ||
- | |||
- | |||
- | |||
- | // | ||
- | |||
- | sx1272.setPacketType(PKT_TYPE_DATA); | ||
- | if (gps.location.isValid()) | ||
- | static const double target_lat = 53.000000, target_lon = 8.000000; | ||
- | distancetoTarget = | ||
- | (unsigned long)TinyGPSPlus:: | ||
- | gps.location.lat(), | ||
- | gps.location.lng(), | ||
- | target_lat, | ||
- | target_lon); | ||
- | // | ||
- | Serial.println(distancetoTarget); | ||
- | char disbuffer [33]; | ||
- | uint8_t message[100]; | ||
- | itoa (distancetoTarget, | ||
- | | ||
- | int r_size=sprintf((char*)message, | ||
- | e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, | ||
- | } | ||
- | else { | ||
- | e = sx1272.sendPacketTimeout(DEFAULT_DEST_ADDR, | ||
- | Serial.println(" | ||
- | } | ||
- | |||
- | |||
- | delay(1000); | ||
- | |||
- | } | ||
- | </ |
projekte/arduino_projekte/lora/rangetest.1490123199.txt.gz · Zuletzt geändert: 2022-11-17 22:34 (Externe Bearbeitung)