├── Antenna ├── UCA_Antenna_tuto.pdf ├── UCA_UFL_Connector.pdf └── readme.md ├── Arduino_Code ├── CW │ ├── Arduino_CW.ino │ ├── readme.md │ ├── sx1276Regs-Fsk.h │ └── sx1276Regs-LoRa.h ├── ChannelSounder │ ├── DUT_ChannelSounder_Sender │ │ └── DUT_ChannelSounder_Sender.ino │ ├── LoRaOLED_ChannelSounder_Master │ │ └── LoRaOLED_ChannelSounder_Master.ino │ ├── LoRaOLED_ChannelSounder_Sender │ │ └── LoRaOLED_ChannelSounder_Sender.ino │ └── readme.md ├── LORAWAN │ ├── ABP │ │ └── Basic │ │ │ ├── UCA-ABP_Basic │ │ │ └── UCA-ABP_Basic.ino │ │ │ └── readme.md │ └── OTAA │ │ ├── LED_CONTROLLER │ │ ├── LED_CONTROLLER.ino │ │ └── readme.md │ │ ├── LP_BME280 │ │ ├── LP_BME280.ino │ │ └── readme.md │ │ ├── LP_Basic │ │ ├── LP_Basic.ino │ │ └── readme.md │ │ ├── LP_DHT22 │ │ ├── DHT.cpp │ │ ├── DHT.h │ │ ├── LP_DHT22.ino │ │ └── readme.md │ │ ├── LP_GYVL53L0X │ │ ├── LP_GYVL53L0X.ino │ │ └── readme.md │ │ ├── LP_PIR │ │ └── LP_PIR.ino │ │ ├── LP_SI7021 │ │ ├── LP_SI7021.ino │ │ └── readme.md │ │ ├── LP_SI7021_TEMT6000 │ │ ├── LP_SI7021_TEMT6000.ino │ │ └── readme.md │ │ ├── LP_SOUND │ │ └── LP_SOUND.ino │ │ ├── LP_TEMT6000 │ │ ├── LP_TEMT6000.ino │ │ └── readme.md │ │ └── LP_Thermistance │ │ ├── LP_thermistance.ino │ │ ├── adcvcc.cpp │ │ ├── adcvcc.h │ │ └── readme.md ├── Libraries │ ├── BME280-master │ │ ├── LICENSE │ │ ├── README.md │ │ ├── examples │ │ │ ├── BME280_Modes │ │ │ │ └── BME280_Modes.ino │ │ │ ├── BME_280_BRZO_I2C_Test │ │ │ │ └── BME_280_BRZO_I2C_Test.ino │ │ │ ├── BME_280_I2C_Test │ │ │ │ └── BME_280_I2C_Test.ino │ │ │ ├── BME_280_Spi_Sw_Test │ │ │ │ └── BME_280_Spi_Sw_Test.ino │ │ │ ├── BME_280_Spi_Test │ │ │ │ └── BME_280_Spi_Test.ino │ │ │ └── Environment_Calculations │ │ │ │ └── Environment_Calculations.ino │ │ ├── keywords.txt │ │ ├── library.properties │ │ └── src │ │ │ ├── BME280.cpp │ │ │ ├── BME280.h │ │ │ ├── BME280I2C.cpp │ │ │ ├── BME280I2C.h │ │ │ ├── BME280I2C_BRZO.cpp │ │ │ ├── BME280I2C_BRZO.h │ │ │ ├── BME280Spi.cpp │ │ │ ├── BME280Spi.h │ │ │ ├── BME280SpiSw.cpp │ │ │ ├── BME280SpiSw.h │ │ │ ├── EnvironmentCalculations.cpp │ │ │ └── EnvironmentCalculations.h │ ├── LoRa │ │ ├── LoRa.cpp │ │ └── LoRa.h │ ├── LowPower │ │ ├── Examples │ │ │ ├── desktop.ini │ │ │ ├── idleWakePeriodic │ │ │ │ ├── desktop.ini │ │ │ │ └── idleWakePeriodic.ino │ │ │ ├── powerDownWakeExternalInterrupt │ │ │ │ ├── desktop.ini │ │ │ │ └── powerDownWakeExternalInterrupt.ino │ │ │ ├── powerDownWakePeriodic │ │ │ │ ├── desktop.ini │ │ │ │ └── powerDownWakePeriodic.ino │ │ │ └── standbyExternalInterruptSAMD21 │ │ │ │ ├── desktop.ini │ │ │ │ └── standbyExternalInterruptSAMD21.ino │ │ ├── LowPower.cpp │ │ ├── LowPower.h │ │ ├── README.md │ │ ├── desktop.ini │ │ ├── keywords.txt │ │ └── library.properties │ ├── SI7021-master │ │ ├── .gitattributes │ │ ├── .gitignore │ │ ├── LICENSE │ │ ├── README.md │ │ ├── SI7021.cpp │ │ ├── SI7021.h │ │ ├── examples │ │ │ ├── readsensor │ │ │ │ └── readsensor.ino │ │ │ ├── readsensor_esp8266 │ │ │ │ └── readsensor_esp8266.ino │ │ │ └── readsensor_simple │ │ │ │ └── readsensor_simple.ino │ │ ├── keywords.txt │ │ └── library.json │ ├── SX1272 │ │ ├── SX1272.cpp │ │ └── SX1272.h │ ├── arduino-lmic-custom │ │ ├── README.md │ │ ├── doc │ │ │ ├── LMiC-v1.5.pdf │ │ │ ├── README.txt │ │ │ └── release-notes.txt │ │ ├── examples │ │ │ ├── raw │ │ │ │ └── raw.ino │ │ │ ├── ttn-abp │ │ │ │ └── ttn-abp.ino │ │ │ └── ttn-otaa │ │ │ │ └── ttn-otaa.ino │ │ ├── library.properties │ │ └── src │ │ │ ├── aes │ │ │ ├── ideetron │ │ │ │ └── AES-128_V10.cpp │ │ │ ├── lmic.c │ │ │ └── other.c │ │ │ ├── hal │ │ │ ├── hal.cpp │ │ │ └── hal.h │ │ │ ├── lmic.h │ │ │ └── lmic │ │ │ ├── config.h │ │ │ ├── hal.h │ │ │ ├── lmic.c │ │ │ ├── lmic.h │ │ │ ├── lorabase.h │ │ │ ├── oslmic.c │ │ │ ├── oslmic.h │ │ │ └── radio.c │ ├── cactus_io_BME280_I2C │ │ ├── cactus_io_BME280_I2C.cpp │ │ └── cactus_io_BME280_I2C.h │ ├── readme.md │ └── vl53l0x-arduino-master │ │ ├── .travis.yml │ │ ├── LICENSE.txt │ │ ├── README.md │ │ ├── VL53L0X.cpp │ │ ├── VL53L0X.h │ │ ├── examples │ │ ├── Continuous │ │ │ └── Continuous.ino │ │ └── Single │ │ │ └── Single.ino │ │ ├── keywords.txt │ │ └── library.properties ├── LoRa_PHY │ ├── LoRa.cpp │ ├── LoRa.h │ ├── LoRaReceiver_Phy │ │ └── LoRaReceiver_Phy.ino │ ├── LoRaSender_Phy │ │ └── LoRaSender_Phy.ino │ ├── LoRa_test_States │ │ └── LoRa_test_States.ino │ ├── Power_consumption_Lab.pdf │ └── readme.md ├── Sensors │ ├── readSI7021 │ │ └── readSI7021.ino │ └── readTEMT6000 │ │ └── readTEMT6000.ino └── readme.md ├── Gerber ├── gerber_UCAv2.0.rar └── readme.md ├── README.md └── documents ├── Conferences ├── Atelier_IoT_LoRaWAN_2019.pdf ├── DaNang_UCA_04_2018.pdf ├── EUCAP_UCA_04_2018.pdf ├── IWASI_UCA_06_2017.pdf ├── TTN_UCA_02_2018.pdf └── readme.md ├── Course ├── Course_LPWAN.pdf ├── Course_LoRaWAN.pdf ├── Lab1_Channel_Measurement.pdf ├── Lab2_LoRaWan_Register_device.pdf └── readme.md ├── Labs ├── Lab1_Channel_Measurement.pdf ├── Lab2_Understanding_LoRa_modulation.pdf ├── Lab3_LoRaWan_Register_device.pdf ├── Lab4_Power consumption.pdf └── readme.md ├── pictures ├── LED_Blue.jpg ├── LED_Green.jpg ├── LED_Red.jpg ├── TEMT6000_lx.jpg ├── TEMT6000_lx.png ├── TEMT6000_sch.png ├── TTN_LED.png ├── UCA.jpg ├── UCA_layout.png ├── UCA_layout_bot.png ├── UCA_layout_top.png ├── UCA_mounted.png ├── UCA_sensors.png ├── UCA_top.png ├── cayenne_LED.png └── readme.md └── tutorial ├── DaNang ├── DA NANG SMART CAMPUS-2018_2019_ATIGB.pdf ├── DA NANG SMART CAMPUS-2018_2019_Seminar.pdf ├── IoT_App_service_Tutorial_2018.pdf ├── LORA_tutorial_2017.pdf ├── LoRaWan_TTN_tuto_DaNang_2018_2019.pdf └── readme.md ├── IoT_App_service_Tutorial_2018.pdf ├── LoRaWan_TTN_tuto_v2.pdf ├── Ordering_a_PCB_with_PCBways_V2.pdf ├── UCA_Antenna_tuto.pdf └── readme.md /Antenna/UCA_Antenna_tuto.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Antenna/UCA_Antenna_tuto.pdf -------------------------------------------------------------------------------- /Antenna/UCA_UFL_Connector.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Antenna/UCA_UFL_Connector.pdf -------------------------------------------------------------------------------- /Antenna/readme.md: -------------------------------------------------------------------------------- 1 | # This section is dedicated to the antenna part. 2 | 3 | * Antennas are very sensitive to the environment, a tutorial is proposed to tune the UCA antenna 4 | -------------------------------------------------------------------------------- /Arduino_Code/CW/readme.md: -------------------------------------------------------------------------------- 1 | This code has been realized by CongDuc Pham, 2 | 3 | It provides on Continuous wave for power for TRP measurements 4 | -------------------------------------------------------------------------------- /Arduino_Code/ChannelSounder/DUT_ChannelSounder_Sender/DUT_ChannelSounder_Sender.ino: -------------------------------------------------------------------------------- 1 | //#include 2 | #include 3 | #include 4 | //#include 5 | 6 | 7 | #define SS 10 8 | #define RST 8 9 | #define DI0 2 10 | #define BAND 866E6 11 | #define spreadingFactor 7 12 | #define SignalBandwidth 125E3 13 | //#define SignalBandwidth 31.25E3 14 | #define preambleLength 8 15 | #define codingRateDenominator 8 16 | #define Pow 14 17 | 18 | //#define SHOW_DEBUGINFO // Uncomment if you want to see info on Serial 19 | 20 | int counter = 0; 21 | long freq_start = 863e6; 22 | long freq_stop = 870e6; 23 | long freq_step = 1e6; 24 | 25 | long next_freq = freq_start; 26 | 27 | void setup() { 28 | 29 | LoRa.setPins(SS,RST,DI0); 30 | Serial.begin(115200); 31 | if (!LoRa.begin(BAND)) { 32 | Serial.println("Starting LoRa failed!"); 33 | while (1); 34 | } 35 | LoRa.setSpreadingFactor(spreadingFactor); 36 | LoRa.setSignalBandwidth(SignalBandwidth); 37 | LoRa.setCodingRate4(codingRateDenominator); 38 | LoRa.setPreambleLength(preambleLength); 39 | LoRa.setTxPower(Pow, 1); 40 | 41 | delay(2000); 42 | 43 | #ifdef SHOW_DEBUGINFO 44 | Serial.println("LoRa Sender"); 45 | Serial.print("LoRa Spreading Factor: "); 46 | Serial.println(spreadingFactor); 47 | Serial.print("LoRa Signal Bandwidth: "); 48 | Serial.println(SignalBandwidth); 49 | Serial.print("LoRa power: "); 50 | Serial.println(Pow); 51 | Serial.println("LoRa Initial OK!"); 52 | delay(5000); 53 | #endif 54 | 55 | } 56 | 57 | void loop() { 58 | 59 | LoRa.setFrequency(next_freq); // change frequency 60 | 61 | #ifdef SHOW_DEBUGINFO 62 | Serial.print("Sending packet: "); 63 | Serial.println((String)next_freq + " MHz"); 64 | #endif 65 | 66 | next_freq = next_freq + freq_step ; // increment of the next freq 67 | if(next_freq > freq_stop){ // when freq arrived at freq stop, it restart at freq_start 68 | next_freq = freq_start; 69 | } 70 | 71 | // send packet 72 | LoRa.beginPacket(); 73 | LoRa.print(next_freq); 74 | LoRa.endPacket(); 75 | counter++; 76 | 77 | digitalWrite(13, HIGH); // turn the LED on (HIGH is the voltage level) 78 | delay(100); // wait for a second 79 | digitalWrite(13, LOW); // turn the LED off by making the voltage LOW 80 | delay(100); // wait for a second 81 | 82 | 83 | 84 | 85 | } 86 | -------------------------------------------------------------------------------- /Arduino_Code/ChannelSounder/LoRaOLED_ChannelSounder_Master/LoRaOLED_ChannelSounder_Master.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright (c) 2018 Fabien Ferrero 4 | * 5 | * Permission is hereby granted, free of charge, to anyone 6 | * obtaining a copy of this document and accompanying files, 7 | * to do whatever they want with them without any restriction, 8 | * including, but not limited to, copying, modification and redistribution. 9 | * NO WARRANTY OF ANY KIND IS PROVIDED. 10 | * 11 | * This example receive LoRa packet with frequency hooping information in the 12 | * payload and change the frequency for the next packet. 13 | * This code made for Heltec LoRa board 860-915MHz version 14 | * It can be use to measure LoRa device radiation performance and to tune the 15 | * device antenna 16 | * 17 | */ 18 | 19 | 20 | #include // Only needed for Arduino 1.6.5 and earlier 21 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 22 | #include 23 | #include 24 | // #include "SSD1306.h" 25 | 26 | SSD1306 display(0x3c, 4, 15); // Set the display 27 | 28 | 29 | #define SS 18 30 | #define RST 14 31 | #define DI0 26 32 | 33 | // LoRa Settings 34 | #define BAND 866E6 35 | #define spreadingFactor 7 // Use of a low SF to speed the scanning process 36 | #define SignalBandwidth 125E3 37 | //#define SignalBandwidth 31.25E3 38 | 39 | #define codingRateDenominator 8 40 | 41 | #define interruptPin 0 // PIN 0 for interrupt with PRG button 42 | 43 | long freq = 868e6; // Default frequency at initialisation 44 | long freq_max=870e6; 45 | long freq_min=863e6; 46 | 47 | long max_freq=freq; // freq with max RSSI 48 | long min_freq=freq; // freq with max RSSI 49 | 50 | bool Pushdetected = false; // reset peak freq 51 | 52 | long counter = -1; // number of received packet since the last init 53 | int RSSI = -140; 54 | int max_RSSI=-140; 55 | int min_RSSI=0; 56 | int average_RSSI=0; 57 | int RSSI_array[10000]; 58 | float sqDevSum=0; 59 | 60 | 61 | 62 | void gotPush(){ // reset peak freq on interrupt 63 | Pushdetected = true; 64 | } 65 | 66 | void setup() { 67 | 68 | // Define interrupt on PRG button to reset peak freq 69 | pinMode(interruptPin, INPUT_PULLUP); 70 | attachInterrupt(digitalPinToInterrupt(interruptPin), gotPush, CHANGE); 71 | 72 | pinMode(16,OUTPUT); 73 | digitalWrite(16, LOW); // set GPIO16 low to reset OLED 74 | delay(50); 75 | digitalWrite(16, HIGH); 76 | 77 | display.init(); 78 | display.flipScreenVertically(); 79 | display.setFont(ArialMT_Plain_10); 80 | display.setTextAlignment(TEXT_ALIGN_LEFT); 81 | 82 | Serial.begin(115200); 83 | while (!Serial); //if just the the basic function, must connect to a computer 84 | delay(1000); 85 | 86 | Serial.println("LoRa Receiver"); 87 | display.drawString(5,5,"LoRa Receiver"); 88 | display.display(); 89 | SPI.begin(5,19,27,18); 90 | LoRa.setPins(SS,RST,DI0); 91 | 92 | 93 | 94 | if (!LoRa.begin(BAND)) { 95 | display.drawString(5,25,"Starting LoRa failed!"); 96 | while (1); 97 | } 98 | Serial.println("LoRa Init OK"); 99 | 100 | Serial.print("LoRa Frequency: "); 101 | Serial.println(BAND); 102 | 103 | Serial.print("LoRa Spreading Factor: "); 104 | Serial.println(spreadingFactor); 105 | LoRa.setSpreadingFactor(spreadingFactor); 106 | 107 | Serial.print("LoRa Signal Bandwidth: "); 108 | Serial.println(SignalBandwidth); 109 | LoRa.setSignalBandwidth(SignalBandwidth); 110 | 111 | LoRa.setCodingRate4(codingRateDenominator); 112 | 113 | display.drawString(5,25,"LoRa Init OK"); 114 | display.drawString(5,45,"Wait @ "+(String)((int)(freq/1e6))+ "MHz"); 115 | display.display(); 116 | } 117 | 118 | void loop() { 119 | 120 | if(Pushdetected){ // reset Peak freq and max RSSI value 121 | Pushdetected = false; 122 | max_RSSI=-140; 123 | min_RSSI=0; 124 | counter = -5; // start with count < 0 to add a small delay before the start of the measurement 125 | max_freq=0; 126 | min_freq=0; 127 | 128 | 129 | } 130 | 131 | // try to parse packet 132 | int packetSize = LoRa.parsePacket(); 133 | if (packetSize) { 134 | // received a packets 135 | 136 | 137 | 138 | counter++; 139 | 140 | // read packet 141 | while (LoRa.available()) { 142 | String data = LoRa.readString(); 143 | freq = data.toInt(); // data converted to int 144 | // If a packet is not received with a suitable frequency, set in the good freq range 145 | if(freq > freq_max){ 146 | freq = freq_max; 147 | } 148 | if(freq < freq_min){ 149 | freq = freq_min; 150 | } 151 | 152 | //RSSI calculation 153 | RSSI = LoRa.packetRssi()+157; // Extract raw value of packetrssi register 154 | RSSI = (16*RSSI)/15; //value correction from the datasheet 155 | RSSI = RSSI -157; // Re-Calculate value in dBm 156 | 157 | if(counter >= 0){ 158 | RSSI_array[counter]=RSSI; 159 | 160 | } 161 | 162 | long freq_MHz= freq / 1e6; // freq in MHz 163 | 164 | display.clear(); 165 | display.setFont(ArialMT_Plain_10); 166 | display.drawString(0, 0, "Rx N°" + (String)counter+" "+ (String)freq_MHz + "M: " + (String)RSSI + "dBm"); 167 | display.display(); 168 | 169 | if(counter > 0){ 170 | 171 | average_RSSI = 0; 172 | for( int i=0; i<=counter; i++ ) { 173 | average_RSSI = average_RSSI + RSSI_array[i]; 174 | } 175 | average_RSSI = average_RSSI / counter; 176 | 177 | sqDevSum=0; 178 | for( int i=0; i<=counter; i++ ) { 179 | sqDevSum += (float) pow(average_RSSI - RSSI_array[i], 2); 180 | 181 | } 182 | sqDevSum = sqrt(sqDevSum /counter); 183 | 184 | display.drawString(2, 15,"Av:"+(String)average_RSSI + "dBm Dev:"+(String)sqDevSum+"dB" ); 185 | display.display(); 186 | 187 | if(RSSI > max_RSSI && counter > 0){ 188 | max_RSSI=RSSI; 189 | max_freq=freq; 190 | } 191 | 192 | if(RSSI < min_RSSI && counter > 0){ 193 | min_RSSI=RSSI; 194 | min_freq=freq; 195 | } 196 | // print RSSI of packet 197 | 198 | Serial.print(freq); 199 | long minfreq_MHz= min_freq / 1e6; // freq in MHz 200 | display.drawString(0,33,"Min:"+(String)minfreq_MHz+"MHz:"+(String)min_RSSI + "dBm"); 201 | 202 | display.display(); 203 | } 204 | } 205 | 206 | Serial.print(" "); 207 | Serial.print(RSSI); 208 | Serial.print(" "); 209 | Serial.println(LoRa.packetSnr()); 210 | long maxfreq_MHz= max_freq / 1e6; // freq in MHz 211 | display.drawString(0, 52, "Max:"+(String)maxfreq_MHz+"MHz:"+(String)max_RSSI + "dBm"); 212 | display.display(); 213 | 214 | LoRa.setFrequency(freq); // change frequency 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /Arduino_Code/ChannelSounder/LoRaOLED_ChannelSounder_Sender/LoRaOLED_ChannelSounder_Sender.ino: -------------------------------------------------------------------------------- 1 | #include // Only needed for Arduino 1.6.5 and earlier 2 | #include "SSD1306.h" // alias for `#include "SSD1306Wire.h"` 3 | 4 | #include 5 | #include 6 | // #include "SSD1306.h" 7 | #include 8 | 9 | 10 | //OLED pins to ESP32 GPIOs via this connecthin: 11 | //OLED_SDA — GPIO4 12 | //OLED_SCL — GPIO15 13 | //OLED_RST — GPIO16 14 | 15 | SSD1306 display(0x3c, 4, 15); 16 | 17 | 18 | 19 | // WIFI_LoRa_32 ports 20 | 21 | // GPIO5 — SX1278’s SCK 22 | // GPIO19 — SX1278’s MISO 23 | // GPIO27 — SX1278’s MOSI 24 | // GPIO18 — SX1278’s CS 25 | // GPIO14 — SX1278’s RESET 26 | // GPIO26 — SX1278’s IRQ(Interrupt Request) 27 | 28 | #define SS 18 29 | #define RST 14 30 | #define DI0 26 31 | #define BAND 866E6 32 | 33 | // #define BAND 434500000.00 34 | //#define BAND 866500000.00 35 | 36 | #define spreadingFactor 7 37 | #define SignalBandwidth 125E3 38 | //#define SignalBandwidth 31.25E3 39 | #define preambleLength 8 40 | #define codingRateDenominator 8 41 | #define Pow 14 42 | 43 | int counter = 0; 44 | 45 | 46 | long freq_start = 863e6; 47 | long freq_stop = 870e6; 48 | long freq_step = 1e6; 49 | 50 | long next_freq = freq_start; 51 | 52 | void setup() { 53 | pinMode(25,OUTPUT); //Send success, LED will bright 1 second 54 | 55 | pinMode(16,OUTPUT); 56 | digitalWrite(16, LOW); // set GPIO16 low to reset OLED 57 | delay(50); 58 | digitalWrite(16, HIGH); 59 | 60 | Serial.begin(115200); 61 | while (!Serial); //If just the the basic function, must connect to a computer 62 | 63 | // Initialising the UI will init the display too. 64 | display.init(); 65 | display.flipScreenVertically(); 66 | display.setFont(ArialMT_Plain_10); 67 | display.setTextAlignment(TEXT_ALIGN_LEFT); 68 | display.drawString(5,5,"LoRa Sender"); 69 | display.display(); 70 | 71 | SPI.begin(5,19,27,18); 72 | LoRa.setPins(SS,RST,DI0); 73 | Serial.println("LoRa Sender"); 74 | if (!LoRa.begin(BAND)) { 75 | Serial.println("Starting LoRa failed!"); 76 | while (1); 77 | } 78 | 79 | Serial.print("LoRa Spreading Factor: "); 80 | Serial.println(spreadingFactor); 81 | LoRa.setSpreadingFactor(spreadingFactor); 82 | 83 | Serial.print("LoRa Signal Bandwidth: "); 84 | Serial.println(SignalBandwidth); 85 | LoRa.setSignalBandwidth(SignalBandwidth); 86 | 87 | Serial.print("LoRa power: "); 88 | Serial.println(Pow); 89 | LoRa.setTxPower(Pow, 14); 90 | 91 | LoRa.setCodingRate4(codingRateDenominator); 92 | 93 | LoRa.setPreambleLength(preambleLength); 94 | 95 | Serial.println("LoRa Initial OK!"); 96 | display.drawString(5,20,"LoRa Initializing OK!"); 97 | display.display(); 98 | delay(2000); 99 | } 100 | 101 | void loop() { 102 | 103 | LoRa.setFrequency(next_freq); // change frequency 104 | 105 | 106 | Serial.print("Sending packet: "); 107 | Serial.println(counter); 108 | 109 | display.clear(); 110 | display.setFont(ArialMT_Plain_16); 111 | display.drawString(3, 5, "Sending packet "); 112 | display.drawString(50, 30, String(next_freq/1e6) + " MHz"); 113 | display.display(); 114 | 115 | next_freq = next_freq + freq_step ; // increment of the next freq 116 | 117 | if(next_freq > freq_stop){ // when freq arrived at freq stop, it restart at freq_start 118 | 119 | next_freq = freq_start; 120 | } 121 | 122 | // send packet 123 | LoRa.beginPacket(); 124 | //LoRa.print("Hello.."); 125 | LoRa.print(next_freq); 126 | LoRa.endPacket(); 127 | 128 | counter++; 129 | digitalWrite(25, HIGH); // turn the LED on (HIGH is the voltage level) 130 | delay(100); // wait for a second 131 | digitalWrite(25, LOW); // turn the LED off by making the voltage LOW 132 | delay(200); // wait for a second 133 | 134 | 135 | 136 | // delay(3000); 137 | } 138 | -------------------------------------------------------------------------------- /Arduino_Code/ChannelSounder/readme.md: -------------------------------------------------------------------------------- 1 | Channel sounding is based on Heltec 32 LoRa or TTGO LoRa 32 terminal with the OLED screen. 2 | 3 | In order to perform a channel measurements, two devices are needed : a sender and a receiver. 4 | 5 | For the sender, UCA board or OLED screen board can be used. 6 | The sender send lora packet at different frequencies with the next frequencies in the packet payload. 7 | 8 | For the receiver, use the "LoRaOLED_ChannelSounder_Master" code. 9 | 10 | The code is hopping the receiving frequency by decoding the received payload. 11 | The RSSI is stored in an array and averaged. The min and max value are also displayed 12 | 13 | When the button is pushed the counter is reset and the measurement is restarted. 14 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/ABP/Basic/readme.md: -------------------------------------------------------------------------------- 1 | Exemple of Activation By Personalisation (ABP) 2 | 3 | You have to define : 4 | 5 | NWKSKEY : [16 Bytes] MSB 6 | 7 | APPSKEY : [16 Bytes] MSB 8 | 9 | DEV ADDRESS : [8 Bytes] MSB 10 | 11 | Pay attention to the frame counter in TTN, you have to reset it each time you reset your board. 12 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LED_CONTROLLER/readme.md: -------------------------------------------------------------------------------- 1 | # What the code is doing ? 2 | * LoRaWan OTAA activation 3 | * Adaptative Spreading factor 4 | * Control a RGB LED 5 | * Cayenne LPP Payload 6 | 7 | The luminosity of each color can be adjusted from 0 to 255 using Cayenne my devices 8 | 9 | 10 | 11 | We are using Class C protocol, so the latency mainly depends on the uplink duty cycle. 12 | 13 | For now, only one command can be sent at once, if two commands are sent in the same uplink cycle, only the last one is really sent. 14 | 15 | This code has been tested on EUR868 and AS923 bands 16 | 17 | The bands can be selected in config.h of Arduino_LMIC Lib 18 | 19 | You can use https://mydevices.com/ to control your LED 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_BME280/readme.md: -------------------------------------------------------------------------------- 1 | * LoRaWan OTAA activation 2 | * Adaptative Spreading factor 3 | * Low-power sleep between Tx 4 | * BME280 sensor 5 | * Cayenne LPP Payload 6 | 7 | This code has been tested on EUR868 and AS923 bands 8 | 9 | The bands can be selected in config.h of Arduino_LMIC Lib 10 | 11 | You can use https://mydevices.com/ to plot your data, 12 | 13 | Here is an exemple of my sensor in my cellar : 14 | 15 | https://cayenne.mydevices.com/shared/5a73f72f62205b6761b236af/project/656296df-8284-44bc-bbc4-9d82c5aa18be 16 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_Basic/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : https://github.com/tkerby/minilora-test 2 | 3 | To register on the network, you need to specify : 4 | 5 | *AppEUI :[8 Bytes] LSB format
6 | *DevEUI :[8 Bytes] LSB format
7 | *APPKEY :[8 Bytes] MSB format
8 | 9 | 10 | It includes : 11 | 12 | *LoRaWan OTAA activation 13 | *Adaptative Spreading factor 14 | *Low-power sleep between Tx 15 | *Vcc MCU measurement 16 | *Cayenne Payload 17 | This code has been tested on EUR868 and AS923 bands 18 | 19 | The bands can be selected in config.h of Arduino_LMIC Lib 20 | 21 | The starting SF for the joining process can be changed in the LMIC library : 22 | lmic.c, change in "setDrJoin()" 23 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_DHT22/DHT.cpp: -------------------------------------------------------------------------------- 1 | /* DHT library 2 | 3 | MIT license 4 | written by Adafruit Industries 5 | */ 6 | 7 | #include "DHT.h" 8 | 9 | DHT::DHT(uint8_t pin, uint8_t type, uint8_t count) { 10 | _pin = pin; 11 | _type = type; 12 | _count = count; 13 | firstreading = true; 14 | } 15 | 16 | void DHT::begin(void) { 17 | // set up the pins! 18 | pinMode(_pin, INPUT); 19 | digitalWrite(_pin, HIGH); 20 | _lastreadtime = 0; 21 | } 22 | 23 | //boolean S == Scale. True == Farenheit; False == Celcius 24 | float DHT::readTemperature(bool S) { 25 | float f; 26 | 27 | if (read()) { 28 | switch (_type) { 29 | case DHT11: 30 | f = data[2]; 31 | if(S) 32 | f = convertCtoF(f); 33 | 34 | return f; 35 | case DHT22: 36 | case DHT21: 37 | f = data[2] & 0x7F; 38 | f *= 256; 39 | f += data[3]; 40 | f /= 10; 41 | if (data[2] & 0x80) 42 | f *= -1; 43 | if(S) 44 | f = convertCtoF(f); 45 | 46 | return f; 47 | } 48 | } 49 | return NAN; 50 | } 51 | 52 | float DHT::convertCtoF(float c) { 53 | return c * 9 / 5 + 32; 54 | } 55 | 56 | float DHT::convertFtoC(float f) { 57 | return (f - 32) * 5 / 9; 58 | } 59 | 60 | float DHT::readHumidity(void) { 61 | float f; 62 | if (read()) { 63 | switch (_type) { 64 | case DHT11: 65 | f = data[0]; 66 | return f; 67 | case DHT22: 68 | case DHT21: 69 | f = data[0]; 70 | f *= 256; 71 | f += data[1]; 72 | f /= 10; 73 | return f; 74 | } 75 | } 76 | return NAN; 77 | } 78 | 79 | float DHT::computeHeatIndex(float tempFahrenheit, float percentHumidity) { 80 | // Adapted from equation at: https://github.com/adafruit/DHT-sensor-library/issues/9 and 81 | // Wikipedia: http://en.wikipedia.org/wiki/Heat_index 82 | return -42.379 + 83 | 2.04901523 * tempFahrenheit + 84 | 10.14333127 * percentHumidity + 85 | -0.22475541 * tempFahrenheit*percentHumidity + 86 | -0.00683783 * pow(tempFahrenheit, 2) + 87 | -0.05481717 * pow(percentHumidity, 2) + 88 | 0.00122874 * pow(tempFahrenheit, 2) * percentHumidity + 89 | 0.00085282 * tempFahrenheit*pow(percentHumidity, 2) + 90 | -0.00000199 * pow(tempFahrenheit, 2) * pow(percentHumidity, 2); 91 | } 92 | 93 | 94 | boolean DHT::read(void) { 95 | uint8_t laststate = HIGH; 96 | uint8_t counter = 0; 97 | uint8_t j = 0, i; 98 | unsigned long currenttime; 99 | 100 | // Check if sensor was read less than two seconds ago and return early 101 | // to use last reading. 102 | currenttime = millis(); 103 | if (currenttime < _lastreadtime) { 104 | // ie there was a rollover 105 | _lastreadtime = 0; 106 | } 107 | if (!firstreading && ((currenttime - _lastreadtime) < 2000)) { 108 | return true; // return last correct measurement 109 | //delay(2000 - (currenttime - _lastreadtime)); 110 | } 111 | firstreading = false; 112 | /* 113 | Serial.print("Currtime: "); Serial.print(currenttime); 114 | Serial.print(" Lasttime: "); Serial.print(_lastreadtime); 115 | */ 116 | _lastreadtime = millis(); 117 | 118 | data[0] = data[1] = data[2] = data[3] = data[4] = 0; 119 | 120 | // pull the pin high and wait 250 milliseconds 121 | digitalWrite(_pin, HIGH); 122 | delay(250); 123 | 124 | // now pull it low for ~20 milliseconds 125 | pinMode(_pin, OUTPUT); 126 | digitalWrite(_pin, LOW); 127 | delay(20); 128 | noInterrupts(); 129 | digitalWrite(_pin, HIGH); 130 | delayMicroseconds(40); 131 | pinMode(_pin, INPUT); 132 | 133 | // read in timings 134 | for ( i=0; i< MAXTIMINGS; i++) { 135 | counter = 0; 136 | while (digitalRead(_pin) == laststate) { 137 | counter++; 138 | delayMicroseconds(1); 139 | if (counter == 255) { 140 | break; 141 | } 142 | } 143 | laststate = digitalRead(_pin); 144 | 145 | if (counter == 255) break; 146 | 147 | // ignore first 3 transitions 148 | if ((i >= 4) && (i%2 == 0)) { 149 | // shove each bit into the storage bytes 150 | data[j/8] <<= 1; 151 | if (counter > 3) 152 | data[j/8] |= 1; 153 | j++; 154 | } 155 | 156 | } 157 | 158 | interrupts(); 159 | 160 | /* 161 | Serial.println(j, DEC); 162 | Serial.print(data[0], HEX); Serial.print(", "); 163 | Serial.print(data[1], HEX); Serial.print(", "); 164 | Serial.print(data[2], HEX); Serial.print(", "); 165 | Serial.print(data[3], HEX); Serial.print(", "); 166 | Serial.print(data[4], HEX); Serial.print(" =? "); 167 | Serial.println(data[0] + data[1] + data[2] + data[3], HEX); 168 | */ 169 | 170 | // check we read 40 bits and that the checksum matches 171 | if ((j >= 40) && 172 | (data[4] == ((data[0] + data[1] + data[2] + data[3]) & 0xFF)) ) { 173 | return true; 174 | } 175 | 176 | 177 | return false; 178 | 179 | } 180 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_DHT22/DHT.h: -------------------------------------------------------------------------------- 1 | #ifndef DHT_H 2 | #define DHT_H 3 | #if ARDUINO >= 100 4 | #include "Arduino.h" 5 | #else 6 | #include "WProgram.h" 7 | #endif 8 | 9 | /* DHT library 10 | 11 | MIT license 12 | written by Adafruit Industries 13 | */ 14 | 15 | // how many timing transitions we need to keep track of. 2 * number bits + extra 16 | #define MAXTIMINGS 85 17 | 18 | #define DHT11 11 19 | #define DHT22 22 20 | #define DHT21 21 21 | #define AM2301 21 22 | 23 | class DHT { 24 | private: 25 | uint8_t data[6]; 26 | uint8_t _pin, _type, _count; 27 | unsigned long _lastreadtime; 28 | boolean firstreading; 29 | 30 | public: 31 | DHT(uint8_t pin, uint8_t type, uint8_t count=6); 32 | void begin(void); 33 | float readTemperature(bool S=false); 34 | float convertCtoF(float); 35 | float convertFtoC(float); 36 | float computeHeatIndex(float tempFahrenheit, float percentHumidity); 37 | float readHumidity(void); 38 | boolean read(void); 39 | 40 | }; 41 | #endif 42 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_DHT22/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : https://github.com/tkerby/minilora-test 2 | 3 | It includes : 4 | 5 | * LoRaWan OTAA activation 6 | * Adaptative Spreading factor 7 | * Low-power sleep between Tx 8 | * DHT22 sensor for temperature and humidity 9 | * Cayenne Payload 10 | 11 | This code has been tested on EUR868 and AS923 bands 12 | 13 | The bands can be selected in config.h of Arduino_LMIC Lib 14 | 15 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_GYVL53L0X/readme.md: -------------------------------------------------------------------------------- 1 | # What is inside : 2 | 3 | * LoRaWan OTAA activation 4 | * Adaptative Spreading factor 5 | * Low-power sleep between Tx 6 | * GYVL53L0X sensor 7 | * Cayenne LPP Payload 8 | 9 | # VL53L0X Time of flight Laser ranging sensor 10 | 11 | This I2C sensor is a laser-ranging sensor, with capability to detect a target object up to 2 m away. 12 | The VL53L0X uses time-of-flight measurements of infrared pulses for ranging, allowing it to give accurate results independent of the target’s color and surface. 13 | Distance measurements can be read through a digital I²C interface. 14 | 15 | This component can be found for less than 5$. 16 | 17 | It consumes 5uA in standby mode and 20mA in active ranging mode. A ranging measurement require from 30 to 200ms. 18 | 19 | Nice information on this link : https://www.pololu.com/product/2490 20 | 21 | Datasheet : https://www.st.com/resource/en/datasheet/vl53l0x.pdf 22 | 23 | This code has been tested on EUR868 and AS923 bands 24 | 25 | The bands can be selected in config.h of Arduino_LMIC Lib 26 | 27 | You can use https://mydevices.com/ to plot your data, 28 | 29 | 30 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_SI7021/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : https://github.com/tkerby/minilora-test 2 | 3 | It includes : 4 | 5 | * LoRaWan OTAA activation 6 | * Adaptative Spreading factor 7 | * Low-power sleep between Tx 8 | * SI7021 sensor for temperature and humidity 9 | * Cayenne Payload 10 | 11 | This code has been tested on EUR868 and AS923 bands 12 | 13 | The bands can be selected in config.h of Arduino_LMIC Lib 14 | 15 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_SI7021_TEMT6000/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : https://github.com/tkerby/minilora-test 2 | 3 | It includes : 4 | 5 | * LoRaWan OTAA activation 6 | * Adaptative Spreading factor 7 | * Low-power sleep between Tx 8 | * SI7021 sensor for temperature and humidity 9 | * Cayenne Payload 10 | 11 | This code has been tested on EUR868 and AS923 bands 12 | 13 | The bands can be selected in config.h of Arduino_LMIC Lib 14 | 15 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_TEMT6000/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : https://github.com/tkerby/minilora-test 2 | 3 | It includes : 4 | 5 | * LoRaWan OTAA activation 6 | * Adaptative Spreading factor 7 | * Low-power sleep between Tx 8 | * TEMT6000 sensor for light 9 | * Cayenne Payload 10 | 11 | This code has been tested on EUR868 and AS923 bands 12 | 13 | The bands can be selected in config.h of Arduino_LMIC Lib 14 | 15 | The light sensor is the TEMT6000, and the module integrating this sensor is provided by Sparkfun : https://www.sparkfun.com/products/8688 16 | 17 | This board can be find easily for less than 1€. 18 | 19 | As shown is figure below, the photo transistor is mounted with a 10kohm resistor. 20 | 21 | 22 | 23 | 24 | From the voltage measured on Sig PIN, the source current can be easily calculated, and the figure below extracted from the datasheet can be used to calculate the illuminance in Lx. 25 | The datasheet can be find in this link : https://www.vishay.com/docs/81579/temt6000.pdf 26 | 27 | 28 | 29 | 30 | For Illuminance, the Cayenne LPP code is 101 (Hex is 65), the Data size is 2 Byte with a resoluation of 1 Lux (Unsigned MSB). 31 | 32 | Information about Cayenne payload is available here : https://github.com/myDevicesIoT/cayenne-docs/blob/master/docs/LORA.md 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_Thermistance/adcvcc.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "Arduino.h" 5 | 6 | 7 | volatile uint8_t _adc_irq_cnt; 8 | 9 | 10 | // add this to the INO of you project. 11 | ///* ====================================================================== 12 | //Function: ADC_vect 13 | //Purpose : IRQ Handler for ADC 14 | //Input : - 15 | //Output : - 16 | //Comments: used for measuring 8 samples low power mode, ADC is then in 17 | // free running mode for 8 samples 18 | //====================================================================== */ 19 | //ISR(ADC_vect) 20 | //{ 21 | // // Increment ADC counter 22 | // _adc_irq_cnt++; 23 | //} 24 | 25 | 26 | /* ====================================================================== 27 | Function: readADCLowNoise 28 | Purpose : Read Analog Value with reducing noise 29 | Input : true return the average value, false return only the sum 30 | Output : average value read 31 | Comments: hard coded to read 8 samples each time 32 | AD MUX Channel and ADC must have been set before this call 33 | ====================================================================== */ 34 | uint16_t readADCLowNoise(boolean average) 35 | { 36 | uint8_t low, high; 37 | uint16_t sum = 0; 38 | 39 | // Start 1st Conversion, but ignore it, can be hazardous 40 | ADCSRA |= _BV(ADSC); 41 | 42 | // wait for first dummy conversion 43 | while (bit_is_set(ADCSRA,ADSC)); 44 | 45 | // Init our measure counter 46 | _adc_irq_cnt = 0; 47 | 48 | // We want to have a interrupt when the conversion is done 49 | ADCSRA |= _BV( ADIE ); 50 | 51 | // Loop thru samples 52 | // 8 samples (we don't take the 1st one) 53 | do { 54 | // Enable Noise Reduction Sleep Mode 55 | set_sleep_mode( SLEEP_MODE_ADC ); 56 | sleep_enable(); 57 | 58 | // Wait until conversion is finished 59 | do { 60 | // enabled IRQ before sleeping 61 | sei(); 62 | sleep_cpu(); 63 | cli(); 64 | } 65 | // Check is done with interrupts disabled to avoid a race condition 66 | while (bit_is_set(ADCSRA,ADSC)); 67 | 68 | // No more sleeping 69 | sleep_disable(); 70 | sei(); 71 | 72 | // read low first 73 | low = ADCL; 74 | high = ADCH; 75 | 76 | // Sum the total 77 | sum += ((high << 8) | low); 78 | } 79 | while (_adc_irq_cnt<8); 80 | 81 | // No more interrupts needed for this 82 | // we finished the job 83 | ADCSRA &= ~ _BV( ADIE ); 84 | 85 | // Return the average divided by 8 (8 samples) 86 | return ( average ? sum >> 3 : sum ); 87 | } 88 | 89 | /* ====================================================================== 90 | Function: readVcc 91 | Purpose : Read and Calculate V powered, the Voltage on Arduino VCC pin 92 | Input : - 93 | Output : value readed 94 | Comments: ADC Channel input is modified 95 | ====================================================================== */ 96 | uint16_t readVcc() 97 | { 98 | uint16_t value, _vcc; 99 | 100 | // Enable ADC (just in case going out of low power) 101 | power_adc_enable(); 102 | ADCSRA |= _BV(ADEN) ; 103 | 104 | // Read 1.1V reference against AVcc 105 | // REFS1 REFS0 --> 0 1, AVcc internal ref. -Selects AVcc external reference 106 | // MUX3 MUX2 MUX1 MUX0 --> 1110 1.1V (VBG) -Selects channel 14, bandgap voltage, to measure 107 | ADMUX = (0< 5500 ) _vcc = 5500 ; 124 | 125 | // Vcc in millivolts 126 | return ( _vcc ); 127 | } 128 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_Thermistance/adcvcc.h: -------------------------------------------------------------------------------- 1 | 2 | extern uint16_t readVcc(); 3 | 4 | extern volatile uint8_t _adc_irq_cnt; 5 | -------------------------------------------------------------------------------- /Arduino_Code/LORAWAN/OTAA/LP_Thermistance/readme.md: -------------------------------------------------------------------------------- 1 | This code has been modified from : 2 | https://github.com/tkerby/minilora-test 3 | 4 | A thermistance is used to measure temperature, and the data are formatted in LPP Cayenne format. 5 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/BME280_Modes/BME280_Modes.ino: -------------------------------------------------------------------------------- 1 | /* 2 | BME280I2C Modes.ino 3 | 4 | This code shows how to use predefined recommended settings from Bosch for 5 | the BME280I2C environmental sensor. 6 | 7 | GNU General Public License 8 | 9 | Written: Dec 30 2015. 10 | Last Updated: Sep 23 2017. 11 | 12 | Connecting the BME280 Sensor: 13 | Sensor -> Board 14 | ----------------------------- 15 | Vin (Voltage In) -> 3.3V 16 | Gnd (Ground) -> Gnd 17 | SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro 18 | SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro 19 | 20 | */ 21 | 22 | #include 23 | #include // Needed for legacy versions of Arduino. 24 | 25 | #define SERIAL_BAUD 115200 26 | 27 | /* Recommended Modes - 28 | Based on Bosch BME280I2C environmental sensor data sheet. 29 | 30 | Weather Monitoring : 31 | forced mode, 1 sample/minute 32 | pressure ×1, temperature ×1, humidity ×1, filter off 33 | Current Consumption = 0.16 μA 34 | RMS Noise = 3.3 Pa/30 cm, 0.07 %RH 35 | Data Output Rate 1/60 Hz 36 | 37 | Humidity Sensing : 38 | forced mode, 1 sample/second 39 | pressure ×0, temperature ×1, humidity ×1, filter off 40 | Current Consumption = 2.9 μA 41 | RMS Noise = 0.07 %RH 42 | Data Output Rate = 1 Hz 43 | 44 | Indoor Navigation : 45 | normal mode, standby time = 0.5ms 46 | pressure ×16, temperature ×2, humidity ×1, filter = x16 47 | Current Consumption = 633 μA 48 | RMS Noise = 0.2 Pa/1.7 cm 49 | Data Output Rate = 25Hz 50 | Filter Bandwidth = 0.53 Hz 51 | Response Time (75%) = 0.9 s 52 | 53 | 54 | Gaming : 55 | normal mode, standby time = 0.5ms 56 | pressure ×4, temperature ×1, humidity ×0, filter = x16 57 | Current Consumption = 581 μA 58 | RMS Noise = 0.3 Pa/2.5 cm 59 | Data Output Rate = 83 Hz 60 | Filter Bandwidth = 1.75 Hz 61 | Response Time (75%) = 0.3 s 62 | 63 | */ 64 | 65 | BME280I2C::Settings settings( 66 | BME280::OSR_X1, 67 | BME280::OSR_X1, 68 | BME280::OSR_X1, 69 | BME280::Mode_Forced, 70 | BME280::StandbyTime_1000ms, 71 | BME280::Filter_Off, 72 | BME280::SpiEnable_False, 73 | BME280I2C::I2CAddr_0x76 // I2C address. I2C specific. 74 | ); 75 | 76 | BME280I2C bme(settings); 77 | 78 | ////////////////////////////////////////////////////////////////// 79 | void setup() 80 | { 81 | Serial.begin(SERIAL_BAUD); 82 | 83 | while(!Serial) {} // Wait 84 | 85 | Wire.begin(); 86 | while(!bme.begin()) 87 | { 88 | Serial.println("Could not find BME280I2C sensor!"); 89 | delay(1000); 90 | } 91 | 92 | switch(bme.chipModel()) 93 | { 94 | case BME280::ChipModel_BME280: 95 | Serial.println("Found BME280 sensor! Success."); 96 | break; 97 | case BME280::ChipModel_BMP280: 98 | Serial.println("Found BMP280 sensor! No Humidity available."); 99 | break; 100 | default: 101 | Serial.println("Found UNKNOWN sensor! Error!"); 102 | } 103 | 104 | // Change some settings before using. 105 | settings.tempOSR = BME280::OSR_X4; 106 | 107 | bme.setSettings(settings); 108 | } 109 | 110 | ////////////////////////////////////////////////////////////////// 111 | void loop() 112 | { 113 | printBME280Data(&Serial); 114 | delay(500); 115 | } 116 | 117 | ////////////////////////////////////////////////////////////////// 118 | void printBME280Data 119 | ( 120 | Stream* client 121 | ) 122 | { 123 | float temp(NAN), hum(NAN), pres(NAN); 124 | 125 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 126 | BME280::PresUnit presUnit(BME280::PresUnit_Pa); 127 | 128 | bme.read(pres, temp, hum, tempUnit, presUnit); 129 | 130 | client->print("Temp: "); 131 | client->print(temp); 132 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F')); 133 | client->print("\t\tHumidity: "); 134 | client->print(hum); 135 | client->print("% RH"); 136 | client->print("\t\tPressure: "); 137 | client->print(pres); 138 | client->println("Pa"); 139 | 140 | delay(1000); 141 | } 142 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/BME_280_BRZO_I2C_Test/BME_280_BRZO_I2C_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | BME280 BRZO I2C Test.ino 3 | 4 | This code shows how to record data from the BME280 environmental sensor 5 | using I2C interface and https://github.com/pasko-zh/brzo_i2c library 6 | on ESP8266. 7 | 8 | This file is an example file, part of the Arduino BME280 library. 9 | 10 | Copyright (C) 2016 Tyler Glenn 11 | Forked by Alex Shavlovsky 12 | to support https://github.com/pasko-zh/brzo_i2c library on ESP8266. 13 | 14 | GNU General Public License 15 | 16 | Written: Dec 30 2015. 17 | Last Updated: Oct 07 2017. 18 | 19 | Connecting the BME280 Sensor: 20 | Sensor -> Board 21 | ----------------------------- 22 | Vin (Voltage In) -> 3.3V 23 | Gnd (Ground) -> Gnd 24 | SDA (Serial Data) -> D2 on ESP8266 25 | SCK (Serial Clock) -> D1 on ESP8266 26 | 27 | */ 28 | #include "Arduino.h" 29 | 30 | #include "brzo_i2c.h" 31 | #define USING_BRZO 1 32 | #include "BME280I2C_BRZO.h" 33 | 34 | #define SERIAL_BAUD 115200 35 | 36 | const uint32_t I2C_ACK_TIMEOUT = 2000; 37 | 38 | BME280I2C_BRZO bme; // Default : forced mode, standby time = 1000 ms 39 | // Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off, 40 | 41 | bool metric = true; 42 | 43 | ////////////////////////////////////////////////////////////////// 44 | void setup() 45 | { 46 | Serial.begin(SERIAL_BAUD); 47 | 48 | while(!Serial) {} // Wait 49 | 50 | brzo_i2c_setup(SDA,SCL,I2C_ACK_TIMEOUT); 51 | 52 | while(!bme.begin()) 53 | { 54 | Serial.println("Could not find BME280 sensor!"); 55 | delay(1000); 56 | } 57 | 58 | switch(bme.chipModel()) 59 | { 60 | case BME280::ChipModel_BME280: 61 | Serial.println("Found BME280 sensor! Success."); 62 | break; 63 | case BME280::ChipModel_BMP280: 64 | Serial.println("Found BMP280 sensor! No Humidity available."); 65 | break; 66 | default: 67 | Serial.println("Found UNKNOWN sensor! Error!"); 68 | } 69 | } 70 | 71 | ////////////////////////////////////////////////////////////////// 72 | void loop() 73 | { 74 | printBME280Data(&Serial); 75 | delay(500); 76 | } 77 | 78 | ////////////////////////////////////////////////////////////////// 79 | void printBME280Data 80 | ( 81 | Stream* client 82 | ) 83 | { 84 | float temp(NAN), hum(NAN), pres(NAN); 85 | 86 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 87 | BME280::PresUnit presUnit(BME280::PresUnit_Pa); 88 | 89 | bme.read(pres, temp, hum, tempUnit, presUnit); 90 | 91 | client->print("Temp: "); 92 | client->print(temp); 93 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F')); 94 | client->print("\t\tHumidity: "); 95 | client->print(hum); 96 | client->print("% RH"); 97 | client->print("\t\tPressure: "); 98 | client->print(pres); 99 | client->println("Pa"); 100 | 101 | delay(1000); 102 | } 103 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/BME_280_I2C_Test/BME_280_I2C_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | BME280 I2C Test.ino 3 | 4 | This code shows how to record data from the BME280 environmental sensor 5 | using I2C interface. This file is an example file, part of the Arduino 6 | BME280 library. 7 | 8 | GNU General Public License 9 | 10 | Written: Dec 30 2015. 11 | Last Updated: Oct 07 2017. 12 | 13 | Connecting the BME280 Sensor: 14 | Sensor -> Board 15 | ----------------------------- 16 | Vin (Voltage In) -> 3.3V 17 | Gnd (Ground) -> Gnd 18 | SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro 19 | SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro 20 | 21 | */ 22 | 23 | #include 24 | #include 25 | 26 | #define SERIAL_BAUD 115200 27 | 28 | BME280I2C bme; // Default : forced mode, standby time = 1000 ms 29 | // Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off, 30 | 31 | ////////////////////////////////////////////////////////////////// 32 | void setup() 33 | { 34 | Serial.begin(SERIAL_BAUD); 35 | 36 | while(!Serial) {} // Wait 37 | 38 | Wire.begin(); 39 | 40 | while(!bme.begin()) 41 | { 42 | Serial.println("Could not find BME280 sensor!"); 43 | delay(1000); 44 | } 45 | 46 | switch(bme.chipModel()) 47 | { 48 | case BME280::ChipModel_BME280: 49 | Serial.println("Found BME280 sensor! Success."); 50 | break; 51 | case BME280::ChipModel_BMP280: 52 | Serial.println("Found BMP280 sensor! No Humidity available."); 53 | break; 54 | default: 55 | Serial.println("Found UNKNOWN sensor! Error!"); 56 | } 57 | } 58 | 59 | ////////////////////////////////////////////////////////////////// 60 | void loop() 61 | { 62 | printBME280Data(&Serial); 63 | delay(500); 64 | } 65 | 66 | ////////////////////////////////////////////////////////////////// 67 | void printBME280Data 68 | ( 69 | Stream* client 70 | ) 71 | { 72 | float temp(NAN), hum(NAN), pres(NAN); 73 | 74 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 75 | BME280::PresUnit presUnit(BME280::PresUnit_Pa); 76 | 77 | bme.read(pres, temp, hum, tempUnit, presUnit); 78 | 79 | client->print("Temp: "); 80 | client->print(temp); 81 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F')); 82 | client->print("\t\tHumidity: "); 83 | client->print(hum); 84 | client->print("% RH"); 85 | client->print("\t\tPressure: "); 86 | client->print(pres); 87 | client->println("Pa"); 88 | 89 | delay(1000); 90 | } 91 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/BME_280_Spi_Sw_Test/BME_280_Spi_Sw_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | BME280 Spi Sw Test.ino 3 | 4 | This code shows how to record data from the BME280 environmental sensor 5 | using Spi interface. This file is an example file, part of the Arduino 6 | BME280 library. 7 | 8 | GNU General Public License 9 | 10 | Written: Dec 30 2015. 11 | Last Updated: Oct 07 2017. 12 | 13 | Connecting the BME280 Sensor: 14 | Sensor -> Board 15 | ----------------------------- 16 | Vin (Voltage In) -> 3.3V 17 | Gnd (Ground) -> Gnd 18 | SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro 19 | SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro 20 | 21 | */ 22 | 23 | #include 24 | 25 | #define SERIAL_BAUD 115200 26 | 27 | #define CHIP_SELECT_PIN 10 28 | #define MOSI_PIN 11 29 | #define MISO_PIN 12 30 | #define SCK_PIN 13 31 | 32 | BME280SpiSw::Settings settings(CHIP_SELECT_PIN, MOSI_PIN, MISO_PIN, SCK_PIN); 33 | BME280SpiSw bme(settings); 34 | 35 | bool metric = false; 36 | 37 | ////////////////////////////////////////////////////////////////// 38 | void setup() 39 | { 40 | Serial.begin(SERIAL_BAUD); 41 | 42 | while(!Serial) {} // Wait 43 | 44 | while(!bme.begin()) 45 | { 46 | Serial.println("Could not find BME280 sensor!"); 47 | delay(1000); 48 | } 49 | 50 | switch(bme.chipModel()) 51 | { 52 | case BME280::ChipModel_BME280: 53 | Serial.println("Found BME280 sensor! Success."); 54 | break; 55 | case BME280::ChipModel_BMP280: 56 | Serial.println("Found BMP280 sensor! No Humidity available."); 57 | break; 58 | default: 59 | Serial.println("Found UNKNOWN sensor! Error!"); 60 | } 61 | } 62 | 63 | ////////////////////////////////////////////////////////////////// 64 | void loop() 65 | { 66 | printBME280Data(&Serial); 67 | delay(1000); 68 | } 69 | 70 | ////////////////////////////////////////////////////////////////// 71 | void printBME280Data 72 | ( 73 | Stream* client 74 | ) 75 | { 76 | float temp(NAN), hum(NAN), pres(NAN); 77 | 78 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 79 | BME280::PresUnit presUnit(BME280::PresUnit_Pa); 80 | 81 | bme.read(pres, temp, hum, tempUnit, presUnit); 82 | 83 | client->print("Temp: "); 84 | client->print(temp); 85 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F')); 86 | client->print("\t\tHumidity: "); 87 | client->print(hum); 88 | client->print("% RH"); 89 | client->print("\t\tPressure: "); 90 | client->print(pres); 91 | client->println("Pa"); 92 | 93 | delay(1000); 94 | } 95 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/BME_280_Spi_Test/BME_280_Spi_Test.ino: -------------------------------------------------------------------------------- 1 | /* 2 | BME280 Spi Test.ino 3 | 4 | This code shows how to record data from the BME280 environmental sensor 5 | using Spi interface. This file is an example file, part of the Arduino 6 | BME280 library. 7 | 8 | GNU General Public License 9 | 10 | Written: Dec 30 2015. 11 | Last Updated: Oct 07 2017. 12 | 13 | Connecting the BME280 Sensor: 14 | Sensor -> Board 15 | ----------------------------- 16 | Vin (Voltage In) -> 3.3V 17 | Gnd (Ground) -> Gnd 18 | SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro 19 | SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro 20 | 21 | */ 22 | 23 | #include // Needed for legacy versions of Arduino. 24 | #include 25 | 26 | #define SERIAL_BAUD 115200 27 | 28 | #define DEVICE_PIN 10 29 | 30 | BME280Spi::Settings settings(DEVICE_PIN); // Default : forced mode, standby time = 1000 ms 31 | // Oversampling = pressure ×1, temperature ×1, humidity ×1, filter off, 32 | 33 | BME280Spi bme(settings); 34 | 35 | 36 | ////////////////////////////////////////////////////////////////// 37 | void setup() 38 | { 39 | Serial.begin(SERIAL_BAUD); 40 | 41 | while(!Serial) {} // Wait 42 | 43 | SPI.begin(); 44 | 45 | while(!bme.begin()) 46 | { 47 | Serial.println("Could not find BME280 sensor!"); 48 | delay(1000); 49 | } 50 | 51 | switch(bme.chipModel()) 52 | { 53 | case BME280::ChipModel_BME280: 54 | Serial.println("Found BME280 sensor! Success."); 55 | break; 56 | case BME280::ChipModel_BMP280: 57 | Serial.println("Found BMP280 sensor! No Humidity available."); 58 | break; 59 | default: 60 | Serial.println("Found UNKNOWN sensor! Error!"); 61 | } 62 | } 63 | 64 | ////////////////////////////////////////////////////////////////// 65 | void loop() 66 | { 67 | printBME280Data(&Serial); 68 | delay(500); 69 | } 70 | 71 | ////////////////////////////////////////////////////////////////// 72 | void printBME280Data 73 | ( 74 | Stream* client 75 | ) 76 | { 77 | float temp(NAN), hum(NAN), pres(NAN); 78 | 79 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 80 | BME280::PresUnit presUnit(BME280::PresUnit_Pa); 81 | 82 | bme.read(pres, temp, hum, tempUnit, presUnit); 83 | 84 | client->print("Temp: "); 85 | client->print(temp); 86 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? 'C' :'F')); 87 | client->print("\t\tHumidity: "); 88 | client->print(hum); 89 | client->print("% RH"); 90 | client->print("\t\tPressure: "); 91 | client->print(pres); 92 | client->println("Pa"); 93 | 94 | delay(1000); 95 | } 96 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/examples/Environment_Calculations/Environment_Calculations.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Environment_Calculations.ino 3 | 4 | This code shows how to record data from the BME280 environmental sensor 5 | and perform various calculations. 6 | 7 | GNU General Public License 8 | 9 | Written: Dec 30 2015. 10 | Last Updated: Oct 07 2017. 11 | 12 | Connecting the BME280 Sensor: 13 | Sensor -> Board 14 | ----------------------------- 15 | Vin (Voltage In) -> 3.3V 16 | Gnd (Ground) -> Gnd 17 | SDA (Serial Data) -> A4 on Uno/Pro-Mini, 20 on Mega2560/Due, 2 Leonardo/Pro-Micro 18 | SCK (Serial Clock) -> A5 on Uno/Pro-Mini, 21 on Mega2560/Due, 3 Leonardo/Pro-Micro 19 | 20 | */ 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define SERIAL_BAUD 115200 27 | 28 | // Assumed environmental values: 29 | float referencePressure = 1018.6; // hPa local QFF (official meteor-station reading) 30 | float outdoorTemp = 4.7; // °C measured local outdoor temp. 31 | float barometerAltitude = 1650.3; // meters ... map readings + barometer position 32 | 33 | 34 | BME280I2C::Settings settings( 35 | BME280::OSR_X1, 36 | BME280::OSR_X1, 37 | BME280::OSR_X1, 38 | BME280::Mode_Forced, 39 | BME280::StandbyTime_1000ms, 40 | BME280::Filter_16, 41 | BME280::SpiEnable_False, 42 | BME280I2C::I2CAddr_0x76 43 | ); 44 | 45 | BME280I2C bme(settings); 46 | 47 | ////////////////////////////////////////////////////////////////// 48 | void setup() 49 | { 50 | Serial.begin(SERIAL_BAUD); 51 | 52 | while(!Serial) {} // Wait 53 | 54 | Wire.begin(); 55 | 56 | while(!bme.begin()) 57 | { 58 | Serial.println("Could not find BME280 sensor!"); 59 | delay(1000); 60 | } 61 | 62 | switch(bme.chipModel()) 63 | { 64 | case BME280::ChipModel_BME280: 65 | Serial.println("Found BME280 sensor! Success."); 66 | break; 67 | case BME280::ChipModel_BMP280: 68 | Serial.println("Found BMP280 sensor! No Humidity available."); 69 | break; 70 | default: 71 | Serial.println("Found UNKNOWN sensor! Error!"); 72 | } 73 | Serial.print("Assumed outdoor temperature: "); Serial.print(outdoorTemp); 74 | Serial.print("°C\nAssumed reduced sea level Pressure: "); Serial.print(referencePressure); 75 | Serial.print("hPa\nAssumed barometer altitude: "); Serial.print(barometerAltitude); 76 | Serial.println("m\n***************************************"); 77 | 78 | } 79 | 80 | ////////////////////////////////////////////////////////////////// 81 | void loop() 82 | { 83 | printBME280Data(&Serial); 84 | delay(500); 85 | } 86 | 87 | ////////////////////////////////////////////////////////////////// 88 | void printBME280Data 89 | ( 90 | Stream* client 91 | ) 92 | { 93 | float temp(NAN), hum(NAN), pres(NAN); 94 | 95 | BME280::TempUnit tempUnit(BME280::TempUnit_Celsius); 96 | BME280::PresUnit presUnit(BME280::PresUnit_hPa); 97 | 98 | bme.read(pres, temp, hum, tempUnit, presUnit); 99 | 100 | client->print("Temp: "); 101 | client->print(temp); 102 | client->print("°"+ String(tempUnit == BME280::TempUnit_Celsius ? "C" :"F")); 103 | client->print("\t\tHumidity: "); 104 | client->print(hum); 105 | client->print("% RH"); 106 | client->print("\t\tPressure: "); 107 | client->print(pres); 108 | client->print(String(presUnit == BME280::PresUnit_hPa ? "hPa" : "Pa")); // expected hPa and Pa only 109 | 110 | EnvironmentCalculations::AltitudeUnit envAltUnit = EnvironmentCalculations::AltitudeUnit_Meters; 111 | EnvironmentCalculations::TempUnit envTempUnit = EnvironmentCalculations::TempUnit_Celsius; 112 | 113 | /// To get correct local altitude/height (QNE) the reference Pressure 114 | /// should be taken from meteorologic messages (QNH or QFF) 115 | float altitude = EnvironmentCalculations::Altitude(pres, envAltUnit, referencePressure, outdoorTemp, envTempUnit); 116 | 117 | float dewPoint = EnvironmentCalculations::DewPoint(temp, hum, envTempUnit); 118 | 119 | /// To get correct seaLevel pressure (QNH, QFF) 120 | /// the altitude value should be independent on measured pressure. 121 | /// It is necessary to use fixed altitude point e.g. the altitude of barometer read in a map 122 | float seaLevel = EnvironmentCalculations::EquivalentSeaLevelPressure(barometerAltitude, temp, pres, envAltUnit, envTempUnit); 123 | 124 | float absHum = EnvironmentCalculations::AbsoluteHumidity(temp, hum, envTempUnit); 125 | 126 | client->print("\t\tAltitude: "); 127 | client->print(altitude); 128 | client->print((envAltUnit == EnvironmentCalculations::AltitudeUnit_Meters ? "m" : "ft")); 129 | client->print("\t\tDew point: "); 130 | client->print(dewPoint); 131 | client->print("°"+ String(envTempUnit == EnvironmentCalculations::TempUnit_Celsius ? "C" :"F")); 132 | client->print("\t\tEquivalent Sea Level Pressure: "); 133 | client->print(seaLevel); 134 | client->print(String( presUnit == BME280::PresUnit_hPa ? "hPa" :"Pa")); // expected hPa and Pa only 135 | 136 | client->print("\t\tHeat Index: "); 137 | if (temp > (tempUnit == BME280::TempUnit_Celsius ? 26.7 : 80)) 138 | { 139 | int heatIndex = EnvironmentCalculations::HeatIndex(temp, hum, envTempUnit); 140 | client->print(heatIndex); 141 | } 142 | else 143 | { 144 | client->print("Temperature out of range"); 145 | } 146 | 147 | client->print("\t\tAbsolute Humidity: "); 148 | client->println(absHum); 149 | 150 | delay(1000); 151 | } 152 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/keywords.txt: -------------------------------------------------------------------------------- 1 | BME280I2C KEYWORD1 2 | BME280Spi KEYWORD1 3 | begin KEYWORD2 4 | temp KEYWORD2 5 | pres KEYWORD2 6 | hum KEYWORD2 7 | read KEYWORD2 8 | Altitude KEYWORD2 9 | EquivalentSeaLevelPressure KEYWORD2 10 | DewPoint KEYWORD2 11 | HeatIndex KEYWORD2 12 | AbsoluteHumidity KEYWORD2 13 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/library.properties: -------------------------------------------------------------------------------- 1 | name=BME280 2 | version=3.0.0 3 | author=Tyler Glenn 4 | maintainer=Tyler Glenn 5 | sentence=Provides a library for reading and interpreting Bosch BME280 environmental sensor data over I2C, SPI or Sw SPI. 6 | paragraph=Reads temperature, humidity, and pressure. Includes environment calculations. Provides functions for english and metric. Also reads pressure in Pa, hPa, inHg, atm, bar, torr, N/m^2 and psi. ESP and BRZO I2C support. 7 | category=Sensors 8 | url=https://www.github.com/finitespace/BME280 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280I2C.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BME280I2CI2C.cpp 3 | This code records data from the BME280I2C sensor and provides an API. 4 | This file is part of the Arduino BME280I2C library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Dec 30 2015. 21 | Last Updated: Jan 1 2016. - Happy New year! 22 | 23 | This header must be included in any derived code or copies of the code. 24 | 25 | Based on the data sheet provided by Bosch for the BME280I2C environmental sensor, 26 | calibration code based on algorithms providedBosch, some unit conversations courtesy 27 | of www.endmemo.com, altitude equation courtesy of NOAA, and dew point equation 28 | courtesy of Brian McNoldy at http://andrew.rsmas.miami.edu. 29 | */ 30 | 31 | #include 32 | 33 | #include "BME280I2C.h" 34 | 35 | 36 | /****************************************************************/ 37 | BME280I2C::BME280I2C 38 | ( 39 | const Settings& settings 40 | ):BME280(settings), 41 | m_settings(settings) 42 | { 43 | } 44 | 45 | 46 | /****************************************************************/ 47 | void BME280I2C::setSettings 48 | ( 49 | const Settings& settings 50 | ) 51 | { 52 | m_settings = settings; 53 | BME280::setSettings(settings); 54 | } 55 | 56 | 57 | /****************************************************************/ 58 | const BME280I2C::Settings& BME280I2C::getSettings() const 59 | { 60 | return m_settings; 61 | } 62 | 63 | 64 | /****************************************************************/ 65 | bool BME280I2C::WriteRegister 66 | ( 67 | uint8_t addr, 68 | uint8_t data 69 | ) 70 | { 71 | Wire.beginTransmission(m_settings.bme280Addr); 72 | Wire.write(addr); 73 | Wire.write(data); 74 | Wire.endTransmission(); 75 | 76 | return true; // TODO: Chech return values from wire calls. 77 | } 78 | 79 | 80 | /****************************************************************/ 81 | bool BME280I2C::ReadRegister 82 | ( 83 | uint8_t addr, 84 | uint8_t data[], 85 | uint8_t length 86 | ) 87 | { 88 | uint8_t ord(0); 89 | 90 | Wire.beginTransmission(m_settings.bme280Addr); 91 | Wire.write(addr); 92 | Wire.endTransmission(); 93 | 94 | Wire.requestFrom(static_cast(m_settings.bme280Addr), length); 95 | 96 | while(Wire.available()) 97 | { 98 | data[ord++] = Wire.read(); 99 | } 100 | 101 | return ord == length; 102 | } 103 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280I2C.h: -------------------------------------------------------------------------------- 1 | /* 2 | BME280I2C.h 3 | This code records data from the BME280 sensor and provides an API. 4 | This file is part of the Arduino BME280 library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Sep 19 2016. 21 | Last Updated: Oct 07 2017. 22 | 23 | This code is licensed under the GNU LGPL and is open for ditrbution 24 | and copying in accordance with the license. 25 | This header must be included in any derived code or copies of the code. 26 | 27 | Based on the data sheet provided by Bosch for the Bme280 environmental sensor. 28 | */ 29 | 30 | #ifndef TG_BME_280_I2C_H 31 | #define TG_BME_280_I2C_H 32 | 33 | #include "BME280.h" 34 | 35 | ////////////////////////////////////////////////////////////////// 36 | /// BME280I2C - I2C Implementation of BME280. 37 | class BME280I2C: public BME280 38 | { 39 | 40 | public: 41 | 42 | enum I2CAddr 43 | { 44 | I2CAddr_0x76 = 0x76, 45 | I2CAddr_0x77 = 0x77 46 | }; 47 | 48 | 49 | struct Settings : public BME280::Settings 50 | { 51 | Settings( 52 | OSR _tosr = OSR_X1, 53 | OSR _hosr = OSR_X1, 54 | OSR _posr = OSR_X1, 55 | Mode _mode = Mode_Forced, 56 | StandbyTime _st = StandbyTime_1000ms, 57 | Filter _filter = Filter_16, 58 | SpiEnable _se = SpiEnable_False, 59 | I2CAddr _addr = I2CAddr_0x76 60 | ): BME280::Settings(_tosr, _hosr, _posr, _mode, _st, _filter, _se), 61 | bme280Addr(_addr) {} 62 | 63 | I2CAddr bme280Addr; 64 | }; 65 | 66 | /////////////////////////////////////////////////////////////// 67 | /// Constructor used to create the class. All parameters have 68 | /// default values. 69 | BME280I2C( 70 | const Settings& settings = Settings()); 71 | 72 | 73 | /*****************************************************************/ 74 | /* ACCESSOR FUNCTIONS */ 75 | /*****************************************************************/ 76 | 77 | ///////////////////////////////////////////////////////////////// 78 | virtual void setSettings( 79 | const Settings& settings); 80 | 81 | ///////////////////////////////////////////////////////////////// 82 | const Settings& getSettings() const; 83 | 84 | 85 | protected: 86 | 87 | private: 88 | 89 | Settings m_settings; 90 | 91 | ////////////////////////////////////////////////////////////////// 92 | /// Write values to BME280 registers. 93 | virtual bool WriteRegister( 94 | uint8_t addr, 95 | uint8_t data); 96 | 97 | ///////////////////////////////////////////////////////////////// 98 | /// Read values from BME280 registers. 99 | virtual bool ReadRegister( 100 | uint8_t addr, 101 | uint8_t data[], 102 | uint8_t length); 103 | 104 | }; 105 | #endif // TG_BME_280_I2C_H 106 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280I2C_BRZO.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BME280I2C_BRZO.cpp 3 | This code records data from the BME280 sensor and provides an API. 4 | This file is part of the Arduino BME280 library. 5 | 6 | Copyright (C) 2016 Tyler Glenn 7 | Forked by Alex Shavlovsky 8 | to support https://github.com/pasko-zh/brzo_i2c library on ESP8266. 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | Written: Dec 30 2015. 24 | Last Updated: Oct 07 2017. 25 | 26 | This header must be included in any derived code or copies of the code. 27 | 28 | Based on the data sheet provided by Bosch for the BME280I2C_BRZO environmental sensor, 29 | calibration code based on algorithms providedBosch, some unit conversations courtesy 30 | of www.endmemo.com, altitude equation courtesy of NOAA, and dew point equation 31 | courtesy of Brian McNoldy at http://andrew.rsmas.miami.edu. 32 | */ 33 | 34 | #include "BME280I2C_BRZO.h" 35 | 36 | #ifdef USING_BRZO 37 | 38 | #include "brzo_i2c.h" 39 | 40 | /****************************************************************/ 41 | BME280I2C_BRZO::BME280I2C_BRZO 42 | ( 43 | const Settings& settings 44 | ):BME280I2C(settings), 45 | m_settings(settings) 46 | { 47 | } 48 | 49 | /****************************************************************/ 50 | void BME280I2C_BRZO::setSettings 51 | ( 52 | const Settings& settings 53 | ) 54 | { 55 | m_settings = settings; 56 | BME280::setSettings(settings); 57 | } 58 | 59 | 60 | /****************************************************************/ 61 | const BME280I2C_BRZO::Settings& BME280I2C_BRZO::getSettings() const 62 | { 63 | return m_settings; 64 | } 65 | 66 | 67 | /****************************************************************/ 68 | bool BME280I2C_BRZO::WriteRegister 69 | ( 70 | uint8_t addr, 71 | uint8_t data 72 | ) 73 | { 74 | uint8_t bf[2]; 75 | bf[0] = addr; 76 | bf[1] = data; 77 | brzo_i2c_start_transaction(m_settings.bme280Addr, m_settings.i2cClockRate); 78 | brzo_i2c_write(bf, 2, false); 79 | return (brzo_i2c_end_transaction()==0); 80 | } 81 | 82 | /****************************************************************/ 83 | bool BME280I2C_BRZO::ReadRegister 84 | ( 85 | uint8_t addr, 86 | uint8_t data[], 87 | uint8_t length 88 | ) 89 | { 90 | brzo_i2c_start_transaction(m_settings.bme280Addr, m_settings.i2cClockRate); 91 | brzo_i2c_write(&addr, 1, true); 92 | brzo_i2c_read(data, length, false); 93 | brzo_i2c_end_transaction(); 94 | return (brzo_i2c_end_transaction()==0); 95 | } 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280I2C_BRZO.h: -------------------------------------------------------------------------------- 1 | /* 2 | BME280I2C_BRZO.h 3 | This code records data from the BME280 sensor and provides an API. 4 | This file is part of the Arduino BME280 library. 5 | 6 | Copyright (C) 2016 Tyler Glenn 7 | Forked by Alex Shavlovsky 8 | to support https://github.com/pasko-zh/brzo_i2c library on ESP8266. 9 | 10 | This program is free software: you can redistribute it and/or modify 11 | it under the terms of the GNU General Public License as published by 12 | the Free Software Foundation, either version 3 of the License, or 13 | (at your option) any later version. 14 | 15 | This program is distributed in the hope that it will be useful, 16 | but WITHOUT ANY WARRANTY; without even the implied warranty of 17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 | GNU General Public License for more details. 19 | 20 | You should have received a copy of the GNU General Public License 21 | along with this program. If not, see . 22 | 23 | Written: Sep 19 2016. 24 | Last Updated: Oct 07 2017. 25 | 26 | This code is licensed under the GNU LGPL and is open for ditrbution 27 | and copying in accordance with the license. 28 | This header must be included in any derived code or copies of the code. 29 | 30 | Based on the data sheet provided by Bosch for the Bme280 environmental sensor. 31 | */ 32 | 33 | #ifndef BME280I2C_BRZO_H 34 | #define BME280I2C_BRZO_H 35 | 36 | #include "BME280I2C.h" 37 | 38 | ////////////////////////////////////////////////////////////////// 39 | /// BME280I2C_BRZO - I2C Implementation of BME280. 40 | class BME280I2C_BRZO : public BME280I2C 41 | { 42 | 43 | public: 44 | 45 | struct Settings : public BME280I2C::Settings 46 | { 47 | Settings( 48 | OSR _tosr = OSR_X1, 49 | OSR _hosr = OSR_X1, 50 | OSR _posr = OSR_X1, 51 | Mode _mode = Mode_Forced, 52 | StandbyTime _st = StandbyTime_1000ms, 53 | Filter _filter = Filter_Off, 54 | SpiEnable _se = SpiEnable_False, 55 | uint16_t _cr = 400 56 | ): BME280I2C::Settings(_tosr, _hosr, _posr, _mode, _st, _filter, _se), 57 | i2cClockRate(_cr) {} 58 | 59 | uint16_t i2cClockRate; 60 | }; 61 | 62 | /////////////////////////////////////////////////////////////// 63 | /// Constructor used to create the class. All parameters have 64 | /// default values. 65 | BME280I2C_BRZO( 66 | const Settings& settings = Settings()); 67 | 68 | 69 | /*****************************************************************/ 70 | /* ACCESSOR FUNCTIONS */ 71 | /*****************************************************************/ 72 | 73 | ///////////////////////////////////////////////////////////////// 74 | virtual void setSettings( 75 | const Settings& settings); 76 | 77 | ///////////////////////////////////////////////////////////////// 78 | const Settings& getSettings() const; 79 | 80 | 81 | protected: 82 | 83 | private: 84 | 85 | Settings m_settings; 86 | 87 | ////////////////////////////////////////////////////////////////// 88 | /// Write values to BME280 registers. 89 | virtual bool WriteRegister( 90 | uint8_t addr, 91 | uint8_t data); 92 | 93 | ///////////////////////////////////////////////////////////////// 94 | /// Read values from BME280 registers. 95 | virtual bool ReadRegister( 96 | uint8_t addr, 97 | uint8_t data[], 98 | uint8_t length); 99 | 100 | }; 101 | #endif // BME280I2C_BRZO_H 102 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280Spi.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BME280Spi.cpp 3 | This code records data from the BME280Spi sensor and provides an API. 4 | This file is part of the Arduino BME280Spi library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Dec 18 2016. - Happy Holidays! 21 | Last Updated: Oct 07 2017. 22 | 23 | This header must be included in any derived code or copies of the code. 24 | 25 | Based on the data sheet provided by Bosch for the BME280Spi environmental sensor, 26 | calibration code based on algorithms providedBosch, some unit conversations courtesy 27 | of www.endmemo.com, altitude equation courtesy of NOAA, and dew point equation 28 | courtesy of Brian McNoldy at http://andrew.rsmas.miami.edu. 29 | */ 30 | 31 | #include "Arduino.h" 32 | #include "BME280Spi.h" 33 | 34 | #include 35 | 36 | /****************************************************************/ 37 | BME280Spi::BME280Spi 38 | ( 39 | const Settings& settings 40 | ) 41 | :BME280(settings), 42 | m_settings(settings) 43 | { 44 | } 45 | 46 | 47 | /****************************************************************/ 48 | bool BME280Spi::Initialize() 49 | { 50 | pinMode(m_settings.spiCsPin, OUTPUT); 51 | digitalWrite(m_settings.spiCsPin, HIGH); 52 | 53 | return BME280::Initialize(); 54 | } 55 | 56 | /****************************************************************/ 57 | void BME280Spi::setSettings 58 | ( 59 | const Settings& settings 60 | ) 61 | { 62 | m_settings = settings; 63 | BME280::setSettings(settings); 64 | } 65 | 66 | 67 | /****************************************************************/ 68 | const BME280Spi::Settings& BME280Spi::getSettings() const 69 | { 70 | return m_settings; 71 | } 72 | 73 | /****************************************************************/ 74 | bool BME280Spi::ReadRegister 75 | ( 76 | uint8_t addr, 77 | uint8_t data[], 78 | uint8_t len 79 | ) 80 | { 81 | SPI.beginTransaction(SPISettings(500000,MSBFIRST,SPI_MODE0)); 82 | 83 | // bme280 uses the msb to select read and write 84 | // combine the addr with the read/write bit 85 | uint8_t readAddr = addr | BME280_SPI_READ; 86 | 87 | //select the device 88 | digitalWrite(m_settings.spiCsPin, LOW); 89 | // transfer the addr 90 | SPI.transfer(readAddr); 91 | 92 | // read the data 93 | for(int i = 0; i < len; ++i) 94 | { 95 | // transfer 0x00 to get the data 96 | data[i] = SPI.transfer(0); 97 | } 98 | 99 | // de-select the device 100 | digitalWrite(m_settings.spiCsPin, HIGH); 101 | 102 | SPI.endTransaction(); 103 | 104 | return true; 105 | } 106 | 107 | 108 | /****************************************************************/ 109 | bool BME280Spi::WriteRegister 110 | ( 111 | uint8_t addr, 112 | uint8_t data 113 | ) 114 | { 115 | SPI.beginTransaction(SPISettings(500000,MSBFIRST,SPI_MODE0)); 116 | 117 | // bme280 uses the msb to select read and write 118 | // combine the addr with the read/write bit 119 | uint8_t writeAddr = addr & ~0x80; 120 | 121 | // select the device 122 | digitalWrite(m_settings.spiCsPin, LOW); 123 | 124 | // transfer the addr and then the data to spi device 125 | SPI.transfer(writeAddr); 126 | SPI.transfer(data); 127 | 128 | // de-select the device 129 | digitalWrite(m_settings.spiCsPin, HIGH); 130 | 131 | SPI.endTransaction(); 132 | 133 | return true; 134 | } 135 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280Spi.h: -------------------------------------------------------------------------------- 1 | /* 2 | BME280Spi.h 3 | This code records data from the BME280 sensor and provides an API. 4 | This file is part of the Arduino BME280 library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Dec 18 2016. - Happy Holidays! 21 | Last Updated: Oct 07 2017. 22 | 23 | This code is licensed under the GNU LGPL and is open for ditrbution 24 | and copying in accordance with the license. 25 | This header must be included in any derived code or copies of the code. 26 | 27 | Based on the data sheet provided by Bosch for the Bme280 environmental sensor. 28 | */ 29 | 30 | #ifndef TG_BME_280_SPI_H 31 | #define TG_BME_280_SPI_H 32 | 33 | #include "BME280.h" 34 | 35 | 36 | class BME280Spi: public BME280 37 | { 38 | public: 39 | 40 | struct Settings : public BME280::Settings 41 | { 42 | Settings( 43 | uint8_t _cspin, 44 | OSR _tosr = OSR_X1, 45 | OSR _hosr = OSR_X1, 46 | OSR _posr = OSR_X1, 47 | Mode _mode = Mode_Forced, 48 | StandbyTime _st = StandbyTime_1000ms, 49 | Filter _filter = Filter_Off, 50 | SpiEnable _se = SpiEnable_False 51 | ): BME280::Settings(_tosr, _hosr, _posr, _mode, _st, _filter, _se), 52 | spiCsPin(_cspin) {} 53 | 54 | uint8_t spiCsPin; 55 | }; 56 | 57 | //////////////////////////////////////////////////////////////// 58 | /// Constructor used to create the class. All parameters have 59 | /// default values. 60 | BME280Spi( 61 | const Settings& settings); 62 | 63 | /*****************************************************************/ 64 | /* ACCESSOR FUNCTIONS */ 65 | /*****************************************************************/ 66 | 67 | ///////////////////////////////////////////////////////////////// 68 | virtual void setSettings( 69 | const Settings& settings); 70 | 71 | ///////////////////////////////////////////////////////////////// 72 | const Settings& getSettings() const; 73 | 74 | 75 | protected: 76 | 77 | //////////////////////////////////////////////////////////////// 78 | /// Method used at start up to initialize the class. Starts the 79 | /// I2C interface. 80 | virtual bool Initialize(); 81 | 82 | private: 83 | 84 | static const uint8_t BME280_SPI_WRITE = 0x7F; 85 | static const uint8_t BME280_SPI_READ = 0x80; 86 | 87 | Settings m_settings; 88 | 89 | //////////////////////////////////////////////////////////////// 90 | /// Read the data from the BME280 addr into an array and 91 | /// return true if successful. 92 | virtual bool ReadRegister( 93 | uint8_t addr, 94 | uint8_t array[], 95 | uint8_t len); 96 | 97 | //////////////////////////////////////////////////////////////// 98 | /// Write values to BME280 registers. 99 | virtual bool WriteRegister( 100 | uint8_t addr, 101 | uint8_t data); 102 | 103 | }; 104 | #endif // TG_BME_280_SPI_H 105 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280SpiSw.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | BME280SpiSw.cpp 3 | This code records data from the BME280SpiSw sensor and provides an API. 4 | This file is part of the Arduino BME280SpiSw library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Dec 18 2016. - Happy Holidays! 21 | Last Updated: Dec 18 2016. - Happy Holidays! 22 | 23 | This header must be included in any derived code or copies of the code. 24 | 25 | Based on the data sheet provided by Bosch for the BME280SpiSw environmental sensor, 26 | calibration code based on algorithms providedBosch, some unit conversations courtesy 27 | of www.endmemo.com, altitude equation courtesy of NOAA, and dew point equation 28 | courtesy of Brian McNoldy at http://andrew.rsmas.miami.edu. 29 | */ 30 | 31 | #include "Arduino.h" 32 | #include "BME280SpiSw.h" 33 | 34 | 35 | 36 | /****************************************************************/ 37 | BME280SpiSw::BME280SpiSw 38 | ( 39 | const Settings& settings 40 | ) 41 | :BME280(settings), 42 | m_settings(settings) 43 | { 44 | } 45 | 46 | 47 | /****************************************************************/ 48 | bool BME280SpiSw::Initialize(){ 49 | 50 | digitalWrite(m_settings.spiCsPin, HIGH); 51 | pinMode(m_settings.spiCsPin, OUTPUT); 52 | 53 | pinMode(m_settings.spiSckPin, OUTPUT); 54 | pinMode(m_settings.spiMosiPin, OUTPUT); 55 | pinMode(m_settings.spiMisoPin, INPUT); 56 | 57 | return BME280::Initialize(); 58 | } 59 | 60 | 61 | /****************************************************************/ 62 | void BME280SpiSw::setSettings 63 | ( 64 | const Settings& settings 65 | ) 66 | { 67 | m_settings = settings; 68 | BME280::setSettings(settings); 69 | } 70 | 71 | 72 | /****************************************************************/ 73 | const BME280SpiSw::Settings& BME280SpiSw::getSettings() const 74 | { 75 | return m_settings; 76 | } 77 | 78 | 79 | /****************************************************************/ 80 | uint8_t BME280SpiSw::SpiTransferSw 81 | ( 82 | uint8_t data 83 | ) 84 | { 85 | uint8_t resp = 0; 86 | for (int bit = 7; bit >= 0; --bit) { 87 | resp <<= 1; 88 | digitalWrite(m_settings.spiSckPin, LOW); 89 | digitalWrite(m_settings.spiMosiPin, data & (1 << bit)); 90 | digitalWrite(m_settings.spiSckPin, HIGH); 91 | resp |= digitalRead(m_settings.spiMisoPin); 92 | } 93 | return resp; 94 | } 95 | 96 | 97 | /****************************************************************/ 98 | bool BME280SpiSw::ReadRegister 99 | ( 100 | uint8_t addr, 101 | uint8_t data[], 102 | uint8_t length 103 | ) 104 | { 105 | 106 | // bme280 uses the msb to select read and write 107 | // combine the addr with the read/write bit 108 | uint8_t readAddr = addr | BME280_SPI_READ; 109 | 110 | //select the device 111 | digitalWrite(m_settings.spiCsPin, LOW); 112 | // transfer the addr 113 | SpiTransferSw(readAddr); 114 | 115 | // read the data 116 | for(int i = 0; i < length; ++i) 117 | { 118 | // transfer 0x00 to get the data 119 | data[i] = SpiTransferSw(0); 120 | } 121 | 122 | // de-select the device 123 | digitalWrite(m_settings.spiCsPin, HIGH); 124 | 125 | return true; 126 | } 127 | 128 | 129 | /****************************************************************/ 130 | bool BME280SpiSw::WriteRegister 131 | ( 132 | uint8_t addr, 133 | uint8_t data 134 | ) 135 | { 136 | // bme280 uses the msb to select read and write 137 | // combine the addr with the read/write bit 138 | uint8_t writeAddr = addr & ~0x80; 139 | 140 | // select the device 141 | digitalWrite(m_settings.spiCsPin, LOW); 142 | 143 | // transfer the addr and then the data to spi device 144 | SpiTransferSw(writeAddr); 145 | SpiTransferSw(data); 146 | 147 | // de-select the device 148 | digitalWrite(m_settings.spiCsPin, HIGH); 149 | 150 | return true; 151 | } 152 | 153 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/BME280SpiSw.h: -------------------------------------------------------------------------------- 1 | /* 2 | BME280SpiSw.h 3 | This code records data from the BME280 sensor and provides an API. 4 | This file is part of the Arduino BME280 library. 5 | Copyright (C) 2016 Tyler Glenn 6 | 7 | This program is free software: you can redistribute it and/or modify 8 | it under the terms of the GNU General Public License as published by 9 | the Free Software Foundation, either version 3 of the License, or 10 | (at your option) any later version. 11 | 12 | This program is distributed in the hope that it will be useful, 13 | but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | GNU General Public License for more details. 16 | 17 | You should have received a copy of the GNU General Public License 18 | along with this program. If not, see . 19 | 20 | Written: Dec 18 2016. - Happy Holidays! 21 | Last Updated: Oct 07 2017. 22 | 23 | This code is licensed under the GNU LGPL and is open for ditrbution 24 | and copying in accordance with the license. 25 | This header must be included in any derived code or copies of the code. 26 | 27 | Based on the data sheet provided by Bosch for the Bme280 environmental sensor. 28 | */ 29 | 30 | #ifndef TG_BME_280_SPI_H 31 | #define TG_BME_280_SPI_H 32 | 33 | #include "BME280.h" 34 | 35 | class BME280SpiSw: public BME280{ 36 | 37 | public: 38 | struct Settings : public BME280::Settings 39 | { 40 | Settings( 41 | uint8_t _cs, 42 | uint8_t _mosi, 43 | uint8_t _miso, 44 | uint8_t _sck, 45 | OSR _tosr = OSR_X1, 46 | OSR _hosr = OSR_X1, 47 | OSR _posr = OSR_X1, 48 | Mode _mode = Mode_Forced, 49 | StandbyTime _st = StandbyTime_1000ms, 50 | Filter _filter = Filter_Off, 51 | SpiEnable _se = SpiEnable_False 52 | ): BME280::Settings(_tosr, _hosr, _posr, _mode, _st, _filter, _se), 53 | spiCsPin(_cs), 54 | spiMosiPin(_mosi), 55 | spiMisoPin(_miso), 56 | spiSckPin(_sck) {} 57 | 58 | uint8_t spiCsPin; 59 | uint8_t spiMosiPin; 60 | uint8_t spiMisoPin; 61 | uint8_t spiSckPin; 62 | }; 63 | 64 | //////////////////////////////////////////////////////////////// 65 | /// Constructor for software spi 66 | BME280SpiSw( 67 | const Settings& settings); 68 | 69 | 70 | /*****************************************************************/ 71 | /* ACCESSOR FUNCTIONS */ 72 | /*****************************************************************/ 73 | 74 | ///////////////////////////////////////////////////////////////// 75 | virtual void setSettings( 76 | const Settings& settings); 77 | 78 | ///////////////////////////////////////////////////////////////// 79 | const Settings& getSettings() const; 80 | 81 | protected: 82 | 83 | //////////////////////////////////////////////////////////////// 84 | /// Method used at start up to initialize the class. Starts the I2C interface. 85 | virtual bool Initialize(); 86 | 87 | private: 88 | 89 | static const uint8_t BME280_SPI_WRITE = 0x7F; 90 | static const uint8_t BME280_SPI_READ = 0x80; 91 | 92 | Settings m_settings; 93 | 94 | //////////////////////////////////////////////////////////////// 95 | /// Does a sw spi transfer. 96 | uint8_t SpiTransferSw( 97 | uint8_t data); 98 | 99 | //////////////////////////////////////////////////////////////// 100 | /// Read the data from the BME280 addr into an array and return 101 | /// true if successful. 102 | virtual bool ReadRegister( 103 | uint8_t addr, 104 | uint8_t data[], 105 | uint8_t length); 106 | 107 | //////////////////////////////////////////////////////////////// 108 | /// Write values to BME280 registers. 109 | virtual bool WriteRegister( 110 | uint8_t addr, 111 | uint8_t data); 112 | 113 | }; 114 | #endif // TG_BME_280_SPI_H 115 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/EnvironmentCalculations.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | EnvironmentCalculations.cpp 3 | 4 | Copyright (C) 2016 Tyler Glenn 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation, either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | This program is distributed in the hope that it will be useful, 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . 18 | 19 | Written: Dec 30 2015. 20 | Last Updated: Dec 23 2017. 21 | 22 | This header must be included in any derived code or copies of the code. 23 | 24 | */ 25 | 26 | #include "EnvironmentCalculations.h" 27 | 28 | #include 29 | #include 30 | 31 | 32 | /****************************************************************/ 33 | float EnvironmentCalculations::Altitude 34 | ( 35 | float pressure, 36 | AltitudeUnit altUnit, 37 | float referencePressure, 38 | float outdoorTemp, 39 | TempUnit tempUnit 40 | ) 41 | { 42 | // Equation inverse to EquivalentSeaLevelPressure calculation. 43 | float altitude = NAN; 44 | if (!isnan(pressure) && !isnan(referencePressure) && !isnan(outdoorTemp)) 45 | { 46 | if(tempUnit != TempUnit_Celsius) 47 | outdoorTemp = (outdoorTemp - 32.0) * (5.0 / 9.0); /*conversion to [�C]*/ 48 | 49 | altitude = pow(referencePressure / pressure, 0.190234) - 1; 50 | altitude *= ((outdoorTemp + 273.15) / 0.0065); 51 | if(altUnit != AltitudeUnit_Meters) altitude *= 3.28084; 52 | } 53 | return altitude; 54 | } 55 | 56 | 57 | /****************************************************************/ 58 | float EnvironmentCalculations::AbsoluteHumidity 59 | ( 60 | float temperature, 61 | float humidity, 62 | TempUnit tempUnit 63 | ) 64 | { 65 | //taken from https://carnotcycle.wordpress.com/2012/08/04/how-to-convert-relative-humidity-to-absolute-humidity/ 66 | //precision is about 0.1°C in range -30 to 35°C 67 | //August-Roche-Magnus 6.1094 exp(17.625 x T)/(T + 243.04) 68 | //Buck (1981) 6.1121 exp(17.502 x T)/(T + 240.97) 69 | //reference https://www.eas.ualberta.ca/jdwilson/EAS372_13/Vomel_CIRES_satvpformulae.html 70 | float temp = NAN; 71 | const float mw = 18.01534; // molar mass of water g/mol 72 | const float r = 8.31447215; // Universal gas constant J/mol/K 73 | 74 | if (isnan(temperature) || isnan(humidity) ) 75 | { 76 | return NAN; 77 | } 78 | 79 | if(tempUnit != TempUnit_Celsius) 80 | { 81 | temperature = (temperature - 32.0) * (5.0 / 9.0); /*conversion to [°C]*/ 82 | } 83 | 84 | temp = pow(2.718281828, (17.67 * temperature) / (temperature + 243.5)); 85 | 86 | //return (6.112 * temp * humidity * 2.1674) / (273.15 + temperature); //simplified version 87 | return (6.112 * temp * humidity * mw) / ((273.15 + temperature) * r); //long version 88 | } 89 | 90 | 91 | /****************************************************************/ 92 | int EnvironmentCalculations::HeatIndex 93 | ( 94 | float temperature, 95 | float humidity, 96 | TempUnit tempUnit 97 | ) 98 | { 99 | float heatindex = NAN; 100 | bool metric = true; 101 | float hi[2][9] = { {-8.784695,1.61139411,2.338549,-0.14611605,-1.2308094/100,-1.6424828/100,2.211732/1000,7.2546/10000,-3.582/1000000}, 102 | {-42.379,2.04901523,10.1433127,-0.22475541,-6.83783/1000,-5.481717/100,1.22874/1000,8.5282/10000,-1.99/1000000} }; 103 | 104 | //taken from https://de.wikipedia.org/wiki/Hitzeindex#Berechnung 105 | if (tempUnit != TempUnit_Celsius) 106 | { 107 | metric = false; 108 | } 109 | if (!isnan(humidity) && !isnan(temperature) && humidity>40 && (metric ? temperature>26.7 : temperature>80)) { 110 | heatindex = hi[metric ? 0: 1][0]; 111 | heatindex =+ hi[metric ? 0: 1][1] * temperature; 112 | heatindex =+ hi[metric ? 0: 1][2] * humidity; 113 | heatindex =+ hi[metric ? 0: 1][3] * temperature * humidity; 114 | heatindex =+ hi[metric ? 0: 1][4] * temperature * temperature; 115 | heatindex =+ hi[metric ? 0: 1][5] * humidity * humidity; 116 | heatindex =+ hi[metric ? 0: 1][6] * temperature * temperature * humidity; 117 | heatindex =+ hi[metric ? 0: 1][7] * temperature * humidity * humidity; 118 | heatindex =+ hi[metric ? 0: 1][8] * temperature * temperature * humidity * humidity; 119 | return int(heatindex); 120 | } 121 | else { 122 | return NAN; 123 | } 124 | } 125 | 126 | /****************************************************************/ 127 | float EnvironmentCalculations::EquivalentSeaLevelPressure 128 | ( 129 | float altitude, 130 | float temp, 131 | float pres, 132 | AltitudeUnit altUnit, 133 | TempUnit tempUnit 134 | ) 135 | { 136 | float seaPress = NAN; 137 | if(!isnan(altitude) && !isnan(temp) && !isnan(pres)) 138 | { 139 | if(tempUnit != TempUnit_Celsius) 140 | temp = (temp - 32.0) * (5.0 / 9.0); /*conversion to [�C]*/ 141 | 142 | if(altUnit != AltitudeUnit_Meters) 143 | altitude *= 0.3048; /*conversion to meters*/ 144 | 145 | seaPress = (pres / pow(1 - ((0.0065 *altitude) / (temp + (0.0065 *altitude) + 273.15)), 5.257)); 146 | } 147 | return seaPress; 148 | } 149 | 150 | 151 | /****************************************************************/ 152 | float EnvironmentCalculations::DewPoint 153 | ( 154 | float temp, 155 | float hum, 156 | TempUnit tempUnit 157 | ) 158 | { 159 | // Equations courtesy of Brian McNoldy from http://andrew.rsmas.miami.edu; 160 | float dewPoint = NAN; 161 | 162 | if(!isnan(temp) && !isnan(hum)) 163 | { 164 | if (tempUnit == TempUnit_Celsius) 165 | { 166 | dewPoint = 243.04 * (log(hum/100.0) + ((17.625 * temp)/(243.04 + temp))) 167 | /(17.625 - log(hum/100.0) - ((17.625 * temp)/(243.04 + temp))); 168 | } 169 | else 170 | { 171 | float ctemp = (temp - 32.0) * 5.0/9.0; 172 | 173 | dewPoint = 243.04 * (log(hum/100.0) + ((17.625 * ctemp)/(243.04 + ctemp))) 174 | /(17.625 - log(hum/100.0) - ((17.625 * ctemp)/(243.04 + ctemp))); 175 | 176 | dewPoint = dewPoint * 9.0/5.0 + 32.0; 177 | } 178 | } 179 | 180 | return dewPoint; 181 | } 182 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/BME280-master/src/EnvironmentCalculations.h: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | EnvironmentCalculations.h 4 | 5 | This code records data from the BME280 sensor and provides an API. 6 | This file is part of the Arduino BME280 library. 7 | Copyright (C) 2016 Tyler Glenn 8 | 9 | This program is free software: you can redistribute it and/or modify 10 | it under the terms of the GNU General Public License as published by 11 | the Free Software Foundation, either version 3 of the License, or 12 | (at your option) any later version. 13 | 14 | This program is distributed in the hope that it will be useful, 15 | but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | GNU General Public License for more details. 18 | 19 | You should have received a copy of the GNU General Public License 20 | along with this program. If not, see . 21 | 22 | Written: Oct 7 2017. 23 | Last Updated: Dec 11 2017. 24 | This code is licensed under the GNU LGPL and is open for distrbution 25 | and copying in accordance with the license. 26 | This header must be included in any derived code or copies of the code. 27 | 28 | */ 29 | 30 | #ifndef TG_ENVIRONMENT_CALCULATIONS_H 31 | #define TG_ENVIRONMENT_CALCULATIONS_H 32 | 33 | namespace EnvironmentCalculations 34 | { 35 | ///////////////////////////////////////////////////////////////// 36 | /// Temperature unit enumeration. 37 | enum TempUnit 38 | { 39 | TempUnit_Celsius, 40 | TempUnit_Fahrenheit 41 | }; 42 | 43 | ///////////////////////////////////////////////////////////////// 44 | /// Altitude unit enumeration. 45 | enum AltitudeUnit 46 | { 47 | AltitudeUnit_Meters, 48 | AltitudeUnit_Feet 49 | }; 50 | 51 | 52 | ///////////////////////////////////////////////////////////////// 53 | /// Calculate the altitude based on the pressure and temperature 54 | /// in temptUnit. 55 | /// @param pressure at the station in any units. 56 | /// @param altUnit meters or feet. default=AltitudeUnit_Meters 57 | /// @param referencePressure (usually pressure on MSL) 58 | /// in the same units as pressure. default=1013.25hPa (ISA) 59 | /// @param outdoorTemp temperature at the station in tempUnit 60 | /// default=15°C (ISA) 61 | /// @param temptUnit in °C or °F. default=TempUnit_Celsius 62 | /// @return Calculated Altitude in altUnit. 63 | float Altitude( 64 | float pressure, 65 | AltitudeUnit altUnit = AltitudeUnit_Meters, 66 | float referencePressure = 1013.25, // [hPa] ....ISA value 67 | float outdoorTemp = 15, // [°C] .... ISA value 68 | TempUnit tempUnit = TempUnit_Celsius); 69 | 70 | ///////////////////////////////////////////////////////////////// 71 | /// Calculate the heatindex based on the humidity and temperature 72 | /// in tempUnit. 73 | /// the heatindex does work for values above 26.7°C/80°F and 40% humidity. 74 | /// @param temperature in tempUnit 75 | /// @param humidity in percentage 76 | /// @param temptUnit in °C or °F. default=TempUnit_Celsius 77 | /// @return Calculated heatindex as integer in TempUnit 78 | int HeatIndex( 79 | float temperature, 80 | float humidity, 81 | TempUnit tempUnit = TempUnit_Celsius); 82 | 83 | ///////////////////////////////////////////////////////////////// 84 | /// Calculate the absolute humidity based on the relative humidity and temperature 85 | /// in tempUnit. 86 | /// the formula does work for values between -30°C and 35°C with 0.1°C precision 87 | /// @param temperature in tempUnit 88 | /// @param humidity in percentage 89 | /// @param tempUnit in °C. default=TempUnit_Celsius 90 | /// @return Calculated absolute humidity in grams/m³ 91 | float AbsoluteHumidity 92 | ( 93 | float temperature, 94 | float humidity, 95 | TempUnit tempUnit 96 | ); 97 | 98 | ///////////////////////////////////////////////////////////////// 99 | /// Convert current pressure to equivalent sea-level pressure. 100 | /// @param altitude in altUnit. 101 | /// @param temp in tempUnit. 102 | /// @param pressure at the station in any units. 103 | /// @param altUnit meters or feet. default=AltitudeUnit_Meters 104 | /// @param tempUnit in °C or °F. default=TempUnit_Celsius 105 | /// @return Equivalent pressure at sea level. The input pressure 106 | /// unit will determine the output 107 | /// pressure unit. 108 | float EquivalentSeaLevelPressure( 109 | float altitude, 110 | float temp, 111 | float pres, 112 | AltitudeUnit altUnit = AltitudeUnit_Meters, 113 | TempUnit tempUnit = TempUnit_Celsius); 114 | 115 | ///////////////////////////////////////////////////////////////// 116 | /// Calculate the dew point based on the temperature in tempUnit 117 | /// and humidity. 118 | /// @param temp in tempUnit. 119 | /// @param hum in %. 120 | /// @param temptUnit in °C or °F. default=TempUnit_Celsius 121 | float DewPoint( 122 | float temp, 123 | float hum, 124 | TempUnit tempUnit = TempUnit_Celsius); 125 | 126 | } 127 | 128 | #endif // TG_ENVIRONMENT_CALCULATIONS_H 129 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LoRa/LoRa.h: -------------------------------------------------------------------------------- 1 | #ifndef LORA_H 2 | #define LORA_H 3 | 4 | #include 5 | #include 6 | 7 | #define LORA_DEFAULT_SS_PIN 10 8 | #define LORA_DEFAULT_RESET_PIN 8 9 | #define LORA_DEFAULT_DIO0_PIN 2 10 | 11 | #define PA_OUTPUT_RFO_PIN 0 12 | #define PA_OUTPUT_PA_BOOST_PIN 1 13 | 14 | class LoRaClass : public Stream { 15 | public: 16 | LoRaClass(); 17 | 18 | int begin(long frequency); 19 | void end(); 20 | 21 | int beginPacket(int implicitHeader = false); 22 | int endPacket(); 23 | 24 | int parsePacket(int size = 0); 25 | int packetRssi(); 26 | int RssiValue(); 27 | float packetSnr(); 28 | 29 | // from Print 30 | virtual size_t write(uint8_t byte); 31 | virtual size_t write(const uint8_t *buffer, size_t size); 32 | 33 | // from Stream 34 | virtual int available(); 35 | virtual int read(); 36 | virtual int peek(); 37 | virtual void flush(); 38 | 39 | void onReceive(void(*callback)(int)); 40 | 41 | void receive(int size = 0); 42 | void idle(); 43 | void sleep(); 44 | 45 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 46 | void setFrequency(long frequency); 47 | void setSpreadingFactor(int sf); 48 | void setSignalBandwidth(long sbw); 49 | void setCodingRate4(int denominator); 50 | void setPreambleLength(long length); 51 | void setSyncWord(int sw); 52 | void enableCrc(); 53 | void disableCrc(); 54 | void setFSK(); 55 | void setOOK(); 56 | void setPolarity(int pol); 57 | 58 | // deprecated 59 | void crc() { enableCrc(); } 60 | void noCrc() { disableCrc(); } 61 | 62 | byte random(); 63 | 64 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 65 | void setSPIFrequency(uint32_t frequency); 66 | 67 | void dumpRegisters(Stream& out); 68 | 69 | private: 70 | void explicitHeaderMode(); 71 | void implicitHeaderMode(); 72 | 73 | void handleDio0Rise(); 74 | 75 | uint8_t readRegister(uint8_t address); 76 | void writeRegister(uint8_t address, uint8_t value); 77 | uint8_t singleTransfer(uint8_t address, uint8_t value); 78 | 79 | static void onDio0Rise(); 80 | 81 | private: 82 | SPISettings _spiSettings; 83 | int _ss; 84 | int _reset; 85 | int _dio0; 86 | int _frequency; 87 | int _packetIndex; 88 | int _implicitHeaderMode; 89 | void (*_onReceive)(int); 90 | }; 91 | 92 | extern LoRaClass LoRa; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/Examples/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/idleWakePeriodic/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/Examples/idleWakePeriodic/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/idleWakePeriodic/idleWakePeriodic.ino: -------------------------------------------------------------------------------- 1 | // **** INCLUDES ***** 2 | #include "LowPower.h" 3 | 4 | void setup() 5 | { 6 | // No setup is required for this library 7 | } 8 | 9 | void loop() 10 | { 11 | // Enter idle state for 8 s with the rest of peripherals turned off 12 | // Each microcontroller comes with different number of peripherals 13 | // Comment off line of code where necessary 14 | 15 | // ATmega328P, ATmega168 16 | LowPower.idle(SLEEP_8S, ADC_OFF, TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, 17 | SPI_OFF, USART0_OFF, TWI_OFF); 18 | 19 | // ATmega32U4 20 | //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER4_OFF, TIMER3_OFF, TIMER1_OFF, 21 | // TIMER0_OFF, SPI_OFF, USART1_OFF, TWI_OFF, USB_OFF); 22 | 23 | // ATmega2560 24 | //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER5_OFF, TIMER4_OFF, TIMER3_OFF, 25 | // TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, USART3_OFF, 26 | // USART2_OFF, USART1_OFF, USART0_OFF, TWI_OFF); 27 | 28 | // ATmega256RFR2 29 | //LowPower.idle(SLEEP_8S, ADC_OFF, TIMER5_OFF, TIMER4_OFF, TIMER3_OFF, 30 | // TIMER2_OFF, TIMER1_OFF, TIMER0_OFF, SPI_OFF, 31 | // USART1_OFF, USART0_OFF, TWI_OFF); 32 | 33 | // Do something here 34 | // Example: Read sensor, data logging, data transmission. 35 | } 36 | 37 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/powerDownWakeExternalInterrupt/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/Examples/powerDownWakeExternalInterrupt/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/powerDownWakeExternalInterrupt/powerDownWakeExternalInterrupt.ino: -------------------------------------------------------------------------------- 1 | // **** INCLUDES ***** 2 | #include "LowPower.h" 3 | 4 | // Use pin 2 as wake up pin 5 | const int wakeUpPin = 2; 6 | 7 | void wakeUp() 8 | { 9 | // Just a handler for the pin interrupt. 10 | } 11 | 12 | void setup() 13 | { 14 | // Configure wake up pin as input. 15 | // This will consumes few uA of current. 16 | pinMode(wakeUpPin, INPUT); 17 | } 18 | 19 | void loop() 20 | { 21 | // Allow wake up pin to trigger interrupt on low. 22 | attachInterrupt(0, wakeUp, LOW); 23 | 24 | // Enter power down state with ADC and BOD module disabled. 25 | // Wake up when wake up pin is low. 26 | LowPower.powerDown(SLEEP_FOREVER, ADC_OFF, BOD_OFF); 27 | 28 | // Disable external pin interrupt on wake up pin. 29 | detachInterrupt(0); 30 | 31 | // Do something here 32 | // Example: Read sensor, data logging, data transmission. 33 | } 34 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/powerDownWakePeriodic/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/Examples/powerDownWakePeriodic/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/powerDownWakePeriodic/powerDownWakePeriodic.ino: -------------------------------------------------------------------------------- 1 | // **** INCLUDES ***** 2 | #include "LowPower.h" 3 | 4 | void setup() 5 | { 6 | // No setup is required for this library 7 | } 8 | 9 | void loop() 10 | { 11 | // Enter power down state for 8 s with ADC and BOD module disabled 12 | LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 13 | 14 | // Do something here 15 | // Example: Read sensor, data logging, data transmission. 16 | } 17 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/standbyExternalInterruptSAMD21/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/Examples/standbyExternalInterruptSAMD21/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/Examples/standbyExternalInterruptSAMD21/standbyExternalInterruptSAMD21.ino: -------------------------------------------------------------------------------- 1 | // **** INCLUDES ***** 2 | #include "LowPower.h" 3 | 4 | // External interrupt on pin 0 (use pin 0 to 24, except pin 4 on Arduino Zero) 5 | const int pin = 0; 6 | unsigned char count = 10; 7 | 8 | void setup() 9 | { 10 | // Wait for serial USB port to open 11 | while(!SerialUSB); 12 | SerialUSB.println("***** ATSAMD21 Standby Mode Example *****"); 13 | 14 | // ***** IMPORTANT ***** 15 | // Delay is required to allow the USB interface to be active during 16 | // sketch upload process 17 | SerialUSB.println("Entering standby mode in:"); 18 | for (count; count > 0; count--) 19 | { 20 | SerialUSB.print(count); 21 | SerialUSB.println(" s"); 22 | delay(1000); 23 | } 24 | // ********************* 25 | 26 | // External interrupt on pin (example: press of an active low button) 27 | // A pullup resistor is used to hold the signal high when no button press 28 | attachInterrupt(pin, blink, LOW); 29 | } 30 | 31 | void loop() 32 | { 33 | SerialUSB.println("Entering standby mode."); 34 | SerialUSB.println("Apply low signal to wake the processor."); 35 | SerialUSB.println("Zzzz..."); 36 | // Detach USB interface 37 | USBDevice.detach(); 38 | // Enter standby mode 39 | LowPower.standby(); 40 | // Attach USB interface 41 | USBDevice.attach(); 42 | // Wait for serial USB port to open 43 | while(!SerialUSB); 44 | // Serial USB is blazing fast, you might miss the messages 45 | delay(1000); 46 | SerialUSB.println("Awake!"); 47 | SerialUSB.println("Send any character to enter standby mode again"); 48 | // Wait for user response 49 | while(!SerialUSB.available()); 50 | while(SerialUSB.available() > 0) 51 | { 52 | SerialUSB.read(); 53 | } 54 | } 55 | 56 | void blink(void) 57 | { 58 | 59 | } 60 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/LowPower.h: -------------------------------------------------------------------------------- 1 | #ifndef LowPower_h 2 | #define LowPower_h 3 | 4 | #include "Arduino.h" 5 | 6 | enum period_t 7 | { 8 | SLEEP_15MS, 9 | SLEEP_30MS, 10 | SLEEP_60MS, 11 | SLEEP_120MS, 12 | SLEEP_250MS, 13 | SLEEP_500MS, 14 | SLEEP_1S, 15 | SLEEP_2S, 16 | SLEEP_4S, 17 | SLEEP_8S, 18 | SLEEP_FOREVER 19 | }; 20 | 21 | enum bod_t 22 | { 23 | BOD_OFF, 24 | BOD_ON 25 | }; 26 | 27 | enum adc_t 28 | { 29 | ADC_OFF, 30 | ADC_ON 31 | }; 32 | 33 | enum timer5_t 34 | { 35 | TIMER5_OFF, 36 | TIMER5_ON 37 | }; 38 | 39 | enum timer4_t 40 | { 41 | TIMER4_OFF, 42 | TIMER4_ON 43 | }; 44 | 45 | enum timer3_t 46 | { 47 | TIMER3_OFF, 48 | TIMER3_ON 49 | }; 50 | 51 | enum timer2_t 52 | { 53 | TIMER2_OFF, 54 | TIMER2_ON 55 | }; 56 | 57 | enum timer1_t 58 | { 59 | TIMER1_OFF, 60 | TIMER1_ON 61 | }; 62 | 63 | enum timer0_t 64 | { 65 | TIMER0_OFF, 66 | TIMER0_ON 67 | }; 68 | 69 | enum spi_t 70 | { 71 | SPI_OFF, 72 | SPI_ON 73 | }; 74 | 75 | enum usart0_t 76 | { 77 | USART0_OFF, 78 | USART0_ON 79 | }; 80 | 81 | enum usart1_t 82 | { 83 | USART1_OFF, 84 | USART1_ON 85 | }; 86 | 87 | enum usart2_t 88 | { 89 | USART2_OFF, 90 | USART2_ON 91 | }; 92 | 93 | enum usart3_t 94 | { 95 | USART3_OFF, 96 | USART3_ON 97 | }; 98 | 99 | enum twi_t 100 | { 101 | TWI_OFF, 102 | TWI_ON 103 | }; 104 | 105 | enum usb_t 106 | { 107 | USB_OFF, 108 | USB_ON 109 | }; 110 | 111 | enum idle_t 112 | { 113 | IDLE_0, 114 | IDLE_1, 115 | IDLE_2 116 | }; 117 | 118 | class LowPowerClass 119 | { 120 | public: 121 | #if defined (__AVR__) 122 | 123 | #if defined (__AVR_ATmega328P__) || defined (__AVR_ATmega168__) 124 | void idle(period_t period, adc_t adc, timer2_t timer2, 125 | timer1_t timer1, timer0_t timer0, spi_t spi, 126 | usart0_t usart0, twi_t twi); 127 | #elif defined __AVR_ATmega2560__ 128 | void idle(period_t period, adc_t adc, timer5_t timer5, 129 | timer4_t timer4, timer3_t timer3, timer2_t timer2, 130 | timer1_t timer1, timer0_t timer0, spi_t spi, 131 | usart3_t usart3, usart2_t usart2, usart1_t usart1, 132 | usart0_t usart0, twi_t twi); 133 | #elif defined __AVR_ATmega256RFR2__ 134 | void idle(period_t period, adc_t adc, timer5_t timer5, 135 | timer4_t timer4, timer3_t timer3, timer2_t timer2, 136 | timer1_t timer1, timer0_t timer0, spi_t spi, 137 | usart1_t usart1, 138 | usart0_t usart0, twi_t twi); 139 | #elif defined __AVR_ATmega32U4__ 140 | void idle(period_t period, adc_t adc, timer4_t timer4, 141 | timer3_t timer3, timer1_t timer1, timer0_t timer0, 142 | spi_t spi, usart1_t usart1, twi_t twi, usb_t usb); 143 | #else 144 | #error "Please ensure chosen MCU is either 168, 328P, 32U4, 2560 or 256RFR2." 145 | #endif 146 | void adcNoiseReduction(period_t period, adc_t adc, timer2_t timer2) __attribute__((optimize("-O1"))); 147 | void powerDown(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1"))); 148 | void powerSave(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1"))); 149 | void powerStandby(period_t period, adc_t adc, bod_t bod) __attribute__((optimize("-O1"))); 150 | void powerExtStandby(period_t period, adc_t adc, bod_t bod, timer2_t timer2) __attribute__((optimize("-O1"))); 151 | 152 | #elif defined (__arm__) 153 | 154 | #if defined (__SAMD21G18A__) 155 | void idle(idle_t idleMode); 156 | void standby(); 157 | #else 158 | #error "Please ensure chosen MCU is ATSAMD21G18A." 159 | #endif 160 | 161 | #else 162 | 163 | #error "Processor architecture is not supported." 164 | 165 | #endif 166 | }; 167 | 168 | extern LowPowerClass LowPower; 169 | #endif 170 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/README.md: -------------------------------------------------------------------------------- 1 | ### Low-Power 2 | Lightweight low power library for Arduino. 3 | 4 | Version: 1.60 5 | 6 | Date: 01-04-2016 7 | 8 | Devices Supported: 9 | * ATMega168 10 | * ATMega328P 11 | * ATMega32U4 12 | * ATMega2560 13 | * ATMega256RFR2 14 | * ATSAMD21G18A 15 | 16 | ####Notes: 17 | External interrupt during standby on ATSAMD21G18A requires a patch to the Arduino SAMD Core in order for it to work. Fix is provided by this particular pull request. 18 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/desktop.ini: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/LowPower/desktop.ini -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map LowPower 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | ####################################### 10 | # Methods and Functions (KEYWORD2) 11 | ####################################### 12 | 13 | idle KEYWORD2 14 | adcNoiseReduction KEYWORD2 15 | powerDown KEYWORD2 16 | powerSave KEYWORD2 17 | powerStandby KEYWORD2 18 | powerExtStandby KEYWORD2 19 | standby KEYWORD2 20 | 21 | ####################################### 22 | # Instances (KEYWORD2) 23 | ####################################### 24 | 25 | LowPower KEYWORD2 26 | 27 | ####################################### 28 | # Constants (LITERAL1) 29 | ####################################### 30 | 31 | SLEEP_15MS LITERAL1 32 | SLEEP_30MS LITERAL1 33 | SLEEP_60MS LITERAL1 34 | SLEEP_120MS LITERAL1 35 | SLEEP_250MS LITERAL1 36 | SLEEP_500MS LITERAL1 37 | SLEEP_1S LITERAL1 38 | SLEEP_2S LITERAL1 39 | SLEEP_4S LITERAL1 40 | SLEEP_8S LITERAL1 41 | SLEEP_FOREVER LITERAL1 42 | ADC_OFF LITERAL1 43 | ADC_ON LITERAL1 44 | BOD_OFF LITERAL1 45 | BOD_ON LITERAL1 46 | TIMER4_OFF LITERAL1 47 | TIMER4_ON LITERAL1 48 | TIMER3_OFF LITERAL1 49 | TIMER3_ON LITERAL1 50 | TIMER2_OFF LITERAL1 51 | TIMER2_ON LITERAL1 52 | TIMER1_OFF LITERAL1 53 | TIMER1_ON LITERAL1 54 | TIMER0_OFF LITERAL1 55 | TIMER0_ON LITERAL1 56 | USART3_OFF LITERAL1 57 | USART3_ON LITERAL1 58 | USART2_OFF LITERAL1 59 | USART2_ON LITERAL1 60 | USART1_OFF LITERAL1 61 | USART1_ON LITERAL1 62 | USART0_OFF LITERAL1 63 | USART0_ON LITERAL1 64 | SPI_OFF LITERAL1 65 | SPI_ON LITERAL1 66 | TWI_OFF LITERAL1 67 | TWI_ON LITERAL1 68 | USB_OFF LITERAL1 69 | USB_ON LITERAL1 70 | IDLE_0 LITERAL1 71 | IDLE_1 LITERAL1 72 | IDLE_2 LITERAL1 73 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/LowPower/library.properties: -------------------------------------------------------------------------------- 1 | name=Low-Power 2 | version=1.6 3 | author=Rocket Scream Electronics 4 | maintainer=Rocket Scream Electronics 5 | sentence=Lightweight power management library 6 | paragraph=Lightweight power management library 7 | category=Other 8 | url=https://github.com/rocketscream/Low-Power 9 | architectures=avr,samd 10 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | 4 | # Custom for Visual Studio 5 | *.cs diff=csharp 6 | 7 | # Standard to msysgit 8 | *.doc diff=astextplain 9 | *.DOC diff=astextplain 10 | *.docx diff=astextplain 11 | *.DOCX diff=astextplain 12 | *.dot diff=astextplain 13 | *.DOT diff=astextplain 14 | *.pdf diff=astextplain 15 | *.PDF diff=astextplain 16 | *.rtf diff=astextplain 17 | *.RTF diff=astextplain 18 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/.gitignore: -------------------------------------------------------------------------------- 1 | # Windows image file caches 2 | Thumbs.db 3 | ehthumbs.db 4 | 5 | # Folder config file 6 | Desktop.ini 7 | 8 | # Recycle Bin used on file shares 9 | $RECYCLE.BIN/ 10 | 11 | # Windows Installer files 12 | *.cab 13 | *.msi 14 | *.msm 15 | *.msp 16 | 17 | # Windows shortcuts 18 | *.lnk 19 | 20 | # ========================= 21 | # Operating System Files 22 | # ========================= 23 | 24 | # OSX 25 | # ========================= 26 | 27 | .DS_Store 28 | .AppleDouble 29 | .LSOverride 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear on external disk 35 | .Spotlight-V100 36 | .Trashes 37 | 38 | # Directories potentially created on remote AFP share 39 | .AppleDB 40 | .AppleDesktop 41 | Network Trash Folder 42 | Temporary Items 43 | .apdisk 44 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2016 SparkFun Electronics, Inc. 4 | Copyright (c) 2016 LowPowerLab LLC 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | 24 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/README.md: -------------------------------------------------------------------------------- 1 | SI7021 2 | ====== 3 | 4 | Arduino library for SI7020 and SI7021 environmental sensors 5 | Install as usual in your Arduino/libraries folder, restart IDE. -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/SI7021.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Marcus Sorensen 3 | 4 | This program is licensed, please check with the copyright holder for terms 5 | 6 | Updated: Jul 16, 2015: TomWS1: 7 | eliminated Byte constants, 8 | fixed 'sizeof' error in _command(), 9 | added getTempAndRH() function to simplify calls for C & RH only 10 | */ 11 | #include "Arduino.h" 12 | #include "SI7021.h" 13 | #include 14 | 15 | #define I2C_ADDR 0x40 16 | 17 | // I2C commands 18 | #define RH_READ 0xE5 19 | #define TEMP_READ 0xE3 20 | #define POST_RH_TEMP_READ 0xE0 21 | #define RESET 0xFE 22 | #define USER1_READ 0xE7 23 | #define USER1_WRITE 0xE6 24 | 25 | // compound commands 26 | byte SERIAL1_READ[] ={ 0xFA, 0x0F }; 27 | byte SERIAL2_READ[] ={ 0xFC, 0xC9 }; 28 | 29 | bool _si_exists = false; 30 | 31 | SI7021::SI7021() { 32 | } 33 | 34 | #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) 35 | bool SI7021::begin(int SDA, int SCL) { 36 | Wire.begin(SDA,SCL); 37 | #else 38 | bool SI7021::begin() { 39 | Wire.begin(); 40 | #endif 41 | Wire.beginTransmission(I2C_ADDR); 42 | if (Wire.endTransmission() == 0) { 43 | _si_exists = true; 44 | } 45 | return _si_exists; 46 | } 47 | 48 | bool SI7021::sensorExists() { 49 | return _si_exists; 50 | } 51 | 52 | int SI7021::getFahrenheitHundredths() { 53 | int c = getCelsiusHundredths(); 54 | return (1.8 * c) + 3200; 55 | } 56 | 57 | int SI7021::getCelsiusHundredths() { 58 | byte tempbytes[2]; 59 | _command(TEMP_READ, tempbytes); 60 | long tempraw = (long)tempbytes[0] << 8 | tempbytes[1]; 61 | return ((17572 * tempraw) >> 16) - 4685; 62 | } 63 | 64 | int SI7021::_getCelsiusPostHumidity() { 65 | byte tempbytes[2]; 66 | _command(POST_RH_TEMP_READ, tempbytes); 67 | long tempraw = (long)tempbytes[0] << 8 | tempbytes[1]; 68 | return ((17572 * tempraw) >> 16) - 4685; 69 | } 70 | 71 | 72 | unsigned int SI7021::getHumidityPercent() { 73 | byte humbytes[2]; 74 | _command(RH_READ, humbytes); 75 | long humraw = (long)humbytes[0] << 8 | humbytes[1]; 76 | return ((125 * humraw) >> 16) - 6; 77 | } 78 | 79 | unsigned int SI7021::getHumidityBasisPoints() { 80 | byte humbytes[2]; 81 | _command(RH_READ, humbytes); 82 | long humraw = (long)humbytes[0] << 8 | humbytes[1]; 83 | return ((12500 * humraw) >> 16) - 600; 84 | } 85 | 86 | void SI7021::_command(byte cmd, byte * buf ) { 87 | _writeReg(&cmd, sizeof cmd); 88 | #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) 89 | delay(25); 90 | #endif 91 | _readReg(buf, 2); 92 | } 93 | 94 | void SI7021::_writeReg(byte * reg, int reglen) { 95 | Wire.beginTransmission(I2C_ADDR); 96 | for(int i = 0; i < reglen; i++) { 97 | reg += i; 98 | Wire.write(*reg); 99 | } 100 | Wire.endTransmission(); 101 | } 102 | 103 | int SI7021::_readReg(byte * reg, int reglen) { 104 | Wire.requestFrom(I2C_ADDR, reglen); 105 | //while(Wire.available() < reglen); //remove redundant loop-wait per https://github.com/LowPowerLab/SI7021/issues/12 106 | for(int i = 0; i < reglen; i++) { 107 | reg[i] = Wire.read(); 108 | } 109 | return 1; 110 | } 111 | 112 | int SI7021::getSerialBytes(byte * buf) { 113 | byte serial[8]; 114 | _writeReg(SERIAL1_READ, sizeof SERIAL1_READ); 115 | _readReg(serial, 8); 116 | 117 | //Page23 - https://www.silabs.com/Support%20Documents%2FTechnicalDocs%2FSi7021-A20.pdf 118 | buf[0] = serial[0]; //SNA_3 119 | buf[1] = serial[2]; //SNA_2 120 | buf[2] = serial[4]; //SNA_1 121 | buf[3] = serial[6]; //SNA_0 122 | 123 | _writeReg(SERIAL2_READ, sizeof SERIAL2_READ); 124 | _readReg(serial, 6); 125 | buf[4] = serial[0]; //SNB_3 - device ID byte 126 | buf[5] = serial[1]; //SNB_2 127 | buf[6] = serial[3]; //SNB_1 128 | buf[7] = serial[4]; //SNB_0 129 | return 1; 130 | } 131 | 132 | int SI7021::getDeviceId() { 133 | //0x0D=13=Si7013 134 | //0x14=20=Si7020 135 | //0x15=21=Si7021 136 | byte serial[8]; 137 | getSerialBytes(serial); 138 | int id = serial[4]; 139 | return id; 140 | } 141 | 142 | // 0x00 = 14 bit temp, 12 bit RH (default) 143 | // 0x01 = 12 bit temp, 8 bit RH 144 | // 0x80 = 13 bit temp, 10 bit RH 145 | // 0x81 = 11 bit temp, 11 bit RH 146 | void SI7021::setPrecision(byte setting) { 147 | byte reg = USER1_READ; 148 | _writeReg(®, 1); 149 | _readReg(®, 1); 150 | 151 | reg = (reg & 0x7E) | (setting & 0x81); 152 | byte userwrite[] = {USER1_WRITE, reg}; 153 | _writeReg(userwrite, sizeof userwrite); 154 | } 155 | 156 | // NOTE on setHeater() function: 157 | // Depending if 'on' parameter it sets it to: 158 | // - 0x3A (0011_1010 - POR default) for OFF 159 | // - 0x3E (0011_1110) for ON 160 | // This resets the resolution bits to 00 in both cases - which is maximum resolution (12bit RH and 14bit Temp) 161 | // For User1 register usage see p26 (section 6) in DSheet https://www.silabs.com/documents/public/data-sheets/Si7021-A20.pdf 162 | void SI7021::setHeater(bool on) { 163 | byte userbyte; 164 | if (on) { 165 | userbyte = 0x3E; 166 | } else { 167 | userbyte = 0x3A; 168 | } 169 | byte userwrite[] = {USER1_WRITE, userbyte}; 170 | _writeReg(userwrite, sizeof userwrite); 171 | } 172 | 173 | // get humidity, then get temperature reading from humidity measurement 174 | struct si7021_env SI7021::getHumidityAndTemperature() { 175 | si7021_env ret = {0, 0, 0}; 176 | ret.humidityBasisPoints = getHumidityBasisPoints(); 177 | ret.celsiusHundredths = _getCelsiusPostHumidity(); 178 | ret.fahrenheitHundredths = (1.8 * ret.celsiusHundredths) + 3200; 179 | return ret; 180 | } 181 | 182 | // get temperature (C only) and RH Percent 183 | struct si7021_thc SI7021::getTempAndRH() 184 | { 185 | si7021_thc ret; 186 | 187 | ret.humidityPercent = getHumidityPercent(); 188 | ret.celsiusHundredths = _getCelsiusPostHumidity(); 189 | return ret; 190 | 191 | } 192 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/SI7021.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2014 Marcus Sorensen 3 | 4 | This program is licensed, please check with the copyright holder for terms 5 | 6 | Updated: Jul 16, 2015: TomWS1: eliminated Byte constants, fixed 'sizeof' error in _command(), added getTempAndRH() function to simplify calls for C & RH only 7 | */ 8 | #ifndef si7021_h 9 | #define si7021_h 10 | 11 | #if (ARDUINO >= 100) 12 | #include "Arduino.h" 13 | #else 14 | #include "WProgram.h" 15 | #endif 16 | 17 | #ifdef __AVR_ATtiny85__ 18 | #include "TinyWireM.h" 19 | #define Wire TinyWireM 20 | #elif defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) 21 | #include 22 | #else 23 | #if (defined(__AVR__)) || defined(ARDUINO_ARCH_NRF5) 24 | #include 25 | #else 26 | #include 27 | #endif 28 | #include 29 | #endif 30 | 31 | typedef struct si7021_env { 32 | int celsiusHundredths; 33 | int fahrenheitHundredths; 34 | unsigned int humidityBasisPoints; 35 | } si7021_env; 36 | 37 | // same as above but without fahrenheit parameter and RH % 38 | typedef struct si7021_thc { 39 | int celsiusHundredths; 40 | unsigned int humidityPercent; 41 | } si7021_thc; 42 | 43 | class SI7021 44 | { 45 | public: 46 | SI7021(); 47 | #if defined(ARDUINO_ARCH_ESP8266) || defined(ARDUINO_ARCH_ESP32) 48 | bool begin(int SDA, int SCL); 49 | #else 50 | bool begin(); 51 | #endif 52 | bool sensorExists(); 53 | int getFahrenheitHundredths(); 54 | int getCelsiusHundredths(); 55 | unsigned int getHumidityPercent(); 56 | unsigned int getHumidityBasisPoints(); 57 | struct si7021_env getHumidityAndTemperature(); 58 | struct si7021_thc getTempAndRH(); 59 | int getSerialBytes(byte * buf); 60 | int getDeviceId(); 61 | void setPrecision(byte setting); 62 | void setHeater(bool on); 63 | private: 64 | void _command(byte cmd, byte * buf ); 65 | void _writeReg(byte * reg, int reglen); 66 | int _readReg(byte * reg, int reglen); 67 | int _getCelsiusPostHumidity(); 68 | }; 69 | 70 | #endif 71 | 72 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/examples/readsensor/readsensor.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | SI7021 sensor; 6 | int led1 = 3; 7 | int led2 = 4; 8 | 9 | void setup() { 10 | pinMode(led1, OUTPUT); 11 | pinMode(led2, OUTPUT); 12 | sensor.begin(); 13 | } 14 | 15 | 16 | void loop() { 17 | 18 | // temperature is an integer in hundredths 19 | int temperature = sensor.getCelsiusHundredths(); 20 | temperature = temperature / 100; 21 | for (int i = 0; i < temperature; i++) { 22 | pulse(led1); 23 | } 24 | 25 | delay(5000); 26 | 27 | // humidity is an integer representing percent 28 | int humidity = sensor.getHumidityPercent(); 29 | for (int i = 0; i < humidity; i++) { 30 | pulse(led2); 31 | } 32 | 33 | delay(5000); 34 | 35 | // this driver should work for SI7020 and SI7021, this returns 20 or 21 36 | int deviceid = sensor.getDeviceId(); 37 | for (int i = 0; i < deviceid; i++) { 38 | pulse(led1); 39 | } 40 | delay(5000); 41 | 42 | // enable internal heater for testing 43 | sensor.setHeater(true); 44 | delay(20000); 45 | sensor.setHeater(false); 46 | 47 | // see if heater changed temperature 48 | temperature = sensor.getCelsiusHundredths(); 49 | temperature = temperature / 100; 50 | for (int i = 0; i < temperature; i++) { 51 | pulse(led2); 52 | } 53 | 54 | //cool down 55 | delay(20000); 56 | 57 | // get humidity and temperature in one shot, saves power because sensor takes temperature when doing humidity anyway 58 | si7021_env data = sensor.getHumidityAndTemperature(); 59 | for (int i = 0; i < data.celsiusHundredths/100; i++) { 60 | pulse(led1); 61 | } 62 | for (int i = 0; i < data.humidityBasisPoints/100; i++) { 63 | pulse(led2); 64 | } 65 | delay(5000); 66 | } 67 | 68 | void pulse(int pin) { 69 | // software pwm, flash light for ~1 second with short duty cycle 70 | for (int i = 0; i < 20; i++) { 71 | digitalWrite(pin, HIGH); 72 | delay(1); 73 | digitalWrite(pin,LOW); 74 | delay(9); 75 | } 76 | digitalWrite(pin,LOW); 77 | delay(300); 78 | } -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/examples/readsensor_esp8266/readsensor_esp8266.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | const char* ssid = "SSID"; 8 | const char* password = "PASSWORD"; 9 | 10 | #define SDA 0 // GPIO0 on ESP-01 module 11 | #define SCL 2 // GPIO2 on ESP-01 module 12 | 13 | ESP8266WiFiMulti wifiMulti; 14 | ESP8266WebServer server(80); 15 | SI7021 sensor; 16 | 17 | void handle_root() { 18 | int temperature = sensor.getCelsiusHundredths(); 19 | int humidity = sensor.getHumidityPercent(); 20 | server.send(200, "text/plain", String() + F("{\"temperature:\": ") + String(temperature) + F(", \"humidity:\": ") + String(humidity) + F("}")); 21 | } 22 | 23 | void setup() { 24 | WiFi.mode(WIFI_STA); // Wifi-client 25 | wifiMulti.addAP(ssid,password); 26 | 27 | wifiMulti.run(); 28 | server.on("/", handle_root); 29 | sensor.begin(SDA,SCL); 30 | } 31 | 32 | 33 | void loop() { 34 | if (wifiMulti.run() == WL_CONNECTED) { 35 | server.handleClient(); 36 | } 37 | } 38 | 39 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/examples/readsensor_simple/readsensor_simple.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | SI7021 sensor; 6 | int led1 = 13; 7 | int led2 = 4; 8 | 9 | void setup() { 10 | pinMode(led1, OUTPUT); 11 | pinMode(led2, OUTPUT); 12 | sensor.begin(); 13 | Serial.begin(9600); 14 | } 15 | 16 | 17 | void loop() { 18 | 19 | // temperature is an integer in hundredths 20 | int temperature = sensor.getCelsiusHundredths(); 21 | temperature = temperature / 100; 22 | for (int i = 0; i < temperature; i++) { 23 | pulse(led1); 24 | } 25 | 26 | delay(5000); 27 | 28 | // humidity is an integer representing percent 29 | int humidity = sensor.getHumidityPercent(); 30 | for (int i = 0; i < humidity; i++) { 31 | pulse(led2); 32 | } 33 | 34 | delay(5000); 35 | 36 | // this driver should work for SI7020 and SI7021, this returns 20 or 21 37 | int deviceid = sensor.getDeviceId(); 38 | for (int i = 0; i < deviceid; i++) { 39 | pulse(led1); 40 | } 41 | delay(5000); 42 | 43 | // enable internal heater for testing 44 | sensor.setHeater(true); 45 | delay(20000); 46 | sensor.setHeater(false); 47 | 48 | // see if heater changed temperature 49 | temperature = sensor.getCelsiusHundredths(); 50 | temperature = temperature / 100; 51 | for (int i = 0; i < temperature; i++) { 52 | pulse(led2); 53 | } 54 | 55 | //cool down 56 | delay(20000); 57 | 58 | // get humidity and temperature in one shot, saves power because sensor takes temperature when doing humidity anyway 59 | si7021_env data = sensor.getHumidityAndTemperature(); 60 | for (int i = 0; i < data.celsiusHundredths/100; i++) { 61 | pulse(led1); 62 | } 63 | for (int i = 0; i < data.humidityBasisPoints/100; i++) { 64 | pulse(led2); 65 | } 66 | delay(5000); 67 | } 68 | 69 | void pulse(int pin) { 70 | // software pwm, flash light for ~1 second with short duty cycle 71 | for (int i = 0; i < 20; i++) { 72 | digitalWrite(pin, HIGH); 73 | delay(1); 74 | digitalWrite(pin,LOW); 75 | delay(9); 76 | } 77 | digitalWrite(pin,LOW); 78 | delay(300); 79 | } 80 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map for Si7021 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | SI7021 KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | begin KEYWORD2 16 | sensorExists KEYWORD2 17 | getFahrenheitHundredths KEYWORD2 18 | getCelsiusHundredths KEYWORD2 19 | getHumidityPercent KEYWORD2 20 | 21 | getSerialBytes KEYWORD2 22 | getDeviceId KEYWORD2 23 | setHeater KEYWORD2 24 | 25 | ####################################### 26 | # Constants (LITERAL1) 27 | ####################################### -------------------------------------------------------------------------------- /Arduino_Code/Libraries/SI7021-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Si7021", 3 | "keywords": "Si7021, temperature, humidity, sensor, i2c", 4 | "description": "Library for Si7021 high accuracy temperature and humidity sensor", 5 | "repository": 6 | { 7 | "type": "git", 8 | "url": "https://github.com/LowPowerLab/SI7021.git" 9 | }, 10 | "frameworks": "arduino", 11 | "platforms": "*" 12 | } 13 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/doc/LMiC-v1.5.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/Libraries/arduino-lmic-custom/doc/LMiC-v1.5.pdf -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/doc/README.txt: -------------------------------------------------------------------------------- 1 | DISCLAIMER: 2 | Please note that the software is provided AS IS and we cannot 3 | provide support for optimizations, adaptations, integration, 4 | ports to other platforms or device drivers! 5 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/doc/release-notes.txt: -------------------------------------------------------------------------------- 1 | ============================================================================== 2 | LMIC VERSION 1.4 (17-Mar-2015) 3 | ------------------------------- 4 | 5 | - changed API: inverted port indicator flag in LMIC.txrxFlags 6 | (now TXRX_PORT, previously TXRX_NOPORT) 7 | 8 | - fixed offset OFF_CFLIST constant 9 | 10 | - changed CRC-16 algorithm for beacons to CCITT(XMODEM) polynomial 11 | 12 | - fixed radio driver (low data rate optimization for SF11+SF12 only for BW125) 13 | 14 | - fixed timer rollover handling in job queue 15 | 16 | ============================================================================== 17 | LMIC VERSION 1.5 (8-May-2015) 18 | ------------------------------ 19 | 20 | - fixed condition in convFreq() 21 | 22 | - fixed freq*100 bug and freq==0 bug for CFList 23 | 24 | - fixed TX scheduling bug 25 | 26 | - better support for GNU compiler toolchain 27 | 28 | ============================================================================== 29 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/examples/raw/raw.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Matthijs Kooijman 3 | * 4 | * Permission is hereby granted, free of charge, to anyone 5 | * obtaining a copy of this document and accompanying files, 6 | * to do whatever they want with them without any restriction, 7 | * including, but not limited to, copying, modification and redistribution. 8 | * NO WARRANTY OF ANY KIND IS PROVIDED. 9 | * 10 | * This example transmits data on hardcoded channel and receives data 11 | * when not transmitting. Running this sketch on two nodes should allow 12 | * them to communicate. 13 | *******************************************************************************/ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #if !defined(DISABLE_INVERT_IQ_ON_RX) 20 | #error This example requires DISABLE_INVERT_IQ_ON_RX to be set. Update \ 21 | config.h in the lmic library to set it. 22 | #endif 23 | 24 | // How often to send a packet. Note that this sketch bypasses the normal 25 | // LMIC duty cycle limiting, so when you change anything in this sketch 26 | // (payload length, frequency, spreading factor), be sure to check if 27 | // this interval should not also be increased. 28 | // See this spreadsheet for an easy airtime and duty cycle calculator: 29 | // https://docs.google.com/spreadsheets/d/1voGAtQAjC1qBmaVuP1ApNKs1ekgUjavHuVQIXyYSvNc 30 | #define TX_INTERVAL 2000 31 | 32 | // Pin mapping 33 | const lmic_pinmap lmic_pins = { 34 | .nss = 6, 35 | .rxtx = LMIC_UNUSED_PIN, 36 | .rst = 5, 37 | .dio = {2, 3, 4}, 38 | }; 39 | 40 | 41 | // These callbacks are only used in over-the-air activation, so they are 42 | // left empty here (we cannot leave them out completely unless 43 | // DISABLE_JOIN is set in config.h, otherwise the linker will complain). 44 | void os_getArtEui (u1_t* buf) { } 45 | void os_getDevEui (u1_t* buf) { } 46 | void os_getDevKey (u1_t* buf) { } 47 | 48 | void onEvent (ev_t ev) { 49 | } 50 | 51 | osjob_t txjob; 52 | osjob_t timeoutjob; 53 | static void tx_func (osjob_t* job); 54 | 55 | // Transmit the given string and call the given function afterwards 56 | void tx(const char *str, osjobcb_t func) { 57 | os_radio(RADIO_RST); // Stop RX first 58 | delay(1); // Wait a bit, without this os_radio below asserts, apparently because the state hasn't changed yet 59 | LMIC.dataLen = 0; 60 | while (*str) 61 | LMIC.frame[LMIC.dataLen++] = *str++; 62 | LMIC.osjob.func = func; 63 | os_radio(RADIO_TX); 64 | Serial.println("TX"); 65 | } 66 | 67 | // Enable rx mode and call func when a packet is received 68 | void rx(osjobcb_t func) { 69 | LMIC.osjob.func = func; 70 | LMIC.rxtime = os_getTime(); // RX _now_ 71 | // Enable "continuous" RX (e.g. without a timeout, still stops after 72 | // receiving a packet) 73 | os_radio(RADIO_RXON); 74 | Serial.println("RX"); 75 | } 76 | 77 | static void rxtimeout_func(osjob_t *job) { 78 | digitalWrite(LED_BUILTIN, LOW); // off 79 | } 80 | 81 | static void rx_func (osjob_t* job) { 82 | // Blink once to confirm reception and then keep the led on 83 | digitalWrite(LED_BUILTIN, LOW); // off 84 | delay(10); 85 | digitalWrite(LED_BUILTIN, HIGH); // on 86 | 87 | // Timeout RX (i.e. update led status) after 3 periods without RX 88 | os_setTimedCallback(&timeoutjob, os_getTime() + ms2osticks(3*TX_INTERVAL), rxtimeout_func); 89 | 90 | // Reschedule TX so that it should not collide with the other side's 91 | // next TX 92 | os_setTimedCallback(&txjob, os_getTime() + ms2osticks(TX_INTERVAL/2), tx_func); 93 | 94 | Serial.print("Got "); 95 | Serial.print(LMIC.dataLen); 96 | Serial.println(" bytes"); 97 | Serial.write(LMIC.frame, LMIC.dataLen); 98 | Serial.println(); 99 | 100 | // Restart RX 101 | rx(rx_func); 102 | } 103 | 104 | static void txdone_func (osjob_t* job) { 105 | rx(rx_func); 106 | } 107 | 108 | // log text to USART and toggle LED 109 | static void tx_func (osjob_t* job) { 110 | // say hello 111 | tx("Hello, world!", txdone_func); 112 | // reschedule job every TX_INTERVAL (plus a bit of random to prevent 113 | // systematic collisions), unless packets are received, then rx_func 114 | // will reschedule at half this time. 115 | os_setTimedCallback(job, os_getTime() + ms2osticks(TX_INTERVAL + random(500)), tx_func); 116 | } 117 | 118 | // application entry point 119 | void setup() { 120 | Serial.begin(115200); 121 | Serial.println("Starting"); 122 | #ifdef VCC_ENABLE 123 | // For Pinoccio Scout boards 124 | pinMode(VCC_ENABLE, OUTPUT); 125 | digitalWrite(VCC_ENABLE, HIGH); 126 | delay(1000); 127 | #endif 128 | 129 | pinMode(LED_BUILTIN, OUTPUT); 130 | 131 | // initialize runtime env 132 | os_init(); 133 | 134 | // Set up these settings once, and use them for both TX and RX 135 | 136 | #if defined(CFG_eu868) 137 | // Use a frequency in the g3 which allows 10% duty cycling. 138 | LMIC.freq = 869525000; 139 | #elif defined(CFG_us915) 140 | LMIC.freq = 902300000; 141 | #endif 142 | 143 | // Maximum TX power 144 | LMIC.txpow = 27; 145 | // Use a medium spread factor. This can be increased up to SF12 for 146 | // better range, but then the interval should be (significantly) 147 | // lowered to comply with duty cycle limits as well. 148 | LMIC.datarate = DR_SF9; 149 | // This sets CR 4/5, BW125 (except for DR_SF7B, which uses BW250) 150 | LMIC.rps = updr2rps(LMIC.datarate); 151 | 152 | Serial.println("Started"); 153 | Serial.flush(); 154 | 155 | // setup initial job 156 | os_setCallback(&txjob, tx_func); 157 | } 158 | 159 | void loop() { 160 | // execute scheduled jobs and events 161 | os_runloop_once(); 162 | } 163 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/examples/ttn-otaa/ttn-otaa.ino: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Thomas Telkamp and Matthijs Kooijman 3 | * 4 | * Permission is hereby granted, free of charge, to anyone 5 | * obtaining a copy of this document and accompanying files, 6 | * to do whatever they want with them without any restriction, 7 | * including, but not limited to, copying, modification and redistribution. 8 | * NO WARRANTY OF ANY KIND IS PROVIDED. 9 | * 10 | * This example sends a valid LoRaWAN packet with payload "Hello, 11 | * world!", using frequency and encryption settings matching those of 12 | * the The Things Network. 13 | * 14 | * This uses OTAA (Over-the-air activation), where where a DevEUI and 15 | * application key is configured, which are used in an over-the-air 16 | * activation procedure where a DevAddr and session keys are 17 | * assigned/generated for use with all further communication. 18 | * 19 | * Note: LoRaWAN per sub-band duty-cycle limitation is enforced (1% in 20 | * g1, 0.1% in g2), but not the TTN fair usage policy (which is probably 21 | * violated by this sketch when left running for longer)! 22 | 23 | * To use this sketch, first register your application and device with 24 | * the things network, to set or generate an AppEUI, DevEUI and AppKey. 25 | * Multiple devices can use the same AppEUI, but each device has its own 26 | * DevEUI and AppKey. 27 | * 28 | * Do not forget to define the radio type correctly in config.h. 29 | * 30 | *******************************************************************************/ 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | // This EUI must be in little-endian format, so least-significant-byte 37 | // first. When copying an EUI from ttnctl output, this means to reverse 38 | // the bytes. For TTN issued EUIs the last bytes should be 0xD5, 0xB3, 39 | // 0x70. 40 | static const u1_t PROGMEM APPEUI[8]={ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 41 | void os_getArtEui (u1_t* buf) { memcpy_P(buf, APPEUI, 8);} 42 | 43 | // This should also be in little endian format, see above. 44 | static const u1_t PROGMEM DEVEUI[8]={ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; 45 | void os_getDevEui (u1_t* buf) { memcpy_P(buf, DEVEUI, 8);} 46 | 47 | // This key should be in big endian format (or, since it is not really a 48 | // number but a block of memory, endianness does not really apply). In 49 | // practice, a key taken from ttnctl can be copied as-is. 50 | // The key shown here is the semtech default key. 51 | static const u1_t PROGMEM APPKEY[16] = { 0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6, 0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C }; 52 | void os_getDevKey (u1_t* buf) { memcpy_P(buf, APPKEY, 16);} 53 | 54 | static uint8_t mydata[] = "Hello, world!"; 55 | static osjob_t sendjob; 56 | 57 | // Schedule TX every this many seconds (might become longer due to duty 58 | // cycle limitations). 59 | const unsigned TX_INTERVAL = 60; 60 | 61 | // Pin mapping 62 | const lmic_pinmap lmic_pins = { 63 | .nss = 6, 64 | .rxtx = LMIC_UNUSED_PIN, 65 | .rst = 5, 66 | .dio = {2, 3, 4}, 67 | }; 68 | 69 | void onEvent (ev_t ev) { 70 | Serial.print(os_getTime()); 71 | Serial.print(": "); 72 | switch(ev) { 73 | case EV_SCAN_TIMEOUT: 74 | Serial.println(F("EV_SCAN_TIMEOUT")); 75 | break; 76 | case EV_BEACON_FOUND: 77 | Serial.println(F("EV_BEACON_FOUND")); 78 | break; 79 | case EV_BEACON_MISSED: 80 | Serial.println(F("EV_BEACON_MISSED")); 81 | break; 82 | case EV_BEACON_TRACKED: 83 | Serial.println(F("EV_BEACON_TRACKED")); 84 | break; 85 | case EV_JOINING: 86 | Serial.println(F("EV_JOINING")); 87 | break; 88 | case EV_JOINED: 89 | Serial.println(F("EV_JOINED")); 90 | 91 | // Disable link check validation (automatically enabled 92 | // during join, but not supported by TTN at this time). 93 | LMIC_setLinkCheckMode(0); 94 | break; 95 | case EV_RFU1: 96 | Serial.println(F("EV_RFU1")); 97 | break; 98 | case EV_JOIN_FAILED: 99 | Serial.println(F("EV_JOIN_FAILED")); 100 | break; 101 | case EV_REJOIN_FAILED: 102 | Serial.println(F("EV_REJOIN_FAILED")); 103 | break; 104 | break; 105 | case EV_TXCOMPLETE: 106 | Serial.println(F("EV_TXCOMPLETE (includes waiting for RX windows)")); 107 | if (LMIC.txrxFlags & TXRX_ACK) 108 | Serial.println(F("Received ack")); 109 | if (LMIC.dataLen) { 110 | Serial.println(F("Received ")); 111 | Serial.println(LMIC.dataLen); 112 | Serial.println(F(" bytes of payload")); 113 | } 114 | // Schedule next transmission 115 | os_setTimedCallback(&sendjob, os_getTime()+sec2osticks(TX_INTERVAL), do_send); 116 | break; 117 | case EV_LOST_TSYNC: 118 | Serial.println(F("EV_LOST_TSYNC")); 119 | break; 120 | case EV_RESET: 121 | Serial.println(F("EV_RESET")); 122 | break; 123 | case EV_RXCOMPLETE: 124 | // data received in ping slot 125 | Serial.println(F("EV_RXCOMPLETE")); 126 | break; 127 | case EV_LINK_DEAD: 128 | Serial.println(F("EV_LINK_DEAD")); 129 | break; 130 | case EV_LINK_ALIVE: 131 | Serial.println(F("EV_LINK_ALIVE")); 132 | break; 133 | default: 134 | Serial.println(F("Unknown event")); 135 | break; 136 | } 137 | } 138 | 139 | void do_send(osjob_t* j){ 140 | // Check if there is not a current TX/RX job running 141 | if (LMIC.opmode & OP_TXRXPEND) { 142 | Serial.println(F("OP_TXRXPEND, not sending")); 143 | } else { 144 | // Prepare upstream data transmission at the next possible time. 145 | LMIC_setTxData2(1, mydata, sizeof(mydata)-1, 0); 146 | Serial.println(F("Packet queued")); 147 | } 148 | // Next TX is scheduled after TX_COMPLETE event. 149 | } 150 | 151 | void setup() { 152 | Serial.begin(9600); 153 | Serial.println(F("Starting")); 154 | 155 | #ifdef VCC_ENABLE 156 | // For Pinoccio Scout boards 157 | pinMode(VCC_ENABLE, OUTPUT); 158 | digitalWrite(VCC_ENABLE, HIGH); 159 | delay(1000); 160 | #endif 161 | 162 | // LMIC init 163 | os_init(); 164 | // Reset the MAC state. Session and pending data transfers will be discarded. 165 | LMIC_reset(); 166 | 167 | // Start job (sending automatically starts OTAA too) 168 | do_send(&sendjob); 169 | } 170 | 171 | void loop() { 172 | os_runloop_once(); 173 | } 174 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/library.properties: -------------------------------------------------------------------------------- 1 | name=IBM LMIC framework 2 | version=1.5.0+arduino-1 3 | author=IBM 4 | maintainer=Matthijs Kooijman 5 | sentence=Arduino port of the LMIC (LoraWAN-in-C, formerly LoraMAC-in-C) framework provided by IBM. 6 | paragraph=Supports SX1272/SX1276 and HopeRF RFM92/RFM95 tranceivers 7 | category=Communication 8 | url=http://www.research.ibm.com/labs/zurich/ics/lrsc/lmic.html 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/aes/other.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2016 Matthijs Kooijman 3 | * 4 | * LICENSE 5 | * 6 | * Permission is hereby granted, free of charge, to anyone 7 | * obtaining a copy of this document and accompanying files, 8 | * to do whatever they want with them without any restriction, 9 | * including, but not limited to, copying, modification and 10 | * redistribution. 11 | * 12 | * NO WARRANTY OF ANY KIND IS PROVIDED. 13 | *******************************************************************************/ 14 | 15 | /* 16 | * The original LMIC AES implementation integrates raw AES encryption 17 | * with CMAC and AES-CTR in a single piece of code. Most other AES 18 | * implementations (only) offer raw single block AES encryption, so this 19 | * file contains an implementation of CMAC and AES-CTR, and offers the 20 | * same API through the os_aes() function as the original AES 21 | * implementation. This file assumes that there is an encryption 22 | * function available with this signature: 23 | * 24 | * extern "C" void lmic_aes_encrypt(u1_t *data, u1_t *key); 25 | * 26 | * That takes a single 16-byte buffer and encrypts it wit the given 27 | * 16-byte key. 28 | */ 29 | 30 | #include "../lmic/oslmic.h" 31 | 32 | #if !defined(USE_ORIGINAL_AES) 33 | 34 | // This should be defined elsewhere 35 | void lmic_aes_encrypt(u1_t *data, u1_t *key); 36 | 37 | // global area for passing parameters (aux, key) 38 | u4_t AESAUX[16/sizeof(u4_t)]; 39 | u4_t AESKEY[16/sizeof(u4_t)]; 40 | 41 | // Shift the given buffer left one bit 42 | static void shift_left(xref2u1_t buf, u1_t len) { 43 | while (len--) { 44 | u1_t next = len ? buf[1] : 0; 45 | 46 | u1_t val = (*buf << 1); 47 | if (next & 0x80) 48 | val |= 1; 49 | *buf++ = val; 50 | } 51 | } 52 | 53 | // Apply RFC4493 CMAC, using AESKEY as the key. If prepend_aux is true, 54 | // AESAUX is prepended to the message. AESAUX is used as working memory 55 | // in any case. The CMAC result is returned in AESAUX as well. 56 | static void os_aes_cmac(xref2u1_t buf, u2_t len, u1_t prepend_aux) { 57 | if (prepend_aux) 58 | lmic_aes_encrypt(AESaux, AESkey); 59 | else 60 | memset (AESaux, 0, 16); 61 | 62 | while (len > 0) { 63 | u1_t need_padding = 0; 64 | for (u1_t i = 0; i < 16; ++i, ++buf, --len) { 65 | if (len == 0) { 66 | // The message is padded with 0x80 and then zeroes. 67 | // Since zeroes are no-op for xor, we can just skip them 68 | // and leave AESAUX unchanged for them. 69 | AESaux[i] ^= 0x80; 70 | need_padding = 1; 71 | break; 72 | } 73 | AESaux[i] ^= *buf; 74 | } 75 | 76 | if (len == 0) { 77 | // Final block, xor with K1 or K2. K1 and K2 are calculated 78 | // by encrypting the all-zeroes block and then applying some 79 | // shifts and xor on that. 80 | u1_t final_key[16]; 81 | memset(final_key, 0, sizeof(final_key)); 82 | lmic_aes_encrypt(final_key, AESkey); 83 | 84 | // Calculate K1 85 | u1_t msb = final_key[0] & 0x80; 86 | shift_left(final_key, sizeof(final_key)); 87 | if (msb) 88 | final_key[sizeof(final_key)-1] ^= 0x87; 89 | 90 | // If the final block was not complete, calculate K2 from K1 91 | if (need_padding) { 92 | msb = final_key[0] & 0x80; 93 | shift_left(final_key, sizeof(final_key)); 94 | if (msb) 95 | final_key[sizeof(final_key)-1] ^= 0x87; 96 | } 97 | 98 | // Xor with K1 or K2 99 | for (u1_t i = 0; i < sizeof(final_key); ++i) 100 | AESaux[i] ^= final_key[i]; 101 | } 102 | 103 | lmic_aes_encrypt(AESaux, AESkey); 104 | } 105 | } 106 | 107 | // Run AES-CTR using the key in AESKEY and using AESAUX as the 108 | // counter block. The last byte of the counter block will be incremented 109 | // for every block. The given buffer will be encrypted in place. 110 | static void os_aes_ctr (xref2u1_t buf, u2_t len) { 111 | u1_t ctr[16]; 112 | while (len) { 113 | // Encrypt the counter block with the selected key 114 | memcpy(ctr, AESaux, sizeof(ctr)); 115 | lmic_aes_encrypt(ctr, AESkey); 116 | 117 | // Xor the payload with the resulting ciphertext 118 | for (u1_t i = 0; i < 16 && len > 0; i++, len--, buf++) 119 | *buf ^= ctr[i]; 120 | 121 | // Increment the block index byte 122 | AESaux[15]++; 123 | } 124 | } 125 | 126 | u4_t os_aes (u1_t mode, xref2u1_t buf, u2_t len) { 127 | switch (mode & ~AES_MICNOAUX) { 128 | case AES_MIC: 129 | os_aes_cmac(buf, len, /* prepend_aux */ !(mode & AES_MICNOAUX)); 130 | return os_rmsbf4(AESaux); 131 | 132 | case AES_ENC: 133 | // TODO: Check / handle when len is not a multiple of 16 134 | for (u1_t i = 0; i < len; i += 16) 135 | lmic_aes_encrypt(buf+i, AESkey); 136 | break; 137 | 138 | case AES_CTR: 139 | os_aes_ctr(buf, len); 140 | break; 141 | } 142 | return 0; 143 | } 144 | 145 | #endif // !defined(USE_ORIGINAL_AES) 146 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/hal/hal.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2015 Matthijs Kooijman 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * This the HAL to run LMIC on top of the Arduino environment. 9 | *******************************************************************************/ 10 | #ifndef _hal_hal_h_ 11 | #define _hal_hal_h_ 12 | 13 | static const int NUM_DIO = 3; 14 | 15 | struct lmic_pinmap { 16 | u1_t nss; 17 | u1_t rxtx; 18 | u1_t rst; 19 | u1_t dio[NUM_DIO]; 20 | }; 21 | 22 | // Use this for any unused pins. 23 | const u1_t LMIC_UNUSED_PIN = 0xff; 24 | 25 | // Declared here, to be defined an initialized by the application 26 | extern const lmic_pinmap lmic_pins; 27 | 28 | #endif // _hal_hal_h_ 29 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/lmic.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C"{ 3 | #endif 4 | 5 | #include "lmic/lmic.h" 6 | 7 | #ifdef __cplusplus 8 | } 9 | #endif 10 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/lmic/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _lmic_config_h_ 2 | #define _lmic_config_h_ 3 | 4 | // In the original LMIC code, these config values were defined on the 5 | // gcc commandline. Since Arduino does not allow easily modifying the 6 | // compiler commandline, use this file instead. 7 | 8 | #define CFG_eu868 1 9 | //#define CFG_us915 1 10 | //#define CFG_as923 1 11 | // This is the SX1272/SX1273 radio, which is also used on the HopeRF 12 | // RFM92 boards. 13 | //#define CFG_sx1272_radio 1 14 | // This is the SX1276/SX1277/SX1278/SX1279 radio, which is also used on 15 | // the HopeRF RFM95 boards. 16 | #define CFG_sx1276_radio 1 17 | 18 | // 16 μs per tick 19 | // LMIC requires ticks to be 15.5μs - 100 μs long 20 | #define US_PER_OSTICK_EXPONENT 4 21 | #define US_PER_OSTICK (1 << US_PER_OSTICK_EXPONENT) 22 | #define OSTICKS_PER_SEC (1000000 / US_PER_OSTICK) 23 | 24 | // Set this to 1 to enable some basic debug output (using printf) about 25 | // RF settings used during transmission and reception. Set to 2 to 26 | // enable more verbose output. Make sure that printf is actually 27 | // configured (e.g. on AVR it is not by default), otherwise using it can 28 | // cause crashing. 29 | #define LMIC_DEBUG_LEVEL 0 30 | 31 | // Enable this to allow using printf() to print to the given serial port 32 | // (or any other Print object). This can be easy for debugging. The 33 | // current implementation only works on AVR, though. 34 | //#define LMIC_PRINTF_TO Serial 35 | 36 | // Any runtime assertion failures are printed to this serial port (or 37 | // any other Print object). If this is unset, any failures just silently 38 | // halt execution. 39 | #define LMIC_FAILURE_TO Serial 40 | 41 | // Uncomment this to disable all code related to joining 42 | //#define DISABLE_JOIN 43 | // Uncomment this to disable all code related to ping 44 | //#define DISABLE_PING 45 | // Uncomment this to disable all code related to beacon tracking. 46 | // Requires ping to be disabled too 47 | //#define DISABLE_BEACONS 48 | 49 | // Uncomment these to disable the corresponding MAC commands. 50 | // Class A 51 | //#define DISABLE_MCMD_DCAP_REQ // duty cycle cap 52 | //#define DISABLE_MCMD_DN2P_SET // 2nd DN window param 53 | //#define DISABLE_MCMD_SNCH_REQ // set new channel 54 | // Class B 55 | //#define DISABLE_MCMD_PING_SET // set ping freq, automatically disabled by DISABLE_PING 56 | //#define DISABLE_MCMD_BCNI_ANS // next beacon start, automatical disabled by DISABLE_BEACON 57 | 58 | // In LoRaWAN, a gateway applies I/Q inversion on TX, and nodes do the 59 | // same on RX. This ensures that gateways can talk to nodes and vice 60 | // versa, but gateways will not hear other gateways and nodes will not 61 | // hear other nodes. By uncommenting this macro, this inversion is 62 | // disabled and this node can hear other nodes. If two nodes both have 63 | // this macro set, they can talk to each other (but they can no longer 64 | // hear gateways). This should probably only be used when debugging 65 | // and/or when talking to the radio directly (e.g. like in the "raw" 66 | // example). 67 | //#define DISABLE_INVERT_IQ_ON_RX 68 | 69 | // This allows choosing between multiple included AES implementations. 70 | // Make sure exactly one of these is uncommented. 71 | // 72 | // This selects the original AES implementation included LMIC. This 73 | // implementation is optimized for speed on 32-bit processors using 74 | // fairly big lookup tables, but it takes up big amounts of flash on the 75 | // AVR architecture. 76 | // #define USE_ORIGINAL_AES 77 | // 78 | // This selects the AES implementation written by Ideetroon for their 79 | // own LoRaWAN library. It also uses lookup tables, but smaller 80 | // byte-oriented ones, making it use a lot less flash space (but it is 81 | // also about twice as slow as the original). 82 | #define USE_IDEETRON_AES 83 | 84 | #endif // _lmic_config_h_ 85 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/lmic/hal.h: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014-2015 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Zurich Research Lab - initial API, implementation and documentation 10 | *******************************************************************************/ 11 | 12 | #ifndef _hal_hpp_ 13 | #define _hal_hpp_ 14 | 15 | #ifdef __cplusplus 16 | extern "C"{ 17 | #endif 18 | 19 | /* 20 | * initialize hardware (IO, SPI, TIMER, IRQ). 21 | */ 22 | void hal_init (void); 23 | 24 | /* 25 | * drive radio NSS pin (0=low, 1=high). 26 | */ 27 | void hal_pin_nss (u1_t val); 28 | 29 | /* 30 | * drive radio RX/TX pins (0=rx, 1=tx). 31 | */ 32 | void hal_pin_rxtx (u1_t val); 33 | 34 | /* 35 | * control radio RST pin (0=low, 1=high, 2=floating) 36 | */ 37 | void hal_pin_rst (u1_t val); 38 | 39 | /* 40 | * perform 8-bit SPI transaction with radio. 41 | * - write given byte 'outval' 42 | * - read byte and return value 43 | */ 44 | u1_t hal_spi (u1_t outval); 45 | 46 | /* 47 | * disable all CPU interrupts. 48 | * - might be invoked nested 49 | * - will be followed by matching call to hal_enableIRQs() 50 | */ 51 | void hal_disableIRQs (void); 52 | 53 | /* 54 | * enable CPU interrupts. 55 | */ 56 | void hal_enableIRQs (void); 57 | 58 | /* 59 | * put system and CPU in low-power mode, sleep until interrupt. 60 | */ 61 | void hal_sleep (void); 62 | 63 | /* 64 | * return 32-bit system time in ticks. 65 | */ 66 | u4_t hal_ticks (void); 67 | 68 | /* 69 | * busy-wait until specified timestamp (in ticks) is reached. 70 | */ 71 | void hal_waitUntil (u4_t time); 72 | 73 | /* 74 | * check and rewind timer for target time. 75 | * - return 1 if target time is close 76 | * - otherwise rewind timer for target time or full period and return 0 77 | */ 78 | u1_t hal_checkTimer (u4_t targettime); 79 | 80 | /* 81 | * perform fatal failure action. 82 | * - called by assertions 83 | * - action could be HALT or reboot 84 | */ 85 | void hal_failed (const char *file, u2_t line); 86 | 87 | #ifdef __cplusplus 88 | } // extern "C" 89 | #endif 90 | 91 | #endif // _hal_hpp_ 92 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/arduino-lmic-custom/src/lmic/oslmic.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************* 2 | * Copyright (c) 2014-2015 IBM Corporation. 3 | * All rights reserved. This program and the accompanying materials 4 | * are made available under the terms of the Eclipse Public License v1.0 5 | * which accompanies this distribution, and is available at 6 | * http://www.eclipse.org/legal/epl-v10.html 7 | * 8 | * Contributors: 9 | * IBM Zurich Research Lab - initial API, implementation and documentation 10 | *******************************************************************************/ 11 | 12 | #include "lmic.h" 13 | #include 14 | 15 | // RUNTIME STATE 16 | static struct { 17 | osjob_t* scheduledjobs; 18 | osjob_t* runnablejobs; 19 | } OS; 20 | 21 | void os_init () { 22 | memset(&OS, 0x00, sizeof(OS)); 23 | hal_init(); 24 | radio_init(); 25 | LMIC_init(); 26 | } 27 | 28 | ostime_t os_getTime () { 29 | return hal_ticks(); 30 | } 31 | 32 | static u1_t unlinkjob (osjob_t** pnext, osjob_t* job) { 33 | for( ; *pnext; pnext = &((*pnext)->next)) { 34 | if(*pnext == job) { // unlink 35 | *pnext = job->next; 36 | return 1; 37 | } 38 | } 39 | return 0; 40 | } 41 | 42 | // clear scheduled job 43 | void os_clearCallback (osjob_t* job) { 44 | hal_disableIRQs(); 45 | u1_t res = unlinkjob(&OS.scheduledjobs, job) || unlinkjob(&OS.runnablejobs, job); 46 | hal_enableIRQs(); 47 | #if LMIC_DEBUG_LEVEL > 1 48 | if (res) 49 | lmic_printf("%lu: Cleared job %p\n", os_getTime(), job); 50 | #endif 51 | } 52 | 53 | // schedule immediately runnable job 54 | void os_setCallback (osjob_t* job, osjobcb_t cb) { 55 | osjob_t** pnext; 56 | hal_disableIRQs(); 57 | // remove if job was already queued 58 | os_clearCallback(job); 59 | // fill-in job 60 | job->func = cb; 61 | job->next = NULL; 62 | // add to end of run queue 63 | for(pnext=&OS.runnablejobs; *pnext; pnext=&((*pnext)->next)); 64 | *pnext = job; 65 | hal_enableIRQs(); 66 | #if LMIC_DEBUG_LEVEL > 1 67 | lmic_printf("%lu: Scheduled job %p, cb %p ASAP\n", os_getTime(), job, cb); 68 | #endif 69 | } 70 | 71 | // schedule timed job 72 | void os_setTimedCallback (osjob_t* job, ostime_t time, osjobcb_t cb) { 73 | osjob_t** pnext; 74 | hal_disableIRQs(); 75 | // remove if job was already queued 76 | os_clearCallback(job); 77 | // fill-in job 78 | job->deadline = time; 79 | job->func = cb; 80 | job->next = NULL; 81 | // insert into schedule 82 | for(pnext=&OS.scheduledjobs; *pnext; pnext=&((*pnext)->next)) { 83 | if((*pnext)->deadline - time > 0) { // (cmp diff, not abs!) 84 | // enqueue before next element and stop 85 | job->next = *pnext; 86 | break; 87 | } 88 | } 89 | *pnext = job; 90 | hal_enableIRQs(); 91 | #if LMIC_DEBUG_LEVEL > 1 92 | lmic_printf("%lu: Scheduled job %p, cb %p at %lu\n", os_getTime(), job, cb, time); 93 | #endif 94 | } 95 | 96 | // execute jobs from timer and from run queue 97 | void os_runloop () { 98 | while(1) { 99 | os_runloop_once(); 100 | } 101 | } 102 | 103 | void os_runloop_once() { 104 | #if LMIC_DEBUG_LEVEL > 1 105 | bool has_deadline = false; 106 | #endif 107 | osjob_t* j = NULL; 108 | hal_disableIRQs(); 109 | // check for runnable jobs 110 | if(OS.runnablejobs) { 111 | j = OS.runnablejobs; 112 | OS.runnablejobs = j->next; 113 | } else if(OS.scheduledjobs && hal_checkTimer(OS.scheduledjobs->deadline)) { // check for expired timed jobs 114 | j = OS.scheduledjobs; 115 | OS.scheduledjobs = j->next; 116 | #if LMIC_DEBUG_LEVEL > 1 117 | has_deadline = true; 118 | #endif 119 | } else { // nothing pending 120 | hal_sleep(); // wake by irq (timer already restarted) 121 | } 122 | hal_enableIRQs(); 123 | if(j) { // run job callback 124 | #if LMIC_DEBUG_LEVEL > 1 125 | lmic_printf("%lu: Running job %p, cb %p, deadline %lu\n", os_getTime(), j, j->func, has_deadline ? j->deadline : 0); 126 | #endif 127 | j->func(j); 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/cactus_io_BME280_I2C/cactus_io_BME280_I2C.h: -------------------------------------------------------------------------------- 1 | 2 | /*************************************************************************** 3 | 4 | cactus.io 5 | 6 | This is a library for the BME280 humidity, temperature & pressure sensor. It 7 | only supports the I2C bus. It does not support the SPI bus connection. 8 | 9 | 10 | ***************************************************************************/ 11 | 12 | #ifndef __BME280_I2C_H__ 13 | 14 | #define __BME280_I2C_H__ 15 | 16 | #include "Arduino.h" 17 | 18 | #define BME280_ADDRESS 0x77 // define the default I2C address 19 | 20 | // Name of Registers used in the BME280 21 | 22 | #define BME280_DIG_T1_REG 0x88 23 | #define BME280_DIG_T2_REG 0x8A 24 | #define BME280_DIG_T3_REG 0x8C 25 | #define BME280_DIG_P1_REG 0x8E 26 | #define BME280_DIG_P2_REG 0x90 27 | #define BME280_DIG_P3_REG 0x92 28 | #define BME280_DIG_P4_REG 0x94 29 | #define BME280_DIG_P5_REG 0x96 30 | #define BME280_DIG_P6_REG 0x98 31 | #define BME280_DIG_P7_REG 0x9A 32 | #define BME280_DIG_P8_REG 0x9C 33 | #define BME280_DIG_P9_REG 0x9E 34 | 35 | 36 | #define BME280_DIG_H1_REG 0xA1 37 | #define BME280_DIG_H2_REG 0xE1 38 | #define BME280_DIG_H3_REG 0xE3 39 | #define BME280_DIG_H4_REG 0xE4 40 | #define BME280_DIG_H5_REG 0xE5 41 | #define BME280_DIG_H6_REG 0xE7 42 | 43 | 44 | #define BME280_REGISTER_CHIPID 0xD0 45 | #define BME280_REGISTER_VERSION 0xD1 46 | #define BME280_REGISTER_SOFTRESET 0xE0 47 | #define BME280_REGISTER_CAL26 0xE1 48 | #define BME280_REGISTER_CONTROLHUMID 0xF2 49 | #define BME280_REGISTER_CONTROL 0xF4 50 | #define BME280_REGISTER_CONFIG 0xF5 51 | #define BME280_REGISTER_PRESSUREDATA 0xF7 52 | #define BME280_REGISTER_TEMPDATA 0xFA 53 | #define BME280_REGISTER_HUMIDDATA 0xFD 54 | 55 | 56 | // structure to hold the calibration data that is programmed into the sensor in the factory 57 | // during manufacture 58 | 59 | struct BME280_Calibration_Data 60 | { 61 | public: 62 | 63 | uint16_t dig_T1; 64 | int16_t dig_T2; 65 | int16_t dig_T3; 66 | 67 | uint16_t dig_P1; 68 | int16_t dig_P2; 69 | int16_t dig_P3; 70 | int16_t dig_P4; 71 | int16_t dig_P5; 72 | int16_t dig_P6; 73 | int16_t dig_P7; 74 | int16_t dig_P8; 75 | int16_t dig_P9; 76 | 77 | uint8_t dig_H1; 78 | int16_t dig_H2; 79 | uint8_t dig_H3; 80 | int16_t dig_H4; 81 | int16_t dig_H5; 82 | int8_t dig_H6; 83 | 84 | }; 85 | 86 | /*========================================================================= 87 | 88 | Main Class for the BME280 library 89 | 90 | =========================================================================*/ 91 | 92 | 93 | class BME280_I2C 94 | 95 | { 96 | 97 | public: 98 | 99 | BME280_I2C(void); // uses the default 0x77 address and no cal 100 | 101 | BME280_I2C(uint8_t); // use when using 0x76 address 102 | 103 | bool begin(void); 104 | 105 | void setTempCal(float); // we can set a calibration ofsset for the temperature. 106 | // this offset is in degrees celsius 107 | 108 | void readSensor(void); // read the sensor for data 109 | 110 | float getTemperature_C(void); 111 | float getTemperature_F(void); 112 | float getHumidity(void); 113 | float getPressure_HP(void); // pressure in hectapascals 114 | float getPressure_MB(void); // pressure in millibars 115 | 116 | 117 | private: 118 | 119 | BME280_Calibration_Data cal_data; // holds all of the sensor calibration data 120 | 121 | void readTemperature(void); 122 | void readPressure(void); 123 | void readHumidity(void); 124 | void readSensorCoefficients(void); 125 | 126 | float tempcal; // stores the temp offset calibration 127 | float temperature; // stores temperature value 128 | float humidity; // stores humidity value 129 | float pressure; // stores pressure value 130 | 131 | // functions used for sensor communications 132 | 133 | // uint8_t spixfer(uint8_t x); 134 | void write8(byte reg, byte value); 135 | uint8_t read8(byte reg); 136 | uint16_t read16(byte reg); 137 | uint32_t read24(byte reg); 138 | int16_t readS16(byte reg); 139 | uint16_t read16_LE(byte reg); // little endian 140 | int16_t readS16_LE(byte reg); // little endian 141 | uint8_t _i2caddr; 142 | int32_t _sensorID; 143 | int32_t t_fine; 144 | 145 | }; 146 | 147 | #endif 148 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/readme.md: -------------------------------------------------------------------------------- 1 | # Libraries 2 | 3 | In this section, you can fin all the libraries needed for the different exemples. 4 | 5 | * LowPower : This lib implement the low power mode of the 328p. 6 | It is copied from : https://github.com/rocketscream/Low-Power 7 | 8 | * Arduino_LMIC_Custom : This lib is needed for LoRaWan. This lib is a mix between : https://github.com/matthijskooijman/arduino-lmic 9 | and : https://github.com/orenonline/arduino-lmic-as923/blob/master/src/lmic/lorabase.h 10 | 11 | The version supports European 868, US 915 and AS923 bands 12 | 13 | * cactus_io_BME280_I2C : This lib is used for BME280 sensors with I2C control 14 | It is copied from : http://cactus.io/hookups/sensors/barometric/bme280/hookup-arduino-to-bme280-barometric-pressure-sensor 15 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/.travis.yml: -------------------------------------------------------------------------------- 1 | language: python 2 | 3 | cache: 4 | directories: 5 | - "~/.platformio" 6 | 7 | install: 8 | - pip install -U platformio 9 | 10 | env: 11 | - BOARD=uno 12 | - BOARD=leonardo 13 | - BOARD=micro 14 | - BOARD=megaatmega2560 15 | - BOARD=due 16 | - BOARD=yun 17 | - BOARD=genuino101 18 | - BOARD=zero 19 | 20 | script: 21 | - set -eo pipefail; 22 | for e in examples/*; do 23 | platformio ci --board=$BOARD --lib=. $e/*; 24 | done 25 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 Pololu Corporation. For more information, see 2 | 3 | https://www.pololu.com/ 4 | https://forum.pololu.com/ 5 | 6 | Permission is hereby granted, free of charge, to any person 7 | obtaining a copy of this software and associated documentation 8 | files (the "Software"), to deal in the Software without 9 | restriction, including without limitation the rights to use, 10 | copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the 12 | Software is furnished to do so, subject to the following 13 | conditions: 14 | 15 | The above copyright notice and this permission notice shall be 16 | included in all copies or substantial portions of the Software. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 19 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 20 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 21 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 22 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 23 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 25 | OTHER DEALINGS IN THE SOFTWARE. 26 | 27 | ================================================================= 28 | 29 | Most of the functionality of this library is based on the VL53L0X 30 | API provided by ST (STSW-IMG005), and some of the explanatory 31 | comments are quoted or paraphrased from the API source code, API 32 | user manual (UM2039), and the VL53L0X datasheet. 33 | 34 | The following applies to source code reproduced or derived from 35 | the API: 36 | 37 | ----------------------------------------------------------------- 38 | 39 | Copyright © 2016, STMicroelectronics International N.V. All 40 | rights reserved. 41 | 42 | Redistribution and use in source and binary forms, with or 43 | without modification, are permitted provided that the following 44 | conditions are met: 45 | * Redistributions of source code must retain the above copyright 46 | notice, this list of conditions and the following disclaimer. 47 | * Redistributions in binary form must reproduce the above 48 | copyright notice, this list of conditions and the following 49 | disclaimer in the documentation and/or other materials provided 50 | with the distribution. 51 | * Neither the name of STMicroelectronics nor the 52 | names of its contributors may be used to endorse or promote 53 | products derived from this software without specific prior 54 | written permission. 55 | 56 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND 57 | CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, 58 | INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 59 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND 60 | NON-INFRINGEMENT OF INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED. 61 | IN NO EVENT SHALL STMICROELECTRONICS INTERNATIONAL N.V. BE LIABLE 62 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 63 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 64 | OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 65 | OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 66 | LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 67 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 68 | USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 69 | DAMAGE. 70 | 71 | ----------------------------------------------------------------- 72 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/VL53L0X.h: -------------------------------------------------------------------------------- 1 | #ifndef VL53L0X_h 2 | #define VL53L0X_h 3 | 4 | #include 5 | 6 | class VL53L0X 7 | { 8 | public: 9 | // register addresses from API vl53l0x_device.h (ordered as listed there) 10 | enum regAddr 11 | { 12 | SYSRANGE_START = 0x00, 13 | 14 | SYSTEM_THRESH_HIGH = 0x0C, 15 | SYSTEM_THRESH_LOW = 0x0E, 16 | 17 | SYSTEM_SEQUENCE_CONFIG = 0x01, 18 | SYSTEM_RANGE_CONFIG = 0x09, 19 | SYSTEM_INTERMEASUREMENT_PERIOD = 0x04, 20 | 21 | SYSTEM_INTERRUPT_CONFIG_GPIO = 0x0A, 22 | 23 | GPIO_HV_MUX_ACTIVE_HIGH = 0x84, 24 | 25 | SYSTEM_INTERRUPT_CLEAR = 0x0B, 26 | 27 | RESULT_INTERRUPT_STATUS = 0x13, 28 | RESULT_RANGE_STATUS = 0x14, 29 | 30 | RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN = 0xBC, 31 | RESULT_CORE_RANGING_TOTAL_EVENTS_RTN = 0xC0, 32 | RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF = 0xD0, 33 | RESULT_CORE_RANGING_TOTAL_EVENTS_REF = 0xD4, 34 | RESULT_PEAK_SIGNAL_RATE_REF = 0xB6, 35 | 36 | ALGO_PART_TO_PART_RANGE_OFFSET_MM = 0x28, 37 | 38 | I2C_SLAVE_DEVICE_ADDRESS = 0x8A, 39 | 40 | MSRC_CONFIG_CONTROL = 0x60, 41 | 42 | PRE_RANGE_CONFIG_MIN_SNR = 0x27, 43 | PRE_RANGE_CONFIG_VALID_PHASE_LOW = 0x56, 44 | PRE_RANGE_CONFIG_VALID_PHASE_HIGH = 0x57, 45 | PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT = 0x64, 46 | 47 | FINAL_RANGE_CONFIG_MIN_SNR = 0x67, 48 | FINAL_RANGE_CONFIG_VALID_PHASE_LOW = 0x47, 49 | FINAL_RANGE_CONFIG_VALID_PHASE_HIGH = 0x48, 50 | FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT = 0x44, 51 | 52 | PRE_RANGE_CONFIG_SIGMA_THRESH_HI = 0x61, 53 | PRE_RANGE_CONFIG_SIGMA_THRESH_LO = 0x62, 54 | 55 | PRE_RANGE_CONFIG_VCSEL_PERIOD = 0x50, 56 | PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x51, 57 | PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x52, 58 | 59 | SYSTEM_HISTOGRAM_BIN = 0x81, 60 | HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT = 0x33, 61 | HISTOGRAM_CONFIG_READOUT_CTRL = 0x55, 62 | 63 | FINAL_RANGE_CONFIG_VCSEL_PERIOD = 0x70, 64 | FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI = 0x71, 65 | FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO = 0x72, 66 | CROSSTALK_COMPENSATION_PEAK_RATE_MCPS = 0x20, 67 | 68 | MSRC_CONFIG_TIMEOUT_MACROP = 0x46, 69 | 70 | SOFT_RESET_GO2_SOFT_RESET_N = 0xBF, 71 | IDENTIFICATION_MODEL_ID = 0xC0, 72 | IDENTIFICATION_REVISION_ID = 0xC2, 73 | 74 | OSC_CALIBRATE_VAL = 0xF8, 75 | 76 | GLOBAL_CONFIG_VCSEL_WIDTH = 0x32, 77 | GLOBAL_CONFIG_SPAD_ENABLES_REF_0 = 0xB0, 78 | GLOBAL_CONFIG_SPAD_ENABLES_REF_1 = 0xB1, 79 | GLOBAL_CONFIG_SPAD_ENABLES_REF_2 = 0xB2, 80 | GLOBAL_CONFIG_SPAD_ENABLES_REF_3 = 0xB3, 81 | GLOBAL_CONFIG_SPAD_ENABLES_REF_4 = 0xB4, 82 | GLOBAL_CONFIG_SPAD_ENABLES_REF_5 = 0xB5, 83 | 84 | GLOBAL_CONFIG_REF_EN_START_SELECT = 0xB6, 85 | DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD = 0x4E, 86 | DYNAMIC_SPAD_REF_EN_START_OFFSET = 0x4F, 87 | POWER_MANAGEMENT_GO1_POWER_FORCE = 0x80, 88 | 89 | VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV = 0x89, 90 | 91 | ALGO_PHASECAL_LIM = 0x30, 92 | ALGO_PHASECAL_CONFIG_TIMEOUT = 0x30, 93 | }; 94 | 95 | enum vcselPeriodType { VcselPeriodPreRange, VcselPeriodFinalRange }; 96 | 97 | uint8_t last_status; // status of last I2C transmission 98 | 99 | VL53L0X(void); 100 | 101 | void setAddress(uint8_t new_addr); 102 | inline uint8_t getAddress(void) { return address; } 103 | 104 | bool init(bool io_2v8 = true); 105 | 106 | void writeReg(uint8_t reg, uint8_t value); 107 | void writeReg16Bit(uint8_t reg, uint16_t value); 108 | void writeReg32Bit(uint8_t reg, uint32_t value); 109 | uint8_t readReg(uint8_t reg); 110 | uint16_t readReg16Bit(uint8_t reg); 111 | uint32_t readReg32Bit(uint8_t reg); 112 | 113 | void writeMulti(uint8_t reg, uint8_t const * src, uint8_t count); 114 | void readMulti(uint8_t reg, uint8_t * dst, uint8_t count); 115 | 116 | bool setSignalRateLimit(float limit_Mcps); 117 | float getSignalRateLimit(void); 118 | 119 | bool setMeasurementTimingBudget(uint32_t budget_us); 120 | uint32_t getMeasurementTimingBudget(void); 121 | 122 | bool setVcselPulsePeriod(vcselPeriodType type, uint8_t period_pclks); 123 | uint8_t getVcselPulsePeriod(vcselPeriodType type); 124 | 125 | void startContinuous(uint32_t period_ms = 0); 126 | void stopContinuous(void); 127 | uint16_t readRangeContinuousMillimeters(void); 128 | uint16_t readRangeSingleMillimeters(void); 129 | 130 | inline void setTimeout(uint16_t timeout) { io_timeout = timeout; } 131 | inline uint16_t getTimeout(void) { return io_timeout; } 132 | bool timeoutOccurred(void); 133 | 134 | private: 135 | // TCC: Target CentreCheck 136 | // MSRC: Minimum Signal Rate Check 137 | // DSS: Dynamic Spad Selection 138 | 139 | struct SequenceStepEnables 140 | { 141 | boolean tcc, msrc, dss, pre_range, final_range; 142 | }; 143 | 144 | struct SequenceStepTimeouts 145 | { 146 | uint16_t pre_range_vcsel_period_pclks, final_range_vcsel_period_pclks; 147 | 148 | uint16_t msrc_dss_tcc_mclks, pre_range_mclks, final_range_mclks; 149 | uint32_t msrc_dss_tcc_us, pre_range_us, final_range_us; 150 | }; 151 | 152 | uint8_t address; 153 | uint16_t io_timeout; 154 | bool did_timeout; 155 | uint16_t timeout_start_ms; 156 | 157 | uint8_t stop_variable; // read by init and used when starting measurement; is StopVariable field of VL53L0X_DevData_t structure in API 158 | uint32_t measurement_timing_budget_us; 159 | 160 | bool getSpadInfo(uint8_t * count, bool * type_is_aperture); 161 | 162 | void getSequenceStepEnables(SequenceStepEnables * enables); 163 | void getSequenceStepTimeouts(SequenceStepEnables const * enables, SequenceStepTimeouts * timeouts); 164 | 165 | bool performSingleRefCalibration(uint8_t vhv_init_byte); 166 | 167 | static uint16_t decodeTimeout(uint16_t value); 168 | static uint16_t encodeTimeout(uint16_t timeout_mclks); 169 | static uint32_t timeoutMclksToMicroseconds(uint16_t timeout_period_mclks, uint8_t vcsel_period_pclks); 170 | static uint32_t timeoutMicrosecondsToMclks(uint32_t timeout_period_us, uint8_t vcsel_period_pclks); 171 | }; 172 | 173 | #endif 174 | 175 | 176 | 177 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/examples/Continuous/Continuous.ino: -------------------------------------------------------------------------------- 1 | /* This example shows how to use continuous mode to take 2 | range measurements with the VL53L0X. It is based on 3 | vl53l0x_ContinuousRanging_Example.c from the VL53L0X API. 4 | 5 | The range readings are in units of mm. */ 6 | 7 | #include 8 | #include 9 | 10 | VL53L0X sensor; 11 | 12 | void setup() 13 | { 14 | Serial.begin(9600); 15 | Wire.begin(); 16 | 17 | sensor.init(); 18 | sensor.setTimeout(500); 19 | 20 | // Start continuous back-to-back mode (take readings as 21 | // fast as possible). To use continuous timed mode 22 | // instead, provide a desired inter-measurement period in 23 | // ms (e.g. sensor.startContinuous(100)). 24 | sensor.startContinuous(); 25 | } 26 | 27 | void loop() 28 | { 29 | Serial.print(sensor.readRangeContinuousMillimeters()); 30 | if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } 31 | 32 | Serial.println(); 33 | } 34 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/examples/Single/Single.ino: -------------------------------------------------------------------------------- 1 | /* This example shows how to get single-shot range 2 | measurements from the VL53L0X. The sensor can optionally be 3 | configured with different ranging profiles, as described in 4 | the VL53L0X API user manual, to get better performance for 5 | a certain application. This code is based on the four 6 | "SingleRanging" examples in the VL53L0X API. 7 | 8 | The range readings are in units of mm. */ 9 | 10 | #include 11 | #include 12 | 13 | VL53L0X sensor; 14 | 15 | 16 | // Uncomment this line to use long range mode. This 17 | // increases the sensitivity of the sensor and extends its 18 | // potential range, but increases the likelihood of getting 19 | // an inaccurate reading because of reflections from objects 20 | // other than the intended target. It works best in dark 21 | // conditions. 22 | 23 | //#define LONG_RANGE 24 | 25 | 26 | // Uncomment ONE of these two lines to get 27 | // - higher speed at the cost of lower accuracy OR 28 | // - higher accuracy at the cost of lower speed 29 | 30 | //#define HIGH_SPEED 31 | //#define HIGH_ACCURACY 32 | 33 | 34 | void setup() 35 | { 36 | Serial.begin(9600); 37 | Wire.begin(); 38 | 39 | sensor.init(); 40 | sensor.setTimeout(500); 41 | 42 | #if defined LONG_RANGE 43 | // lower the return signal rate limit (default is 0.25 MCPS) 44 | sensor.setSignalRateLimit(0.1); 45 | // increase laser pulse periods (defaults are 14 and 10 PCLKs) 46 | sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodPreRange, 18); 47 | sensor.setVcselPulsePeriod(VL53L0X::VcselPeriodFinalRange, 14); 48 | #endif 49 | 50 | #if defined HIGH_SPEED 51 | // reduce timing budget to 20 ms (default is about 33 ms) 52 | sensor.setMeasurementTimingBudget(20000); 53 | #elif defined HIGH_ACCURACY 54 | // increase timing budget to 200 ms 55 | sensor.setMeasurementTimingBudget(200000); 56 | #endif 57 | } 58 | 59 | void loop() 60 | { 61 | Serial.print(sensor.readRangeSingleMillimeters()); 62 | if (sensor.timeoutOccurred()) { Serial.print(" TIMEOUT"); } 63 | 64 | Serial.println(); 65 | } 66 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/keywords.txt: -------------------------------------------------------------------------------- 1 | VL53L0X KEYWORD1 2 | 3 | setAddress KEYWORD2 4 | getAddress KEYWORD2 5 | init KEYWORD2 6 | writeReg KEYWORD2 7 | writeReg16Bit KEYWORD2 8 | writeReg32Bit KEYWORD2 9 | readReg KEYWORD2 10 | readReg16Bit KEYWORD2 11 | readReg32Bit KEYWORD2 12 | writeMulti KEYWORD2 13 | readMulti KEYWORD2 14 | setSignalRateLimit KEYWORD2 15 | getSignalRateLimit KEYWORD2 16 | setMeasurementTimingBudget KEYWORD2 17 | getMeasurementTimingBudget KEYWORD2 18 | setVcselPulsePeriod KEYWORD2 19 | getVcselPulsePeriod KEYWORD2 20 | startContinuous KEYWORD2 21 | stopContinuous KEYWORD2 22 | readRangeContinuousMillimeters KEYWORD2 23 | readRangeSingleMillimeters KEYWORD2 24 | setTimeout KEYWORD2 25 | getTimeout KEYWORD2 26 | timeoutOccurred KEYWORD2 27 | 28 | SYSRANGE_START LITERAL1 29 | SYSTEM_THRESH_HIGH LITERAL1 30 | SYSTEM_THRESH_LOW LITERAL1 31 | SYSTEM_SEQUENCE_CONFIG LITERAL1 32 | SYSTEM_RANGE_CONFIG LITERAL1 33 | SYSTEM_INTERMEASUREMENT_PERIOD LITERAL1 34 | SYSTEM_INTERRUPT_CONFIG_GPIO LITERAL1 35 | GPIO_HV_MUX_ACTIVE_HIGH LITERAL1 36 | SYSTEM_INTERRUPT_CLEAR LITERAL1 37 | RESULT_INTERRUPT_STATUS LITERAL1 38 | RESULT_RANGE_STATUS LITERAL1 39 | RESULT_CORE_AMBIENT_WINDOW_EVENTS_RTN LITERAL1 40 | RESULT_CORE_RANGING_TOTAL_EVENTS_RTN LITERAL1 41 | RESULT_CORE_AMBIENT_WINDOW_EVENTS_REF LITERAL1 42 | RESULT_CORE_RANGING_TOTAL_EVENTS_REF LITERAL1 43 | RESULT_PEAK_SIGNAL_RATE_REF LITERAL1 44 | ALGO_PART_TO_PART_RANGE_OFFSET_MM LITERAL1 45 | I2C_SLAVE_DEVICE_ADDRESS LITERAL1 46 | MSRC_CONFIG_CONTROL LITERAL1 47 | PRE_RANGE_CONFIG_MIN_SNR LITERAL1 48 | PRE_RANGE_CONFIG_VALID_PHASE_LOW LITERAL1 49 | PRE_RANGE_CONFIG_VALID_PHASE_HIGH LITERAL1 50 | PRE_RANGE_MIN_COUNT_RATE_RTN_LIMIT LITERAL1 51 | FINAL_RANGE_CONFIG_MIN_SNR LITERAL1 52 | FINAL_RANGE_CONFIG_VALID_PHASE_LOW LITERAL1 53 | FINAL_RANGE_CONFIG_VALID_PHASE_HIGH LITERAL1 54 | FINAL_RANGE_CONFIG_MIN_COUNT_RATE_RTN_LIMIT LITERAL1 55 | PRE_RANGE_CONFIG_SIGMA_THRESH_HI LITERAL1 56 | PRE_RANGE_CONFIG_SIGMA_THRESH_LO LITERAL1 57 | PRE_RANGE_CONFIG_VCSEL_PERIOD LITERAL1 58 | PRE_RANGE_CONFIG_TIMEOUT_MACROP_HI LITERAL1 59 | PRE_RANGE_CONFIG_TIMEOUT_MACROP_LO LITERAL1 60 | SYSTEM_HISTOGRAM_BIN LITERAL1 61 | HISTOGRAM_CONFIG_INITIAL_PHASE_SELECT LITERAL1 62 | HISTOGRAM_CONFIG_READOUT_CTRL LITERAL1 63 | FINAL_RANGE_CONFIG_VCSEL_PERIOD LITERAL1 64 | FINAL_RANGE_CONFIG_TIMEOUT_MACROP_HI LITERAL1 65 | FINAL_RANGE_CONFIG_TIMEOUT_MACROP_LO LITERAL1 66 | CROSSTALK_COMPENSATION_PEAK_RATE_MCPS LITERAL1 67 | MSRC_CONFIG_TIMEOUT_MACROP LITERAL1 68 | SOFT_RESET_GO2_SOFT_RESET_N LITERAL1 69 | IDENTIFICATION_MODEL_ID LITERAL1 70 | IDENTIFICATION_REVISION_ID LITERAL1 71 | OSC_CALIBRATE_VAL LITERAL1 72 | GLOBAL_CONFIG_VCSEL_WIDTH LITERAL1 73 | GLOBAL_CONFIG_SPAD_ENABLES_REF_0 LITERAL1 74 | GLOBAL_CONFIG_SPAD_ENABLES_REF_1 LITERAL1 75 | GLOBAL_CONFIG_SPAD_ENABLES_REF_2 LITERAL1 76 | GLOBAL_CONFIG_SPAD_ENABLES_REF_3 LITERAL1 77 | GLOBAL_CONFIG_SPAD_ENABLES_REF_4 LITERAL1 78 | GLOBAL_CONFIG_SPAD_ENABLES_REF_5 LITERAL1 79 | GLOBAL_CONFIG_REF_EN_START_SELECT LITERAL1 80 | DYNAMIC_SPAD_NUM_REQUESTED_REF_SPAD LITERAL1 81 | DYNAMIC_SPAD_REF_EN_START_OFFSET LITERAL1 82 | POWER_MANAGEMENT_GO1_POWER_FORCE LITERAL1 83 | VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV LITERAL1 84 | ALGO_PHASECAL_LIM LITERAL1 85 | ALGO_PHASECAL_CONFIG_TIMEOUT LITERAL1 86 | 87 | VcselPeriodPreRange LITERAL1 88 | VcselPeriodFinalRange LITERAL1 89 | 90 | 91 | -------------------------------------------------------------------------------- /Arduino_Code/Libraries/vl53l0x-arduino-master/library.properties: -------------------------------------------------------------------------------- 1 | name=VL53L0X 2 | version=1.0.2 3 | author=Pololu 4 | maintainer=Pololu 5 | sentence=VL53L0X distance sensor library 6 | paragraph=This is a library for the Arduino IDE that helps interface with ST's VL53L0X distance sensor. 7 | category=Sensors 8 | url=https://github.com/pololu/vl53l0x-arduino 9 | architectures=* 10 | -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/LoRa.h: -------------------------------------------------------------------------------- 1 | #ifndef LORA_H 2 | #define LORA_H 3 | 4 | #include 5 | #include 6 | 7 | #define LORA_DEFAULT_SS_PIN 10 8 | #define LORA_DEFAULT_RESET_PIN 8 9 | #define LORA_DEFAULT_DIO0_PIN 2 10 | 11 | #define PA_OUTPUT_RFO_PIN 0 12 | #define PA_OUTPUT_PA_BOOST_PIN 1 13 | 14 | class LoRaClass : public Stream { 15 | public: 16 | LoRaClass(); 17 | 18 | int begin(long frequency); 19 | void end(); 20 | 21 | int beginPacket(int implicitHeader = false); 22 | int endPacket(); 23 | 24 | int parsePacket(int size = 0); 25 | int packetRssi(); 26 | int RssiValue(); 27 | float packetSnr(); 28 | 29 | // from Print 30 | virtual size_t write(uint8_t byte); 31 | virtual size_t write(const uint8_t *buffer, size_t size); 32 | 33 | // from Stream 34 | virtual int available(); 35 | virtual int read(); 36 | virtual int peek(); 37 | virtual void flush(); 38 | 39 | void onReceive(void(*callback)(int)); 40 | 41 | void receive(int size = 0); 42 | void idle(); 43 | void sleep(); 44 | 45 | void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN); 46 | void setFrequency(long frequency); 47 | void setSpreadingFactor(int sf); 48 | void setSignalBandwidth(long sbw); 49 | void setCodingRate4(int denominator); 50 | void setPreambleLength(long length); 51 | void setSyncWord(int sw); 52 | void enableCrc(); 53 | void disableCrc(); 54 | void setFSK(); 55 | void setOOK(); 56 | void setPolarity(int pol); 57 | 58 | // deprecated 59 | void crc() { enableCrc(); } 60 | void noCrc() { disableCrc(); } 61 | 62 | byte random(); 63 | 64 | void setPins(int ss = LORA_DEFAULT_SS_PIN, int reset = LORA_DEFAULT_RESET_PIN, int dio0 = LORA_DEFAULT_DIO0_PIN); 65 | void setSPIFrequency(uint32_t frequency); 66 | 67 | void dumpRegisters(Stream& out); 68 | 69 | private: 70 | void explicitHeaderMode(); 71 | void implicitHeaderMode(); 72 | 73 | void handleDio0Rise(); 74 | 75 | uint8_t readRegister(uint8_t address); 76 | void writeRegister(uint8_t address, uint8_t value); 77 | uint8_t singleTransfer(uint8_t address, uint8_t value); 78 | 79 | static void onDio0Rise(); 80 | 81 | private: 82 | SPISettings _spiSettings; 83 | int _ss; 84 | int _reset; 85 | int _dio0; 86 | int _frequency; 87 | int _packetIndex; 88 | int _implicitHeaderMode; 89 | void (*_onReceive)(int); 90 | }; 91 | 92 | extern LoRaClass LoRa; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/LoRaReceiver_Phy/LoRaReceiver_Phy.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int counter = 0; 5 | 6 | // Parameters you can play with : 7 | 8 | int txPower = 14; // from 0 to 20, default is 14 9 | int spreadingFactor = 12; // from 7 to 12, default is 12 10 | long signalBandwidth = 125E3; // 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,41.7E3,62.5E3,125E3,250E3,500e3, default is 125E3 11 | int codingRateDenominator=5; // Numerator is 4, and denominator from 5 to 8, default is 5 12 | int preambleLength=8; // from 2 to 20, default is 8 13 | String payload = "hello"; // you can change the payload 14 | 15 | #define SS 10 16 | #define RST 8 17 | #define DI0 2 18 | #define BAND 865E6 // Here you define the frequency carrier 19 | 20 | void setup() { 21 | Serial.begin(115200); 22 | while (!Serial); 23 | 24 | Serial.println("LoRa Receiver"); 25 | Serial.print("SetFrequency : "); 26 | Serial.print(BAND); 27 | Serial.println("Hz"); 28 | Serial.print("SetSpreadingFactor : SF"); 29 | Serial.println(spreadingFactor); 30 | 31 | 32 | SPI.begin(); 33 | LoRa.setPins(SS,RST,DI0); 34 | 35 | 36 | 37 | if (!LoRa.begin(BAND)) { 38 | Serial.println("Starting LoRa failed!"); 39 | while (1); 40 | } 41 | LoRa.setTxPower(txPower,1); 42 | LoRa.setSpreadingFactor(spreadingFactor); 43 | LoRa.setSignalBandwidth(signalBandwidth); 44 | LoRa.setCodingRate4(codingRateDenominator); 45 | LoRa.setPreambleLength(preambleLength); 46 | 47 | } 48 | 49 | void loop() { 50 | // try to parse packet 51 | int packetSize = LoRa.parsePacket(); 52 | if (packetSize) { 53 | // received a packet 54 | Serial.print("Received packet '"); 55 | 56 | // read packet 57 | while (LoRa.available()) { 58 | Serial.print((char)LoRa.read()); 59 | } 60 | 61 | // print RSSI of packet 62 | Serial.print("' with RSSI "); 63 | Serial.println(LoRa.packetRssi()); 64 | } 65 | } 66 | 67 | 68 | 69 | 70 | 71 | -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/LoRaSender_Phy/LoRaSender_Phy.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int counter = 0; 5 | 6 | // Parameters you can play with : 7 | 8 | int txPower = 14; // from 0 to 20, default is 14 9 | int spreadingFactor = 12; // from 7 to 12, default is 12 10 | long signalBandwidth = 125E3; // 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,41.7E3,62.5E3,125E3,250E3,500e3, default is 125E3 11 | int codingRateDenominator=5; // Numerator is 4, and denominator from 5 to 8, default is 5 12 | int preambleLength=8; // from 2 to 20, default is 8 13 | String payload = "hello"; // you can change the payload 14 | 15 | #define SS 10 16 | #define RST 8 17 | #define DI0 2 18 | #define BAND 865E6 // Here you define the frequency carrier 19 | 20 | void setup() { 21 | Serial.begin(115200); 22 | while (!Serial); 23 | 24 | Serial.println("LoRa Sender"); 25 | Serial.print("SetFrequency : "); 26 | Serial.print(BAND); 27 | Serial.println("Hz"); 28 | Serial.print("SetSpreadingFactor : SF"); 29 | Serial.println(spreadingFactor); 30 | 31 | SPI.begin(); 32 | LoRa.setPins(SS,RST,DI0); 33 | 34 | 35 | 36 | if (!LoRa.begin(BAND)) { 37 | Serial.println("Starting LoRa failed!"); 38 | while (1); 39 | } 40 | LoRa.setTxPower(txPower,1); 41 | LoRa.setSpreadingFactor(spreadingFactor); 42 | LoRa.setSignalBandwidth(signalBandwidth); 43 | LoRa.setCodingRate4(codingRateDenominator); 44 | LoRa.setPreambleLength(preambleLength); 45 | // LoRa.setPolarity(1); 46 | //LoRa.setFSK(); 47 | 48 | } 49 | 50 | void loop() { 51 | 52 | // send packet 53 | 54 | LoRa.beginPacket(); 55 | LoRa.print(payload); 56 | 57 | LoRa.endPacket(); 58 | counter++; 59 | 60 | Serial.print("Sending packet with payload {"); 61 | Serial.print(payload); 62 | Serial.print("} N°"); 63 | Serial.println(counter); 64 | 65 | 66 | delay(100); 67 | } 68 | -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/LoRa_test_States/LoRa_test_States.ino: -------------------------------------------------------------------------------- 1 | /* 2 | LoRa test States 3 | 4 | The objective of this sketch is to measure the power consumption in different states 5 | 6 | The code was modified from LoRa Duplex from Tom Igoe 7 | */ 8 | #include // include libraries 9 | #include 10 | #include "LowPower.h" 11 | 12 | #define debugSerial Serial 13 | #define SHOW_DEBUGINFO 14 | 15 | 16 | int txPower = 14; // Will affect the power consumption in Transmit mode 17 | 18 | 19 | int spreadingFactor = 12; // from 7 to 12 20 | long signalBandwidth = 125E3; // 7.8E3, 10.4E3, 15.6E3, 20.8E3, 31.25E3,41.7E3,62.5E3,125E3,250E3 21 | int codingRateDenominator=5; 22 | int preambleLength=8; 23 | 24 | int receive = 0; 25 | 26 | const int csPin = 10; // LoRa radio chip select 27 | const int resetPin = 8; // LoRa radio reset 28 | const int irqPin = 2; // change for your board; must be a hardware interrupt pin 29 | 30 | String outgoing; // outgoing message 31 | 32 | byte msgCount = 0; // count of outgoing messages 33 | byte localAddress = 0xBB; // address of this device 34 | byte destination = 0xFF; // destination to send to 35 | long lastSendTime = 0; // last send time 36 | int interval = 2000; // interval between sends 37 | 38 | void setup() { 39 | 40 | delay(2000); // wait to be sure that measurement with a DC source will start 41 | Serial.begin(9600); // initialize serial 42 | while (!Serial); 43 | Serial.println("LoRa States power Consumption"); 44 | 45 | // override the default CS, reset, and IRQ pins (optional) 46 | LoRa.setPins(csPin, resetPin, irqPin);// set CS, reset, IRQ pin 47 | 48 | if (!LoRa.begin(870E6)) { // initialize ratio at 870 MHz to limit interferance with LoRaWan 49 | Serial.println("LoRa init failed. Check your connections."); 50 | while (true); // if failed, do nothing 51 | } 52 | 53 | Serial.println("LoRa init succeeded."); 54 | LoRa.setTxPower(txPower,1); 55 | LoRa.setSpreadingFactor(spreadingFactor); 56 | LoRa.setSignalBandwidth(signalBandwidth); 57 | LoRa.setCodingRate4(codingRateDenominator); 58 | LoRa.setPreambleLength(preambleLength); 59 | } 60 | 61 | void loop() { 62 | if (millis() - lastSendTime > interval) { 63 | String message = "HeLoRa World!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"; // send a message 64 | Serial.println("Sending State : " + message); 65 | sendMessage(message); 66 | 67 | lastSendTime = millis(); // timestamp the message 68 | interval = 10000; // 2-3 seconds 69 | 70 | Serial.println("Normal mode "); 71 | delay (3000); // Wait for 3s in Normal mode 72 | 73 | LoRa.sleep(); // move LoRa transciever in Sleep mode 74 | do_sleep(5); 75 | receive = 1; 76 | } 77 | 78 | // parse for a packet, and call onReceive with the result: 79 | if (receive == 1) 80 | { 81 | Serial.println("Receiving State "); 82 | receive = 0;} 83 | onReceive(LoRa.parsePacket()); 84 | } 85 | 86 | void sendMessage(String outgoing) { 87 | LoRa.beginPacket(); // start packet 88 | LoRa.write(destination); // add destination address 89 | LoRa.write(localAddress); // add sender address 90 | LoRa.write(msgCount); // add message ID 91 | LoRa.write(outgoing.length()); // add payload length 92 | LoRa.print(outgoing); // add payload 93 | LoRa.endPacket(); // finish packet and send it 94 | msgCount++; // increment message ID 95 | } 96 | 97 | void onReceive(int packetSize) { 98 | if (packetSize == 0) return; // if there's no packet, return 99 | 100 | // read packet header bytes: 101 | int recipient = LoRa.read(); // recipient address 102 | byte sender = LoRa.read(); // sender address 103 | byte incomingMsgId = LoRa.read(); // incoming msg ID 104 | byte incomingLength = LoRa.read(); // incoming msg length 105 | String incoming = ""; 106 | 107 | while (LoRa.available()) { 108 | incoming += (char)LoRa.read(); 109 | } 110 | 111 | if (incomingLength != incoming.length()) { // check length for error 112 | Serial.println("error: message length does not match length"); 113 | return; // skip rest of function 114 | } 115 | 116 | // if the recipient isn't this device or broadcast, 117 | if (recipient != localAddress && recipient != 0xFF) { 118 | Serial.println("This message is not for me."); 119 | return; // skip rest of function 120 | } 121 | 122 | // if message is for this device, or broadcast, print details: 123 | Serial.println("Received from: 0x" + String(sender, HEX)); 124 | Serial.println("Sent to: 0x" + String(recipient, HEX)); 125 | Serial.println("Message ID: " + String(incomingMsgId)); 126 | Serial.println("Message length: " + String(incomingLength)); 127 | Serial.println("Message: " + incoming); 128 | Serial.println("RSSI: " + String(LoRa.packetRssi())); 129 | Serial.println("Snr: " + String(LoRa.packetSnr())); 130 | Serial.println(); 131 | } 132 | 133 | extern volatile unsigned long timer0_millis; 134 | void addMillis(unsigned long extra_millis) { 135 | uint8_t oldSREG = SREG; 136 | cli(); 137 | timer0_millis += extra_millis; 138 | SREG = oldSREG; 139 | sei(); 140 | } 141 | 142 | void do_sleep(unsigned int sleepyTime) { 143 | unsigned int eights = sleepyTime / 8; 144 | unsigned int fours = (sleepyTime % 8) / 4; 145 | unsigned int twos = ((sleepyTime % 8) % 4) / 2; 146 | unsigned int ones = ((sleepyTime % 8) % 4) % 2; 147 | 148 | #ifdef SHOW_DEBUGINFO 149 | Serial.print("Sleeping for "); 150 | Serial.print(sleepyTime); 151 | Serial.println(" seconds"); 152 | delay(100); //Wait for serial to complete 153 | #endif 154 | 155 | 156 | for ( int x = 0; x < eights; x++) { 157 | // put the processor to sleep for 8 seconds 158 | LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF); 159 | } 160 | for ( int x = 0; x < fours; x++) { 161 | // put the processor to sleep for 4 seconds 162 | LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF); 163 | } 164 | for ( int x = 0; x < twos; x++) { 165 | // put the processor to sleep for 2 seconds 166 | LowPower.powerDown(SLEEP_2S, ADC_OFF, BOD_OFF); 167 | } 168 | for ( int x = 0; x < ones; x++) { 169 | // put the processor to sleep for 1 seconds 170 | LowPower.powerDown(SLEEP_1S, ADC_OFF, BOD_OFF); 171 | } 172 | addMillis(sleepyTime * 1000); 173 | } 174 | -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/Power_consumption_Lab.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Arduino_Code/LoRa_PHY/Power_consumption_Lab.pdf -------------------------------------------------------------------------------- /Arduino_Code/LoRa_PHY/readme.md: -------------------------------------------------------------------------------- 1 | Code for Lab on LoRa physical layer 2 | -------------------------------------------------------------------------------- /Arduino_Code/Sensors/readSI7021/readSI7021.ino: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | 5 | SI7021 sensor; 6 | 7 | void setup() { 8 | Serial.begin(115200); 9 | sensor.begin(); 10 | } 11 | 12 | void loop() { 13 | 14 | // temperature is an integer in hundredths 15 | int temperature = sensor.getCelsiusHundredths(); 16 | temperature = temperature / 100; 17 | Serial.print("Temperature :"); 18 | Serial.print(temperature); 19 | Serial.println("°Celcius"); 20 | 21 | delay(500); 22 | 23 | // humidity is an integer representing percent 24 | int humidity = sensor.getHumidityPercent(); 25 | Serial.print("Humidity :"); 26 | Serial.print(humidity); 27 | Serial.println("%"); 28 | 29 | 30 | delay(500); 31 | 32 | 33 | // enable internal heater for testing 34 | sensor.setHeater(true); 35 | Serial.println("Activate heater"); 36 | 37 | delay(20000); 38 | sensor.setHeater(false); 39 | Serial.println("Desactivate heater"); 40 | 41 | // see if heater changed temperature 42 | temperature = sensor.getCelsiusHundredths(); 43 | temperature = temperature / 100; 44 | Serial.print("Temperature :"); 45 | Serial.print(temperature); 46 | Serial.println("°Celcius"); 47 | 48 | 49 | //cool down 50 | delay(20000); 51 | 52 | // get humidity and temperature in one shot, saves power because sensor takes temperature when doing humidity anyway 53 | si7021_env data = sensor.getHumidityAndTemperature(); 54 | Serial.print("Temperature :"); 55 | Serial.print(data.celsiusHundredths/100); 56 | Serial.println("°Celcius"); 57 | 58 | delay(500); 59 | } 60 | 61 | -------------------------------------------------------------------------------- /Arduino_Code/Sensors/readTEMT6000/readTEMT6000.ino: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define LAPIN A0 // PIN with Light sensor analog output 4 | #define LPPIN 4 // PIN with Light power input 5 | 6 | 7 | static float light; 8 | 9 | void setup() { 10 | Serial.begin(115200); 11 | pinMode(LPPIN, OUTPUT); 12 | 13 | } 14 | 15 | void loop() { 16 | 17 | // temperature is an integer in hundredths 18 | light = readLight(); 19 | 20 | Serial.print("Light :"); 21 | Serial.print(light); 22 | Serial.println("Lx"); 23 | 24 | delay(500); 25 | } 26 | 27 | float readLight() { 28 | float result; 29 | // Light sensor Voltage 30 | digitalWrite(LPPIN, HIGH); // Power the sensor 31 | delay(10); 32 | int sensorValue = analogRead(LAPIN); 33 | // Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 3.3V): 34 | float voltage = sensorValue * (3.3 / 1023.0); // Batvalue is 3.3V 35 | result = voltage*2000; // multiply by 2000 to have Lx 36 | digitalWrite(LPPIN, LOW); // switch off the sensor 37 | return result; 38 | } 39 | 40 | -------------------------------------------------------------------------------- /Arduino_Code/readme.md: -------------------------------------------------------------------------------- 1 | Some codes are provided as an exemple. 2 | 3 | 4 | -------------------------------------------------------------------------------- /Gerber/gerber_UCAv2.0.rar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/Gerber/gerber_UCAv2.0.rar -------------------------------------------------------------------------------- /Gerber/readme.md: -------------------------------------------------------------------------------- 1 | The PCB has been layout by hand, I'm an antenna designer and not a professional PCB layout maker, 2 | so you may find the layout not so much professional. 3 | 4 | Whatever, this PCB is working quite well for proof of concept projects. 5 | 6 | If you want to give an hand to make this project more professional, please send me an email. 7 | 8 | 9 | Top View from ADS software 10 | 11 | 12 | 13 | Top view from DipTrace 14 | 15 | 16 | 17 | Bottom view from DipTrace 18 | 19 | 20 | 21 | Picture of the Top view of the pcb 22 | 23 | 24 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UCA_Board 2 | 3 | 4 | Version 1.0.0, November, 2017 5 | Author: Fabien Ferrero 6 | 7 | 8 | 9 | This PCB was developed to ease connection between an Arduino Mini Pro, and RFM95 LoRa module, AA battery and a printed antenna. 10 | 11 | Codes for the microcontroller for LoRa communications can be found on this link in the Arduino section : https://github.com/CongducPham/LowCostLoRaGw 12 | 13 | I'm also including in this github some codes compatible with LoRaWan in the /Arduino_Code section. 14 | 15 | # PCB UCA 16 | 17 | 18 | 19 | This PCB has been designed to enable the connection of multiple sensors, few possibilities are listed in this figure : 20 | 21 | 22 | 23 | # Bill Of Material 24 | 25 | 26 | * Arduino Mini Pro 3.3V 8MHz 27 | https://fr.aliexpress.com/item/10pcs-ATMEGA328P-Pro-Mini-328-Mini-ATMEGA328-3-3V-16-MHz-for-Arduino-3-3V-16/32784455996.html?spm=a2g0s.13010208.99999999.276.LOMiw9 28 | * RFM95W 29 | https://fr.aliexpress.com/item/RFM95W-RFM95-868MHz-LORA-SX1276-wireless-transceiver-module-20DBM-3KM-Best-quality/32810607598.html?spm=a2g0s.9042311.0.0.bMWhGH 30 | 31 | Optional : 32 | 33 | * DHT-22 ( temperature and humidity sensor) 34 | https://fr.aliexpress.com/item/Free-Shipping-1pcs-DHT22-digital-temperature-and-humidity-sensor-Temperature-and-humidity-module-AM2302-replace-SHT11/32730343520.html?spm=a2g0s.9042311.0.0.RsBFuh 35 | * BME280 ( temperature, barometer and humidity sensor) 36 | https://fr.aliexpress.com/item/3In1-BME280-GY-BME280-Digital-Sensor-SPI-I2C-Humidity-Temperature-and-Barometric-Pressure-Sensor-Module-1/32830483099.html?spm=a2g0s.9042311.0.0.2GH3nf 37 | * RGB LED 38 | https://fr.aliexpress.com/item/100pcs-Ultra-Bright-Red-Green-Blue-SMT-SMD-LED-RGB-5050-LED-DIODE-Chip-Light-Emitting/32340120687.html?spm=a2g0s.9042311.0.0.RsBFuh 39 | * Ultrasound distance sensor (pay attention that this sensor need 5V to work properly, and you will need some resistor divider to not damage your Arduino board) 40 | https://fr.aliexpress.com/item/Free-shipping-10Pcs-lot-Ultrasonic-Module-HC-SR04-Distance-Measuring-Transducer-Sensor-for-ar-du-ino/32745224945.html?spm=a2g0s.9042311.0.0.RsBFuh 41 | * Step-up voltage booster 42 | https://fr.aliexpress.com/item/5pcs-2-in-1-DC-DC-Step-Down-Step-Up-Converter-0-8V-6V-to-3/32759171595.html?spm=a2g0s.9042311.0.0.bMWhGH 43 | 44 | * 3-axis accelerometer : https://learn.sparkfun.com/tutorials/mma8452q-accelerometer-breakout-hookup-guide 45 | 46 | 47 | 48 | 49 | # Wiring 50 | 51 | ``` 52 | Arduino Mini LoRa RFM95W 53 | Mini Pro Module 54 | D8 <----> RST 55 | MISO (D12) <----> MISO 56 | MOSI (D11) <----> MOSI 57 | SCK (D13) <----> CLK 58 | SS (D10) <----> SEL (Chip Select) 59 | D2 <----> DIO0 60 | D7 <----> DIO1 61 | D9 <----> DIO2 62 | 3.3V <----> Vcc 63 | 64 | ``` 65 | 66 | # Layout 67 | 68 | The layout of the PCB is available the gerber section. 69 | It has been designed to be fabricated on a 0.8mm-thick FR4 2 layer PCB. 70 | Depending of your need, it can be fabricated with different thickness, but the antenna has to be adjusted. 71 | 72 | 73 | 74 | # Librairies 75 | 76 | You will need some librairies to run the code, you can look in the libraries section to find the different libs needed for running the code. 77 | 78 | # License 79 | 80 | All rights reserved. This Gerber, program and the accompanying materials are made available under the terms of the MIT License which accompanies this distribution, and is available at https://opensource.org/licenses/mit-license.php 81 | 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. 82 | 83 | Maintained by Fabien Ferrero 84 | 85 | -------------------------------------------------------------------------------- /documents/Conferences/Atelier_IoT_LoRaWAN_2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Conferences/Atelier_IoT_LoRaWAN_2019.pdf -------------------------------------------------------------------------------- /documents/Conferences/DaNang_UCA_04_2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Conferences/DaNang_UCA_04_2018.pdf -------------------------------------------------------------------------------- /documents/Conferences/EUCAP_UCA_04_2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Conferences/EUCAP_UCA_04_2018.pdf -------------------------------------------------------------------------------- /documents/Conferences/IWASI_UCA_06_2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Conferences/IWASI_UCA_06_2017.pdf -------------------------------------------------------------------------------- /documents/Conferences/TTN_UCA_02_2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Conferences/TTN_UCA_02_2018.pdf -------------------------------------------------------------------------------- /documents/Conferences/readme.md: -------------------------------------------------------------------------------- 1 | This project has been presented in different conferences : 2 | 3 | * IWASI, Vieste, Italy, 06-2017 4 | 5 | * The Thing Conference, Amsterdam, Netherlands, 02-2018 6 | 7 | * Eucap, London, UK, 04-2018 8 | 9 | -------------------------------------------------------------------------------- /documents/Course/Course_LPWAN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Course/Course_LPWAN.pdf -------------------------------------------------------------------------------- /documents/Course/Course_LoRaWAN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Course/Course_LoRaWAN.pdf -------------------------------------------------------------------------------- /documents/Course/Lab1_Channel_Measurement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Course/Lab1_Channel_Measurement.pdf -------------------------------------------------------------------------------- /documents/Course/Lab2_LoRaWan_Register_device.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Course/Lab2_LoRaWan_Register_device.pdf -------------------------------------------------------------------------------- /documents/Course/readme.md: -------------------------------------------------------------------------------- 1 | You will find in this directory the course on LP-WAN technology in the frame of the MIT module 2 | -------------------------------------------------------------------------------- /documents/Labs/Lab1_Channel_Measurement.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Labs/Lab1_Channel_Measurement.pdf -------------------------------------------------------------------------------- /documents/Labs/Lab2_Understanding_LoRa_modulation.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Labs/Lab2_Understanding_LoRa_modulation.pdf -------------------------------------------------------------------------------- /documents/Labs/Lab3_LoRaWan_Register_device.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Labs/Lab3_LoRaWan_Register_device.pdf -------------------------------------------------------------------------------- /documents/Labs/Lab4_Power consumption.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/Labs/Lab4_Power consumption.pdf -------------------------------------------------------------------------------- /documents/Labs/readme.md: -------------------------------------------------------------------------------- 1 | This Labs are done in the frame of Connected Objet course in Polytech'Nice 2 | -------------------------------------------------------------------------------- /documents/pictures/LED_Blue.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/LED_Blue.jpg -------------------------------------------------------------------------------- /documents/pictures/LED_Green.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/LED_Green.jpg -------------------------------------------------------------------------------- /documents/pictures/LED_Red.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/LED_Red.jpg -------------------------------------------------------------------------------- /documents/pictures/TEMT6000_lx.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/TEMT6000_lx.jpg -------------------------------------------------------------------------------- /documents/pictures/TEMT6000_lx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/TEMT6000_lx.png -------------------------------------------------------------------------------- /documents/pictures/TEMT6000_sch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/TEMT6000_sch.png -------------------------------------------------------------------------------- /documents/pictures/TTN_LED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/TTN_LED.png -------------------------------------------------------------------------------- /documents/pictures/UCA.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA.jpg -------------------------------------------------------------------------------- /documents/pictures/UCA_layout.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_layout.png -------------------------------------------------------------------------------- /documents/pictures/UCA_layout_bot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_layout_bot.png -------------------------------------------------------------------------------- /documents/pictures/UCA_layout_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_layout_top.png -------------------------------------------------------------------------------- /documents/pictures/UCA_mounted.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_mounted.png -------------------------------------------------------------------------------- /documents/pictures/UCA_sensors.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_sensors.png -------------------------------------------------------------------------------- /documents/pictures/UCA_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/UCA_top.png -------------------------------------------------------------------------------- /documents/pictures/cayenne_LED.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/pictures/cayenne_LED.png -------------------------------------------------------------------------------- /documents/pictures/readme.md: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /documents/tutorial/DaNang/DA NANG SMART CAMPUS-2018_2019_ATIGB.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/DaNang/DA NANG SMART CAMPUS-2018_2019_ATIGB.pdf -------------------------------------------------------------------------------- /documents/tutorial/DaNang/DA NANG SMART CAMPUS-2018_2019_Seminar.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/DaNang/DA NANG SMART CAMPUS-2018_2019_Seminar.pdf -------------------------------------------------------------------------------- /documents/tutorial/DaNang/IoT_App_service_Tutorial_2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/DaNang/IoT_App_service_Tutorial_2018.pdf -------------------------------------------------------------------------------- /documents/tutorial/DaNang/LORA_tutorial_2017.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/DaNang/LORA_tutorial_2017.pdf -------------------------------------------------------------------------------- /documents/tutorial/DaNang/LoRaWan_TTN_tuto_DaNang_2018_2019.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/DaNang/LoRaWan_TTN_tuto_DaNang_2018_2019.pdf -------------------------------------------------------------------------------- /documents/tutorial/DaNang/readme.md: -------------------------------------------------------------------------------- 1 | This section is dedicated to Da Nang 2 | -------------------------------------------------------------------------------- /documents/tutorial/IoT_App_service_Tutorial_2018.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/IoT_App_service_Tutorial_2018.pdf -------------------------------------------------------------------------------- /documents/tutorial/LoRaWan_TTN_tuto_v2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/LoRaWan_TTN_tuto_v2.pdf -------------------------------------------------------------------------------- /documents/tutorial/Ordering_a_PCB_with_PCBways_V2.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/Ordering_a_PCB_with_PCBways_V2.pdf -------------------------------------------------------------------------------- /documents/tutorial/UCA_Antenna_tuto.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/FabienFerrero/UCA_Board/b4f3685153ad06e99eb5302d3c68e15b423f86be/documents/tutorial/UCA_Antenna_tuto.pdf -------------------------------------------------------------------------------- /documents/tutorial/readme.md: -------------------------------------------------------------------------------- 1 | You can find here some tutorial on the antenna, PCB ordering ... 2 | --------------------------------------------------------------------------------