Install Sqlite3:
opkg update opkg install sqlite3-cli sqlite3 /mnt/sda1/sensor.db
sqlite> CREATE TABLE sensor_data( id INTEGER PRIMARY KEY, temperature VARCHAR(64), sqlitetimestamp DATETIME DEFAULT CURRENT_TIMESTAMP ); sqlite> INSERT INTO sensor_data (temperature) VALUES (30); sqlite> select * from sensor_data; sqlite>.quit
sqlitetimestamp DATETIME DEFAULT CURRENT_TIMESTAMP, will auto CURRENT_TIMESTAMP.
Php command line:
opkg update opkg install php5-cli php5-mod-sqlite3 nano /mnt/sda1/sensor.php
#!/usr/bin/php-cli <?php $db = new SQLite3('/mnt/sda1/sensor.db'); $query = "INSERT INTO sensor_data (temperature) VALUES( ".$argv[1]." )"; $db->exec($query); $db->close(); ?>
chmod 755 /mnt/sda1/sensor.php /mnt/sda1/sensor.php 50
ATmega32u4 code:
#include <Process.h> void setup() { Bridge.begin(); // Initialize Bridge } void loop() { int temperature = 50 + random(0, 5); Process p; p.begin("/mnt/sda1/sensor.php"); p.addParameter(String(temperature)); p.run(); delay(5000); }
Comments powered by CComment