Page 1 of 1

Annex and MySQL

Posted: Thu Apr 29, 2021 8:06 pm
by Fernando Perez
I am experimenting with MySQL databases and PHP web pages.
I found this: https://randomnerdtutorials.com/esp32-e ... abase-php/ and have applied it to Annex.
In the folder of my domain https://www.myrapidq.it/php/ I have uploaded the files that I attach so that you can examine them in case they interest you:
https://www.myrapidq.it/public/mysql.zip

In my MySQL manager I have created a table using the following query:

Code: [Local Link Removed for Guests]

CREATE TABLE Sensores (
    id INT(6) UNSIGNED AUTO_INCREMENT PRIMARY KEY,
    sensor VARCHAR(1) NOT NULL,
    room VARCHAR(30) NOT NULL,
    type VARCHAR(1),
    value VARCHAR(10),
    reading_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
)
And the code to load in any ESP8266 or ESP32 that you have on hand is this:

Code: [Local Link Removed for Guests]

serverName$ = "https://www.myrapidq.it/php/"
apiKey$ = "x25TyxCCv7JPk"
sensor$ = "0"
room$ = "Dormitorio"
type$ = "L"
value$ = "223"

body$ = "api_key="+apiKey$+"&sensor="+sensor$+"&room="+room$+"&type="+type$+"&value="+value$
wlog WPOST$(serverName$, body$, 1)

Now I wanted to ask you to load it yourself, change the variables as you want (room$ for example, your name) and run it a few times to see if it works correctly for you.
The uploaded data should be seen at https://www.myrapidq.it/php/data.php
Thanks a lot.