File tree Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Expand file tree Collapse file tree 1 file changed +77
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* ==================================
2
+
3
+ CLEAN BOX SOURCE CODE
4
+
5
+ Codigo fonte de afericao dos sensores de PH e TURBIDEZ
6
+
7
+ AUTOR: NEWTON R. DOS SANTOS
8
+ DATA: 28 de julho de 2019
9
+
10
+ */
11
+
12
+ // FUNCOES
13
+
14
+ double calcNTU (double volt_TURB);
15
+ double calcPH (double volt_PH);
16
+
17
+ // PORTAS Analogicas
18
+ int pin_PH = A2;
19
+ int pin_TURB = A0;
20
+
21
+
22
+ // variaveis globais
23
+ double NTU = 0.0 ;
24
+ double PH = 0.0 ;
25
+
26
+ // configuracoes iniciais
27
+
28
+ void setup (){
29
+ Serial.begin (115200 );
30
+ }
31
+
32
+ // LOOP
33
+
34
+ void loop (){
35
+
36
+ // faz a leitura das portas analogicas A0 e A2
37
+ int turbidSensor = analogRead (pin_TURB);
38
+ int phSensor = analogRead (pin_PH);
39
+
40
+ // converte em volts
41
+ double volt_TURB = turbidSensor * (5.0 / 1024.0 );
42
+ double volt_PH = phSensor * (5.0 / 1024.0 );
43
+
44
+
45
+ // calcula NTU e PH
46
+ NTU = calcNTU (volt_TURB);
47
+ PH = calcPH (volt_PH);
48
+
49
+
50
+ // envia os dados para a porta Serial
51
+ Serial.print (NTU);
52
+ Serial.print (" | " );
53
+ Serial.println (PH);
54
+
55
+ // pausa de 2 SEG para a prox leitura
56
+ delay (2000 );
57
+
58
+ }
59
+
60
+
61
+ // Funcoes
62
+
63
+ // calcula NTU
64
+ double calcNTU (double volt_TURB){
65
+
66
+ double NTU = -(1120.4 *volt_TURB*volt_TURB)+(5742.3 *volt_TURB)-4352.9 ;
67
+
68
+ return NTU;
69
+ }
70
+
71
+ // calcula PH
72
+ double calcPH (double volt_PH){
73
+
74
+ double PH = 7 + ((2.5 - volt_PH) / 0.18 );
75
+
76
+ return PH;
77
+ }
You can’t perform that action at this time.
0 commit comments