diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4811bb3 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +HGD4_reversed/.vscode/extensions.json diff --git a/HGD4_reversed/platformio.ini b/HGD4_reversed/platformio.ini index e2ca6c8..0f310c3 100644 --- a/HGD4_reversed/platformio.ini +++ b/HGD4_reversed/platformio.ini @@ -18,5 +18,6 @@ lib_deps = adafruit/Adafruit Unified Sensor@^1.1.15 adafruit/Adafruit LIS3DH@^1.3.0 sparkfun/SparkFun Ambient Light Sensor Arduino Library@^1.0.4 + https://github.com/stm32duino/LPS22HB build_unflags = -DNRF52 -DUSE_LFXO build_flags = -DNRF52840_XXAA -DUSE_LFRC \ No newline at end of file diff --git a/HGD4_reversed/src/main.cpp b/HGD4_reversed/src/main.cpp index 49974ae..3c1ebf4 100644 --- a/HGD4_reversed/src/main.cpp +++ b/HGD4_reversed/src/main.cpp @@ -3,6 +3,7 @@ SparkFun_Ambient_Light light(AL_ADDR); ENS210 ens210; +LPS22HBSensor lps22hb(&Wire); Adafruit_LIS3DH acc1 = Adafruit_LIS3DH(ACCL1_CS); Adafruit_LIS3DH acc2 = Adafruit_LIS3DH(ACCL2_CS); @@ -12,11 +13,12 @@ void setup() { } void loop() { - Serial.println("loop"); - busscan(); + Serial.println(); + Serial.println("|---------Starting loop---------|"); //powerupesp(); //powerupmodem(); measuretemp(); + measurepressure(); lightsense(); delay(1000); } @@ -83,53 +85,56 @@ long luxVal = 0; Serial.println("Could not communicate with the light sensor!"); light.setGain(gain); light.setIntegTime(time); + + Serial.println("|-----------------------------|"); + Serial.println("| Sensor: VEML6035 |"); + Serial.println("| Gain | Integration Time |"); + Serial.print("| "); + Serial.print(gain, 3); + Serial.print(" | "); + Serial.print(time); + Serial.println(" |"); + luxVal = light.readLight(); - Serial.print("Ambient Light Reading: "); + + Serial.println("|-----------------------------|"); + Serial.println("| Ambient Light Reading |"); + Serial.print("| "); Serial.print(luxVal); - Serial.println(" Lux"); + Serial.println(" Lux"); + Serial.println("|-----------------------------|"); } void measuretemp(){ ens210.begin(); int t_data, t_status, h_data, h_status; ens210.measure(&t_data, &t_status, &h_data, &h_status ); - Serial.print( ens210.toCelsius(t_data,10)/10.0, 1 ); Serial.print(" C, "); - Serial.print( ens210.toPercentageH(h_data,1) ); Serial.print(" %RH"); - Serial.println(); + + Serial.println("|-------------------------------|"); + Serial.println("| Sensor: ENS210 |"); + Serial.println("| Temperature | Humidity |"); + Serial.print("| "); + Serial.print(ens210.toCelsius(t_data, 10) / 10.0, 1); + Serial.print(" C | "); + Serial.print(ens210.toPercentageH(h_data, 1)); + Serial.println(" %RH |"); + Serial.println("|-------------------------------|"); } -void busscan(){ - byte error, address; - int nDevices; - - Serial.println("Scanning..."); - - nDevices = 0; - for(address = 1; address < 127; address++ ) - { - Wire.beginTransmission(address); - error = Wire.endTransmission(); - - if (error == 0) - { - Serial.print("I2C device found at address 0x"); - if (address<16) - Serial.print("0"); - Serial.print(address,HEX); - Serial.println(" !"); - - nDevices++; - } - else if (error==4) - { - Serial.print("Unknown error at address 0x"); - if (address<16) - Serial.print("0"); - Serial.println(address,HEX); - } - } - if (nDevices == 0) - Serial.println("No I2C devices found\n"); - else - Serial.println("done\n"); +void measurepressure(){ + lps22hb.begin(); + lps22hb.Enable(); + float pressure, temperature; + lps22hb.GetPressure(&pressure); + lps22hb.GetTemperature(&temperature); + + Serial.println("|----------------------------------|"); + Serial.println("| Sensor: LPS22HB |"); + Serial.println("| Pressure[hPa] | Temperature[C] |"); + Serial.print("| "); + Serial.print(pressure, 2); + Serial.print(" | "); + Serial.print(temperature, 2); + Serial.println(" |"); + Serial.println("|----------------------------------|"); } \ No newline at end of file diff --git a/HGD4_reversed/src/main.h b/HGD4_reversed/src/main.h index b71998f..73c5dc3 100644 --- a/HGD4_reversed/src/main.h +++ b/HGD4_reversed/src/main.h @@ -5,9 +5,10 @@ #include #include "ens210.h" #include "SparkFun_VEML6030_Ambient_Light_Sensor.h" +#include -void busscan(); void measuretemp(); +void measurepressure(); void lightsense(); void powerupesp(); void wd_handler(); diff --git a/README.md b/README.md index 7a60d2f..bbda154 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Information about the LOCO Track Primary HGD4 GPS tracker | VEML6035 | Light Sensor | Next to push button, used for wake-up | IC7 | | ENS210 | Temperature + Humidity Sensor | - | IC3 | | TPL5010 | Watchdog | needs to be fed | IC4 | -| Unspecified Pressure Sensor | Pressure Sensor | - | IC5 | +| LPS22HB | Pressure Sensor | - | IC5 | | Red LED | LED | - | LED1 | | Green LED | LED | - | LED2 | | Button | Push Button | Wakes the device power off | SW1 |