Proyectos

Servidor UDP con Esp32 visualizando lo enviado en una pantalla led matricial.

Tutorial de conexión y de pantalla matricial seguido:

http://www.iotsharing.com/2017/05/how-to-use-arduino-esp32-to-display-spi-led-matrix.html

Pinout de referencia utilizado con mi esp32 Devkit v1.

Enlace placa desarrollo esp32 aliexpress:

https://es.aliexpress.com/item/32996463686.html?spm=a2g0s.9042311.0.0.274263c09lkXNx

Enlace aliexpress de la matriz de leds utilizada:

https://es.aliexpress.com/item/33027396703.html?spm=a2g0s.9042311.0.0.274263c0VwmlyG

Los 5V para la matriz de leds se consiguen conectando el pin Vin del ESP32.

[ESP32 GPIO14 – LED CLK]
[ESP32 GPIO12 – LED DIN (MOSI)]
[ESP32 GPIO15 – LED CS]
[ESP32 GND – LED GND]
[LED VCC – 5V]

Como en la pantalla sale un scroll de abajo a arriba, he cambiado en la librería descargada en el fichero LedMatrix.cpp todo el void LedMatrix::Commit(){…} por

void LedMatrix::commit() {
for (byte dev = 0; dev < myNumberOfDevices; dev++) {
byte m[8] = {0}; 
for (byte col = 0; col < 8; col++) {
byte b = cols[dev*8+col]; 
for (byte bit = 0; bit < 8; bit++) {
if (b & 1) m[bit] |= (128>>col); b >>= 1; 
} } 
for (byte col = 0; col < 8; col++) sendByte(dev, col + 1, m[col]); } }

Programa utilizado. Ojo con el poco amperaje que dan los conectores USB de los ordenadores que hacen que no arranque bien el cacharrito.

#include "WiFi.h"
#include "AsyncUDP.h"
#include <SPI.h>
#include "LedMatrix.h"
#define NUMBER_OF_DEVICES 4 //number of led matrix connect in series
#define CS_PIN 15
#define CLK_PIN 14
#define MISO_PIN 2 //we do not use this pin just fill to match constructor
#define MOSI_PIN 12

const char * ssid = "*********";
const char * password = "***********";

AsyncUDP udp;

LedMatrix ledMatrix = LedMatrix(NUMBER_OF_DEVICES, CLK_PIN, MISO_PIN, MOSI_PIN, CS_PIN);


void setup() {
ledMatrix.init();

Serial.begin(115200);
WiFi.mode(WIFI_STA);
WiFi.begin(ssid, password);
if (WiFi.waitForConnectResult() != WL_CONNECTED) {
Serial.println("WiFi Failed");
while(1) {
delay(1000);
}
}
if(udp.listen(1234)) {
Serial.print("UDP Listening on IP: ");
Serial.println(WiFi.localIP());

ledMatrix.setText(WiFi.localIP().toString().c_str());

}
}

void loop() {
ledMatrix.clear();
ledMatrix.scrollTextLeft();
ledMatrix.drawText();
ledMatrix.commit();
delay(50);

//Send broadcast
udp.onPacket([](AsyncUDPPacket packet) {
Serial.print("UDP Packet Type: ");
Serial.print(packet.isBroadcast()?"Broadcast":packet.isMulticast()?"Multicast":"Unicast");
Serial.print(", From: ");
Serial.print(packet.remoteIP());
Serial.print(":");
Serial.print(packet.remotePort());
Serial.print(", To: ");
Serial.print(packet.localIP());
Serial.print(":");
Serial.print(packet.localPort());
Serial.print(", Length: ");
Serial.print(packet.length());
Serial.print(", Data: ");
Serial.write(packet.data(), packet.length());
Serial.println();
//reply to the client
packet.printf("Got %u bytes of data", packet.length());
String myString = (const char*)packet.data()-1;
ledMatrix.setText(myString.substring(1,packet.length())); 
});
udp.broadcast("Anyone here?");

}

Para enviar paquetes udp usamos lo siguiente desde Linux:

echo "Texto a enviar" | ncat -u DIRECCIÓN_IP 1234

Para enviar paquetes udp usamos lo siguiente en Openwrt:

echo "Texto a enviar" | nc -uc DIRECCIÓN_IP 1234

Script que envía paquetes udp con nc (netcat) para Openwrt

#!/bin/sh
i=0
while [ $i -lt 500 ]
do
  i=$(($i+1))
  echo $i | nc -uc 192.168.24.199 1234
done

 

Enlace Opencv para elegir color con sliders

https://inneka.com/ml/opencv/color-detection-using-opencv-python/

Script para desautenticar a los clientes que no tengan un patrón de MAC

#!/bin/sh

MACS_PERMITIDAS="dc:ee:16 , 58:20:59"

bloquea()
{
  echo "Bloquea -- $mac --"
  iw wlan0 station del $mac subtype 0xA
}

comprueba()
{
  mac=$(echo $line  | awk '{ print $4 }')
  vendor=${mac:0:8}
  echo "Vendor=$vendor"
  echo $MACS_PERMITIDAS | grep -q -e $vendor
  [ "$?" -eq '0' ] || bloquea
}


iw event | while read line
 do
 echo $line | grep -q -e "new station"
   [ $? -ne '0' ] || comprueba
 done
