From b3617f831a0d455b6a7799a4a61769c3bed2b25d Mon Sep 17 00:00:00 2001
From: Sergio Pernas <sergio.pernas@rndcoop.com>
Date: Tue, 5 Apr 2022 18:42:54 -0300
Subject: [PATCH] turbidez

---
 0x01-temperatura/0x01-temperatura.ino  |  18 +++-----
 0x02-turbidez/0x02-turbidez.ino        |  58 +++++++++++++++++--------
 0x02-turbidez/turbidez conectores.jpeg | Bin 0 -> 9197 bytes
 3 files changed, 44 insertions(+), 32 deletions(-)
 create mode 100644 0x02-turbidez/turbidez conectores.jpeg

diff --git a/0x01-temperatura/0x01-temperatura.ino b/0x01-temperatura/0x01-temperatura.ino
index 4729f4e..3e76957 100644
--- a/0x01-temperatura/0x01-temperatura.ino
+++ b/0x01-temperatura/0x01-temperatura.ino
@@ -42,22 +42,16 @@ void loop() {
 
   if ( Serial.available() > 0) {
     inQuery = Serial.read();
-    if ( inQuery = devID) {
-
-
-
-
-
-
+    if ( inQuery == devID) {
 
       Serial.write(itoa(devID, devIDstr, 10));
       Serial.write(" ");
       Serial.write("T");
-      //Serial.write(" ");
+      Serial.write(" ");
 
-      float lectura = getData();
-      char lecturaStr[8]; // Buffer big enough for 7-character float
-      dtostrf(lectura, 6, 2, lecturaStr); // Leave room for too large numbers!
+      
+      char lecturaStr[6]; // Buffer big enough for 7-character float
+      dtostrf(getData(), 2, 4, lecturaStr); // Leave room for too large numbers!
 
 
       Serial.write(lecturaStr);
@@ -71,6 +65,4 @@ void loop() {
 
   }
 
-  delay(1500);
-
 }
diff --git a/0x02-turbidez/0x02-turbidez.ino b/0x02-turbidez/0x02-turbidez.ino
index 5ce20dc..64f3408 100644
--- a/0x02-turbidez/0x02-turbidez.ino
+++ b/0x02-turbidez/0x02-turbidez.ino
@@ -1,30 +1,50 @@
-int inData;
-const char* valueSensor;
+
+// Dispositivo
+const int devID = 2;
+char devIDstr[5];
+int inQuery;
+
+
+
+
+double getData() {
+  int sensorValue = analogRead(A2);
+  return (sensorValue * (5.0 / 1024.0));
+}
+
 
 void setup() {
   Serial.begin(9600);
 }
+void loop() {
 
 
- void loop() {
-
   if ( Serial.available() > 0) {
-    inData = Serial.read();
+    inQuery = Serial.read();
+
+
+
+
+
+    if ( inQuery == devID) {
+
+      Serial.write(itoa(devID, devIDstr, 10));
+      Serial.write(" ");
+      Serial.write("Tur");
+      Serial.write(" ");
+
+
+      char lecturaStr[6]; // Buffer big enough for 7-character float
+      dtostrf(getData(), 2, 4, lecturaStr); // Leave room for too large numbers!
+
+      Serial.write(lecturaStr);
+      Serial.write(" ");
+      Serial.write("TSS");
+      Serial.write(" ");
+      Serial.write("99");
+
 
-    switch (inData) {
-      case 2:
-        Serial.print(2);
-        Serial.print(" ");
-        Serial.print("hum");
-        Serial.print(" ");
-        Serial.print("78");
-        Serial.print(" ");
-        Serial.print("P");
-        Serial.print(" ");
-        Serial.print("99");
-        Serial.print(" ");
-         
-        break;
     }
   }
+
 }
diff --git a/0x02-turbidez/turbidez conectores.jpeg b/0x02-turbidez/turbidez conectores.jpeg
new file mode 100644
index 0000000000000000000000000000000000000000..1865c2eb16afc8d01bfd0ea3deda84850cd6e68d
GIT binary patch
