Compare commits
2 commits
fbd5edd62b
...
b3617f831a
Author | SHA1 | Date | |
---|---|---|---|
Sergio Pernas | b3617f831a | ||
Sergio Pernas | 0d80d649b3 |
|
@ -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);
|
||||
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
BIN
0x02-turbidez/turbidez conectores.jpeg
Normal file
BIN
0x02-turbidez/turbidez conectores.jpeg
Normal file
Binary file not shown.
After Width: | Height: | Size: 9 KiB |
|
@ -6,7 +6,7 @@ import sys
|
|||
|
||||
ser = serial.Serial(
|
||||
port='/dev/serial0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
|
||||
baudrate = 14400,
|
||||
baudrate = 9600,
|
||||
parity=serial.PARITY_NONE,
|
||||
stopbits=serial.STOPBITS_ONE,
|
||||
bytesize=serial.EIGHTBITS,
|
||||
|
@ -22,7 +22,7 @@ ser.flush()
|
|||
while True:
|
||||
if ser.in_waiting > 0:
|
||||
line = ser.readline().decode('utf-8', errors='replace').rstrip()
|
||||
time.sleep(0.5)
|
||||
#time.sleep(0.1)
|
||||
print(line)
|
||||
ser.flush()
|
||||
break
|
||||
|
|
|
@ -37,13 +37,14 @@ funcion_datos_simulados() {
|
|||
funcion_datos_sensores() {
|
||||
|
||||
peticiones=1
|
||||
arduinos=( 0x01 0x02 )
|
||||
arduinos=( 1 2 )
|
||||
for arduino_id in ${arduinos[@]};do
|
||||
lectura_arduino=($(timeout 3 $arduinos_py $arduino_id))
|
||||
|
||||
let "bloques = (${#lectura_arduino[@]} - 1) / 4"
|
||||
|
||||
lecturas="$lecturas id:${lectura_arduino[0]}"
|
||||
#lecturas="$lecturas id:${lectura_arduino[0]}"
|
||||
lecturas="$lecturas id:${arduino_id[0]}"
|
||||
|
||||
indice=1
|
||||
vueltas=1
|
||||
|
|
Loading…
Reference in a new issue