diff --git a/arduino/SDcard/config.txt b/arduino/SDcard/config.txt deleted file mode 100755 index 4f30564..0000000 --- a/arduino/SDcard/config.txt +++ /dev/null @@ -1,4 +0,0 @@ -#Fichier de configuration du contrôleur du projet -# Camétéo -time_step=2000 -data_file=datalog3.csv \ No newline at end of file diff --git a/arduino/cameteo-teensy-bug/cameteo-teensy/RaspBerryPi_COM.cpp b/arduino/cameteo-teensy-bug/cameteo-teensy/RaspBerryPi_COM.cpp deleted file mode 100755 index 08976cc..0000000 --- a/arduino/cameteo-teensy-bug/cameteo-teensy/RaspBerryPi_COM.cpp +++ /dev/null @@ -1,42 +0,0 @@ - -#include "cameteo_teensy.h" - -void stopRPI() { - //Stop the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN) - - pinMode(RPI_PWR_PIN, INPUT); //Eteint via le MOSFET - rpi_status = false; -} - -bool isStartedPI() { - //Return true if the R-Pi respond to an simple request - return rpi_status; -} - -void startRPI() { - //Start the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN) - if (!isStartedPI()) { - pinMode(RPI_PWR_PIN, OUTPUT); - digitalWrite(RPI_PWR_PIN, LOW); - rpi_status = true; - } -} - -void sendDataToSerial(String data) { - if (isStartedPI()) { - char c[100]; // char buffer for conversion String->char - data.toCharArray(c, sizeof(data)); //convert data string to char array - -// //start serial comm. if needed -// if(!SERIAL_PORT) { -// SERIAL_PORT.begin(SERIAL_BAUD_RATE); -// //while(!SERIAL_PORT); -// } - - SERIAL_PORT.print(c); // send data on serial port - - } - else { - //error RPI is not started - } -} diff --git a/arduino/cameteo-teensy-bug/cameteo-teensy/SerialMessages.cpp b/arduino/cameteo-teensy-bug/cameteo-teensy/SerialMessages.cpp deleted file mode 100755 index f70c4a2..0000000 --- a/arduino/cameteo-teensy-bug/cameteo-teensy/SerialMessages.cpp +++ /dev/null @@ -1,55 +0,0 @@ - -#include "cameteo_teensy.h" - -void BootMessage(String s) { - char c[13]; // char buffer for conversion String->char - s.toCharArray(c, sizeof(s)); - SERIAL_PORT.printf("%-12s", c); -} - -void BootOK() { - SERIAL_PORT.println("OK"); -} - -void BootError() { - SERIAL_PORT.println("EE"); -} - -void sendDataOnSerial() { - - //Print date & hour on serial port - SERIAL_PORT.printf("%04d/%02d/%02d_%02d:%02d:%02d\n", year(), month(), day(), hour(), minute(), second()); - -// if (isnan(dht22_event_hum.relative_humidity) || -// isnan(dht22_event_temp.temperature)) { -// SERIAL_PORT.printf("Failed to read from DHT sensor!\n"); -// } -// else { -// SERIAL_PORT.printf("Temperature:%8.2f %cC | Humidity:%8.0f %%\n", -// dht22_event_temp.temperature, DEGREE, dht22_event_hum.relative_humidity); -// } - -// if (bme280_event.pressure) { - SERIAL_PORT.printf("Temperature:%8.2f %cC | Humidity: %8.2f % | Pressure: %8.2f hPa | Altitude:%8.2f m\n", - bme280_temp, DEGREE, bme280_press, bme280_alti); -// } -// else { -// SERIAL_PORT.printf("BME280 Sensor error\n"); -// } - - SERIAL_PORT.printf("Lightning strikes (from start) : %d | Perturb.: %d | Noise : %d | Unknown detect.: %d\n", lightning_nb_total, - as3935_perturb_total, - as3935_noise_total, - as3935_unknown_total); - - //SERIAL_PORT.printf("Temperature:%8.2f %cC\n", tcn75a_temp, DEGREE); - - SERIAL_PORT.printf("GPS data: %04d/%02d/%02d_%02d:%02d:%02d (%d)\n", gps_year, gps_month, gps_day, - gps_hour, gps_minutes, gps_second, - gps_fix_age); - SERIAL_PORT.printf(" Latitude: %11.8f | Longitude: %11.8f | Altitude: %5.2f m\n", gps_latitude, gps_longitude, gps_altitude); - SERIAL_PORT.printf(" Speed: %4.1f km/h | Course : %4.1f %c\n", gps_speed, gps_course, DEGREE); - SERIAL_PORT.printf(" Chars: %11d | Sentences: %11d | Failed cheksum: %4d\n", gps_chars, gps_sentences, gps_failed_checksum); - - SERIAL_PORT.printf("Battery : %10d mV | Low Battery : %d\n", batt_voltage, low_battery_flag); -} diff --git a/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo-teensy.ino b/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo-teensy.ino deleted file mode 100755 index 3bf0cf6..0000000 --- a/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo-teensy.ino +++ /dev/null @@ -1,36 +0,0 @@ -/* - * CAMETEO project - * - * This is a personnal project of weather station with - * automatic photo taking. - * This code is the weather station part and is meant - * to be run on a PJRC Teensy 3.2 board. - * - * Author : Arofarn - * - * Licence : GPL v3 - * - */ - -//Protocols -#include // library used with I2C protocol -#include // SPI protocol - -//Teensy3.x Real Time Clock -#include - -//SD card -#include - -// Sensors -#include // Generic -//#include // DHT22 -//#include // DHT22 unified -//#include // BMP180 -#include // BME280 -#include - -//GPS -//#include // Adafruit Ultimate GPS -#include //Builtin GPS lib - diff --git a/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo.cpp b/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo.cpp deleted file mode 100755 index 6ca1aca..0000000 --- a/arduino/cameteo-teensy-bug/cameteo-teensy/cameteo.cpp +++ /dev/null @@ -1,399 +0,0 @@ -/* - * CAMETEO project - * - * This is a personnal project of weather station with - * automatic photo taking. - * This code is the weather station part and is meant - * to be run on a PJRC Teensy 3.2 board. - * - * Author : Arofarn - * - * Licence : GPL v3 - * - */ - -#include - -#include "cameteo_teensy.h" -#include "SerialMessages.cpp" -#include "RaspBerryPi_COM.cpp" - -//sensors_event_t bme280_event; -float seaLevelPressure = 1015.0; -float bme280_press; -float bme280_temp; -float bme280_alti; -float bme280_hum; - -enum strike_sources { UNKNOWN_SRC, LIGHTNING, PERTURBATION, NOISE }; -volatile int8_t AS3935_ISR_Trig = 0; // Trigger for AS3935 lightning sensor - -void AS3935_ISR() { - AS3935_ISR_Trig = 1; -} - -PWF_AS3935 lightning(AS3935_CS_PIN, AS3935_IRQ_PIN, 33); - -int as3935_src; -int as3935_distance; -long lightning_nb_total = 0; -int lightning_nb_hour = 0; -int lightning_nb_day = 0; -int as3935_perturb_total = 0; -int as3935_noise_total = 0; -int as3935_unknown_total = 0; -char lightning_log_file[12] = "lghtnng.log"; - -//GPS -//Adafruit_GPS GPS(&GPS_SERIAL_PORT); -TinyGPS GPS; -float gps_latitude, gps_longitude, gps_altitude; // returns +- latitude/longitude in degrees -float gps_speed, gps_course; -unsigned long gps_time, gps_date, gps_fix_age; -int gps_year; -byte gps_month, gps_day, gps_hour, gps_minutes, gps_second, gps_hundreths; -unsigned long gps_chars, gps_hdop; -unsigned short gps_sentences, gps_failed_checksum, gps_satellites; - -//Miscellaneous -bool rpi_status; -rpi_status = false; -int batt_voltage; -bool low_battery_flag = false; - -// Tasks timers -elapsedMillis since_bme280; -//elapsedMillis since_dht; -elapsedMillis since_gps; -elapsedMillis since_display; -elapsedMillis since_serial_send; -elapsedMillis since_sd_log; -elapsedMillis since_batt_chk; - -//SD Card -#define CONFIGFILE "config.txt" - -//Configuration -char data_file[13] = "datalog.csv"; - - //Delays - -unsigned int bme280_delay = 500; -//unsigned int dht_delay = 3000; -unsigned int gps_delay = 100; -unsigned int serial_send_delay = 5000; -unsigned int sd_log_delay = 5000; -unsigned int batt_chk_delay = 5000; - -//Date and time -int TZ = 1; //Time zone - -/* - * SETUP - */ - -void setup() { - - //To be sure Raspberry-Pi won't be turned on unexpectedly - stopRPI(); - - pinMode(LOW_BATT_PIN, INPUT_PULLUP); - low_battery_flag = !digitalRead(LOW_BATT_PIN); - - pinMode(GPS_BUT_PIN, INPUT_PULLUP); - pinMode(GPS_EN_PIN, OUTPUT); - gps_power(); - - SERIAL_PORT.begin(SERIAL_BAUD_RATE); - delay(1000); - //while (!SERIAL_PORT) { }; //Wait for serial port to start - SERIAL_PORT.printf("Serial Comm. OK\nNow booting...\n"); - - BootMessage("SDcard"); - // see if the card is present and can be initialized: - if (!SD.begin(SD_CS_PIN)) { - BootError(); - while(1); - } - BootOK(); - - BootMessage("RT Clock"); - // set the Time library to use Teensy 3.0's RTC to keep time - setSyncProvider(getTeensy3Time); - if (timeStatus()!= timeSet) { - BootError(); - while(1); - } - BootOK(); - -// BootMessage("AM2302/DHT22 (Humidity and Temperature)"); -// dht.begin(); -// //sensor_t sensor; -// BootOK(); - - BootMessage("BME280 (Pressure and Temperature)"); - /* Initialise the sensor */ - if(!bme.begin()) - { - /* There was a problem detecting the BMP085 ... check your connections */ - BootError(); - while(1); - } - BootOK(); - - BootMessage("AS3935 (Lightning)"); - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV16); // SPI speed to SPI_CLOCK_DIV16/1MHz (max 2MHz, NEVER 500kHz!) - SPI.setDataMode(SPI_MODE1); // MAX31855 is a Mode 1 device --> clock starts low, read on rising edge - SPI.setBitOrder(MSBFIRST); // data sent to chip MSb first - lightning.AS3935_DefInit(); // set registers to default - // now update sensor cal for your application and power up chip - lightning.AS3935_ManualCal(AS3935_CAPACITANCE, AS3935_INDOORS, AS3935_DIST_EN); - // enable interrupt (hook IRQ pin to Arduino Uno/Mega interrupt input: 0 -> pin 2, 1 -> pin 3 ) - attachInterrupt(AS3935_IRQ_PIN, AS3935_ISR, RISING); - BootOK(); - - BootMessage("GPS"); - GPS_SERIAL_PORT.begin(GPS_SERIAL_BAUD_RATE); - while (!GPS_SERIAL_PORT) {} ; - BootOK(); - -} - -/* - * LOOP - */ - -void loop() { - - //Power ON/OFF GPS - gps_power(); - - //Lightning detection - if (AS3935_ISR_Trig != 0) { - AS3935_ISR_Trig = 0; - time_t t = now(); - int distance = -9999; - int energy = -9999; - switch (as3935_src) { - case UNKNOWN_SRC: - //source inconnue - as3935_unknown_total++; - SERIAL_PORT.printf("Interruption (AS3935) : unkown source (not lightning)\n"); - break; - case LIGHTNING: - //Foudre !!! - lightning_nb_total++; - distance = lightning.AS3935_GetLightningDistKm(); - energy = lightning.AS3935_GetStrikeEnergyRaw(); - SERIAL_PORT.printf("Interruption (AS3935) : Lightningbolt !!!\n"); - SERIAL_PORT.printf("Distance : %4d km | Energy : %d \n", distance, energy); - break; - case PERTURBATION: - //Perturbation - as3935_perturb_total++; - SERIAL_PORT.printf("Interruption (AS3935) : perturbation...\n"); - break; - case NOISE: - //Trop de bruit électromagnétique - as3935_noise_total++; - SERIAL_PORT.printf("Interruption (AS3935) : Too much electromagnetic noise!\n"); - break; - } - writeLightningToSD(as3935_src, t, distance, energy); - } - - if (since_batt_chk >= batt_chk_delay) { - since_batt_chk -= batt_chk_delay; - //Check battery status and voltage - low_battery_flag = !digitalRead(LOW_BATT_PIN); - batt_voltage = getBatteryVoltage(); - } - -// if (since_dht >= dht_delay) { -// since_dht = since_dht - dht_delay; -// // Read temperature or humidity -// dht.humidity().getEvent(&dht22_event_hum); -// dht.temperature().getEvent(&dht22_event_temp); -// } - - if (since_bme280 >= bme280_delay) { - since_bme280 = since_bme280 - bme280_delay; - /* Get a new sensor event */ - bmp.getEvent(&bme280_event); - - /* Get the values (barometric pressure is measure in hPa) */ - if (bme280_event.pressure) - { - bme280_press = bme280_event.pressure; - bmp.getTemperature(&bme280_temp); - bme280_alti = bmp.pressureToAltitude(seaLevelPressure, bme280_press); - } - } - - if (since_gps >= gps_delay) { - since_gps = since_gps - gps_delay; - while (GPS_SERIAL_PORT.available()) { - char c = GPS_SERIAL_PORT.read(); - if (GPS.encode(c)) { - GPS.get_datetime(&gps_date, &gps_time, &gps_fix_age); - GPS.crack_datetime(&gps_year, &gps_month, &gps_day, - &gps_hour, &gps_minutes, &gps_second, - &gps_hundreths, &gps_fix_age); - GPS.f_get_position(&gps_latitude, &gps_longitude, &gps_fix_age); - gps_altitude = GPS.f_altitude(); - gps_speed = GPS.f_speed_kmph(); - GPS.stats(&gps_chars, &gps_sentences, &gps_failed_checksum); - gps_satellites = GPS.satellites(); - gps_hdop = GPS.hdop(); - } - } - } - - if (since_sd_log >= sd_log_delay) { - since_sd_log = since_sd_log - sd_log_delay; - writeDataToSD(); - } - - if (since_serial_send >= serial_send_delay) { - since_serial_send = since_serial_send - serial_send_delay; - sendDataOnSerial(); - } - -} - -/* - * FUNCTIONS - */ - -time_t getTeensy3Time() { - return Teensy3Clock.get(); -} - -void gps_power() { - if (digitalRead(GPS_BUT_PIN) == 0) { digitalWrite(GPS_EN_PIN, LOW); } - else { digitalWrite(GPS_EN_PIN, HIGH); } -} - -int getBatteryVoltage() { - long mean = 0; - int U = 0; - int n = 10; - int res = 12; - - analogReadResolution(res); - - for (int i=0; i // library used with I2C protocol -#include // SPI protocol - -//Teensy3.x Real Time Clock -#include - -//SD card -#include - -// Sensors -#include // Generic -//#include // DHT22 -//#include // DHT22 unified -//#include // BMP180 -#include // BME280 -#include - -//GPS -//#include // Adafruit Ultimate GPS -#include //Builtin GPS lib - -/* - * DEFINE - * & - * DECLARE - */ - -//Special characteres -#define DEGREE (char)176 //degree symbol in ISO 8859-1 -#define DEGREE_LCD (char)222 //degree symbol for lcd display - -// Pins used -#define RX1_PIN 0 // Raspberry Pi2 serial comm. - Hard wired -#define TX1_PIN 1 // Raspberry Pi2 serial comm. - Hard wired -#define RPI_PWR_PIN 2 // Raspberry Pi power control - Hard wired -#define SD_CS_PIN 4 // SPI SD CS - Hard wired -#define GPS_EN_PIN 6 // GPS ENable -#define RX3_PIN 7 // GPS serial comm. -#define TX3_PIN 8 // GPS serial comm. -#define AS3935_IRQ_PIN 9 // Interrupts from AS3935 lightning sensor -#define AS3935_CS_PIN 10 // SPI CS AS3935 lightning sensor -#define SPI_DI_PIN 11 // SPI MOSI AS3935 lightning sensor -#define SPI_DO_PIN 12 // SPI MISO AS3935 lightning sensor -#define SPI_CK_PIN 13 // SPI clock SD + AS3935 lightning sensor + built-in LED -//#define DHT_PIN 14 // Humidity sensor data -#define GPS_BUT_PIN 16 // GPS switch power control - -#define I2C_SDA_PIN 18 // I2C SDA -#define I2C_SCL_PIN 19 // I2C SCL - -#define BATT_VOLT_PIN 22 // Battery voltage monitoring (Analog Input) -#define LOW_BATT_PIN 23 // Low Battery signal from charger (digital input) - -//I2C addresses -//#define TCN75A_ADDR 0x00 //Sensor I2C bus address -#define BMP180_ADDR 0x77 -//#define BME280_ADDR 0x00 // ??? - -//Serial over USB communication -#define SERIAL_PORT Serial -#define SERIAL_BAUD_RATE 9600 - -//Raspberry Pi Serial Comm. -#define RPI_SERIAL_PORT Serial1 -#define RPI_SERIAL_BAUD_RATE 115200 - -//GPS -#define GPS_SERIAL_PORT Serial3 -#define GPS_SERIAL_BAUD_RATE 9600 - -// AS3935 Lightning sensor -#define AS3935_INDOORS 0 -#define AS3935_OUTDOORS 1 -#define AS3935_DIST_DIS 0 -#define AS3935_DIST_EN 1 -#define AS3935_CAPACITANCE 72 // 72pF for THIS board (from seller) - - diff --git a/arduino/cameteo-teensy/cameteo-teensy.ino b/arduino/cameteo-teensy/cameteo-teensy.ino deleted file mode 100755 index f64c225..0000000 --- a/arduino/cameteo-teensy/cameteo-teensy.ino +++ /dev/null @@ -1,553 +0,0 @@ -/* - * CAMETEO project - * - * This is a personnal project of weather station with - * automatic photo taking. - * This code is the weather station part and is meant - * to be run on a PJRC Teensy 3.2 board. - * - * Author : Arofarn - * - * Licence : GPL v3 - * - */ - -/* - * LIBRARIES - */ - -//Protocols -#include // library used with I2C protocol -#include // SPI protocol - -//Teensy3.x Real Time Clock -#include - -//SD card -#include - -// Sensors -#include // Generic -#include // BME280 -#include - -//GPS -//#include // Adafruit Ultimate GPS -#include //Builtin GPS lib - -/* - * DEFINE - * & - * DECLARE - */ - -//Special characteres -#define DEGREE (char)176 //degree symbol in ISO 8859-1 -#define DEGREE_LCD (char)222 //degree symbol for lcd display - -// Pins used -#define RX1_PIN 0 // Raspberry Pi2 serial comm. - Hard wired -#define TX1_PIN 1 // Raspberry Pi2 serial comm. - Hard wired -#define RPI_PWR_PIN 2 // Raspberry Pi power control - Hard wired -#define AS3935_CS_PIN 4 // SPI SD CS - Hard wired -#define GPS_EN_PIN 6 // GPS ENable -#define RX3_PIN 7 // GPS serial comm. -#define TX3_PIN 8 // GPS serial comm. -#define AS3935_IRQ_PIN 9 // Interrupts from AS3935 lightning sensor -#define SD_CS_PIN 10 // SPI CS AS3935 lightning sensor -#define SPI_DI_PIN 11 // SPI MOSI AS3935 lightning sensor -#define SPI_DO_PIN 12 // SPI MISO AS3935 lightning sensor -#define SPI_CK_PIN 13 // SPI clock SD + AS3935 lightning sensor + built-in LED -#define BATT_VOLT_PIN 16 // Battery voltage monitoring (Analog Input) -#define LOW_BATT_PIN 17 // Low Battery signal from charger (digital input) -#define I2C_SDA_PIN 18 // I2C SDA BME280 sensor -#define I2C_SCL_PIN 19 // I2C SCL BME280 sensor -#define GPS_BUT_PIN 20 // GPS switch power control (unused) - -//I2C addresses -//#define TCN75A_ADDR 0x00 //Sensor I2C bus address -//#define BMP180_ADDR 0x77 - -//Serial over USB communication -#define SERIAL_PORT Serial -#define SERIAL_BAUD_RATE 9600 - -//Raspberry Pi Serial Comm. -#define RPI_SERIAL_PORT Serial1 -#define RPI_SERIAL_BAUD_RATE 9600 - -//GPS -#define GPS_SERIAL_PORT Serial3 -#define GPS_SERIAL_BAUD_RATE 9600 - -//Sensors -Adafruit_BME280 bme; -float seaLevelPressure = SENSORS_PRESSURE_SEALEVELHPA; -float bme280_press; -float bme280_temp; -float bme280_alti; -float bme280_humi; - -// AS3935 Lightning sensor -#define AS3935_INDOORS 0 -#define AS3935_OUTDOORS 1 -#define AS3935_DIST_DIS 0 -#define AS3935_DIST_EN 1 -#define AS3935_CAPACITANCE 72 // 72pF for THIS board (from seller) -enum strike_sources { UNKNOWN_SRC, LIGHTNING, PERTURBATION, NOISE }; -volatile int8_t AS3935_ISR_Trig = 0; // Trigger for AS3935 lightning sensor - -void AS3935_ISR() { - AS3935_ISR_Trig = 1; -} - -PWF_AS3935 lightning(AS3935_CS_PIN, AS3935_IRQ_PIN, 33); - -int as3935_src; -int as3935_distance; -long lightning_nb_total = 0; -int lightning_nb_hour = 0; -int lightning_nb_day = 0; -int as3935_perturb_total = 0; -int as3935_noise_total = 0; -int as3935_unknown_total = 0; -char lightning_log_file[12] = "lghtnng.log"; - -//GPS -//Adafruit_GPS GPS(&GPS_SERIAL_PORT); -TinyGPS GPS; -float gps_latitude, gps_longitude, gps_altitude; // returns +- latitude/longitude in degrees -float gps_speed, gps_course; -unsigned long gps_time, gps_date, gps_fix_age; -int gps_year; -byte gps_month, gps_day, gps_hour, gps_minutes, gps_second, gps_hundreths; -unsigned long gps_chars, gps_hdop; -unsigned short gps_sentences, gps_failed_checksum, gps_satellites; - -//Miscellaneous -bool rpi_status = true; -int batt_voltage; -bool low_battery_flag = false; - -// Tasks timers -elapsedMillis since_bme280; -elapsedMillis since_gps; -elapsedMillis since_display; -elapsedMillis since_serial_send; -elapsedMillis since_sd_log; -elapsedMillis since_batt_chk; - - -void BootMessage(String s) { - char c[13]; // char buffer for conversion String->char - s.toCharArray(c, sizeof(s)); - SERIAL_PORT.printf("%-12s", c); -} - -void BootOK() { - SERIAL_PORT.println("OK"); -} - -void BootError() { - SERIAL_PORT.println("EE"); -} - -void sendDataOnSerial() { - - //Print date & hour on serial port - SERIAL_PORT.printf("%04d/%02d/%02d_%02d:%02d:%02d\n", year(), month(), day(), hour(), minute(), second()); - - //if (bme280_event.pressure) { - SERIAL_PORT.printf("Temperature:%8.2f %cC | Pressure: %8.2f hPa | Altitude:%8.2f m\n", - bme280_temp, DEGREE, bme280_press, bme280_alti); -// } -// else { -// SERIAL_PORT.printf("BMP180 Sensor error\n"); -// } - - SERIAL_PORT.printf("Lightning strikes (from start) : %d | Perturb.: %d | Noise : %d | Unknown detect.: %d\n", lightning_nb_total, - as3935_perturb_total, - as3935_noise_total, - as3935_unknown_total); - - //SERIAL_PORT.printf("Temperature:%8.2f %cC\n", tcn75a_temp, DEGREE); - - SERIAL_PORT.printf("GPS data: %04d/%02d/%02d_%02d:%02d:%02d (%d)\n", gps_year, gps_month, gps_day, - gps_hour, gps_minutes, gps_second, - gps_fix_age); - SERIAL_PORT.printf(" Latitude: %11.8f | Longitude: %11.8f | Altitude: %5.2f m\n", gps_latitude, gps_longitude, gps_altitude); - SERIAL_PORT.printf(" Speed: %4.1f km/h | Course : %4.1f %c\n", gps_speed, gps_course, DEGREE); - SERIAL_PORT.printf(" Chars: %11d | Sentences: %11d | Failed cheksum: %4d\n", gps_chars, gps_sentences, gps_failed_checksum); - - SERIAL_PORT.printf("Battery : %10d mV | Low Battery : %d\n", batt_voltage, low_battery_flag); -} - - -bool isStartedPI() { - //Return true if the R-Pi respond to an simple request - return rpi_status; -} - -void startRPI() { - //Start the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN) - if (!isStartedPI()) { - pinMode(RPI_PWR_PIN, OUTPUT); - digitalWrite(RPI_PWR_PIN, LOW); - rpi_status = true; - } -} - -void stopRPI() { - //Stop the Raspberry Pi via the MOSFET (grid connected to the RPI_PWR_PIN) - - pinMode(RPI_PWR_PIN, INPUT); //Eteint via le MOSFET - rpi_status = false; -} - -void sendDataToRPI() { - //if (isStartedPI()) { - //Print date & hour on serial port - RPI_SERIAL_PORT.printf("%04d/%02d/%02d_%02d:%02d:%02d\n", year(), month(), day(), hour(), minute(), second()); - - //if (bme280_event.pressure) { - RPI_SERIAL_PORT.printf("Temperature:%8.2f %cC | Pressure: %8.2f hPa | Altitude:%8.2f m\n", - bme280_temp, DEGREE, bme280_press, bme280_alti); - //} - //else { - // RPI_SERIAL_PORT.printf("BMP180 Sensor error\n"); - //} - - RPI_SERIAL_PORT.printf("Lightning strikes (from start) : %d | Perturb.: %d | Noise : %d | Unknown detect.: %d\n", lightning_nb_total, - as3935_perturb_total, - as3935_noise_total, - as3935_unknown_total); - - RPI_SERIAL_PORT.printf("GPS data: %04d/%02d/%02d_%02d:%02d:%02d (%d)\n", gps_year, gps_month, gps_day, - gps_hour, gps_minutes, gps_second, - gps_fix_age); - RPI_SERIAL_PORT.printf(" Latitude: %11.8f | Longitude: %11.8f | Altitude: %5.2f m\n", gps_latitude, gps_longitude, gps_altitude); - RPI_SERIAL_PORT.printf(" Speed: %4.1f km/h | Course : %4.1f %c\n", gps_speed, gps_course, DEGREE); - RPI_SERIAL_PORT.printf(" Chars: %11d | Sentences: %11d | Failed cheksum: %4d\n", gps_chars, gps_sentences, gps_failed_checksum); - - RPI_SERIAL_PORT.printf("Battery : %10d mV | Low Battery : %d\n", batt_voltage, low_battery_flag); -// } -// else { -// //error RPI is not started -// } -} - - -//SD Card -#define CONFIGFILE "config.txt" - -//Configuration -char data_file[13] = "datalog.csv"; - - //Delays - -unsigned int bme280_delay = 500; -//unsigned int dht_delay = 3000; -unsigned int gps_delay = 100; -unsigned int serial_send_delay = 5000; -unsigned int sd_log_delay = 5000; -unsigned int batt_chk_delay = 5000; - -//Date and time -int TZ = 1; //Time zone - -/* - * SETUP - */ - -void setup() { - - //To be sure Raspberry-Pi won't be turned on unexpectedly - stopRPI(); - - pinMode(LOW_BATT_PIN, INPUT_PULLUP); - low_battery_flag = !digitalRead(LOW_BATT_PIN); - - pinMode(GPS_BUT_PIN, INPUT_PULLUP); - pinMode(GPS_EN_PIN, OUTPUT); - gps_power(); - - SERIAL_PORT.begin(SERIAL_BAUD_RATE); - delay(1000); - //while (!SERIAL_PORT) { }; //Wait for serial port to start - SERIAL_PORT.printf("Serial Comm. OK\nNow booting...\n"); - - RPI_SERIAL_PORT.begin(RPI_SERIAL_BAUD_RATE); - delay(1000); - //while (!RPI_SERIAL_PORT) { }; //Wait for serial port to start - RPI_SERIAL_PORT.printf("Raspberry's Serial Comm. OK\nNow booting...\n"); - - BootMessage("SDcard"); - // see if the card is present and can be initialized: - if (!SD.begin(SD_CS_PIN)) { - BootError(); - while(1); - } - BootOK(); - - BootMessage("RT Clock"); - // set the Time library to use Teensy 3.0's RTC to keep time - setSyncProvider(getTeensy3Time); - if (timeStatus()!= timeSet) { - BootError(); - while(1); - } - BootOK(); - - - BootMessage("BME280 (Pressure, Humidity and Temperature)"); - /* Initialise the sensor */ -// if(!bme.begin()) -// { -// /* There was a problem detecting the BMP085 ... check your connections */ -// BootError(); -// while(1); -// } - BootOK(); - - BootMessage("AS3935 (Lightning)"); - SPI.begin(); - SPI.setClockDivider(SPI_CLOCK_DIV16); // SPI speed to SPI_CLOCK_DIV16/1MHz (max 2MHz, NEVER 500kHz!) - SPI.setDataMode(SPI_MODE1); // MAX31855 is a Mode 1 device --> clock starts low, read on rising edge - SPI.setBitOrder(MSBFIRST); // data sent to chip MSb first - lightning.AS3935_DefInit(); // set registers to default - // now update sensor cal for your application and power up chip - lightning.AS3935_ManualCal(AS3935_CAPACITANCE, AS3935_OUTDOORS, AS3935_DIST_EN); - // enable interrupt (hook IRQ pin to Arduino Uno/Mega interrupt input: 0 -> pin 2, 1 -> pin 3 ) - attachInterrupt(AS3935_IRQ_PIN, AS3935_ISR, RISING); - BootOK(); - - BootMessage("GPS"); - GPS_SERIAL_PORT.begin(GPS_SERIAL_BAUD_RATE); - while (!GPS_SERIAL_PORT) {} ; - BootOK(); - -} - -/* - * LOOP - */ - -void loop() { - - //Power ON/OFF GPS - gps_power(); - - //Lightning detection - if (AS3935_ISR_Trig != 0) { - AS3935_ISR_Trig = 0; - time_t t = now(); - int distance = -9999; - int energy = -9999; - switch (as3935_src) { - case UNKNOWN_SRC: - //source inconnue - as3935_unknown_total++; - SERIAL_PORT.printf("Interruption (AS3935) : unkown source (not lightning)\n"); - break; - case LIGHTNING: - //Foudre !!! - lightning_nb_total++; - distance = lightning.AS3935_GetLightningDistKm(); - energy = lightning.AS3935_GetStrikeEnergyRaw(); - SERIAL_PORT.printf("Interruption (AS3935) : Lightningbolt !!!\n"); - SERIAL_PORT.printf("Distance : %4d km | Energy : %d \n", distance, energy); - break; - case PERTURBATION: - //Perturbation - as3935_perturb_total++; - SERIAL_PORT.printf("Interruption (AS3935) : perturbation...\n"); - break; - case NOISE: - //Trop de bruit électromagnétique - as3935_noise_total++; - SERIAL_PORT.printf("Interruption (AS3935) : Too much electromagnetic noise!\n"); - break; - } - writeLightningToSD(as3935_src, t, distance, energy); - } - - if (since_batt_chk >= batt_chk_delay) { - since_batt_chk -= batt_chk_delay; - //Check battery status and voltage - low_battery_flag = !digitalRead(LOW_BATT_PIN); - batt_voltage = getBatteryVoltage(); - } - -// if (since_bme280 >= bme280_delay) { -// since_bme280 = since_bme280 - bme280_delay; -// -// bme280_press = bme.readPressure() / 100.0F; -// bme280_alti = bme.readAltitude(seaLevelPressure); -// bme280_temp = bme.readTemperature(); -// bme280_humi = bme.readHumidity(); -// } - - if (since_gps >= gps_delay) { - since_gps = since_gps - gps_delay; - while (GPS_SERIAL_PORT.available()) { - char c = GPS_SERIAL_PORT.read(); - if (GPS.encode(c)) { - GPS.get_datetime(&gps_date, &gps_time, &gps_fix_age); - GPS.crack_datetime(&gps_year, &gps_month, &gps_day, - &gps_hour, &gps_minutes, &gps_second, - &gps_hundreths, &gps_fix_age); - GPS.f_get_position(&gps_latitude, &gps_longitude, &gps_fix_age); - gps_altitude = GPS.f_altitude(); - gps_speed = GPS.f_speed_kmph(); - GPS.stats(&gps_chars, &gps_sentences, &gps_failed_checksum); - gps_satellites = GPS.satellites(); - gps_hdop = GPS.hdop(); - } - } - } - - if (since_sd_log >= sd_log_delay) { - since_sd_log = since_sd_log - sd_log_delay; - writeDataToSD(); - } - - if (since_serial_send >= serial_send_delay) { - since_serial_send = since_serial_send - serial_send_delay; - sendDataOnSerial(); - sendDataToRPI(); - } - -} - -/* - * FUNCTIONS - */ - -time_t getTeensy3Time() { - return Teensy3Clock.get(); -} - -void gps_power() { - if (digitalRead(GPS_BUT_PIN) == 0) { digitalWrite(GPS_EN_PIN, LOW); } - else { digitalWrite(GPS_EN_PIN, HIGH); } -} - -int getBatteryVoltage() { - long mean = 0; - int U = 0; - int n = 10; - int res = 12; - - analogReadResolution(res); - - for (int i=0; i -#include -#include -#include -#include -#include -#include -#include - -/************************* WiFi Access Point *********************************/ - -#define WLAN_SSID "arowifi2" -#define WLAN_PASS "nAGjywhCQ4iUBcbmf0PBn_srrghpOur4-aIzcJ_8Uxm1b58dH1c4Vy-LEMLd" - -/************************* MQTT broker Setup *********************************/ - -#define MQTT_SERVER "192.168.0.18" -#define MQTT_SERVERPORT 1883 // use 8883 for SSL -#define MQTT_USERNAME "arofarn" -#define MQTT_KEY "WaKaW9XMGUZ3rRJD" -#define MQTT_ID "huzzah0" -#define MQTT_PUB_INTERVAL 15000 // milliseconds - -/************************* Time and NTP Setup *********************************/ - -#define NTP_SERVER "fr.pool.ntp.org" -#define TIMEZONE 0 // UTC+0 -#define DAYLIGHT false -#define NTP_REFRESH_INTERVAL 3600 - -/************************* Atmospheric Pressure Mode *********************************/ - -#define MODE_STATION true -#define DEFAULT_ALTITUDE 140.0 -#define DEFAULT_MSLP 1013.25 //Mean Atmospheric Pressure at Mean Sea-Level - -// Create an ESP8266 WiFiClient class to connect to the MQTT server. -WiFiClient wifi_client; -MQTTClient mqtt_client; - -//Create a class for the sensor -Adafruit_BME280 bme; // I2C - -bool mode_station = MODE_STATION; -float altitude = DEFAULT_ALTITUDE; -float atm_press_sea_level = DEFAULT_MSLP; - -bool led0_status = true ; -unsigned long previousPub = 0; - -/*************************** Sketch Code ************************************/ -// Bug workaround for Arduino 1.6.6, it seems to need a function declaration -// for some reason (only affects ESP8266, likely an arduino-builder bug). -void MQTT_connect(); - -void setup() { - bool wstatus=false; - - Serial.begin(115200); - delay(10); - - pinMode(LED_BUILTIN, OUTPUT); - pinMode(2, OUTPUT); - - digitalWrite(2, wstatus); - digitalWrite(LED_BUILTIN, led0_status); - - // Connect to WiFi access point. - Serial.println(); Serial.println(); - Serial.print("Connecting to "); - Serial.println(WLAN_SSID); - - WiFi.begin(WLAN_SSID, WLAN_PASS); - while (WiFi.status() != WL_CONNECTED) { - wstatus = !wstatus; - delay(500); - Serial.print("."); - digitalWrite(2, wstatus); - } - Serial.println(); - - digitalWrite(2, LOW); - Serial.println("WiFi connected"); - Serial.println("IP address: "); Serial.println(WiFi.localIP()); - - delay(500); - - NTP.begin(NTP_SERVER, TIMEZONE, DAYLIGHT); //Local french NTP server, timezone, summertime= false - NTP.setInterval(NTP_REFRESH_INTERVAL); - NTP.onNTPSyncEvent([](NTPSyncEvent_t error) { - if (error) { - Serial.print("Time Sync error: "); - if (error == noResponse) - Serial.println("NTP server not reachable"); - else if (error == invalidAddress) - Serial.println("Invalid NTP server address"); - } - else { - Serial.print("Got NTP time: "); - Serial.println(NTP.getTimeDateString(NTP.getLastNTPSync())); - } - }); - - time_t nowNTP; - nowNTP = NTP.getTime(); - Serial.println(nowNTP); - - // default settings - bool status; - status = bme.begin(); - if (!status) { - Serial.println("Could not find a valid BME280 sensor, check wiring!"); - while (1); - } - - mqtt_client.begin(MQTT_SERVER, MQTT_SERVERPORT, wifi_client); //MQTT_SERVERPORT, MQTT_USERNAME, MQTT_KEY); - //client.onMessage(messageReceived); - - MQTT_connect(); - mqtt_client.onMessage(messageReceived); - - previousPub = millis(); -} - -uint32_t x=0; - -void loop() { - mqtt_client.loop(); - - if (!mqtt_client.connected()) { - MQTT_connect(); - } - - unsigned long currentMillis = millis(); - - if(currentMillis - previousPub > MQTT_PUB_INTERVAL) { - // save the last time you blinked the LED - previousPub = currentMillis; - - float pressure_val = -99.9; - float temperature_val = -99.9; - float humidity_val = -99.9; - String date_str = ""; - char date_val[20] = "00:00:00 00-00-0000"; - char tosend[120]; - - pressure_val = bme.readPressure() / 100.0F; - temperature_val = bme.readTemperature(); - humidity_val = bme.readHumidity(); - - date_str = NTP.getTimeDateString(); - date_str.toCharArray(date_val,20); - - // Now we can publish stuff! - Serial.print(F("Sending pressure value ")); - Serial.print(pressure_val); - Serial.print("..."); - val2json(pressure_val, date_str, "hPa", "AP").toCharArray(tosend, 120); - if (! mqtt_client.publish("huzzah0/AdaBME280_1/pressure", tosend, true, 2) ) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - if(mode_station) { - //Sea-level atmospheric pressure calculus - atm_press_sea_level = bme.seaLevelForAltitude(altitude, pressure_val); - } else { - altitude = bme.readAltitude(atm_press_sea_level); - } - - Serial.print(F("Sending sea-level pressure value ")); - Serial.print(atm_press_sea_level); - Serial.print("..."); - val2json(atm_press_sea_level, date_str, "hPa", "MSLP").toCharArray(tosend, 120); - if (! mqtt_client.publish("huzzah0/AdaBME280_1/sea_level_pressure", tosend, true, 2) ) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - Serial.print(F("Sending altitude value ")); - Serial.print(altitude); - Serial.print("..."); - val2json(altitude, date_str, "m", "ALTI").toCharArray(tosend, 120); - if (! mqtt_client.publish("huzzah0/AdaBME280_1/altitude", tosend, true, 2) ) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - - // Now we can publish stuff! - Serial.print(F("Sending humity value ")); - Serial.print(humidity_val); - Serial.print("..."); - val2json(humidity_val, date_str, "%", "RH").toCharArray(tosend, 120); - if (! mqtt_client.publish("huzzah0/AdaBME280_1/humidity", tosend, true, 2)) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - - // Now we can publish stuff! - Serial.print(F("Sending temperature value ")); - Serial.print(temperature_val); - Serial.print("..."); - val2json(temperature_val, date_str, "degC", "AT").toCharArray(tosend, 120); - if (! mqtt_client.publish("huzzah0/AdaBME280_1/temperature", tosend, true, 2)) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - - // __LAST__ thing to send : Date and Time - Serial.print(F("Sending date and time ")); - Serial.print(date_val); - Serial.print("..."); - if (! mqtt_client.publish("huzzah0/NTP/date", date_val, true, 2)) { - Serial.println(F("Failed")); - } else { - Serial.println(F("OK!")); - } - } - - delay(10); -} - -void MQTT_connect() { - Serial.print("checking wifi..."); - while (WiFi.status() != WL_CONNECTED) { - Serial.print("."); - delay(1000); - } - - Serial.print("\nconnecting..."); - while (!mqtt_client.connect(MQTT_ID, MQTT_USERNAME, MQTT_KEY)) { - Serial.print("."); - delay(1000); - } - - Serial.println("\nconnected!"); - - mqtt_client.subscribe("huzzah0/led0", 1); - mqtt_client.subscribe("huzzah0/mode_station", 1); - if(mode_station) { - mqtt_client.unsubscribe("huzzah0/sea_level_pressure"); - mqtt_client.subscribe("huzzah0/altitude", 2); - } - else { - mqtt_client.unsubscribe("huzzah0/altitude"); - mqtt_client.subscribe("huzzah0/sea_level_pressure", 1); - } -} - -void messageReceived(String &topic, String &payload) { - Serial.println("incoming: " + topic + " - " + payload); - - if(topic == "huzzah0/led0") { - if(payload == "0") led0_status = HIGH; - if(payload == "1") led0_status = LOW; - digitalWrite(LED_BUILTIN, led0_status); - } - if(topic == "huzzah0/mode_station") { - if(payload == "0") { - mode_station = false; - mqtt_client.unsubscribe("huzzah0/altitude"); - mqtt_client.subscribe("huzzah0/sea_level_pressure", 1); - } - if(payload == "1") { - mode_station = true; - mqtt_client.unsubscribe("huzzah0/sea_level_pressure"); - mqtt_client.subscribe("huzzah0/altitude", 1); - } - } - if(topic == "huzzah0/altitude") { - String pl = payload; - altitude = pl.toFloat(); - Serial.print("New altitude :"); - Serial.println(altitude); - } -} - -String int2str(int a) { - String ret = ""; - if (a < 10) { - ret +="0"; - } - if (a > 99) - a = 99; - ret += a; - return ret; -} - -String val2json (float val, String date, String unit, String type) { - String json = "{\"date\": \""; - json += date; - json += "\", \"value\": \""; - json += val; - json += "\", \"unit\": \""; - json += unit; - json += "\", \"type\": \""; - json += type; - json += "\" }"; - //Serial.println(json); - return json; -} - diff --git a/circuitpython/boot.py b/circuitpython/boot.py new file mode 100644 index 0000000..5d5b19c --- /dev/null +++ b/circuitpython/boot.py @@ -0,0 +1,17 @@ +# Selectively setting readonly to False on boot + +import board +import digitalio +import storage + +switch = digitalio.DigitalInOut(board.D5) +switch.direction = digitalio.Direction.INPUT +switch.pull = digitalio.Pull.UP +led = digitalio.DigitalInOut(board.D13) +led.direction = digitalio.Direction.OUTPUT + +# If the D0 is connected to ground with a wire +# CircuitPython can write to the drive +storage.remount("/", switch.value) +print("Readonly : {}".format(switch.value)) +led.value = switch.value \ No newline at end of file diff --git a/circuitpython/lib/adafruit_bme280.mpy b/circuitpython/lib/adafruit_bme280.mpy new file mode 100644 index 0000000..252e9be Binary files /dev/null and b/circuitpython/lib/adafruit_bme280.mpy differ diff --git a/circuitpython/lib/adafruit_bus_device/__init__.py b/circuitpython/lib/adafruit_bus_device/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/circuitpython/lib/adafruit_bus_device/i2c_device.mpy b/circuitpython/lib/adafruit_bus_device/i2c_device.mpy new file mode 100644 index 0000000..0cd7576 Binary files /dev/null and b/circuitpython/lib/adafruit_bus_device/i2c_device.mpy differ diff --git a/circuitpython/lib/adafruit_bus_device/spi_device.mpy b/circuitpython/lib/adafruit_bus_device/spi_device.mpy new file mode 100644 index 0000000..2a44783 Binary files /dev/null and b/circuitpython/lib/adafruit_bus_device/spi_device.mpy differ diff --git a/circuitpython/lib/adafruit_gps.mpy b/circuitpython/lib/adafruit_gps.mpy new file mode 100644 index 0000000..9193605 Binary files /dev/null and b/circuitpython/lib/adafruit_gps.mpy differ diff --git a/circuitpython/lib/neopixel.mpy b/circuitpython/lib/neopixel.mpy new file mode 100644 index 0000000..d9e5480 Binary files /dev/null and b/circuitpython/lib/neopixel.mpy differ diff --git a/circuitpython/main.py b/circuitpython/main.py new file mode 100644 index 0000000..b768ab6 --- /dev/null +++ b/circuitpython/main.py @@ -0,0 +1,126 @@ +# Simple weather and GPS logger + +import board +from busio import I2C, UART +from time import sleep +from analogio import AnalogIn +import microcontroller +import gc +import micropython +import os + +from adafruit_bme280 import Adafruit_BME280_I2C +from adafruit_gps import GPS +import neopixel + +######### +# Setup # +######### + +# BME280 sensors (I2C) +i2c = I2C(board.SCL, board.SDA) +bme280 = Adafruit_BME280_I2C(i2c) + +# Integrated Neopixel +pixel = neopixel.NeoPixel(board.NEOPIXEL, 1, brightness=0.2) + +# Battery voltage +vbat = AnalogIn(board.D9, ) + +# GPS on Feather board +gps_uart = UART(board.TX, board.RX, baudrate=9600, timeout=3000) +gps = GPS(gps_uart) +# Turn on the basic GGA and RMC info +gps.send_command('PMTK314,0,1,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0') +gps.send_command('PMTK220,2000') # 1000 ms refresh + +gc.collect() +micropython.mem_info() + +temp, hum, press = 0.0, 0.0, 0.0 +rouge, vert, bleu = 0, 0, 0 + +# Check if data directory exists +if 'data' not in os.listdir(): + os.mkdir('data') + os.mkdir('data/hourly') + os.mkdir('data/daily') + +############# +# Main loop # +############# +while True: + sleep(5) + + gc.collect() + # micropython.mem_info(1) + # print('Memory free: {} allocated: {}'.format(gc.mem_free(), gc.mem_alloc())) + + temp = bme280.temperature + hum = bme280.humidity + press = bme280.pressure + + print("Temperature: {:>+.1f} degC | Humidite: {:>.1f} % | Pression: {:>.1f} hPa".format(temp, hum, press)) + print("Tension batterie : {:>.2f} V | CPU Temp: {:>+.1f} degC".format((vbat.value*2*3.3/65536), microcontroller.cpu.temperature)) + # 0.00644531 = 2*3.3/1024 : + # 2 : voltage is divided by 2 + # 3.3 : Vref = 3.3V + # 1024 : 10bit ADC + + # Conversion des donn?es en couleur + # ROUGE => temp?rature : max = 35?C, min =10?C soit une amplitude de 25?C + rouge = int((temp-10)*255/25) + if rouge > 255: + rouge = 255 + if rouge < 0: + rouge = 0 + + # BLEU => humidit? : max= 100%, mini=0% + bleu = int(hum*255/100) + + # VERT => Pression : mini=960hPa, maxi = 1030hPa soit une amplitude 70hPa + vert = int((press-960)*255/70) + if vert > 255: + vert = 255 + if vert < 0: + vert = 0 + + rvb = (rouge, vert, bleu) + print("Couleur : {}".format(rvb)) + pixel[0] = rvb + + gps.update() + if not gps.has_fix: + # Try again if we don't have a fix yet. + print('Waiting for fix... {} - {}'.format(gps.has_fix, gps.satellites)) + continue + + print('Fix timestamp: {}/{}/{} {:02}:{:02}:{:02}'.format( + gps.timestamp_utc.tm_mon, # Grab parts of the time from the + gps.timestamp_utc.tm_mday, # struct_time object that holds + gps.timestamp_utc.tm_year, # the fix time. Note you might + gps.timestamp_utc.tm_hour, # not get all data like year, day, + gps.timestamp_utc.tm_min, # month! + gps.timestamp_utc.tm_sec)) + if gps.altitude_m is not None: + print('Latitude: {} deg | Longitude: {} deg | Altitude: {} m'.format(gps.latitude, + gps.longitude, + gps.altitude_m)) + else: + print('Latitude: {} deg | Longitude: {} deg'.format(gps.latitude, + gps.longitude)) + + print('Fix quality: {}'.format(gps.fix_quality)) + # Some attributes beyond latitude, longitude and timestamp are optional + # and might not be present. Check if they're None before trying to use! + if gps.satellites is not None: + print('# satellites: {}'.format(gps.satellites)) + if gps.track_angle_deg is not None: + print('Speed: {} knots'.format(gps.speed_knots)) + if gps.track_angle_deg is not None: + print('Track angle: {} degrees'.format(gps.track_angle_deg)) + if gps.horizontal_dilution is not None: + print('Horizontal dilution: {}'.format(gps.horizontal_dilution)) + if gps.height_geoid is not None: + print('Height geo ID: {} meters'.format(gps.height_geoid)) + diff --git a/doc/cablage-teensy.ods b/doc/cablage-teensy.ods deleted file mode 100755 index 2a105d7..0000000 Binary files a/doc/cablage-teensy.ods and /dev/null differ diff --git a/doc/connections RPi-Arduino.fzz b/doc/connections RPi-Arduino.fzz deleted file mode 100755 index d8ce885..0000000 Binary files a/doc/connections RPi-Arduino.fzz and /dev/null differ diff --git a/doc/connections RPi-teensy.fzz b/doc/connections RPi-teensy.fzz deleted file mode 100755 index a149e9a..0000000 Binary files a/doc/connections RPi-teensy.fzz and /dev/null differ