Good Evening all.
Hopefully someone can please point me in the right direction. I'm trying to use 6 values from my sketch in Python but having a bit of trouble getting it working. I have searched on here and several other places to try and get my head around it however this is my first venture into using Python so that isn't helping much. Hopefully just something silly and obvious I have done.
Here is the sketch:
#include <Bridge.h>
//Setup IO and pin names
int sensorPin = A0; // select the input pin for the LDR
//Setup Vars, constants etc
int sensorValue = 0; // variable to store the value coming from the sensor
int Light = 0;
int OSTemp = 0;
int ISTemp = 0;
int Moisture1 = 0;
int Moisture2 = 0;
int Moisture3 = 0;
void setup()
{
Bridge.begin(); // start the bridge
}
void loop()
{
//Not written the code yet, just want to get the Bridge part working first
ValuesToBridge();
delay(10000);
}
void ValuesToBridge(){
Light=100; //Just some test values
OSTemp=101;
ISTemp=102;
Moisture1=253;
Moisture2=254;
Moisture3=123;
Bridge.put("Light", Light);
delay(100);
Bridge.put("OSTemp", OSTemp);
delay(100);
Bridge.put("ISTemp", ISTemp);
delay(100);
Bridge.put("Moisture1", Moisture1);
delay(100);
Bridge.put("Moisture2", Moisture2);
delay(100);
Bridge.put("Moisture3", Moisture3);
delay(100);
}
Any the Python script
import sys
sys.path.insert(0, '/usr/lib/python2.7/bridge')
from bridgeclient import BridgeClient as bridgeclient
value = bridgeclient()
Light = value.get("Light")
OSTemp = value.get("OSTemp")
ISTemp = value.get("ISTemp")
Moisture1 = value.get("Moisture1")
Moisture2 = value.get("Moisture2")
Moisture3 = value.get("Moisture3")
print "Value for Light: ",Light,"\n"
print "Value for OSTemp: ",OSTemp,"\n"
print "Value for ISTemp: ",ISTemp,"\n"
print "Value for Moisture1: ",Moisture1,"\n"
print "Value for Moisture2: ",Moisture2,"\n"
print "Value for Moisture3: ",Moisture3,"\n"
If I run this using putty I am getting the following output:
root@Arduino:/mnt/sda1/arduino/www/Gardenino# python commstest.py
Value for Light:
Value for OSTemp:
Value for ISTemp: e
Value for Moisture1:
Value for Moisture2:
Value for Moisture3:
I checked on the Bridge/Key value storage manager and this is the same as on there so it would look like the problem is on the sketch side but I have no idea what I have done wrong if someone can please steer me a little.
Thanks
Tom