exit

nlbwmon programa para monitorizar tráfico en Openwrt.

Proyecto 1: Decir “Bienvenido: XXXXX” donde XXXXX es un nombre y apellidos que está en un archivo de texto según el código de barras que se lea.

  • Instalar paquetes para que reconozca los usb.

TO-DO

  • Instalar paquete barcode para lector de codigo de barras y paquete para que lo reconozca.
opkg install kmod-usb-hid
opkg install barcode_2_brcm63xx.ipk
  • Instalar drivers tarjeta sonido Openwrt
opkg install kmod-usb-audio
  • Instalar evoice o svox para lectura de texto escrito.
#para generar voces
opkg install svox
#para reproducir sonido con aplay
opkg install alsa-utils
  • Crear script que busca y reproduce por tarjeta de sonido:

nano buscayreproduce.sh

! /bin/sh
while :
do
read codigo
while IFS=" " read id nombre apellido1 apellido2
do
if [ "$codigo" = "$id" ];
then
mensaje="Bienvenido, $nombre $apellido1 $apellido2"
 pico2wave -l=es-ES -w=test.wav "$mensaje" > /dev/null
 aplay test.wav > /dev/null
fi
done < ./alumnos.txt
done
  • Crear archivo de texto llamado alumnos.txt donde pondremos codigodebarras, nombre, apellido1,apellido2 separado por espacios:
nano alumnos.txt

84160829 Pedro Alvarez Diaz
4030152949717 Carlos Mendez Botin
8430848550030 Manuel Rios Tomate

  • Comando para dejar en background todo funcionando:
barcode /dev/input/event1 | ./busca.sh &

Ojo porque si has conectado los dos dispositivos verás /dev/input/event0 y /dev/input/event1

Como nosotros conectamos el lector de barras después de la tarjeta de sonido usamos event1.

Si tienes dudas  ejecuta lo siguiente y mira donde dice Name=

cat /proc/bus/input/devices

Verás todos los dispositivos de entrada junto con su evento correspondiente.

Poner al arrancar:

https://wiki.openwrt.org/doc/techref/initscripts

—–

Al pulsar un botón del router debe decir “Tienes X equipos encendidos”

Aparentemente el que resulta mejor es el svox.
Se uiliza con la siguiente orden de ejemplo:

pico2wave -l es-ES -w test.wav "Tienes 40 equipos encendidos"

En Linux Mint se instala:

sudo apt-get install libttspico-utils

Control de botones: Enlace

Escuchar .wav

opkg install alsa-utils
aplay -f S16_LE -D plughw:0,0 test.wav
 

BARCODE source

DESCARGAR FUENTE PARA DIFERENTES VERSIONES OPENWRT

18.06.1

git clone git://github.com/openwrt/openwrt.git -b v18.06.1

18.06.0

git clone git://github.com/openwrt/openwrt.git -b v18.06.0

17.01.6

git clone git://github.com/openwrt/openwrt.git -b v17.01.6

17.01.5

git clone git://github.com/openwrt/openwrt.git -b v17.01.5

17.01.4

git clone git://github.com/openwrt/openwrt.git -b v17.01.4

17.01.3

git clone git://github.com/openwrt/openwrt.git -b v17.01.3

17.01.2

git clone git://github.com/openwrt/openwrt.git -b v17.01.2

17.01.1

git clone git://github.com/openwrt/openwrt.git -b v17.01.1

17.01

git clone git://github.com/openwrt/openwrt.git -b v17.01.0

15.05.1

git clone git://github.com/openwrt/archive.git -b v15.05.1

15.05

git clone git://github.com/openwrt/archive.git -b v15.05

14.07

git clone git://github.com/openwrt/archive.git -b v14.07

12.09

git clone git://github.com/openwrt/archive.git -b v12.09

VLANS

Pr-vlan

Portal cautivo pfsense

Telefonía IP

Control de cámaras de seguridad

Autenticación Radius Openwrt. Radius Server Openwrt

OpenVPN Server en openwrt

Portal cautivo openwrt (NoDogSplash)

Multiwan Openwrt

https://www.mediafire.com/folder/4g34yskuoemru/HG556a_A_B_C

Cambio de clave WPA al pulsar un botón junto con gestión de ancho de banda para restaurantes.

Ratón + Detector de presencia

Otra manera de hacer hablar a nuestro router

http://audio1.spanishdict.com/audio?lang=es&text=Esto-es-un-test-para-hacer-hablar-a-nuestro-ruuter.

Comandos para oirlo:

ffmpeg -y -i "http://audio1.spanishdict.com/audio?lang=es&text=Esto-es-un-test-para-hacer-hablar-a-nuestro-ruuter" -codec:a libmp3lame output.mp3
mplayer output.mp3

Paspberry pi + Control de cámaras de seguridad

Radio con clics de ratón:

Mirar y sacar enlaces de radio de:

http://dir.xiph.org/yp.xml

http://www.listenlive.eu/spain.html

http://jonijnm.es/all/pags/radio/

Que el router nos diga qué equipos hay encendidos en la red enviándonos un informe por correo o diciéndolo a viva voz.

Arpwatch funcionando en openwrt chaos calmer (necesita compilar)

Grito Wilhelm – Wikipedia, la enciclopedia libre

Simple Voice Chat