Compare commits

...

17 commits

Author SHA1 Message Date
Sergio Pernas d015af3cd6 update 2022-09-06 15:01:02 -03:00
Sergio Pernas 637e744386 update 2022-09-06 14:53:06 -03:00
Sergio Pernas 079b6152ce update 2022-09-06 14:30:57 -03:00
Sergio Pernas ff1797c66c update 2022-09-06 13:54:28 -03:00
Sergio Pernas cc0ff602eb update 2022-09-06 13:50:50 -03:00
Sergio Pernas ce2e217e72 update 2022-09-06 13:04:41 -03:00
Sergio Pernas d7ee7c5447 update 2022-08-23 22:50:52 -03:00
Sergio Pernas ed27e9a67e update 2022-08-23 18:46:07 -03:00
Sergio Pernas 2e11006105 update 2022-08-23 18:43:16 -03:00
Sergio Pernas 54f2de544c update 2022-08-23 14:31:06 -03:00
Sergio Pernas 71e00f81aa update 2022-08-23 14:29:28 -03:00
Sergio Pernas 0843aea109 update 2022-08-23 14:25:59 -03:00
Sergio Pernas 68314e4c82 debug 2022-08-23 13:28:29 -03:00
Sergio Pernas f4d9bb50a0 debug 2022-08-23 13:24:46 -03:00
Sergio Pernas ffb7126f21 debug 2022-08-23 13:18:48 -03:00
Sergio Pernas abf9d7ee0d debug 2022-08-23 13:15:53 -03:00
Sergio Pernas 8c3c46056f update 2022-05-23 09:39:48 -03:00
18 changed files with 515 additions and 2 deletions

View file

@ -64,5 +64,5 @@ void loop() {
}
}
delay(100);
}

View file

@ -0,0 +1,31 @@
// Dispositivo
int devID = 3;
char devIDstr[5];
int inQuery;
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.write("\n");
delay(1000);
if ( Serial.available() > 0) {
if ( inQuery == devID) {
Serial.write(itoa(devID, devIDstr, 10));
Serial.write(" ");
Serial.write("Tur");
}
}
}

View file

@ -0,0 +1,16 @@
int inQuery;
void setup() {
Serial.begin(9600);
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
Serial.print("Decimal: ");
Serial.println(inQuery);
Serial.print("Hexadecimal: ");
Serial.println(inQuery, HEX);
}
}

View file

@ -0,0 +1,25 @@
// Dispositivo
const int devID = 1;
int inQuery;
void setup() {
Serial.begin(9600);
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
if ( inQuery == devID) {
Serial.write("1");
delay(100);
}
}
}

View file

@ -0,0 +1 @@

View file

@ -0,0 +1,25 @@
// Dispositivo
const int devID = 2;
int inQuery;
void setup() {
Serial.begin(9600);
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
if ( inQuery == devID) {
Serial.write("2");
}
}
}

View file

@ -0,0 +1 @@

167
Debug/README.md Normal file
View file

