Trying to record pH
Posted: Tue Apr 27, 2021 1:10 pm
Hello, I'm trying to record pH using the 1130_PH adapter and I don't really know python super well and it isn't working. Wondered if anyone could take a look and let me know where I've gone wrong:
The error I am getting is:
Code: Select all
from Phidget22.Phidget import *
from Phidget22.Devices.VoltageInput import *
import time
#Create your Phidget channels
voltageInput0 = VoltageInput()
#Set addressing parameters to specify which channel to open (if any)
voltageInput0.setIsHubPortDevice(True)
voltageInput0.setHubPort(0)
#Open your Phidgets and wait for attachment
voltageInput0.openWaitForAttachment(5000)
#Do stuff with your Phidgets here or in your event handlers.
#Set the sensor type to match the analog sensor you are using after opening the Phidget
voltageInput0.setSensorType(VoltageSensorType.SENSOR_TYPE_1130_PH)
#Other valid sensor types for this sensor include: SENSOR_TYPE_1130_ORP
while (True):
#Update user
print("Logging data...")
#Write data to file in CSV format
with open ('phidgets_pH.csv','a') as datafile:
datafile.write(str(voltageInput0.getVoltagee()) + "\n")
#Increment count
count += 1
#If 10 data points have been recorded, close file and exit program
if(count == 10):
print("Logging complete, exiting program")
exit()
Code: Select all
Traceback (most recent call last):
File "/Applications/Thonny.app/Contents/Frameworks/Python.framework/Versions/3.7/lib/python3.7/ast .py", line 35, in parse
return compile(source, filename, mode, PyCF_ONLY_AST)
File "/Users/user/Downloads/example .py", line 7
voltageInput0 = VoltageInput()
^
IndentationError: unexpected indent