Difference between revisions of "TemperatureHumidity"

From TSG Doc
Jump to: navigation, search
(Created page with "{{Infobox tsg | name = TemperatureHumidity | image = | caption = TemperatureHumidity device | downloads = {{bulleted list | Media:tempe...")
 
 
(5 intermediate revisions by 2 users not shown)
Line 4: Line 4:
 
| caption        = TemperatureHumidity device
 
| caption        = TemperatureHumidity device
 
| downloads      = {{bulleted list
 
| downloads      = {{bulleted list
       | [[Media:temperaturehumidity.py|Custom Module]]
+
       | [[Media:temperaturehumidity.zip|Custom Module]]
 
       | [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package)
 
       | [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package)
 
   }}
 
   }}
Line 10: Line 10:
  
 
The TemperatureHumidity is a little (15 x 5 x 5 cm) black box with a black sphere on top. It is connected to your computer with the attached USB cable. When connected it will identify itself as a Virtual Serial port.  
 
The TemperatureHumidity is a little (15 x 5 x 5 cm) black box with a black sphere on top. It is connected to your computer with the attached USB cable. When connected it will identify itself as a Virtual Serial port.  
 +
 +
== Installation ==
 +
Install the rusocsci package. On the lab computers it is already installed for you. Download the [[Media:temperaturehumidity.zip|temperaturehumidity module]] and unzip it in the same directory as your experiment.
 +
 +
== Testing ==
 +
Run the temperaturehumidity module and sensor by running the file 'temperaturehumidity.py'. Double click it in explorer or load in the Psychopy Coder and click 'run'.
  
 
== Code example ==
 
== Code example ==
You can read temperature and humidity values with any software that connects to a serial port. Most conveniently you can use the rusocsci library in python.  Here is a little example how to write a script that read the temperature and humidity and writes it to the standard output (console):
+
You can read temperature and humidity values with any software that connects to a serial port. Most conveniently you can use the [https://pypi.python.org/pypi/RuSocSci RuSocSci] library in python.  Here is a little example how to write a script that reads the temperature and humidity and writes it to the standard output (console):
 +
<syntaxhighlight lang="python">
 +
#!/usr/bin/env python
 +
# -*- coding: utf-8 -*-
 +
import temperaturehumidity
 +
th = temperaturehumidity.TemperatureHumidity()
 +
print(th.waitString())
 +
</syntaxhighlight>
  
<code>
+
== Potential problems ==
#!/usr/bin/env python
+
The temperaturehumidity device identifies as a bttonbox. Lab computer are set up in a way that makes the second buttonbox behave different from all other devices. If you are using both the buttonbox and the temperaturehumidity device, please look up the portname of the temperaturehumidity device in the windows device manager and if it is for instance 'COM3' then change the code above into:
# -*- coding: utf-8 -*-
+
<syntaxhighlight lang="python">
import temperaturehumidity
+
#!/usr/bin/env python
th = temperaturehumidity.TemperatureHumidity()
+
# -*- coding: utf-8 -*-
print(th.waitString())
+
import temperaturehumidity
</code>
+
th = temperaturehumidity.TemperatureHumidity(port='COM3')
 +
print(th.waitString())
 +
</syntaxhighlight>

Latest revision as of 14:06, 8 September 2016

TemperatureHumidity
Downloads

The TemperatureHumidity is a little (15 x 5 x 5 cm) black box with a black sphere on top. It is connected to your computer with the attached USB cable. When connected it will identify itself as a Virtual Serial port.

Installation

Install the rusocsci package. On the lab computers it is already installed for you. Download the temperaturehumidity module and unzip it in the same directory as your experiment.

Testing

Run the temperaturehumidity module and sensor by running the file 'temperaturehumidity.py'. Double click it in explorer or load in the Psychopy Coder and click 'run'.

Code example

You can read temperature and humidity values with any software that connects to a serial port. Most conveniently you can use the RuSocSci library in python. Here is a little example how to write a script that reads the temperature and humidity and writes it to the standard output (console):

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import temperaturehumidity
 th = temperaturehumidity.TemperatureHumidity()
 print(th.waitString())

Potential problems

The temperaturehumidity device identifies as a bttonbox. Lab computer are set up in a way that makes the second buttonbox behave different from all other devices. If you are using both the buttonbox and the temperaturehumidity device, please look up the portname of the temperaturehumidity device in the windows device manager and if it is for instance 'COM3' then change the code above into:

 #!/usr/bin/env python
 # -*- coding: utf-8 -*-
 import temperaturehumidity
 th = temperaturehumidity.TemperatureHumidity(port='COM3')
 print(th.waitString())