@ -0,0 +1,167 @@
## Prueba 1
### 1. Protoboard
Montar componentes según la imagen.
**IMPORTANTE:** El pin `Tx` del Arduino no está conectado al diodo.
![protoboard](proto_01.png)
El protoboard se confecciono según el circuito impreso.
![](placa_impresa.png)
### 2. Firmware
Cargar el fichero `0x00_debug/0x00_debug.ino` en el Arduino 0x01.
Fichero `0x00_debug.ino`.
```
int inQuery;
void setup() {
Serial.begin(9600);
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
Serial.print("Decimal: ");
Serial.println(inQuery);
Serial.print("Hexadecimal: ");
Serial.println(inQuery, HEX);
}
}
```
### 4. Raspbian
**Paso 1.**
Hacer una instalación fresca del sistema operativo (version lite).
**Paso 2.**
Configurar SO.
```
$ sudo raspi-config
```
Seguir el siguiente patrón de opciones:
3 Interface Options > I6 Serial Port > Would you like a login shell to be accessible over serial? \<No\> > Would you like the serial port hardware to be enabled? \<Yes\>. > Seleccionar \<Ok\> > Seleccionar \<Finish\> > Would you like to reboot now? \<Yes\>.
**Paso 3.**
Instalar 'pyserial'.
```
$ sudo apt update && sudo apt upgrade
$ sudo apt install python3-pip
$ sudo pip3 install pyserial
```
**Paso 4.**
Clonar repositorio en la raspberry.
```
$ git clone https://gitea.nulo.in/Nodemecu/nodemecu.git
```
Entrar al directorio de trabajo.
```
$ cd nodemecu
```
Cambiar a rama testing.
```
$ git checkout testing
```
Verificar.
```
$ git branch
master
placa
* testing
```
Entrar al directorio `Debug`.
```
$ cd Debug
```
**Paso 5.**
En la computadora, desde el Arduino IDE, abrir el monitor serial.
**NOTA:** El Arduino debe estar conectado tanto a la raspberry como a la pc por USB según el esquema del protoboard al inicio.
En la raspberry ejecutar `arduinos.py` para enviar caracteres por serial (interrumpir el comando con ctrl-c).
```
$ sudo python arduinos.py 1
```
En el monitor Arduino debería imprimirse lo siguiente.
![](monitor_01.png)
Probar con otros numeros
## Prueba 2
**Paso 1**
Actualizar repositorio en la raspberry, corroborar que se este trabajando en la rama `testing` (ver pasos anteriores).
```
$ git pull
```
**Paso 2.**
Apagar la Raspberry y retirar los Arduinos del protoboard y cargar a cada uno el fichero `.ino` correspondiente:
- Fichero `0x01_debug.ino` -> Arduino `0x01`.
- Fichero `0x02_debug.ino` -> Arduino `0x02`.
Volver a montar en protoboard.
**Paso 3**
El montaje debe quedar de la siguiente forma:
![](proto_02.png)
**Paso 4.**
En la Raspberry ejecutar en terminal.
```
$ sudo python arduinos.py 1
1
$ sudo python arduinos.py 2
2
```
Al pasar los argumentos `1` y `2` el comando debe devolver solo el número pasado, no acepta otros números.

30
Debug/arduinos.py Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env python
import time
import serial
import sys
ser = serial.Serial(
port='/dev/serial0', #Replace ttyS0 with ttyAM0 for Pi1,Pi2,Pi0
baudrate = 9600,
parity=serial.PARITY_NONE,
stopbits=serial.STOPBITS_ONE,
bytesize=serial.EIGHTBITS,
timeout=1
)
ser.flush()
cw = int(sys.argv[1], 0)
com = [cw]
ser.write(serial.to_bytes(com))
ser.flush()
while True:
if ser.in_waiting > 0:
line = ser.readline().decode('utf-8', errors='replace').rstrip()
#time.sleep(0.1)
print(line)
ser.flush()
break
quit()

BIN
Debug/monitor_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
Debug/placa_impresa.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
Debug/placa_mod_1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 MiB

BIN
Debug/proto.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

BIN
Debug/proto_01.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 310 KiB

BIN
Debug/proto_02.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 296 KiB

View file

@ -63,7 +63,7 @@ Una vez que finaliza la grabación extraer la tarjeta MicroSD y colocarla en la
Abra una terminal e instale 'git'.
```
$ sudo apt update && apt install git
$ sudo apt update && sudo apt install git
```
**Paso 2**

View file

