Get Informed out of Data

Full width home advertisement

Raspbian

DataScience

Post Page Advertisement [Top]

Espio Dashboard for Raspberry Pi

Espio Dashboard for Raspberry Pi

 Raspberry Pi and its stream of IoT devices have serious importance in the digital work of getting data and analyzing it.


Esp devices,

  1. ESP8266
  2. ESP32
  3. ESP32-Sim800l
above these devices can be remodeled to work with various other embedded systems like sensors, Arduino where data will be collected.
Highlights of ESP devices is the number of protocols it can support.

  1. I^2 C Bus
  2. Serial
  3. HTTP
  4. UART
  5. MQTT
  6. Wifi
  7. Core
With almost every interacting protocol to communicate, making ESP modules an interesting take on IoT platforms since it works on very low power and also highest possible communication, works a charm.

The Place for Raspberry Pi is slowly replaced as a brand of IoT computer because it can be a way more powerful device to act as a standalone server also easy to have look with touch screen dashboard that can be designed specifically for it.

One such DashBoard concept of making it for ESP modules is ESPIO

Obviously, it can work more than that, as the devices change it is just the protocol to get into the dashboard.

Let's try it out,

ESPIO

A web frontend to control esp, sonoff and raspberry pi's over MQTT. Espio can be used to turn things on and off, receive sensor data and send Infrared commands. Everything you need for a basic home automation system.

Features
  • Control and view all your IoT devices through a single web app
  • Mobile friendly - compatible with devices of all sizes
  • Create switches, sliders, sensors, infrared remote controls
  • Devices are monitored to ensure they are up and responding to requests
  • Devices can be assigned to locations i.e. rooms
  • Set timers based on sunset/sunrise
  • Example scripts for ESP, Raspberry Pi, and sonoff
Installation

These instructions are based on installing espio on a Raspberry Pi with a fresh install of Raspberry Pi OS. The instructions should work for other Debian based systems i.e. Ubuntu, Mint Mosquitto is used as the MQTT broker

Raspberry Pi Static IP

Ensure your Raspberry Pi has a static IP address. Ideally this should be set on your router.

Setting up a Static IP Address on the Raspberry Pi

Mosquitto Broker

sudo apt update
sudo apt upgrade
sudo apt install -y mosquitto  mosquitto-clients
sudo systemctl enable mosquitto.service

Configure Mosquitto Broker

sudo nano /etc/mosquitto/conf.d/mosquitto.conf

Replace contents of file with the text below:

listener 1883
protocol mqtt

listener 8083
protocol websockets

Once done save and exit by pressing CTRL + X and then pressing Y then ENTER.

Restart the mosquitto broker

sudo systemctl restart mosquitto.service

Testing mosquitto broker

mosquitto_pub -d -t testTopic -m "Hello world!"

Apache

For detailed instructions and explanations of the commands see How to Setup a Raspberry Pi Apache Web Server

sudo apt install apache2 -y
sudo usermod -a -G www-data pi
sudo mkdir /var/www/espio
sudo chown -R -f www-data:www-data /var/www/espio

Logout and log back in

PHP7 for Apache

sudo apt install php7.3 php7.3-mysql -y

MySql

For detailed instructions and explanations of the commands see Setup a Raspberry Pi MYSQL Database

Follow the prompts to set a password for the root user and to secure your MySQL installation.

sudo apt install mariadb-server
sudo mysql_secure_installation
sudo apt install php-mysql

Paho-mqtt

Install the python paho-mqtt module.

sudo pip3 install paho-mqtt

Creating a MySQL Database and User

Make sure you change enter a password here before executing the command. Make a note of the password, you will need to enter it later.

sudo mysql -u root -p
CREATE DATABASE espio;
CREATE USER 'espio'@'localhost' IDENTIFIED BY '_enter a password here_';
GRANT ALL PRIVILEGES ON espio.* TO 'espio'@'localhost';```
FLUSH PRIVILEGES;

Type quit to exit mysql

Create Virtual Host

sudo nano /etc/apache2/sites-available/espio.conf

Replace contents of espio.conf with the text below

listen 8080
<VirtualHost *:8080>
    ServerAdmin [email protected]
    ServerName espio.local
    DocumentRoot /var/www/espio/
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
    <Directory /var/www/espio/>
        Options Indexes FollowSymLinks
        AllowOverride ALL
        Require all granted
        Header set Access-Control-Allow-Origin "*"
        IndexIgnore * # prevent directory listing
        RewriteEngine on
        # Rewrite /foo/bar to /foo/bar.php
        RewriteCond %{REQUEST_FILENAME}.php -f
        RewriteRule (.*) $1.php [L]
    </Directory>
</VirtualHost>

Once done save and exit by pressing CTRL + X and then pressing Y then ENTER.

Enable the New Virtual Host File
sudo a2ensite espio.conf
Enable the required apache modules and restart
sudo a2enmod headers
sudo a2enmod rewrite
sudo systemctl restart apache2

Download the Latest Release

wget https://github.com/jasonbrownza/espio/releases/download/v1.0.0/v1.0.0.zip
unzip v1.0.0.zip -d /var/www/espio/

Set Folder Permissions

sudo chmod 775 '/var/www/espio/api/config/'

Timers Service

Configure the timers script.

The only variable that needs to be changed is the mqttServerAddress. Change the IP address to the static IP address of your Raspberry Pi.

nano /var/www/espio/services/espio_timers.py
Make the timers script executable
sudo chmod +x /var/www/espio/services/espio_timers.py

Create a systemd service for the timers service

sudo nano /etc/systemd/system/espio_timers.service

Replace the contents of the file with the text below :

[Unit]
After=network.target

[Service]
ExecStart=/var/www/espio/services/espio_timers.py

[Install]
WantedBy=default.target

Once done save and exit by pressing CTRL + X and then pressing Y then ENTER.

Start the espio_timers service
sudo systemctl daemon-reload
sudo systemctl enable espio_timers.service
sudo systemctl start espio_timers.service

Running Espio

Point your browser to:-

http://raspberry-pi-static-ip:8080
Now, you would get a page to add devices and make a dashboard out of it.


No comments:

Post a Comment

Bottom Ad [Post Page]