Install software:
opkg update opkg install sqlite3-cli opkg install python-sqlite3
Create DB:
sqlite3 /mnt/sda1/test1.db
sqlite> create table tablica(id integer, Temp, Wilg, primary key(id asc)); sqlite> INSERT INTO tablica (Temp,Wilg) VALUES (12, 30); sqlite> INSERT INTO tablica (Temp,Wilg) VALUES (12, 30); sqlite> select * from tablica; 1|12|30 2|12|30 sqlite>.quit
Create python file:
nano /mnt/sda1/pythonsqlite3.py
#!/usr/bin/python import sqlite3 as sqlite import sys script,Temp,Wilg = sys.argv con = sqlite.connect('/mnt/sda1/test1.db') cur = con.cursor() cur.execute('''INSERT INTO tablica (Temp,Wilg) VALUES(?,?)''',(Temp,Wilg)) con.commit() con.close()
chmod 755 /mnt/sda1/pythonsqlite3.py
/mnt/sda1/pythonsqlite3.py 100 200
sqlite3 /mnt/sda1/test1.db
sqlite> select * from tablica; .quit
ATmega32u4 code:
#include <Process.h> void setup() { Bridge.begin(); // Initialize Bridge } void loop() { Process p; // Create a process and call it "p" p.begin("/mnt/sda1/pythonsqlite3.py"); // Process that launch the "pythonsqlite3.py" command p.addParameter("500"); // Add the parameter to "Temp" p.addParameter("1000"); // Add the parameter to "Wilg" p.run(); // Run the process and wait for its termination delay(10000); }
Comments powered by CComment