removed busscan, added Pressure-Sensor, beautified Serial Output and added LPS22HB to README

This commit is contained in:
2025-03-08 00:52:52 +01:00
parent 86c51e326c
commit 513a5aeed8
5 changed files with 51 additions and 43 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
HGD4_reversed/.vscode/extensions.json

View File

@@ -18,5 +18,6 @@ lib_deps =
adafruit/Adafruit Unified Sensor@^1.1.15 adafruit/Adafruit Unified Sensor@^1.1.15
adafruit/Adafruit LIS3DH@^1.3.0 adafruit/Adafruit LIS3DH@^1.3.0
sparkfun/SparkFun Ambient Light Sensor Arduino Library@^1.0.4 sparkfun/SparkFun Ambient Light Sensor Arduino Library@^1.0.4
https://github.com/stm32duino/LPS22HB
build_unflags = -DNRF52 -DUSE_LFXO build_unflags = -DNRF52 -DUSE_LFXO
build_flags = -DNRF52840_XXAA -DUSE_LFRC build_flags = -DNRF52840_XXAA -DUSE_LFRC

View File

@@ -3,6 +3,7 @@
SparkFun_Ambient_Light light(AL_ADDR); SparkFun_Ambient_Light light(AL_ADDR);
ENS210 ens210; ENS210 ens210;
LPS22HBSensor lps22hb(&Wire);
Adafruit_LIS3DH acc1 = Adafruit_LIS3DH(ACCL1_CS); Adafruit_LIS3DH acc1 = Adafruit_LIS3DH(ACCL1_CS);
Adafruit_LIS3DH acc2 = Adafruit_LIS3DH(ACCL2_CS); Adafruit_LIS3DH acc2 = Adafruit_LIS3DH(ACCL2_CS);
@@ -12,11 +13,12 @@ void setup() {
} }
void loop() { void loop() {
Serial.println("loop"); Serial.println();
busscan(); Serial.println("|---------Starting loop---------|");
//powerupesp(); //powerupesp();
//powerupmodem(); //powerupmodem();
measuretemp(); measuretemp();
measurepressure();
lightsense(); lightsense();
delay(1000); delay(1000);
} }
@@ -83,53 +85,56 @@ long luxVal = 0;
Serial.println("Could not communicate with the light sensor!"); Serial.println("Could not communicate with the light sensor!");
light.setGain(gain); light.setGain(gain);
light.setIntegTime(time); 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(); luxVal = light.readLight();
Serial.print("Ambient Light Reading: ");
Serial.println("|-----------------------------|");
Serial.println("| Ambient Light Reading |");
Serial.print("| ");
Serial.print(luxVal); Serial.print(luxVal);
Serial.println(" Lux"); Serial.println(" Lux");
Serial.println("|-----------------------------|");
} }
void measuretemp(){ void measuretemp(){
ens210.begin(); ens210.begin();
int t_data, t_status, h_data, h_status; int t_data, t_status, h_data, h_status;
ens210.measure(&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(){ void measurepressure(){
byte error, address; lps22hb.begin();
int nDevices; lps22hb.Enable();
float pressure, temperature;
Serial.println("Scanning..."); lps22hb.GetPressure(&pressure);
lps22hb.GetTemperature(&temperature);
nDevices = 0;
for(address = 1; address < 127; address++ ) Serial.println("|----------------------------------|");
{ Serial.println("| Sensor: LPS22HB |");
Wire.beginTransmission(address); Serial.println("| Pressure[hPa] | Temperature[C] |");
error = Wire.endTransmission(); Serial.print("| ");
Serial.print(pressure, 2);
if (error == 0) Serial.print(" | ");
{ Serial.print(temperature, 2);
Serial.print("I2C device found at address 0x"); Serial.println(" |");
if (address<16) Serial.println("|----------------------------------|");
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");
} }

View File

@@ -5,9 +5,10 @@
#include <Adafruit_Sensor.h> #include <Adafruit_Sensor.h>
#include "ens210.h" #include "ens210.h"
#include "SparkFun_VEML6030_Ambient_Light_Sensor.h" #include "SparkFun_VEML6030_Ambient_Light_Sensor.h"
#include <LPS22HBSensor.h>
void busscan();
void measuretemp(); void measuretemp();
void measurepressure();
void lightsense(); void lightsense();
void powerupesp(); void powerupesp();
void wd_handler(); void wd_handler();

View File

@@ -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 | | VEML6035 | Light Sensor | Next to push button, used for wake-up | IC7 |
| ENS210 | Temperature + Humidity Sensor | - | IC3 | | ENS210 | Temperature + Humidity Sensor | - | IC3 |
| TPL5010 | Watchdog | needs to be fed | IC4 | | TPL5010 | Watchdog | needs to be fed | IC4 |
| Unspecified Pressure Sensor | Pressure Sensor | - | IC5 | | LPS22HB | Pressure Sensor | - | IC5 |
| Red LED | LED | - | LED1 | | Red LED | LED | - | LED1 |
| Green LED | LED | - | LED2 | | Green LED | LED | - | LED2 |
| Button | Push Button | Wakes the device power off | SW1 | | Button | Push Button | Wakes the device power off | SW1 |