Sending Variables via the Bridge from Python to Sketch on Arduino Yun


hi, trying run simple sketch uses output variables python, can't seem python side "put" variable through sketch side. python , sketch codes based on forum discussion.

the python code looks this:
code: [select]
import sys   
sys.path.insert(0, '/usr/lib/python2.7/bridge/')

from bridgeclient import bridgeclient bridgeclient

value = bridgeclient()                             
   
d_high = 85   
   
value.put("d_high",(d_high))


and sketch looks this:
code: [select]
#include <process.h>
#include <bridge.h>

char d_high[4];

void setup() {
  bridge.begin();
}

void loop() {
  process p;
  p.runshellcommand("python /mnt/sda1/arduino/python.py"); //run python code generate values
   
  bridge.get("d_high",d_high,4);  //get value bridge , store
  int d_high_int = atoi(d_high);  //convert ascii integer
  serial.println(d_high_int);  //print result serial monitor check
  delay(5000);  //wait 5 seconds , update
}


i able "put" , "get" proper data when put discrete value in: value.put("d_high",'70'), if try reference variable (as shown), sketch output returns 0. i'm sure it's simple , i've tried format variable on python side 20 different ways, still can't meaningful value exit sketch, unless use discrete value, know data being passed through bridge.

thanks help!

as update, moved python script "www" folder as suggested forum post.

when call http://local.arduino/data/get when use discrete value, returns this:
code: [select]
{"value":{"d_high":"-70.5"},"response":"get"}

and previous examples returns this:
code: [select]
nil socket, 146 connection refused

which take mean processing error happened , no values stored.

i've looked high , low more information on bridgeclient value.put function, can't find additional examples or resources. maybe calling variable value.put isn't option? or i'm missing something. hope it's latter.


Arduino Forum > Products > Arduino Yún (Moderator: fabioc84) > Sending Variables via the Bridge from Python to Sketch on Arduino Yun


arduino

Comments