Hi
i am having troubles with bridge library.
i am trying to read one value from MYSQL data base and use it on arduino sketch,
so i have one python script that conect to data base and then pass the read value to bridge (i only read just one value))
here is the script
!/usr/bin/python
import socket
import _mysql
import sys
sys.path.insert(0, '/usr/lib/python2.7/bridge/')
from bridgeclient import BridgeClient as bridgeclient
con = _mysql.connect('***.***.*.**', '******', '******', 'tempc')
con.query("SELECT * FROM alarma1")
data=con.use_result()
alarma=data.fetch_row()[0]
con.close()
bc = bridgeclient()
bc.put('alarm',alarma)
and here is the arduino sketch who launch the proccess and wait for bridge value
#include <Process.h>
String ala = "/mnt/sda1/sql2bridge.py";//mira el valor de la alarma
float value=7.3;
char thold[10];
float th_f;
float r;
int t= 1; //// tiempo de espera entre grabacion de datos
void setup() {
Bridge.begin(); // Initialize the Bridge
Console.begin();
pinMode(A0,INPUT);
while(!Console);
Console.println("READY");
}
void loop() {
value = analogRead(A0);
Process e;
e.begin("python");
e.addParameter("/mnt/sda1/sql2bridge.py");
e.run(); // blocking call to run python; ATMega execution halts until complete
// do nothing until the process finishes, so you get the whole output:
while (e.running());
Bridge.get("alarm",thold,10);
th_f=atof(thold);
r=value-th_f;
if(r<=0){
digitalWrite(13,HIGH);
Console.println(r);
Console.print("high");
}
else{digitalWrite(13,LOW);
Console.println(r);
Console.print("low");
}
}
i have try to launct he script manually from putty, and normally appear this error:
Traceback (most recent call last):
File "sql2bridge.py", line 13, in
bc.put('alarm',alarma)
File "/usr/lib/python2.7/bridge/bridgeclient.py", line 92, in put
json = self.socket_open()
File "/usr/lib/python2.7/bridge/bridgeclient.py", line 59, in socket_open
self.json = TCPJSONClient('127.0.0.1', 5700)
File "/usr/lib/python2.7/bridge/tcp.py", line 65, in init
TCPClient.init(self, address, port)
File "/usr/lib/python2.7/bridge/tcp.py", line 38, in init
client.connect((address, port))
File "/usr/lib/python2.7/socket.py", line 224, in meth
return getattr(self._sock,name)(*args)
socket.error: [Errno 146] Connection refused
i am sure that the script obtain data from sql becouse i can print it, and i have try to use console on the arduino side but it crash when arrive to the line: Bridge.get("alarm",thold,10);
if some one can point me how to debug or have an idea how to change somethin would be nice becouse i have use the las two days and i am a bit block today
thanks!!