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 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

View File

@@ -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("|----------------------------------|");
}

View File

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