{ "info": { "author": "urwen", "author_email": "", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Operating System :: POSIX :: Linux", "Programming Language :: Python :: 3" ], "description": "# temper.py\n\nThe USB temperature and temperature/humidity sensors sold my PCsensor are\nwidely available from the parent site\n(http://pcsensor.com/usb-temperature-humidity.html), from Amazon, and from\nEBay.\n\n## Design\n\nThere are several open source software projects that support these sensors,\nsometimes including complicated monitoring and graphing software. Unlike,\nthese projects, the goal of this project is to simply read data from the\nsensors and do nothing else, given the following constraints:\n* must work under Linux,\n* must work with Python 3,\n* third-party software will be avoided when possible,\n* all third-party software must be provided as standard Debian packages.\n\n### libusb is not used\n\nI tried to use libusb (apt-get install python3-usb; \"import usb.core\") and it\nprovides a sophisticated interface to USB devices that was very nice.\nUnfortunately, I have one thermometer that didn't work with raw usb and that\nrequired access via the hidraw device; and I have another thermometer that has\nan undocumented HID protocol, but that is accessible via a serial tty.\n\n### hid and hidapi are not used\n\nI tried using hid (apt-get install python3-hid) and hidapi (apt-get install\npython3-hidapi) and these worked ok for two of the thermometers I have, but\nnot for the one that requires access via a serial tty.\n\n### pySerial is used\n\nAlthough HID devices are accessed directly, pySerial is used for TTYs. This\nmodule is available as a Debian package:\n sudo apt-get install python3-serial\n\n## Supported Devices\n\nI own five kinds of devices from PCsensors. These are all supported by\ntemper.py.\n\nIn the following table \"I\" means the sensor is internal to the USB stick and\n\"E\" means the sensor is on a cable that is plugged into the USB stick.\n\nProduct | Id | Firmware | Temp | Hum | Notes\n-----------|-----------|-----------------|------|-----|---------------\nTEMPer | 0c45:7401 | TEMPerF1.4 | I | | Metal\nTEMPer | 413d:2107 | TEMPerGold_V3.1 | I | | Metal\nTEMPerHUM | 413d:2107 | TEMPerX_V3.1 | I | I | White plastic\nTEMPer2 | 413d:2107 | TEMPerX_V3.3 | I,E | | White plastic\nTEMPer1F | 413d:2107 | TEMPerX_V3.3 | E | | White plastic\nTEMPerX232 | 1a86:5523 | TEMPerX232_V2.0 | I,E | I | White plastic\n\nThe 1a86:5523 device may identify as 413d:2107 depending on button presses,\nbut it cannot be used successfully when in that mode.\n\nIf you try other software that uses libusb, the hidraw device may be\ndisconnected. In this case, remove and re-insert the USB stick.\n\nThe TEMPer1F has only an external sensor, but it is not possible to detect\nthat it is external, so it is reported as an internal temperature.\n\n### TEMPer\n\nThis is a metal USB stick marked \"TEMPer\" with thermometer logo on one side,\nand \"TEMPer\" on the other side. The end opposite the USB connector a screw\nhole. There is *no* humidity detector, but it appears water proof and I have\nsubmerged mine momentarily in ice water and in boiling water.\n\n### TEMPerHUM\n\nThis is a white plastic USB stick marked \"TEMPerHUM\", \"-40C - +85C\", and\n\"0-100%RH\"; with *blue button* marked \"TXT\". On the reverse, \"PCsensor\". This\nmodel does *not* have a jack on the end.\n\nWhen the button is pressed the red LED will blink as messages of the following\nstyle are sent (the temperature line repeats every second).\n\n```\nwww.pcsensor.com\ntemperx v3.1\ncaps lock:on/off/++\nnum lock:off/on/--\ntype:inner-h2\ninner-temperinner-humidityinterval\n32.73 [c]36.82 [%rh]1s\n```\nWhen the button is pressed again, the LED will either be off or be solid red.\nThis is the mode that temper.py uses.\n\n### TEMPer2\n\nphysical description: White plastic USB stick marked \"TEMPer2\",\n\"-40C - +125C\"; with red button marked \"TXT\". On the reverse, \"PCsensor\".\nThis model has a jack for an external sensor on the end.\n\nnotes: When the button is pressed, the red LED will blink as messages\nof the following form are sent (the temperature line repeats every\nsecond).\n\nWithout an external sensor:\n```\nwww.pcsensor.com\ntemperx v3.3\ncaps lock:on/off/++\nnum lock:off/on/--\ntype:inner-tx\ninner-tempinterval\n27.93 [c]1s\n```\n\nWith an external sensor:\n```\nwww.pcsensor.com\ntemperx v3.3\ncaps lock:on/off/++\nnum lock:off/on/--\ntype:inner-tx;outer-tx\ninner-tempintervalinterval\n27.18 [c]29.62 [c]1s\n```\n\nThis program uses the mode where the LED is either off or solid red.\n\n### TEMPer1F\n\nWhite plastic USB stick marked \"TEMPer1F\", \"-40C - +125C\"; with pink button\nmarked \"TXT'. On the reverse, \"PCsensor\". This model has a jack for an\nexternal sensor and does *not* have an internal sensor.\n\nWhen the button is pressed, the red LED will blink as messages\nof the following form are sent (the temperature line repeats every 1\nsecond).\n\nWithout the probe inserted:\n```\nwww.pcsensor.com\ntemperx v3.3\ncaps lock:on/off/++\nnum lock:off/on/--\ntype:unknown\n1s\n```\n\nWith the probe inserted:\n```\nwww.pcsensor.com\ntemperx v3.3\ncaps lock:on/off/++\nnum lock:off/on/--\ntype:outer-tx\nouter-tempinterval\n24.93 [c]1s\n```\n\nThis program uses the mode where the LED is either off or solid red.\n\n### TEMPerX232\n\nWhite plastic USB stick marked \"TEMPerX232\", \"0-100%RH\",\nand \"-40 - +85C\"; with a *green button* marked \"press\". On the reverse,\n\"PCsensor\". On the end opposite the USB connector, there is a jack for an\nexternal temperature sensor (which I do not have and did not try).\n\nWhen the button is pressed and held down until the red LED is solid, a blue\nLED will flash every second. In this mode, the USB vendor:product changes to\n413d:2107, but only one HID device is available, and protocol sent to the\nhidraw device is rejected with an error.\n\nWhen the LED is flashing blue, and the button is pressed momemtarily,\nthe following are sent (the temperature line repeats every second).\n\n```\nwww.PCsensor.com\nTEMPerX232-V2.0\ntype:inner-H2\ninner-temperinner-humidityinterval\n30.48 [C]40.19 [%RH]1\n```\n\nWhen the button is pressed and held down until the red LED is solid, a green\nLED will flash every second. This is the mode temper.py uses. In this mode, if\n\"Help\" is sent to the serial device, the following will be sent back:\n\n```\n >>PCsensor<<\nWelcome to use TEMPerX232!\nFirmware Version:TEMPerX232_V2.0\nThe command is:\n ReadTemp -->read temperature,temp_value = sensor_value + calibration\n ReadCalib -->read calibration\n SetCalib-type:xx.x,xx.x> -->set calibration, xx.x(-10.0~+10.0)\n EraseFlash -->erase calibration\n Version -->read firmware version\n ReadType -->read the sensor type\n ReadAlert-Temp -->read temp alert value\n SetTempUpperAlert-type:xx.xx>-->set temp upper alert value,xx.xx(-40.00~+85.00)\n SetTempLowerAlert-type:xx.xx>-->set temp lower alert value,xx.xx(-40.00~+85.00)\n ReadAlert-Hum -->read hum alert value\n SetHumUpperAlert-type:xx.xx> -->set hum upper alert value,xx.xx(00.00~99.99)\n SetHumLowerAlert-type:xx.xx> -->set hum lower alert value,xx.xx(00.00~99.99)\n SetMode-Temp:x> -->set tempmode, x(0~1)\n ReadMode-Temp -->read tempmode\n Help -->command help\n ? -->command help\nThe COM configuration is:\n Mode: ASCII\n Baud Rate: 9600bps\n Data Bit: 8\n Parity Bit: None\n Stop Bit: 1\nSHENZHEN RDing Tech CO.,LTD\nwww.PCsensor.com\n```\n\nThis is the mode that temper.py uses. I was not successful getting this device\nto respond to any commands sent via the HID device.\n\nI initially had trouble getting a reply to ReadTemp when using a terminal\nprogram (e.g., cu), but the example in the temper.py works without any\nproblems, perhaps because no newline is sent after the comment.\n\n## Example Command Output\n\n### Help\n\n```\n$ ./temper.py --help\nusage: temper.py [-h] [-l] [--json] [--force VENDOR_ID:PRODUCT_ID]\n\ntemper\n\noptional arguments:\n-h, --help show this help message and exit\n-l, --list List all USB devices\n--json Provide output as JSON\n--force VENDOR_ID:PRODUCT_ID\n Force the use of the hex id; ignore other ids\n```\n\n### List Devices\n\nIn this example, one of the devices doesn't have the HID driver attached\nbecause I was using an libusb-based program to access it.\n\n```\n$ ./temper.py -l\nBus 001 Dev 023 413d:2107 * ??? ['hidraw0', 'hidraw1']\nBus 001 Dev 086 0c45:7401 * TEMPerV1.4 []\nBus 002 Dev 002 04d8:f5fe TrueRNG ['ttyACM0']\n```\n\n### Temperature\n\nIn this example, one of the devices doesn't have the HID driver attached\nbecause I was using an libusb-based program to access it.\n\n```\n$ ./temper.py\nBus 001 Dev 023 413d:2107 TEMPerX_V3.1 26.55C 79.79F 43.41%\nBus 001 Dev 086 0c45:7401 Error: no hid/tty devices available\n```\n\n```\n$ ./temper.py --json\n[\n {\n \"path\": \"/sys/bus/usb/devices/1-1.2\",\n \"busnum\": 1,\n \"devnum\": 23,\n \"vendorid\": 16701,\n \"productid\": 8455,\n \"vendor_name\": \"\",\n \"product_name\": \"\",\n \"devices\": [\n \"hidraw0\",\n \"hidraw1\"\n ],\n \"ident\": \"TEMPerX_V3.1\",\n \"celsius\": 26.55,\n \"fahrenheit\": 79.78999999999999,\n \"humidity\": 43.65\n },\n {\n \"path\": \"/sys/bus/usb/devices/1-1.1.1\",\n \"busnum\": 1,\n \"devnum\": 86,\n \"vendorid\": 3141,\n \"productid\": 29697,\n \"vendor_name\": \"RDing\",\n \"product_name\": \"TEMPerV1.4\",\n \"devices\": [\n ],\n \"error\": \"no hid/tty devices available\"\n }\n]\n```\n\nSimilar JSON output can be generated with the --list option.\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/ccwienk/temper", "keywords": "", "license": "", "maintainer": "", "maintainer_email": "", "name": "temper-py", "package_url": "https://pypi.org/project/temper-py/", "platform": "", "project_url": "https://pypi.org/project/temper-py/", "project_urls": { "Homepage": "https://github.com/ccwienk/temper" }, "release_url": "https://pypi.org/project/temper-py/0.0.1/", "requires_dist": null, "requires_python": "", "summary": "Reads temperature data from misc. \"TEMPer\" devices with minimal dependencies", "version": "0.0.1" }, "last_serial": 5255421, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "7149b25550ae32a491d7bcd79a4cc74f", "sha256": "dcfc1a7f6b9ae579301bbedd2285b714739460824659f790e7ded24368d42924" }, "downloads": -1, "filename": "temper_py-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7149b25550ae32a491d7bcd79a4cc74f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10055, "upload_time": "2019-05-11T08:11:12", "url": "https://files.pythonhosted.org/packages/3e/4c/63d9aba2658845e94e733f457fe23d2268d82d09ae328002452919889da8/temper_py-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bec414dbb4c3fdbcda125f8bf3350518", "sha256": "f4fe8dba051151e126558faf2b9c2b1c00e1367431bbeec64b9cc9a5155339f1" }, "downloads": -1, "filename": "temper-py-0.0.1.tar.gz", "has_sig": false, "md5_digest": "bec414dbb4c3fdbcda125f8bf3350518", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10698, "upload_time": "2019-05-11T08:11:14", "url": "https://files.pythonhosted.org/packages/cc/bb/2f676fdf64be88de068938be2193f091e76c53d277277e07f6153223cdda/temper-py-0.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "7149b25550ae32a491d7bcd79a4cc74f", "sha256": "dcfc1a7f6b9ae579301bbedd2285b714739460824659f790e7ded24368d42924" }, "downloads": -1, "filename": "temper_py-0.0.1-py3-none-any.whl", "has_sig": false, "md5_digest": "7149b25550ae32a491d7bcd79a4cc74f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10055, "upload_time": "2019-05-11T08:11:12", "url": "https://files.pythonhosted.org/packages/3e/4c/63d9aba2658845e94e733f457fe23d2268d82d09ae328002452919889da8/temper_py-0.0.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "bec414dbb4c3fdbcda125f8bf3350518", "sha256": "f4fe8dba051151e126558faf2b9c2b1c00e1367431bbeec64b9cc9a5155339f1" }, "downloads": -1, "filename": "temper-py-0.0.1.tar.gz", "has_sig": false, "md5_digest": "bec414dbb4c3fdbcda125f8bf3350518", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10698, "upload_time": "2019-05-11T08:11:14", "url": "https://files.pythonhosted.org/packages/cc/bb/2f676fdf64be88de068938be2193f091e76c53d277277e07f6153223cdda/temper-py-0.0.1.tar.gz" } ] }