Liebe Community,
ich hoffe, jemand kann mir mit diesem Problem weiter helfen. Das GPS zeigt auf dem Display stets 0 an. Die ist der Sketch dazu (in Blockly erstellt und in ARDUINO 1.8.18 übertragen - bei Blockly klappte es auch nicht):
#include <senseBoxIO.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <SparkFun_u-blox_GNSS_Arduino_Library.h>
#include <Adafruit_HDC1000.h>
#include <LTR329.h>
#include <VEML6070.h>
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
SFE_UBLOX_GNSS myGNSS;
Adafruit_HDC1000 hdc = Adafruit_HDC1000();
bool lightsensortype = 0; //0 for tsl - 1 for ltr
//settings for LTR sensor
LTR329 LTR;
unsigned char gain = 1;
unsigned char integrationTime = 0;
unsigned char measurementRate = 3;
VEML6070 veml;
int read_reg(byte address, uint8_t reg)
{
int i = 0;
Wire.beginTransmission(address);
Wire.write(reg);
Wire.endTransmission();
Wire.requestFrom((uint8_t)address, (uint8_t)1);
delay(1);
if(Wire.available())
i = Wire.read();
return i;
}
void write_reg(byte address, uint8_t reg, uint8_t val)
{
Wire.beginTransmission(address);
Wire.write(reg);
Wire.write(val);
Wire.endTransmission();
}
void Lightsensor_begin()
{
Wire.begin();
unsigned int u = 0;
u = read_reg(0x29, 0x80 | 0x0A); //id register
if ((u & 0xF0) == 0xA0) // TSL45315
{
write_reg(0x29, 0x80 | 0x00, 0x03); //control: power on
write_reg(0x29, 0x80 | 0x01, 0x02); //config: M=4 T=100ms
delay(120);
lightsensortype = 0; //TSL45315
}
else
{
LTR.begin();
LTR.setControl(gain, false, false);
LTR.setMeasurementRate(integrationTime, measurementRate);
LTR.setPowerUp(); //power on with default settings
delay(10); //Wait 10 ms (max) - wakeup time from standby
lightsensortype = 1; //
}
}
uint32_t Lightsensor_getIlluminance()
{
unsigned int lux = 0;
if (lightsensortype == 0) // TSL45315
{
unsigned int u = (read_reg(0x29, 0x80 | 0x04) << 0); //data low
u |= (read_reg(0x29, 0x80 | 0x05) << 8); //data high
lux = u * 4; // calc lux with M=4 and T=100ms
}
else if (lightsensortype == 1) //LTR-329ALS-01
{
delay(100);
unsigned int data0, data1;
for (int i = 0; i < 5; i++) {
if (LTR.getData(data0, data1)) {
if(LTR.getLux(gain, integrationTime, data0, data1, lux));
if(lux > 0) break;
else delay(10);
}
else {
byte error = LTR.getError();
}
}
}
return lux;
}
float getSMT50Moisture(int analogPin){
int sensorValue = analogRead(analogPin);
float voltage = sensorValue * (3.3 / 1024.0);
return (voltage * 50) / 3;
}
void setup() {
senseBoxIO.powerI2C(true);
delay(2000);
display.begin(SSD1306_SWITCHCAPVCC, 0x3D);
display.display();
delay(100);
display.clearDisplay();
Wire.begin();
if (myGNSS.begin() == false) //Connect to the Ublox module using Wire port
{
Serial.println(F("Ublox GPS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
myGNSS.saveConfiguration(); //Save the current settings to flash and BBR
hdc.begin();
Lightsensor_begin();
veml.begin();
}
void loop() {
display.setCursor(0,0);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("Breite") + String(myGNSS.getLatitude())));
display.setCursor(0,9);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("Laenge") + String(myGNSS.getLongitude())));
display.setCursor(60,9);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("H(m)") + String(myGNSS.getAltitudeMSL())));
display.setCursor(0,18);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("T(C:)") + String(hdc.readTemperature())));
display.setCursor(0,27);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("rF(%):") + String(hdc.readHumidity())));
display.setCursor(0,36);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("Lux:") + String(Lightsensor_getIlluminance())));
display.setCursor(0,45);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("UV:") + String(veml.getUV())));
display.setCursor(60,45);
display.setTextSize(1);
display.setTextColor(WHITE,BLACK);
display.println((String("BrF(%)") + String(getSMT50Moisture(6))));
display.display();
display.clearDisplay();
}
Die Höhenangabe liefert nur Quatsch -17000. Die anderen Sensoren verrichten ihre Arbeit.
Die RTC funktioniert ebenso nicht - stellt sich nach dem Trennen der Energieversorgung des Boards immer wieder zurück auf ein Datum in 2023. Die RTC habe ich jetzt aber mal rausgelassen.
Viele Grüße
Jens