Components and supplies
Arduino Nano R3
GPS Module (Generic)
Tools and machines
PCB Holder, Soldering Iron
Soldering iron (generic)
Solder Wire, Lead Free
Project description
Code
ibus library
ibus library
iBUS_telemetrie_altitude_voltage_vitesse_coord_divtension.ino
arduino
telemetry turnigy
1 2#include <iBUSTelemetry.h> //https://github.com/adis1313/iBUSTelemetry-Arduino 3#include <Wire.h> 4#include <TinyGPS++.h> 5#include <SPI.h> 6#include <SD.h> 7 8//pin pour carte SD 9const int cs_sd=2; 10 11TinyGPSPlus gps; 12 13#define UPDATE_INTERVAL 500 14 15// pin voltage 16#define dP A0 17 18iBUSTelemetry telemetry(9); // arduino pin pour donnes iBUS 19 20 21 uint32_t prevMillis =0; // neessaire pour updateValues() 22 23 //LED 24 25 const int verte = 3; 26 const int rouge = 4; 27 28 float maxspeed = 0, speed1 = 0; 29 int maxhigh = 0, high1 = 0; 30 int maxsatelite = 0, satelite1 = 0; 31 32 float meters ; 33 float voltage=0.0; 34 35void setup() 36{ 37 Serial.begin(9600); 38 39 40 pinMode(rouge, OUTPUT); 41 pinMode(verte, OUTPUT); 42 43 //Condition vrifiant si la carte SD est prsente dans l'appareil 44 45if(!SD.begin(cs_sd)) 46 { 47 48 digitalWrite(rouge, HIGH);//absence SD 49 return; 50 } 51 52 digitalWrite(rouge, LOW);// carte SD absente 53 54 File data = SD.open("donnees.txt",FILE_WRITE); // Ouvre le fichier "donnees.txt" 55 data.println(""); data.println("Demarrage acquisition ibus"); // Ecrit dans ce fichier 56 data.println(""); data.println("date heure latitude longitude altitude vitesse"); 57 data.close(); 58 59 Wire.begin(); 60 telemetry.begin(); 61 62 // definition capteurs 63 64 telemetry.addSensor(IBUS_MEAS_TYPE_ALT); //altitude 65 telemetry.addSensor(IBUS_MEAS_TYPE_EXTV); //batterie 66 telemetry.addSensor(IBUS_MEAS_TYPE_SPE); //vitesse km/h 67 telemetry.addSensor(IBUS_MEAS_TYPE_GPS_LAT); // latitude 68 telemetry.addSensor(IBUS_MEAS_TYPE_GPS_LON); // longitde 69 70 71} 72 73void loop() 74{ 75 76 updateValues(); 77 telemetry.run(); 78} 79 80void updateValues() 81{ 82 83// lecture donnes Gps et allumage LED si OK 84 85 if (Serial.available()) { 86 digitalWrite(verte, HIGH);//donnes Gps OK 87 gps.encode(Serial.read()); 88} 89 90 91 92 93 94 float meters = (gps.altitude.meters()); 95 voltage=float(analogRead(dP))*(20/1023.00); 96 float airSpeed = (gps.speed.kmph()); 97 98// definition vitesse max 99 100 speed1 = (gps.speed.kmph()); 101 if ( speed1 > maxspeed) { 102 maxspeed = speed1; 103 } 104 105 106 // recuperation date et heure du GPS pour datalogging 107 108 String Temps=String(gps.time.hour()+1)+(":")+(gps.time.minute())+(":")+(gps.time.second()); 109 String Date=String(gps.date.day())+("/")+(gps.date.month())+("/")+(gps.date.year()); 110 111// Temporisation 112 113 uint32_t currMillis = millis(); 114 115 if (currMillis - prevMillis >= UPDATE_INTERVAL) { // Code in the middle of these brackets will be performed every 500ms. 116 prevMillis = currMillis; 117 118 119// affichage donnes capteur sur radiocommande 120 121 telemetry.setSensorValue(1, (meters )*100.0 ); // altitude 122 123 telemetry.setSensorValue(2, voltage*100 ); 124 125 telemetry.setSensorValue(3, speed1 ); 126 127 telemetry.setSensorValue(4, (gps.location.lat()*10000000)); 128 129 telemetry.setSensorValue(5, (gps.location.lng()*10000000)) ; 130 131 132 133 // Ecriture des donnes dans le fichier texte 134 135 136 File data=SD.open("donnees.txt",FILE_WRITE); 137 138 data.println(Date + " " + Temps + " " + String(gps.location.lat(), 6)+" "+String(gps.location.lng(), 6)+(" ")+String(gps.altitude.meters(),0)+(" ")+String(speed1)+(" ")+String(maxspeed)); 139 data.close(); 140 } 141} 142
iBUS_telemetrie_altitude_voltage_vitesse_coord_divtension.ino
arduino
telemetry turnigy
1 2#include <iBUSTelemetry.h> //https://github.com/adis1313/iBUSTelemetry-Arduino 3#include 4 <Wire.h> 5#include <TinyGPS++.h> 6#include <SPI.h> 7#include <SD.h> 8 9//pin 10 pour carte SD 11const int cs_sd=2; 12 13TinyGPSPlus gps; 14 15#define UPDATE_INTERVAL 16 500 17 18// pin voltage 19#define dP A0 20 21iBUSTelemetry telemetry(9); // 22 arduino pin pour donnes iBUS 23 24 25 uint32_t prevMillis =0; // neessaire 26 pour updateValues() 27 28 //LED 29 30 const int verte = 3; 31 const 32 int rouge = 4; 33 34 float maxspeed = 0, speed1 = 0; 35 int maxhigh = 36 0, high1 = 0; 37 int maxsatelite = 0, satelite1 = 0; 38 39 float meters ; 40 41 float voltage=0.0; 42 43void setup() 44{ 45 Serial.begin(9600); 46 47 48 49 pinMode(rouge, OUTPUT); 50 pinMode(verte, OUTPUT); 51 52 //Condition 53 vrifiant si la carte SD est prsente dans l'appareil 54 55if(!SD.begin(cs_sd)) 56 57 { 58 59 digitalWrite(rouge, HIGH);//absence SD 60 return; 61 62 } 63 64 digitalWrite(rouge, LOW);// carte SD absente 65 66 File data = 67 SD.open("donnees.txt",FILE_WRITE); // Ouvre le fichier "donnees.txt" 68 69 data.println(""); data.println("Demarrage acquisition ibus"); // Ecrit dans 70 ce fichier 71 data.println(""); data.println("date heure latitude 72 longitude altitude vitesse"); 73 data.close(); 74 75 Wire.begin(); 76 77 telemetry.begin(); 78 79 // definition capteurs 80 81 telemetry.addSensor(IBUS_MEAS_TYPE_ALT); 82 //altitude 83 telemetry.addSensor(IBUS_MEAS_TYPE_EXTV); //batterie 84 telemetry.addSensor(IBUS_MEAS_TYPE_SPE); 85 //vitesse km/h 86 telemetry.addSensor(IBUS_MEAS_TYPE_GPS_LAT); // latitude 87 88 telemetry.addSensor(IBUS_MEAS_TYPE_GPS_LON); // longitde 89 90 91} 92 93void 94 loop() 95{ 96 97 updateValues(); 98 telemetry.run(); 99} 100 101void 102 updateValues() 103{ 104 105// lecture donnes Gps et allumage LED si OK 106 107 if 108 (Serial.available()) { 109 digitalWrite(verte, HIGH);//donnes Gps OK 110 gps.encode(Serial.read()); 111} 112 113 114 115 116 117 118 float meters = (gps.altitude.meters()); 119 voltage=float(analogRead(dP))*(20/1023.00); 120 121 float airSpeed = (gps.speed.kmph()); 122 123// definition vitesse max 124 125 126 speed1 = (gps.speed.kmph()); 127 if ( speed1 > maxspeed) { 128 maxspeed 129 = speed1; 130 } 131 132 133 // recuperation date et heure du GPS pour datalogging 134 135 136 String Temps=String(gps.time.hour()+1)+(":")+(gps.time.minute())+(":")+(gps.time.second()); 137 138 String Date=String(gps.date.day())+("/")+(gps.date.month())+("/")+(gps.date.year()); 139 140// 141 Temporisation 142 143 uint32_t currMillis = millis(); 144 145 if (currMillis 146 - prevMillis >= UPDATE_INTERVAL) { // Code in the middle of these brackets will 147 be performed every 500ms. 148 prevMillis = currMillis; 149 150 151// 152 affichage donnes capteur sur radiocommande 153 154 telemetry.setSensorValue(1, 155 (meters )*100.0 ); // altitude 156 157 telemetry.setSensorValue(2, voltage*100 158 ); 159 160 telemetry.setSensorValue(3, speed1 ); 161 162 telemetry.setSensorValue(4, 163 (gps.location.lat()*10000000)); 164 165 telemetry.setSensorValue(5, (gps.location.lng()*10000000)) 166 ; 167 168 169 170 // Ecriture des donnes dans le fichier texte 171 172 173 174 File data=SD.open("donnees.txt",FILE_WRITE); 175 176 data.println(Date 177 + " " + Temps + " " + String(gps.location.lat(), 6)+" "+String(gps.location.lng(), 178 6)+(" ")+String(gps.altitude.meters(),0)+(" ")+String(speed1)+(" ")+String(maxspeed)); 179 180 data.close(); 181 } 182} 183
ibus library
ibus library
Downloadable files
untitled
untitled
Comments
Only logged in users can leave comments