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

Negative temperatures #13

Closed
blinkingbee opened this issue Jun 9, 2017 · 15 comments
Closed

Negative temperatures #13

blinkingbee opened this issue Jun 9, 2017 · 15 comments
Labels

Comments

@blinkingbee
Copy link

Problem with temperatures below zero being logged as large positive numbers (e.g. 4085.3 °C). This is also reflected in the graphs auto-scaling to 4000 °C.

When I read the sensor temperature using a python script with an expression such as echo /usr/local/bin/get_temp.py | head -1 | awk -F. '{print $1"."int(($2/100)+0.5)}'`` this returns the correct negative temperature.

Could this be a problem with how Temperature-Machine reads the sensor and handles signing?

negative temp example

get_temp.py.zip

@tobyweston
Copy link
Owner

tobyweston commented Jun 9, 2017

I can reproduce it with the help of an ice pack!

e1 ff 4b 46 7f ff 0c 10 fe : crc=fe YES
e1 ff 4b 46 7f ff 0c 10 fe t=-1937

screen shot 2017-06-09 at 20 24 59

I think there's a problem in Parser.scala, I was trying to be all fancy and calculate the temperature using the raw byte values rather than use the scratch file pre-calculated value (t=-1.2). It has the advantage of being more precise. See http://temperature-machine.com/docs/ds18b20_sensor.html

I may have been a bit naive with my above calculation. See the spec sheet: I think i'll be better off doing the proper two's complement on the bytes.

@blinkingbee
Copy link
Author

Samples taken at 3 different temperatures with icepack from my freezer:
w1_slave samples.zip

It would be very useful if you could use the pre-calculated value from the scratchpad and thus exchange some precision for valid temperatures below zero.

@blinkingbee
Copy link
Author

blinkingbee commented Jun 9, 2017 via email

@blinkingbee
Copy link
Author

I have updated Parser.scala and ParserTest.scala in both client and server but temperatures below zero still display as large positive numbers. Is there anything else I need to do?

@tobyweston
Copy link
Owner

I haven't deployed myself yet so am still testing. I'll prepare a 'package' once done and close the issue here.

How are you deploying (see http://temperature-machine.com/docs/getting_started.html#setup-the-software).

If you're building from source, you can test by following these instructions having first done the following;

$ git pull
$ git checkout issue_13

@blinkingbee
Copy link
Author

Thanks, maybe I jumped the gun here. I originally deployed using the pre-installed image. If I build from source does this just overwrite the original temperature-machine?

@tobyweston
Copy link
Owner

tobyweston commented Jun 12, 2017

Yep, on the pre-installed image under ~/code/temperature-machine. Just run the above and rebuild the .jar file (steps 2. from these instructions).

So basically,

cd ~/code/temperature-machine
git pull
git checkout issue_13
sbt -J-Xmx512m -J-Xms512m assembly

(You can drop/alter the -J settings if you're not running on a Pi Zero)

Then restart.

Note that this will checkout the branch so once it's merged back into master, you'll have to reverse the procedure (i.e, git checkout master then sbt assembly). I'll merge back after testing and building a new image etc (which will prob take a little while)

Let me know how you get on.

Oh, and I tend to take down the server / hub first to upgrade, then take down each child node. To be super safe, you can take them all down and update, server first.

@tobyweston
Copy link
Owner

Just merged bf10a84 to master so ignore the git checkout issue_13 step...

@blinkingbee
Copy link
Author

I have rebuilt both master and slave as described above but am still getting large positive numbers when temperature goes below zero. Separately monitoring the sensor scratch file pre-calculated value shows the correct negative temperature.

@tobyweston
Copy link
Owner

and the sbt assembly step worked for you? Sometimes it crashes on the Pi because of the limited resources and you have to re-run. Check the timestamp of the temperature-machine.jar file. Something like find . -name "*.jar" from the temperature-machine fold should locate it. Make sure it's been updated.

@blinkingbee
Copy link
Author

-rw-r--r-- 1 pi pi 28515459 Apr 2 14:09 temperature-machine-2.0.jar It looks like it's not been updated so I'll try a rerun

@tobyweston
Copy link
Owner

Cool, when you run sbt assembly (on the Pi zero in particular), it can fail more or less silently. Re-running usually works (but don't sbt clean first).

@blinkingbee
Copy link
Author

blinkingbee commented Jun 13, 2017

Mostly success. My two client units built successfully and the one I've tested displays negative temperatures correctly. However the server returns errors and won't build. I have attached the console output for your comment. I may have to start over with the server if I can't solve it.

$ sbt -J-Xmx512m -J-Xms512m assembly
...
[error] Not a valid command: J-Xms512m
[error] Not a valid key: J-Xms512m
[error] J-Xms512m
[error]

attempted build.txt.zip

@blinkingbee
Copy link
Author

I have fixed server by re-installing from image then rebuilding from git. Great to see 24h time in main graph now and I see you have removed reference to sensor serial numbers too. Thanks for your help.

@tobyweston
Copy link
Owner

Great stuff, glad its working for you! (BTW, if you have more than one sensor attached, it'll display the serial numbers again). 😄

@tobyweston tobyweston added the bug label Nov 14, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants