Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad

LE9 DHT arduino - Práctica IoT, Ejercicios de Electrónica

El monitoreo de red es necesario para las redes de cualquier tamaño. Monitorear proactivamente la infraestructura de red puede ayudar a los administradores de red con sus tareas diarias. La amplia variedad de herramientas de red disponibles varía en costo, según las características, la cantidad de ubicaciones de red y de nodos admitidos.

Tipo: Ejercicios

2020/2021

Subido el 23/07/2021

jorge-landeros-1
jorge-landeros-1 🇲🇽

5 documentos

1 / 5

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
Universidad Tecnológica de Tijuana
Tecnologías de Información
Electrónica para IdC Lab exp #18
Pág. 1/5
Lab Experiment #18. PHP TCP Server that receives JSON
messages and stores data to MySQL
Objective
The student will extend the previous PHP TCP server code where after extracting the data in
the JSON, the software will connect to a MySQL database and will insert the node ID, the
message sequence number and the Celsius temperature data into a predefined table.
Material
PC or Laptop with XAMPP (Apache-PHP-MySQL)
PHPmyAdmin working on your system
TCPClientServer freeware tool installed in your system
Arduino-ESP01 and LM35 and IDE (from the previous experiment)
Lab experiment steps
1. You can save the previous script to another name like for example
TCP_server1mysql.php, so you can add the code as shown at the end of this
document.
2. Also create or edit another Batch file as follows. I am calling it Tm.bat:
Fig. 1. Tm.bat executes DOS commands to simplify running the TCP_server1mysql script.
3. For this experiment you have to create and configure in your MySQL system the
following database and user:
$database="arduinotest";
$username="userTest";
$password="userTestpass";
pf3
pf4
pf5

Vista previa parcial del texto

¡Descarga LE9 DHT arduino - Práctica IoT y más Ejercicios en PDF de Electrónica solo en Docsity!

Tecnologías de Información

Lab Experiment #18. PHP TCP Server that receives JSON

messages and stores data to MySQL

Objective

The student will extend the previous PHP TCP server code where after extracting the data in the JSON, the software will connect to a MySQL database and will insert the node ID, the message sequence number and the Celsius temperature data into a predefined table.

Material

 PC or Laptop with XAMPP (Apache-PHP-MySQL)  PHPmyAdmin working on your system  TCPClientServer freeware tool installed in your system  Arduino-ESP01 and LM35 and IDE (from the previous experiment)

Lab experiment steps

  1. You can save the previous script to another name like for example TCP_server1mysql.php , so you can add the code as shown at the end of this document.
  2. Also create or edit another Batch file as follows. I am calling it Tm.bat :

Fig. 1. Tm.bat executes DOS commands to simplify running the TCP_server1mysql script.

  1. For this experiment you have to create and configure in your MySQL system the following database and user: $database="arduinotest"; $username="userTest"; $password="userTestpass";

Tecnologías de Información

So you have to create a DB called arduinotest , and then create a specific user and password so as not to use the mysql root user credentials. Also create a table calling it tbtest_1 , with the following structure:

Fig. 2. Editing the “tbtest_1” table, be sure to mark the ID field as the Primary Key enabling A_I. And also make DATE_TIME update with the current time at each data insertion.

Fig. 3. The “tbtest_1” table structure result.

  1. The server algorithm will listen again on TCP port number 25000, then decodes the JSON messages the same way as before, but now after decoding the data it connects to the previous " arduinotest " localhost (127.0.0.1) database and tries to connect to the MySQL server with the built mysql module function:

$sqlconn = new mysqli($localhost, $username, $password, $database);

Tecnologías de Información

Tecnologías de Información

The End