98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			98 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /*
 | |
|  * 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 <Wire.h>   // library used with I2C protocol
 | |
| #include <SPI.h>    // SPI protocol
 | |
| 
 | |
| //Teensy3.x Real Time Clock
 | |
| #include <TimeLib.h>
 | |
| 
 | |
| //SD card
 | |
| #include <SD.h>
 | |
| 
 | |
| // Sensors
 | |
| #include <Adafruit_Sensor.h>    // Generic
 | |
| //#include <DHT.h>                // DHT22
 | |
| //#include <DHT_U.h>              // DHT22 unified
 | |
| //#include <Adafruit_BMP085_U.h>  // BMP180
 | |
| #include <Adafruit_BME280.h>    // BME280
 | |
| #include <PWFusion_AS3935.h>
 | |
| 
 | |
| //GPS
 | |
| //#include <Adafruit_GPS.h>       // Adafruit Ultimate GPS
 | |
| #include <TinyGPS.h>            //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)
 | |
| 
 | |
| 
 |