CircuitGizmos

Electronic Products for Creative Minds

  • Home
  • Gizmo Store/Products
  • Documentation/Datasheets
  • Projects/Libraries
  • GizmoBlog
  • Services/Contact
    • Design
    • Contact Gizmo!
  • Your Gizmo Cart
    • Your Account
You are here: Home / GizmoBlog / MMBasic Language / Input and Output / Measuring Temperature

Measuring Temperature

The DS18B20() function will get the temperature from a DS18B20 temperature sensor. This device can be purchased on eBay for about $5 in a variety of packages including a waterproof probe version.

MMBasic 5.0: DS18B20() has been renamed to TEMPR(), DS18B20 START is TEMPR START.

The DS18B20 can be powered separately by a 3V to 5V supply or it can operate on parasitic power as shown on the right. Multiple sensors can be used but a separate I/O pin and pullup resistor is required for each one.

To get the current temperature you just use the DS18B20() function in an expression.

For example:


PRINT "Temperature: " DS18B20(pin)


Where ‘pin’ is the I/O pin to which the sensor is connected. You do not have to configure the I/O pin, that is handled by MMBasic.

The returned value is in degrees C with a resolution of 0.25ºC and is accurate to ±0.5 ºC.  If there is an error during the measurement the returned value will be 1000.

The time required for the overall measurement is 200mS and the running program will halt for this period while the measurement is being made. This also means that interrupts will be disabled for this period. If you do not want this you can separately trigger the conversion using the DS18B20 START command then later use the DS18B20() function to retrieve the temperature reading. The DS18B20() function will always wait if the sensor is still making the measurement.

For example:


DS18B20 START 15 < do other tasks > PRINT "Temperature: " DS18B20(15)


 

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

A Ton of Documentation

Open all | Close all

Projects made by Gizmo, Friends, and Members

open all | close all

Recent GizmoBlog Musings

  • Altair 8800 using a ColorMax!
  • Re-energizing the ColorMax, Pt. 3

Visit us!

  • Facebook

Electronic Products for Creative Minds

CircuitGizmos is your source for electronic products that help you create your embedded projects. Here at CircuitGizmos.com you will find a friendly store filled with creative products and all of the documentation that you need to use these gizmos.

We create devices that we believe make electronics fun, but we also know that our products are used for professional designs. For decades we have designed products for commercial, military, and medical industries. Our gizmos here are great for engineers and hobbyists alike.

Copyright © 2008+ CircuitGizmos, L.L.C. All rights reserved

Image already added

Recently Viewed Products

Copyright © 2023 · Generate Pro Theme on Genesis Framework · WordPress · Log in