Internet of Things is when a physical thing for example a chair, a clock, glasses, or other elements of our daily routine are connected to the Internet to send and receive data. Cisco said in 2020 50.000 million are going to be connected to the Internet. First, we are going to understand how the Internet has evolved in these four steps:

  1. Connectivity:

This step is about how the people begin to connect with a network and share information between them with tools like mail and browsers almost 40 years ago.

2. Commerce by Internet

At this time begins the e-commerce maybe at the end of the 90s.

3. Collaborate

Beginnings of 2000, the tools to collaborate like social networks, cloud computing, web services to share information, videocalls, take more easy the way to work.

4. Now, is the time to the Internet of Everything

Internet of everything is the actual phase of the Internet, this step consists of 4 columns (People, Things, Process, and Data)

The evolution of IoT is IoE for this reason I’m going to explain how it works and whats is it.

It is the connection between people, data, process, and things where:

People: This is the main actor of the IoE because we need the people to get o to create the other pillars of IoE.

Data: Information generates by people and objects.

Process: New process created with all the pillars to take actions and take decisions.

Things: Physical hardware connected to the Internet to share data with the Internet, this hardware can have peripherals to connect sensors, displays, buzzers, loudspeakers, motors, and beyond.

All of those help to improve the economy for companies, countries, and people, because is easier to make decisions and do actions.

How to design an IoE solution:

All begins with a problem, is necessary understand a problem to solve with IoE, for example, if you don’t know if you close the door or turn the lights of your house, you can have a device to send data to the internet and you can see in a web platform how is your door or another example could be if you need a system to alert when you have a high vibration inside of a building and maybe It can damage the structure, you could have a system to show that vibration and avoid danger. Now that we have a problem and a possible solution we are going to create a prototype.

For me is more interesting the trouble about vibration in structures (I’m a sound engineer) than the lights and close the door. This example is a remote system to detect vibrations and alert when the amplitude is overage to the regular values. It was for vibrations in structures and the technology infrastructure was: web server, MySQL database, Arduino to receive the signal of Accelerometer, web app (backend PHP, front end HTML and JS)

we are going to work with a MCU because is a prototype, in this case, I’m going to use an Arduino nano. now that we know what is our device to get data and send it to the Internet we are going to understand how to capture the signal.

Vibration in buildings is measured by a transducer (Accelerometer or Velocimeter) this can change the physical signal in electrical and later we are going to receive the electrical signal to processing and understand the amplitude of the signal, we are not working with the value RMS because the idea in this blog only shows a brew explanation about IoT however if you want to know more about the signal, transducer process, signal adequacy, data analysis(Root Means Square, sampling, quantification, and encoding), laws about vibrations in structures, machines and people this link has the final project of three sound engineers (Donaldo García, Carlos Hernández, and Paulo Morillo)

http://biblioteca.usbbog.edu.co:8080/Biblioteca/BDigital/142669.pdf

Now that we are going to get only the peaks values of the transducer we are going to find the output voltage of the transducer when It captures the highest vibration, this process is to safe our MCU because our Analog input only can manage 5V and we are going to use a transducer with a max output 50V.

Now we have a problem here, the max input is 5V and we have 50V, ok we are going to fix our amplitude with a voltage divider (this is because we only are interested in the maximum values but if you are going to do a professional project you should get the most possible data and in this case, we could lose information), ok we are going to do a voltage divider by 10 to get a maximum value of 5V, the regular process would verify the sampling need it (see Nyquist theory) and the bytes of the inputs of our Arduino to digitalize our signal, but we are going to jump this for the reason that I already said.

Now we are going to get the data in MCU, we are going to use the libraries MySQL and sha1 because we are going to send the data to a database and the library ethernet to connect an ethernet shield and SPI because we are going to

the communication process sends data to the database directly but is a better way to do it when you do request and create an API REST to get the data, but in this project, we try to do sending to MySQL directly.

Arduino Code

#include “SPI.h”

#include “Ethernet.h”

#include “sha1.h”

#include “mysql.h”

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };//Setup for Ethernet Library

IPAddress server_addr(172,16,3,138); //change the value with the server IP Address

Connector my_conn; // The Connector/Arduino reference

char user[] = “username”;

char password[] = “passwordDB”;

const char INSERT_DATA[] = “INSERT INTO DBname.tablename(ID,entrada,fecha) VALUES (ID,%s,now())”; //query to insert data

void setup()

{

Ethernet.begin(mac);

Serial.begin(115200);

delay(1000);

Serial.println(“Connecting…”);

if (my_conn.mysql_connect(server_addr, 3306, user, password)) //condition if we are connecting to server in this case with 3306 port

{

delay(500);

float value_read = analogRead(A0); //read the value of Analog Input 1 in this input we connected the voltage divider.

for (int i=0; i <= 100; i++) //loop to run 10s

{

char query[64];

char vibra[10];

dtostrf(value_read, 1, 1, vibra); //value to string

sprintf(query, INSERT_DATA, vibra); //concat all query

my_conn.cmd_query(query); //execute the query

delay(100);

value_read =analogRead(A0); //get another value

Serial.println(value_read); // see value in serial monitor

}

}

else

Serial.println(“Connection failed.”);

}

void loop()

{}

