MySQL for the Internet of Things

(Steven Felgate) #1
Chapter 6 ■ Building low-Cost MysQl data nodes

Let’s check the results of the test runs. To do so, you connect to the database server with the mysql
client and issue a SELECT query. Listing 6-6 shows the results of the three runs from the example. Notice the
different timestamp for each run. As you can see, I ran it once, then waited a few minutes and ran it again
(I used the RESET button on my Arduino Ethernet shield), and then ran it again right away. Very cool, isn’t it?


Listing 6-6. Verifying the Connection with the Serial Monitor


$ mysql -uroot -psecret
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 33
Server version: 5.6.14-log Source distribution


Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license


Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


mysql> select * from test_arduino.hello;
+---------------------+---------------------+
| source | event_date |
+---------------------+---------------------+
| From laptop | 2013-02-19 15:17:38 |
| Hello from Arduino! | 2013-02-19 15:18:12 |
| Hello from Arduino! | 2013-02-19 15:28:39 |
| Hello from Arduino! | 2013-02-19 15:29:16 |
+---------------------+---------------------+
4 rows in set (0.01 sec)


mysql>


Figure 6-17. Results of running the sketch several times

Free download pdf