<commit_before>#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <DallasTemperature.h>
#include <FreqCount.h>
#include <OneWire.h>

#include "NMEASerial.h"

#define PIN_DRD11A_RAIN 4
#define PIN_DRD11A_INTENSITY A0
#define PIN_DRD11A_FREQ 5
#define PIN_ONEWIRE 12
// SCL A5
// SDA A4

static int rainFrequency = 0;
static bool hasRoomSensor = false;
static bool hasInternalSensor = false;
static Adafruit_BME280 bme;
static OneWire onewire(PIN_ONEWIRE);
static DallasTemperature dallasTemperature(&onewire);
static NMEASerial nmeaSerial(NULL);

void setup() {
    pinMode(PIN_DRD11A_RAIN, INPUT);
    pinMode(PIN_DRD11A_INTENSITY, INPUT);

    Serial.begin(57600);
    FreqCount.begin(1000);

    hasRoomSensor = bme.begin();
    dallasTemperature.begin();
    hasInternalSensor = (dallasTemperature.getDeviceCount() > 0);
}

void loop() {
    if (FreqCount.available()) {
        rainFrequency = FreqCount.read();
    }
    bool rain = (digitalRead(PIN_DRD11A_RAIN) == LOW);
    int rainIntensity = analogRead(PIN_DRD11A_INTENSITY);

    String msg = "RAIN=";
    msg += rain ? 1 : 0;
    msg += ",FREQ=";
    msg += rainFrequency;
    msg += ",INTENSITY=";
    msg += rainIntensity;

    if (hasInternalSensor) {
        dallasTemperature.requestTemperatures();
        float internalTemp = dallasTemperature.getTempCByIndex(0);
        msg += ",INTERNALTEMP=";
        msg += internalTemp;
    }
    if (hasRoomSensor) {
        float roomTemp = bme.readTemperature();
        float roomHumidity = bme.readHumidity();
        float roomPressure = bme.readPressure();
        msg += ",ROOMTEMP=";
        msg += roomTemp;
        msg += ",ROOMHUMIDITY=";
        msg += roomHumidity;
        msg += ",ROOMPRESSURE=";
        msg += roomPressure;
    }
    nmeaSerial.print(msg);

    delay(1000);
}
<commit_msg>Fix sensor naming, send reports only every 10s or immediately if the rain sensor is triggered<commit_after>#include <Adafruit_Sensor.h>
#include <Adafruit_BME280.h>
#include <DallasTemperature.h>
#include <FreqCount.h>
#include <OneWire.h>

#include "NMEASerial.h"

#define PIN_DRD11A_RAIN 4
#define PIN_DRD11A_INTENSITY A0
#define PIN_DRD11A_FREQ 5
#define PIN_ONEWIRE 12
// SCL A5
// SDA A4

static int rainFrequency = 0;
static bool hasInteriorSensor = false;
static bool hasEnclosureSensor = false;
static Adafruit_BME280 bme;
static OneWire onewire(PIN_ONEWIRE);
static DallasTemperature dallasTemperature(&onewire);
static NMEASerial nmeaSerial(NULL);

static bool lastRainState = false;
static unsigned long lastReportTime = 0;

void setup() {
    pinMode(PIN_DRD11A_RAIN, INPUT);
    pinMode(PIN_DRD11A_INTENSITY, INPUT);

    Serial.begin(57600);
    FreqCount.begin(1000);

    hasInteriorSensor = bme.begin();
    dallasTemperature.begin();
    hasEnclosureSensor = (dallasTemperature.getDeviceCount() > 0);
}

void loop() {
    if (FreqCount.available()) {
        rainFrequency = FreqCount.read();
    }
    bool rain = (digitalRead(PIN_DRD11A_RAIN) == LOW);
    int rainIntensity = analogRead(PIN_DRD11A_INTENSITY);

    String msg = "RAIN=";
    msg += rain ? 1 : 0;
    msg += ",FREQ=";
    msg += rainFrequency;
    msg += ",INTENSITY=";
    msg += rainIntensity;

    if (hasEnclosureSensor) {
        dallasTemperature.requestTemperatures();
        float enclosureTemp = dallasTemperature.getTempCByIndex(0);
        msg += ",ENCLOSURETEMP=";
        msg += enclosureTemp;
    }
    if (hasInteriorSensor) {
        float interiorTemp = bme.readTemperature();
        float interiorHumidity = bme.readHumidity();
        float interiorPressure = bme.readPressure();
        msg += ",INTERIORTEMP=";
        msg += interiorTemp;
        msg += ",INTERIORHUMIDITY=";
        msg += interiorHumidity;
        msg += ",INTERIORPRESSURE=";
        msg += interiorPressure;
    }

    unsigned long currentTime = millis();
    unsigned long timeSinceLastReport = currentTime - lastReportTime;
    if ((lastRainState == false && rain) || timeSinceLastReport > 10000) {
        lastReportTime = currentTime;
        nmeaSerial.print(msg);
    }
    lastRainState = rain;
}

{'fraction_non_alphanumeric': 0.11616038882138517, 'fraction_numerical': 0.02284325637910085, 'mean_word_length': 3.563192904656319, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1667006', 'n_tokens_mistral': 1496, 'n_tokens_neox': 1396, 'n_words': 300}