Go Down

Topic: how to receive two data in python [solved] (Read 1 time) previous topic - next topic

70agiuseppe

Feb 10, 2014, 10:51 am Last Edit: Feb 11, 2014, 05:00 pm by 70agiuseppe Reason: 1
my first exercise with python  
   arduino sketch:
Code: [Select]
...
float t =  dht.readTemperature();
float h = dht.readHumidity()
bridge.put("temp", t);
bridge.put("umidi", h);
...
 
     
   I would like a very simple python example
   
   
Code: [Select]
 #!/usr/bin/python
      thank you very much

Robin2

Have you tried Googling "arduino python" and what did you find that might be useful?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

sonnyyu

To receive parameters in python you could use sys.argv, use print sys.argv find out how.
At Arduino sketch side:

Code: [Select]
void insertdb() {
  Process p;           
  p.begin("/mnt/sda1/mysql.py");     
  p.addParameter("1");
  p.addParameter("32");
  p.run();


http://forum.arduino.cc/index.php?topic=214431.msg1570756#msg1570756

70agiuseppe

thanks for the suggestions!
I'd like to see an example like:
Code: [Select]
$test= $client->get("temp");
echo $test;


but if it is possible written in python


70agiuseppe

Fortunately, I found a running system:
Code: [Select]
#!/usr/bin/python

import sys   
sys.path.insert(0, '/usr/lib/python2.7/bridge/')
from bridgeclient import BridgeClient as bridgeclient   
value = bridgeclient()     
temperatura =  value.get('temp')
umidita = value.get('umi')

print temperatura
print umidita


I hope it will be useful

Go Up