TemperatureHumidity: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
| (10 intermediate revisions by 2 users not shown) | |||
| Line 4: | Line 4: | ||
| caption = TemperatureHumidity device | | caption = TemperatureHumidity device | ||
| downloads = {{bulleted list | | downloads = {{bulleted list | ||
| | | {{Download link|media=temperaturehumidity.zip|Custom Module|zip}} | ||
| [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | | [https://pypi.python.org/pypi/RuSocSci RuSocSci] (Python package) | ||
}} | }} | ||
}} | }} | ||
The TemperatureHumidity is a little (15 x 5 x 5 cm) black box with a black sphere on top. | The TemperatureHumidity device is a little (15 x 5 x 5 cm) black box with a black sphere on top. As the name suggests, it can measure temperature and humidity. | ||
You can attach the device to a PC via USB. When connected, it will identify itself as a virtual serial port. | |||
== Installation == | == Installation == | ||
Install the rusocsci package. On the lab computers it | Install the ''rusocsci'' package. On the lab computers it may already be installed for you. Also install ''pytz'', ''python-dateutil'' and ''pyqt4''. Download the {{Download link|media=temperaturehumidity.zip|temperaturehumidity module}} and unzip it in the same directory as your experiment. | ||
== Testing == | == Testing == | ||
| Line 18: | Line 20: | ||
== 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 [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):< | 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): | ||
#!/usr/bin/env | <syntaxhighlight lang="python"> | ||
#!/usr/bin/env python3 | |||
import temperaturehumidity | import temperaturehumidity | ||
th = temperaturehumidity.TemperatureHumidity() | th = temperaturehumidity.TemperatureHumidity() | ||
print(th.waitString()) | print(th.waitString()) | ||
</code> | </syntaxhighlight> | ||
== Potential problems == | |||
The temperaturehumidity device identifies as a buttonbox. 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 port name of the temperaturehumidity device in the windows device manager and if it is for instance 'COM3' then change the code above into: | |||
<syntaxhighlight lang="python"> | |||
#!/usr/bin/env python3 | |||
import temperaturehumidity | |||
th = temperaturehumidity.TemperatureHumidity(port='COM3') | |||
print(th.waitString()) | |||
</syntaxhighlight> | |||