PHP JS CODE AND HTML

<HTML>

<BODY>

<?php

echo “ <br><br><center><h1> ALARMA DE ESTRUCTURAS </h1></center>” ;

if(isset($_POST[“enviar_btn”])) {

if ($_POST[“clave_txt”]==”server”) {

echo “<h1> BIENVIENIDO</h1><br>”.$_POST[“nombre_txt”].”<br>”;

$tim=time() ;

echo date(“<br/> D-m-Y (h:i:s)<br><br> <br><br>”,$tim);

echo “<br>”;

}

else {

echo “CLAVE INCORRECTA REGRESE Y VERIFIQUE”;

break;

}

}

else {

echo “nada papá”;

break;

}

?>

<?php

$server = “172.16.3.138”;

$usuario = “mateo”;

$pass = “mateo987”;

$BD = “test_mateo”;

//variable que guarda la conexión de la base de datos

$conexion= mysql_connect($server, $usuario, $pass, $BD)or die(“No se pudo conectar con el server de BD”) ;

//echo “estoy conectado a MySQL”;

// 2) seleccionar BD con la que se va a trabajar.

mysql_select_db($BD) or die (“mo se ha seleccionado la BD”);

//echo “<br>base de datos seleccionada”;

//3) crear consulta

$consulta=”SELECT*FROM tablaredes”;

//4)jecutar consulta mysql_query necesita consulta y conexion

$ejecutar=mysql_query($consulta,$conexion) or die(“No se pudo ejecutar consulta”);

//echo “<br>se ejecutó la consulta SQL”;

//5) MOstrar resultados dentro de un ciclo y en una variable se ingresar la función mysql_fetch_array

$a=0;

while ($registro=mysql_fetch_array($ejecutar)){

//echo “<br>”.$registro[“entrada”].” “.$registro[“fecha”].”<br>”;

//cerrar 1a conexión a la BD

//mysql_close($conexion) or die(“ocurrio un error al cerrar conexión”);

//echo “ conexión cerrada”;

$rawdata[$a][1]=$registro[“entrada”];

$rawdata[$a][2]=$registro[“fecha”];

$a=$a+1;

}

//nos creamos dos arrays para almacenar el tiempo y el valor numérico

$valoresArray;

$timeArray;

header(“refresh:4;url=http://localhost/ALarma/alarma2.php");

$b=0;

for($i = 0 ;$i<count($rawdata);$i++){

$valoresArray[$i]= $rawdata[$i][1];

$time= $rawdata[$i][2];

$date = new DateTime($time);

$timeArray[$i] = $date->getTimestamp()*1000;

if ($rawdata[$i][1] >= 95){

$valorg[$b]= $rawdata[$i][1];

$tiempog[$b]=$time;

$consulta=”INSERT INTO random2 (valores,tiempos) VALUES (‘$valorg[$b]’,’$tiempog[$b]’)”;

$ejecutar=mysql_query($consulta,$conexion);

$b=$b+1;

//$msj=”corran estructura en riesgo”;

}

//echo $msj;

}

//print_r ($valorg);

// print_r ($datosa);

?>

<div id=”contenedor”></div>

<script src=”https://code.jquery.com/jquery.js"></script>

<! — Importo el archivo Javascript de Highcharts directamente desde su servidor →

<script src=”https://code.highcharts.com/stock/highstock.js"></script>

<script src=”https://code.highcharts.com/modules/exporting.js"></script>

<script>

chartCPU = new Highcharts.StockChart({

chart: {

renderTo: ‘contenedor’

//defaultSeriesType: ‘spline’

},

rangeSelector : {

enabled: false

},

title: {

text: ‘Gráfica de Amplitud contra tiempo’

},

xAxis: {

type: ‘datetime’

//tickPixelInterval: 150,

//maxZoom: 20 * 1000

},

yAxis: {

minPadding: 0.2,

maxPadding: 0.2,

title: {

text: ‘Velocidad RMS’,

margin: 10

}

},

series: [{

name: ‘valor’,

data: (function() {

// generate an array of random data

var data = [];

<?php

for($i = 0 ;$i<count($rawdata);$i++){

?>

About security:

The security in IoT is very important and should be thinking since we did the design, be sure that you are including functions to do the update of the firmware, remember close all back doors. Take care with:

Predefined passwords: Remove all accounts predefined if you can’t remove change the passwords.

UPnP: Universal Plug and Play, disable the UPnP protocol in device and Router or ONT because our device can be a vector to attack.

Remote management: Some devices use Telnet o SSH, the best option is to disable the ports to do remote management maybe you can use SSH with a password different from predefined.

Encrypted communications and certificates: enable the certificates and use the most encrypted methods that the device can have.

Nowadays we have created a device to control audio and electrical signals with a web platform.

pauloan@hotmail.com

Bibliography

Cisco Certification “Introduction to IoE”

Cisco Certification “Connecting Things”

Donaldo Garcia, Carlos Hernández, Paulo Morillo-DESIGN AND IMPLEMENTATION OF A PORTABLE SYSTEM OF VIBRATIONS FOR MEASUREMENT AND ANALYSIS http://biblioteca.usbbog.edu.co:8080/Biblioteca/BDigital/142669.pdf

Fullstack developer and sound engineer, learning ML