Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue when running script #1

Closed
DRussellSTFC opened this issue Jan 13, 2022 · 3 comments
Closed

Issue when running script #1

DRussellSTFC opened this issue Jan 13, 2022 · 3 comments

Comments

@DRussellSTFC
Copy link

DRussellSTFC commented Jan 13, 2022

I have tried to use the script with my own PT8005 device for sound meter monitoring however I get the following output error:

root@raspberrypi:/pt8005# ./pt8005_influx.py
Connecting to serial port ...
Connecting to InfluxDB ...
Reading data from PeakTech 8005 ...
Traceback (most recent call last):
File "./pt8005_influx.py", line 140, in
main()
File "./pt8005_influx.py", line 135, in main
value = pt.stream() # Read from serialport
File "./pt8005_influx.py", line 89, in stream
value = (part1*10)+int(part2.hex())+(int(part3.hex())/10)
ValueError: invalid literal for int() with base 10: '0c'

I have printed variables part1, part2 and part3:

3
b'\x05'
b'\x08'

@void4main
Copy link
Owner

Haven't used it for while ... Have to check what my output is.

@void4main
Copy link
Owner

I guess the problem is somewhere else:

Python 3.6.9 (default, Dec  8 2021, 21:08:43)
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> part1 = 3
>>> part2 = b'\x05'
>>> part3 = b'\x08'
>>> type(part3)
<class 'bytes'>
>>> value = (part1*10)+int(part2.hex())+(int(part3.hex())/10)
>>> value
35.8

This looks good. Do you use Python3?

@DRussellSTFC
Copy link
Author

DRussellSTFC commented Jan 14, 2022

Thank you for the reply, yes using python 3.7 on debian. It magically seems to be working now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants