Monday, March 14, 2016

Step Two for Minecraft Virtual Thermometer Project: Rising Temperature Causing Thermometer to Grow

The Pimoroni Explorercraft project I discovered has code that converts the voltage readings from the temperature sensor to Celsius, not Fahrenheit data. I spent about an hour searching for information on how to write python code that would do Farienheit conversion, but just couldn't find enough helpful info to figure out the new code I needed to write to replace the following original code for Celsius format:

while True:
temperature = 25 + (explorerhat.analog.one.read() - 0.75) * 100
print("The temperature is {}c".format(temperature))
thermometer.update(temperature)
time.sleep(0.1)
Hopefully, with  a bit of help from online forums, I'll figure out the Fahrenheit code rewrite.

I then ran into problems with having the RPi Model B+ crashing. I had the overclock settings in the Raspberry Pi configuration set to Turbo overclocking, and I think that was causing the RPi to crash when I tried to run Python IDEL and Minecraft simultaneously. I then set the overclocking to medium and the crashing stopped. It did take me a while to figure out that cursor control with Minecraft the Pi Edition was a bit glitchy... you can only gain control of the basic RPi cursor after you hit escape in Minecraft. Then to regain cursor control you have to get the cursor to hover over the Minecraft window and click.

Once I was able to run the python file, see the temperature sensor read-outs in the Python Shell, and finally see the virtual thermometer in the Minecraft scene, I realized that I couldn't get the temperature readings to go up beyond 30 degrees Celsius while griping the TMP36 sensor with my fingers. To see any visible changes in the virtual thermometer height I had to cool the TMP36 down with an ice-pack. Once I got the temp down to 20 C degrees I finally got some visible results.

Minecraft Pi Edition - Virtual thermometer controlled by TMP36


Minecraft Pi Edition - Analog bars controlled by rotary potentiometer



No comments:

Post a Comment