Martin-Ger esp_wifi_repeater
Hoy voy a Cacharrear con un chip que me encanta: el Esp8266
esta vez voy a cargarle el firmware esp_wifi_repeater (de martin-ger)
Este firmware me permitira convertir el chip en un repetidor wifi de bajo coste (unos 5€) aunque con funciones avanzadas.
QOS ACL NAT Mqtt Mesh y muchas funciones que nos permitira entender y probar muchos comandos de gestion de redes.
Pagina Oficial del firmware: https://github.com/martin-ger/esp_wifi_repeater
1) Instalo utilidad esptool . (necesitaras pyton)
pip install esptool
2) Conecto la placa y averigo a que puerto se ha enganchado el hardware.
dmesg |tail
Deveria ver algo asi:
[ 1958.846149] usb 1-5: new full-speed USB device number 10 using xhci_hcd
[ 1958.994975] usb 1-5: New USB device found, idVendor=1a86, idProduct=7523
[ 1958.994978] usb 1-5: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[ 1958.994980] usb 1-5: Product: USB2.0-Serial
[ 1958.995521] ch341 1-5:1.0: ch341-uart converter detected
[ 1958.995895] usb 1-5: ch341-uart converter now attached to ttyUSB0
Pero con el tiempo ves que la informacion proporcionada es ideal para depurar y bhacer busquedas.
en este caso veo que se ha detectado un nuevo dispositivo usb.
que es tipo
USB2.0-Serial
.el circuito es el
ch341-uart
(esto es mas para los electronicos de la vieja escuela)y lo mas importante que el dispositivo de ha enganchado a
ttyUSB0
Esto es lo que necesito saber para el siguiente comando.
3) Informacion del chip.
esptool.py --port /dev/ttyUSB0 flash_id
Deberia salir algo parecido a esto.
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
MAC: dc:4f:22:f2:25:91
Uploading stub...
Running stub...
Stub running...
Manufacturer: 51
Device: 4014
Detected flash size: 1MB
Hard resetting via RTS pin...
Nota: es posible que te encuentres este error.
could not open port /dev/ttyUSB0: [Errno 13] Permission denied
para solventarlo puedes subir a administrador (sudo esptool.py --port /dev/ttyUSB0 read_flash_status
)
o corregirlo siguiendo este articulo: https://websistent.com/fix-serial-port-permission-denied-errors-linux/
4) descargar martin-ger esp_wifi_repeater
wget https://github.com/martin-ger/esp_wifi_repeater/raw/master/firmware/0x00000.bin
wget https://github.com/martin-ger/esp_wifi_repeater/raw/master/firmware/0x02000.bin
wget https://github.com/martin-ger/esp_wifi_repeater/raw/master/firmware/0x82000.bin
Nota: si el comando falla ir a la pagina del autor y descargar manualmente.
https://github.com/martin-ger/esp_wifi_repeater/tree/master/firmware
5) Bien es hora de Flasear el chip.
Si el chip es un esp8266
esptool.py --port /dev/ttyUSB0 write_flash -fs 4MB -ff 80m -fm dio 0x00000 firmware/0x00000.bin 0x02000 firmware/0x02000.bin
Si el chip es un esp8285
esptool.py --port /dev/ttyUSB0 write_flash -fs 1MB -fm dout 0x00000 0x00000.bin 0x02000 0x02000.bin
En mi caso saldria algo asi:(recuerda yo he usado el esp8285 /hay que añadir fm dout)
em50l@jejo:~$ esptool.py --chip auto --port /dev/ttyUSB0 write_flash -fs detect -fm dout 0x00000 0x00000.bin 0x02000 0x02000.bin
esptool.py v2.6
Serial port /dev/ttyUSB0
Connecting....
Detecting chip type... ESP8266
Chip is ESP8285
Features: WiFi, Embedded Flash
MAC: dc:4f:22:f2:25:91
Uploading stub...
Running stub...
Stub running...
Configuring flash size...
Auto-detected Flash size: 1MB
Flash params set to 0x0320
Compressed 1968 bytes to 1410...
Wrote 1968 bytes (1410 compressed) at 0x00000000 in 0.1 seconds (effective 118.0 kbit/s)...
Hash of data verified.
Compressed 385840 bytes to 263587...
Wrote 385840 bytes (263587 compressed) at 0x00002000 in 23.4 seconds (effective 132.0 kbit/s)...
Hash of data verified.
Leaving...
Hard resetting via RTS pin...
em50l@jejo:~$
6) conectandonos al Dispositivo
screen /dev/ttyUSB0 115200
Nota: Para salir Ctrl+a
y luego AltGr+\
y
Nota: Para ver informacion Serie Ctrl+a
y luego i
Nota: Tambien puedes usar minicom o putty
Deberiamos ver algo asi:
WiFi Repeater V2.2.9 starting
running rom 0
Config found and loaded
Starting Console TCP Server on port 7777
Starting Web Config Server on port 80
mode : sta(dc:4f:22:f2:25:91) + softAP(de:4f:22:f2:25:91)
add if0
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
7) conectarnos al wifi MyAP y configurar.
firefox http://192.168.4.1
abriria la url del router. http://192.168.4.1
solo quedaria poner los datos del wifi a repetir.
nota: si marcamos Automesh el wifi se repetira con el mismo nombre
y si configuramos varios repetidores se repartiran la señal en funcion de la covertura.
Para mas informacion y comandos avanzados ir a la pagina del autor.
https://github.com/martin-ger/esp_wifi_repeater
Conclusion
La verdad es que este chip esta muy bien para el coste que tiene.
Es perfecto para iot. Pero no le pidais transmision de video en tiempo real porque iria muy justo.
Una aplicacion que le he dado es para dar wifi a los clientes de un comercio. ya que es perfecto para que no abusen del wifi a la vez que permite separar las redes. En su caso configure
set upstream_kbps 128
set downstream_kbps 1024
set daily_limit 1024000
set phy_mode 1
asi limito el wifi de invitados a 1Mb de Bajada , 128Kb de subida y 1GB por dia.
y para protegerlo: set config_access 0
y asi solo se podra configurar por USB luego nadie podra reconfigurarlo.
Notas:
Comando para Obtener nombre de dispositivo
dmesg | tail | awk 'match($0,/tty.*/){print "/dev/"substr($0,RSTART,RLENGTH)}'
#si quiero asignarlo a una variable para usarlo luego
puerto=$(dmesg | tail | awk 'match($0,/tty.*/){print "/dev/"substr($0,RSTART,RLENGTH)}')
em50l@jejo:~$ dmesg | tail | awk 'match($0,/tty.*/){print "/dev/"substr($0,RSTART,RLENGTH)}'
/dev/ttyUSB0
em50l@jejo:~$
Enlaces:
esptool Utilidad para clasear los chips Esp82xx/Esp32
https://github.com/espressif/esptool
https://github.com/martin-ger/esp_wifi_repeater