How To - 1-Wire Interface with Arduino!

preview_player
Показать описание
For inquiries or design services:

This video shows how to work with the DS18B20 1-Wire Temperature Sensor:

The Code:

Version 2 - Fixed a whole bunch of stuff

Note! Timing might be a little off, let me know if any issues.

And since this video is soooo long, here are the links to the different parts of the video:
1:55 Hardware Breakdown
4:25 Code Walkthrough Starts
6:17 How to get the temp of one device on the Bus
7:34 Reset the Bus
9:47 Writing a Byte to the Bus
12:24 Reading the Scratch Pad
13:45 Performing the CRC Check of the Scratchpad Read
17:27 Temperature Calculations
24:30 Get the ROM Address of a single Device
27:00 Reading a Byte from the Bus
28:30 Get the temperature of a Device with a specific address
31:21 Write to the Scratchpad
34:00 Search the Bus for devices
41:30 Code Walkthrough of the Search Function
51:00 Searching the Bus for devices that are Alarming
52:35 Demonstration of the Alarm Function


Thanks to all the Patrons for dropping a few bucks in the tip jar to help make these videos happen!

For inquiries or design services:
Рекомендации по теме
Комментарии
Автор

One remark about your bit fiddling to get the right temperature: It is quite easy when you realize that the temperature is a signed int with the value of the temperature * 16. Simply divide by 16 and you have your temperature. This works for all resolutions (9-12 bits), but for resolutions lower than 12-bit you have to mask the lower bits.

wnieuwenhuis
Автор

Excellent breakdown on the coding and function of the device. Thank you for sharing.

fredflintstone
Автор

Thank you very much for all of the work you've put into this.

justinh
Автор

Fantastic video, Kevin. I'd played around some with the DS1820 back when it was still Dallas Semi, but long before the Arduino stuff was around. I was using the Scenix SX series chips, which meant I had to write everything in assembler, which was a huge pain! Seeing this done with a high level language and the Arduino has me excited to start playing again.

mitchmiller
Автор

Awesome! Great teaching. You really master your stuff. Pulling so much from such a small chip is a tour de force I think. Keep doing those teachings. They are valuable.

jimviau
Автор

Great video, If i ever need to do temperature reading in a project i will definitively check this Ds18b20, the fact that you can use a ton of devices connected together is very useful, thanks taking the time to make this video.

stephanenadeau
Автор

Me : pfftt a 55 minute video ? yeah right



55 mins later ' omg has it been 55 mins ?'



felt like 5 mins and totally brilliant, informative and genius

familyplans
Автор

Thanks Kevin, jumped backwards and forwards through the video a bit but, nonetheless, made it through to the end. This is exactly, well almost exactly, what I need to monitor the temperature of 18650 cells as they charge.

jameslamb
Автор

DS18B20 - Such a simple device, until I read the data sheet. Thank you for making it simple(?) again and at least possible.

ribb
Автор

dude.. your timing is scarily awesome! just got a couple of DS18B20s..
planning to hook em up to a nano and display temp on a 3 bit seven segment display to monitor the temps of the motor, battery and such on my RC :D

mriloveethanol
Автор

Excellent. I've watched some of your other videos and you're really good at this. Will be sure to watch the rest.

turnwrightrules
Автор

Excellently put together Well done! That's why your "Top 4 under 40"

GraemeHunter_UK
Автор

love your videos and learn a lot.  I wanted to ask for a 'bitshifting and operands 101' video.  I have a firm knowledge of binary, hex, and gates but using the operands and bitshifting is confusing to me at the software level.  probably because my background up until the past 2 years has always been primarily hardware.  two's compliment is something i've had to work with and would really like that to be included, if you decide to do a bitshifting / operands video tutorial.

relicwebmaster
Автор

great explanation. Thanks for explaining ✨✌🍀

AjinkyaMahajan
Автор

It is almost impossible to follow the software from the Video. Where is the listing so I may follow your fine video?

davewreski
Автор

wow good info, surely there is a library to do all this now...

tablatronix
Автор

What a great tutorial, im new to the arduino and ofcourse also the 1-wire devices. I have already got at much better understanding of how this works in general. i liked and subbed because of this. :) Also i have three questions about the firs part:

Instead of using "DSB_get_temp_one_device(7, 1);" could you use "lcd.write(float tempC_decimal=0.0000); in order to get it visualized on a display?

If you change "tempC_decimal=0.0000" to "tempC_decimal=0);" would the temperature then be displayed in a number without decimals?

And how simple can you make the code to save time for the arduino to convert? The reason im asking is because im constructing a smoking oven, or a smoker with just this one thermometer to open and close a hatch, i have everthing figured out except the ds18b20. It also have a display which shows the temp you select with a potmeter, thats why i would prefer the 750msek converting time :)


I know i could just try it out, but my arduino is currently unavailable to me, and the 1-wire devices aspect of the arduino universe is quite new to me, as the arduino it self. So if its not possible or changes something about what is expected in the code i would have a hard time finding out. Thank you in advance for taking time to read this! :)

jesperrasmussen
Автор

Hi i would like to thank you for the explanation, I do have one suggestion for converting to temperature ... one could do as follows

when you read and check the CRC, you could just bitshift whole MSB anded with 10000111 + LSB and than divide with 16.00 as last four bits represent decimal part -> 2^4=16.
Note that i have also left the sign bit when anding.


little something like - "signed float tempDS18 = (LSB + ((0b10000111 & MSB)<<8))/16.00;" ...in just one line;)

it might help someone else ;)

Anyway thnx for the great tutorial

majstr
Автор

Hi Kevin,

Thanks for the great job on your videos. I really enjoy them and have learned a lot from them.

This specific one tho, I just cant seem to understand this CRC. I've seen your code, your explanation in the vid but no can do maan.

Can you please do a video on just CRC.

Thank you.

sidharthap
Автор

Thank you! kevin~ helpful code and video!

박정은-vw