@ -0,0 +1,104 @@
#include <OneWire.h>
#include <DallasTemperature.h>
#define address 99 //default I2C ID number for EZO pH Circuit.
// SENSOR TEMPERATURA
// Pin donde se conecta el bus 1-Wire
const int pinDatosDQ = 2;
// Instancia a las clases OneWire y DallasTemperature
OneWire oneWireObjeto(pinDatosDQ);
DallasTemperature sensorDS18B20(&oneWireObjeto);
// Funcion que llama al sensor de temperatura
float getDataTemp() {
sensorDS18B20.requestTemperatures();
return (sensorDS18B20.getTempCByIndex(0));
}
// SENSOR TURBIDEZ
// Funcion que llama al sensor de turbidez
int getDataTur() {
int sensorValue = analogRead(A7);
return (map(sensorValue, 0, 700, 100, 0));
}
//
char devIDstr[5];
int inQuery;
void setup() {
Serial.begin(9600);
// Sensor temperatura
sensorDS18B20.begin();
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
switch (inQuery) {
case 1:
Serial.write("1");
Serial.write(" ");
Serial.write("T");
Serial.write(" ");
Serial.write("00");
Serial.write(" ");
Serial.write("C");
Serial.write(" ");
Serial.write("99");
break;
case 2:
Serial.write("2");
Serial.write(" ");
Serial.write("Tur");
Serial.write(" ");
Serial.write("123");
Serial.write(" ");
Serial.write("TSS");
Serial.write(" ");
Serial.write("99");
break;
case 3:
Serial.write("3");
Serial.write(" ");
Serial.write("Con");
Serial.write(" ");
Serial.write("97");
Serial.write(" ");
Serial.write("Con");
Serial.write(" ");
Serial.write("99");
break;
case 4:
Serial.write("4");
Serial.write(" ");
Serial.write("Ph");
Serial.write(" ");
Serial.write("98");
Serial.write(" ");
Serial.write("Ph");
Serial.write(" ");
Serial.write("99");
break;
default:
;
}
}
delay(100);
}

View file

@ -0,0 +1,113 @@
#include <OneWire.h>
#include <DallasTemperature.h>
#define address 99 //default I2C ID number for EZO pH Circuit.
// SENSOR TEMPERATURA
// Pin donde se conecta el bus 1-Wire
const int pinDatosDQ = 2;
// Instancia a las clases OneWire y DallasTemperature
OneWire oneWireObjeto(pinDatosDQ);
DallasTemperature sensorDS18B20(&oneWireObjeto);
// Funcion que llama al sensor de temperatura
float getDataTemp() {
sensorDS18B20.requestTemperatures();
return (sensorDS18B20.getTempCByIndex(0));
}
// SENSOR TURBIDEZ
// Funcion que llama al sensor de turbidez
int getDataTur() {
int sensorValue = analogRead(A7);
return (map(sensorValue, 0, 700, 100, 0));
}
//
char devIDstr[5];
int inQuery;
void setup() {
Serial.begin(9600);
// Sensor temperatura
sensorDS18B20.begin();
}
void loop() {
if ( Serial.available() > 0) {
inQuery = Serial.read();
switch (inQuery) {
case 1:
Serial.write("1");
Serial.write(" ");
Serial.write("T");
Serial.write(" ");
char lecturaStrTemp[6]; // Buffer big enough for 7-character float
dtostrf(getDataTemp(), 2, 4, lecturaStrTemp); // Leave room for too large numbers!
Serial.write(lecturaStrTemp);
Serial.write(" ");
Serial.write("C");
Serial.write(" ");
Serial.write("99");
break;
case 2:
Serial.write("2");
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!
char lecturaStrTur[5]; // Buffer big enough for 7-character float
dtostrf(getDataTur(), 3, 2, lecturaStrTur); // Leave room for too large numbers!
Serial.write(lecturaStrTur);
Serial.write(" ");
Serial.write("TSS");
Serial.write(" ");
Serial.write("99");
break;
case 3:
Serial.write("3");
Serial.write(" ");
Serial.write("Con");
Serial.write(" ");
Serial.write("97");
Serial.write(" ");
Serial.write("Con");
Serial.write(" ");
Serial.write("99");
break;
case 4:
Serial.write("4");
Serial.write(" ");
Serial.write("Ph");
Serial.write(" ");
Serial.write("98");
Serial.write(" ");
Serial.write("Ph");
Serial.write(" ");
Serial.write("99");
break;
default:
;
}
}
delay(100);
}