kompost.ino
1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <Wire.h>
#include "PCF8591.h"
#include "pcf.h"
#include "wifi.h"
#include "sonar.h"
#include "mqtt.h"
#include "queue.h"
#include "device.h"
/* #include "control.h" */
/* #include "control.h" */
unsigned int counter = 0;
void setup(void) {
/* Serial.begin(115200); */
delay(100);
setup_wifi();
/* pinMode(LED_BUILTIN, OUTPUT); */
/* delay(5000); */
setup_pcf();
setup_sonar();
delay(100);
setup_mqtt();
/* setup_queue(); */
}
void loop(void) {
MDNS.update();
delay(500);
counter++;
/* sensors_event_t temp_event, pressure_event; */
/* bmp_temp->getEvent(&temp_event); */
/* bmp_pressure->getEvent(&pressure_event); */
loop_sonar(counter);
/* pcf8574.digitalWrite(0,counter % 2); */
/* float ana0V = pcf8591.voltageRead(AIN0); // Read voltage from analog 0 */
/* int ana = pcf8591.analogRead(AIN0); */
String moistureLevelStr(pcf8591.analogRead(0));
mqttClient.publish(PREAMBLE T_MOIST, moistureLevelStr );
String temp(bmp.readTemperature());
mqttClient.publish(PREAMBLE T_TEMP, temp );
String liquidLevelAvgStr(liquid_level_avg());
mqttClient.publish(PREAMBLE T_SDIST, liquidLevelAvgStr );
/* String temp(temp_event.temperature); */
/* loop_pcf(); */
loop_queue();
loop_device();
/* loop_control(counter); */
}