From a0fe052f90721793d3500448ca6a3f58003c1760 Mon Sep 17 00:00:00 2001 From: Daniel Tartavel Date: Sat, 14 Mar 2020 22:31:24 +0100 Subject: [PATCH] good --- multidetecteur.ino | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/multidetecteur.ino b/multidetecteur.ino index e74a167..ac099ea 100644 --- a/multidetecteur.ino +++ b/multidetecteur.ino @@ -1,7 +1,8 @@ #include #include +#include -#define DHTPIN 10 +#define DHTPIN 6 #define DHTTYPE DHT22 #define LOG_PERIOD 60000 // cetak tiap detik @@ -43,6 +44,17 @@ unsigned long counts; //variable for GM Tube events unsigned long previousMillis;//variable for time measurement String texts[6]= {"UV int:", "Temp", "Humid", "Bq/mn", "Part/s", "Battery"}; float values[6]; +float tab[6][60]; +float total[6]; +unsigned int index = 1; + +float lisse( int capteur, float valeur) +{ + total[capteur] = total[capteur]-tab[capteur][index]+valeur; + tab[capteur][index] = valeur; + return total[capteur] / 60; +} + void impulse() { // dipanggil setiap ada sinyal FALLING di pin 2 counts++; } @@ -54,7 +66,6 @@ void setup() pinMode(BSELECT, INPUT_PULLUP); pinMode(BUP, INPUT_PULLUP); pinMode(BDOWN, INPUT_PULLUP); - pinMode(TEMP_HUMID, INPUT); attachInterrupt(digitalPinToInterrupt(3), impulse, FALLING); //define external interrupts Serial.println("Start counter"); @@ -72,6 +83,7 @@ void setup() void loop() { + bouton = test_bouton(); //retourne la valeur entre Serial.print( "position afficheur =>" ); Serial.print( posaffich ); @@ -85,7 +97,11 @@ void loop() values[PARTICULES] = particules(); values[BATTERY] = battery(); affich(); - delay(200); + index++; + if (index > 60) + { + index=1; + } } void affich() @@ -193,11 +209,7 @@ byte test_bouton() float temp() { - uint32_t start = micros(); float t = dht.readTemperature(); - uint32_t stop = micros(); - - stat.total++; if (isnan(t)) { Serial.println("Failed to read temperature from DHT"); return -199; @@ -208,11 +220,8 @@ float temp() float humid() { - uint32_t start = micros(); float h = dht.readHumidity(); - uint32_t stop = micros(); - stat.total++; if (isnan(h)) { Serial.println("Failed to read humidity from DHT"); return -1; @@ -245,5 +254,9 @@ float battery() { //here the code for acquiring battery //affich(BATTERY, text, value); + unsigned int sondeBat = analogRead(A2); + float b = (sondeBat * (( 3.7 / 1024 )) / 0.6); + Serial.print("Batterie:"); + Serial.println(b); }