MQTT Server for BeagleBone
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

105 lines
3.5 KiB

2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
2 years ago
  1. # Introduction
  2. This reposity includes the basic information to mount a web server using **Node-RED** as a Dashboard and also working as a MQTT server using **Mosquitto**.
  3. *Again, thanks to Andrés Perez for the first version.*
  4. # Servidor Web y comunicación con ESP32 por medio de un broker MQTT
  5. En este repositorio se presenta el proceso para montar un servidor web haciendo uso de Node-RED, y llevar a cabo su conexion con una tarjeta ESP32, haciendo uso del protocolo de comunicacion MQTT.
  6. ## Comunicacion
  7. 1. La comunicacion comienza en el ESP32, el cual se encarga de enviar un texto al broker MQTT por medio de una conexion de red local.
  8. 2. El broker MQTT recibe el valor y permite que otros clientes lo lean a traves de el.
  9. 3. Un servidor web ejecutado por Node-RED lee el dato recibido por el broker y ejecuta una accion de acuerdo al dato leido, en este caso esa accion es mostrar el texto en un sitio web.
  10. ![mqttesp32](./Imagenes/mqttesp32.PNG)
  11. Este proyecto trabaja en conjunto con un programa creado para el esp32, el cual se encuentra en el siguiente repostorio:
  12. http://gmarxcc.com:8088/andrespm/mqtt-server-esp32.git
  13. # MQTT Server
  14. ## Installing Mosquitto
  15. For the Raspberry pi, based on Debian's distribution, we can use:
  16. ```bash
  17. sudo apt update
  18. sudo apt upgrade
  19. sudo apt install mosquitto
  20. ```
  21. To execute *mosquitto* and enable every time the system starts:
  22. ```
  23. sudo systemctl enable mosquitto.service
  24. ```
  25. ## Configuring the Mosquitto server
  26. First replace the default configuration file by the file providing in this repository:
  27. ```
  28. sudo cp ./mosquitto.conf /etc/mosquitto/mosquitto.conf
  29. ```
  30. then, create the password file instanced on the `mosquitto.conf` file
  31. ```
  32. sudo touch /etc/mosquitto/passwd
  33. ```
  34. finally, restart the service:
  35. sudo systemctl restart mosquitto
  36. ## Node-RED installation
  37. To install **nodejs** write in terminal:
  38. ```
  39. sudo apt update
  40. sudo apt install nodejs
  41. sudo apt install npm
  42. ```
  43. Then, let us install the *Node-RED* app and the *Dashboard* complement by using the *Node Package Manager*:
  44. ```
  45. npm install node-red
  46. npm install node-red-dashboard
  47. ```
  48. now, we require to run in background the app and verify that *node-RED* is running:
  49. ```
  50. node-red &
  51. sudo netstat -plnt
  52. ```
  53. then, to get access to *node-RED* go to your web browser at `rasp-hostname.local:1880` or `rasp-ip:18080`.
  54. ## A flow process in Node-RED
  55. In the *Node-RED* App press the `import`button at the right-lower menu and upload the `flows.json` file in this repository.
  56. ![Importar](./Imagenes/Import_Node_Red.png)
  57. Damos clic en el nodo de mqtt in (el morado con el texto prueba/xd), se desplegara un menu con las propiedades del nodo.
  58. ![Propiedades](./Imagenes/Prop_node.png)
  59. Damos clic en el lapiz, el cual nos desplegara un menu con la configuracion, en el apartado de server tecleamos la direccion de nuestro server mosquitto
  60. Una vez configurado, corremos el proceso con boton **Deploy**, en caso de haber configurado correctamente el nodo mqtt, debajo de este habra un mensaje con el texto **connected**
  61. ![Connected](./Imagenes/Connected.png)
  62. Como se puede apreciar, uno de los nodos es una salida de insterfaz de usuario de tipo texto. Para acceder a ella nos dirijimos al navegador y escribimos la siguiente direccion: **localhost:1880/ui**
  63. En esta interfaz se reciben los datos enviados por otros clientes al servidor mqtt
  64. ## Recepcion de datos en DASHBOARD
  65. Al entrar a la pagina del dashboard vemos como node-red recibe el dato y lo muestra en la interfaz de usuario
  66. ![Connected](./Imagenes/Resultado.png)