Showing Temperatures on an ‘Analog’ Gauge – InApps is an article under the topic Software Development Many of you are most interested in today !! Today, let’s InApps.net learn Showing Temperatures on an ‘Analog’ Gauge – InApps in today’s post !

Read more about Showing Temperatures on an ‘Analog’ Gauge – InApps at Wikipedia



You can find content about Showing Temperatures on an ‘Analog’ Gauge – InApps from the Wikipedia website

One of the great things about physical computing is that once you get a few basics down, you’ll start to see how you can just plug “modules” together and come up with new projects. Cobble up a few “modules” and you’ll have your own little Off-The-Shelf inventory of useful gadgets, for use in various jobs. Start thinking of modules as software, firmware, hardware, networking, mechanisms, aesthetics, etc. or any/all of the above.

After having decent luck with the ultrasonic range finder gauge last week, I thought it would be useful to try displaying some other values. This week I hooked up the old thermocouple module to the Linux notebook to see how a Processing programming language-based gauge worked with temperatures.

The thermocouple (and amplifier) I used hooks up to an Arduino Duemilanove via the SPI bus. The Arduino was then connected to the Linux notebook by a standard USB cable. Using USB makes the “module” portable between the notebook, a Raspberry Pi and a CHIP computer. The range finder hooked up to an Arduino Pro Mini that then connected to the Raspberry Pi, on the conference badge. Linux is eating the World!

Using a USB port, on any machine, is a little tricky, so let’s start off with a discussion on that topic.

Straightening out the Serial Port

When installing a new version of Linux, a regular user usually doesn’t have access to reading and writing directly to the USB ports. You could change the permissions with the chmod command, although that’s a bit messy and changes as you plug things in and out of the port.

The easiest way to get access is to add the user (rob, in my case) to the “dialout” group. You’ll need to use sudo, for it to work.

Once, that’s finished, reboot the machine, to clean up any old, crazy permissions and log back in.

After you’re back at the desktop, open a terminal and execute the stty command. This sets the port speed. If the port speed doesn’t match the data rate coming from the Arduino, you won’t be able to see data coming in using the “cat” command. What’s more, the indicator line on the gauge, won’t show up either:

Use the following as a quick check, when you are testing data input from the USB port:

With the USB port squared away, it’s time to get the firmware on the Arduino working.

Reading the MAX Thermocouple

At the end of last year, I talked about using a standard K-type thermocouple and amplifier to measure temperature values, in my kitchen oven.

The code for the Arduino came from the MAX3156 example. I modded it a bit, to take out some un-needed “println” statements and add a Celsius to Fahrenheit conversion. I like to see my temperatures in Fahrenheit degrees. Notice too, that I added an “int” type assignment in the conversion. We don’t really need decimals for an analog gauge, so integer temperature values are fine and make the output easier to read.

Read More:   How Eldarion Helped Bring Scalable Python, Django to Gondor – InApps 2022

If you are using a Duemilanove Arduino, go ahead and compile then upload the firmware to the board. If you are using some other Arduino, like a Pro Mini or Uno, make sure you specify the right board under the ‘Tools’ and ‘Board’ drop-down menus.

Test that the code works with the serial monitor, built into the Arduino IDE. Alternately, close out the Arduino IDE and use the cat command.

Read More:   How to Test for API Reachability in Your Apps – InApps 2022

Occasionally, my Arduino IDE setup won’t release the USB port properly. I haven’t run the problem down completely, so if you have continue having problems reading the USB port, log out and restart the machine. Just a heads up.

Displaying a Temperature on the Gauge

The Arduino Pro Mini, in the ultrasonic range finder gauge project sent distance values to the Processing gauge code, registering from 0 to 100 inches. You can have your Arduino output any range that you like. It’s just data.

The particular thermocouple I used can sense temperatures from about -340 to +900 degrees Fahrenheit. That means that the Arduino connected to the thermocouple can send values, in that range out through the USB port.

Now, the ultrasonic range finder Processing gauge program will only swing the needle from 0 to 100. Actually, that’s good enough to prove that the thermocouple can show values on the gauge, to I didn’t even bother to mod the range, for this project. I wanted to show how you could mix-and-match “modules” with minimal changes and still come out with something useful.

All I changed was to replace the “distance” variable with “temperature.” On the face of the gauge, I also changed it to read “Temperature in degrees F” instead of “Distance (in).” Everything else worked pretty much as is.

The lesson here is to get version 1.0 of a new project (even when plugging modules together) working properly. Then you can always go back and change the code for more functionality and capabilities. Don’t try to change too many things at once. Save the files in a version control program or just increment the names, so you can always go back to working code if you get off track.

Here’s the hacked Processing code.

Load the code in the Processing IDE and hit the “Run” button to bring the gauge up on the screen.

Read More:   Are You Cut Out for That Dev Life? – InApps 2022

Don’t forget to get the USB port in the right state, as previously outlined, otherwise, you won’t see a needle on the gauge.

Here’s a screenshot of the thermocouple/gauge reading the temperature in my freezer. Four degrees Fahrenheit! Maybe I should turn it up a notch and save some electricity. Well, the ice cream is never soupy.

Temperature reading of my freezer.

Going Further

There are tons of upgrade opportunities for this project.

Obviously, expanding the range of the gauge is a good first step. Wouldn’t it be interesting to be able to watch the needle swing from room temperature to 350 degrees F, as the oven warms up?

Another idea might be to mod the Processing code to make the gauge fill the entire notebook screen. I could see using this capability to display the temperature of the Pancake Bot griddle, on the notebook or an auxiliary projector screen, during one of our “Have A Short Stack With InApps” breakfast panel discussions.

It might also make sense to convert the Processing gauge program over to Python. Python runs on most Linux machines, including the Raspberry Pi and CHIP computer. The programs run from the command line and don’t need an IDE environment, like Processing. Sure, you can currently create an “application” that runs outside of Processing. I’ve had mixed results running the same code on an Intel Linux notebook or the Raspberry Pi. I could be that Python is more cross-platform capable.

InApps is a wholly owned subsidiary of Insight Partners, an investor in the following companies mentioned in this article: Shelf.



Source: InApps.net

Rate this post
As a Senior Tech Enthusiast, I bring a decade of experience to the realm of tech writing, blending deep industry knowledge with a passion for storytelling. With expertise in software development to emerging tech trends like AI and IoT—my articles not only inform but also inspire. My journey in tech writing has been marked by a commitment to accuracy, clarity, and engaging storytelling, making me a trusted voice in the tech community.

Let’s create the next big thing together!

Coming together is a beginning. Keeping together is progress. Working together is success.

Let’s talk

Get a custom Proposal

Please fill in your information and your need to get a suitable solution.

    You need to enter your email to download

      Success. Downloading...