CHAPTER 8 ■ IOT PATTERNS: WEB APPS
Database Table (MySQL)
As discussed in the previous chapter, before you can send HTTP requests from Arduino,
you need to build a service that will receive data.
This chapter also uses MySQL as a database. The application needs a very simple
three-column table. So create a new table called TEMPERATURE_MONITORING_DATA using the
SQL script provided in Listing 8-1. Run this script in an existing database or create a new one.
The first column will be an auto-generated ID, the second column will be an
auto-generated timestamp, and the third column will be used to store the temperature
readings.
Listing 8-1. Create Table SQL
CREATE TABLE TEMPERATURE_MONITORING_DATA
(
ID
int(11) NOT NULL AUTO_INCREMENT,
TIMESTAMP
timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE
CURRENT_TIMESTAMP,
TEMPERATURE
double NOT NULL,
PRIMARY KEY (ID
)
)
Figure 8-4. Actual circuit of the temperature monitoring system