good
This commit is contained in:
parent
20932a535c
commit
a0fe052f90
@ -1,7 +1,8 @@
|
|||||||
#include <LiquidCrystal_I2C.h>
|
#include <LiquidCrystal_I2C.h>
|
||||||
#include <DHT.h>
|
#include <DHT.h>
|
||||||
|
#include <uRTCLib.h>
|
||||||
|
|
||||||
#define DHTPIN 10
|
#define DHTPIN 6
|
||||||
#define DHTTYPE DHT22
|
#define DHTTYPE DHT22
|
||||||
#define LOG_PERIOD 60000 // cetak tiap detik
|
#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
|
unsigned long previousMillis;//variable for time measurement
|
||||||
String texts[6]= {"UV int:", "Temp", "Humid", "Bq/mn", "Part/s", "Battery"};
|
String texts[6]= {"UV int:", "Temp", "Humid", "Bq/mn", "Part/s", "Battery"};
|
||||||
float values[6];
|
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
|
void impulse() { // dipanggil setiap ada sinyal FALLING di pin 2
|
||||||
counts++;
|
counts++;
|
||||||
}
|
}
|
||||||
@ -54,7 +66,6 @@ void setup()
|
|||||||
pinMode(BSELECT, INPUT_PULLUP);
|
pinMode(BSELECT, INPUT_PULLUP);
|
||||||
pinMode(BUP, INPUT_PULLUP);
|
pinMode(BUP, INPUT_PULLUP);
|
||||||
pinMode(BDOWN, INPUT_PULLUP);
|
pinMode(BDOWN, INPUT_PULLUP);
|
||||||
pinMode(TEMP_HUMID, INPUT);
|
|
||||||
|
|
||||||
attachInterrupt(digitalPinToInterrupt(3), impulse, FALLING); //define external interrupts
|
attachInterrupt(digitalPinToInterrupt(3), impulse, FALLING); //define external interrupts
|
||||||
Serial.println("Start counter");
|
Serial.println("Start counter");
|
||||||
@ -72,6 +83,7 @@ void setup()
|
|||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
|
||||||
bouton = test_bouton(); //retourne la valeur entre
|
bouton = test_bouton(); //retourne la valeur entre
|
||||||
Serial.print( "position afficheur =>" );
|
Serial.print( "position afficheur =>" );
|
||||||
Serial.print( posaffich );
|
Serial.print( posaffich );
|
||||||
@ -85,7 +97,11 @@ void loop()
|
|||||||
values[PARTICULES] = particules();
|
values[PARTICULES] = particules();
|
||||||
values[BATTERY] = battery();
|
values[BATTERY] = battery();
|
||||||
affich();
|
affich();
|
||||||
delay(200);
|
index++;
|
||||||
|
if (index > 60)
|
||||||
|
{
|
||||||
|
index=1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void affich()
|
void affich()
|
||||||
@ -193,11 +209,7 @@ byte test_bouton()
|
|||||||
|
|
||||||
float temp()
|
float temp()
|
||||||
{
|
{
|
||||||
uint32_t start = micros();
|
|
||||||
float t = dht.readTemperature();
|
float t = dht.readTemperature();
|
||||||
uint32_t stop = micros();
|
|
||||||
|
|
||||||
stat.total++;
|
|
||||||
if (isnan(t)) {
|
if (isnan(t)) {
|
||||||
Serial.println("Failed to read temperature from DHT");
|
Serial.println("Failed to read temperature from DHT");
|
||||||
return -199;
|
return -199;
|
||||||
@ -208,11 +220,8 @@ float temp()
|
|||||||
|
|
||||||
float humid()
|
float humid()
|
||||||
{
|
{
|
||||||
uint32_t start = micros();
|
|
||||||
float h = dht.readHumidity();
|
float h = dht.readHumidity();
|
||||||
uint32_t stop = micros();
|
|
||||||
|
|
||||||
stat.total++;
|
|
||||||
if (isnan(h)) {
|
if (isnan(h)) {
|
||||||
Serial.println("Failed to read humidity from DHT");
|
Serial.println("Failed to read humidity from DHT");
|
||||||
return -1;
|
return -1;
|
||||||
@ -245,5 +254,9 @@ float battery()
|
|||||||
{
|
{
|
||||||
//here the code for acquiring battery
|
//here the code for acquiring battery
|
||||||
//affich(BATTERY, text, value);
|
//affich(BATTERY, text, value);
|
||||||
|
unsigned int sondeBat = analogRead(A2);
|
||||||
|
float b = (sondeBat * (( 3.7 / 1024 )) / 0.6);
|
||||||
|
Serial.print("Batterie:");
|
||||||
|
Serial.println(b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user