Component to read DS18B20 digital temperature sensors

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Hi,
Here I am uploading a custom component to read temperatures from Maxim DS18B20 digital temperature sensors. It implements 1-Wire communication to read sensor temperature at 12bit resolution , simultaneously samples data from up to 8 sensors, returns temperature in float, integer and string formats.

   


Attached archive contains component library, component datasheet, two demo projects and screenshots. Tested on PSoC4200 (PioneerBoard) and PSoC5LP (FreeSoC) under Creator 3.1 SP1

   

regards,
odissey1

main_01.PNG

PioneerBoard_01.PNG

RealTerm_02.PNG
 

0 Likes
36 Replies
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

screenshot and datasheet only

DS18B20_Temperature_sensor_01.PNG

0 Likes
ViDv_264506
Level 5
Level 5
50 sign-ins 25 sign-ins 5 solutions authored

 Hi odissey1

   

many thanks for your usefull component. Nice and usefull work.

   

Best regards

   

Viktor

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

Well done! And a sophisticated documentation! I like that.

   

 

   

Bob

ETRO_SSN583
Level 9
Level 9
100 sign-ins 5 likes given 1000 replies posted

Check it in Creator SP2, just released. Consider re-posting it if

   

necessary.

   

 

   

Regards, Dana.

rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

The demo programs are missing the KEES librarys for the Psoc Pioneer board and the Psoc 420 board and gives the folowing errors The instance 'PSoC_4_Pioneer_Kit_1', of component PSoC_4_Pioneer_Kit, contains an error. Unable to locate and customize component 'PSoC_4_Pioneer_Kit' used in schematic 'C:\Users\Bob\Documents\Cypress Projects\one_wire\Demo1\DS18x8_demo.cydsn\TopDesign\TopDesign.cysch'. and Unable to find dependency 'KEES_Library' at 'C:\Program Files (x86)\Cypress\Component libraries\KEES_Library.cylib\KEES_Library.cyprj'. Please verify your project dependencies are correct.. Where can  these updated library's be found? I have tried the one's in the 100 projects in 100 days in PSOC 3.0 and have hot rried them in the PSOC 3.0 and have not tried them in PSOC 3.1 SP2.  Also they do not contain the PSOC 4200 board.

odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

 @bobgoar,

   

The project page PioneerBoard_IMG has wiring diagram attached as an image file, so one can see PioneerBoard arrangements without having KEES library installed. Simply delete the PioneerBoard page which gives errors , it has nothing else but explanation of external wiring.

   

 

   

 The DS18x8 component itself does not use KEES library.  I will update demo project by removing link to this library. I can't remember where from it came, I searched Cypress website, but can't locate one specifically covering PioneerBoard drawing primitive. Can anyone help us to locate it?

   

 

   

odissey1

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Attached updated component. Projects has been recompiled with latest Creator 3.1 SP2 to avoid warning messages. Links to KEES component library has been removed in demo projects to avoid error messages.

   

odissey1

main_01.PNG

PioneerBoard_01.PNG

RealTerm_02.PNG

0 Likes
Anonymous
Not applicable

 I have successfully used odissey1's DS18B20 1-wire component and found it well-documented and easy to use. However, I would also like to use the DS18B20 in a project that requires nearly all of the UDBs for other functions, not leaving enough for the status and control registers of the DS18B02 component. Does anyone know of a PSoC 4 BLE compatible 1-wire component or library that either bit-bangs a GPIO or uses one of the Serial Comm Blocks? If not, I'd welcome any tips to start to roll my own.

   

 

   

I found the website below, which itself references the Maxim datasheet on how to use a UART as a 1-wire master. I'm thinking that, by using the bidirectional digital pins of the PSoC, I wouldn't need the external two-transistor circuit shown.

   

 

   

dangerousprototypes.com/2012/10/28/app-note-using-uart-to-implement-a-1-wire-bus-master/

   

 

   

Thanks,

   

Don

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

 Don,

   

You can use original 1-wire component made by'pavloven'. It uses buried GPIO pin and no Registers required.

   

odissey1

0 Likes
Anonymous
Not applicable

 Thanks! I've downloaded it and will report on what I find.

0 Likes
lock attach
Attachments are accessible only for community members.
NaDo_1344206
Level 1
Level 1
Welcome!

Dear odissey1,

   

Nice work for decoding DS18B20 using PSOC4.

   

I had made one small change in your original code to get its output on 20x4LCD but just getting 3960 on LCD.

   

Kindly help on same. Thanks in advance.

   

Nain.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Nain: You had some issues with your program and your output to the LCD was incorrect and was flagged by Psoc Creator I changed it to LCD_printString and it seems to work.  Also what version of PSOC Creator are you running. I didn't up-grade it to the latest version as I didn't want you to have issues with opening it. Also the Maxim chip will provide the answer in Deg C or Deg F you just have to read the correct Memory location.  You can also convert it with some math °C  x  9/5 + 32 = °F or (°F  -  32)  x  5/9 = °C. I don't have the DS18B20 device to try it so I was not able to read any real data. Also there is a char LCD library that allows you to use any pin on any port so you don't have to loose so many pins in a row.

0 Likes
Anonymous
Not applicable

Hello there,

   

I am using the DS18B20 sensor (only 1 sensor) with your ds18x8 component and I am experiencing some problems (both with psoc 3 and 5). The problem overall is that the sensor is not communicating, both in parasite and normal mode. In parasite in particular I am connecting both GND and VDD to the mass of my psoc and the DQ to a bidirectional digital pin (open drain drives high, initial state high). I tried two configurations: DQ directly to psoc's pin and Dq to pisoc and in parallel to VDD through a 4K resistor; both are not working. (actually in a case psoc 3 had 15.9365 as fixed output, but I have changed the code and can't come back to that window)

   

My code's flow is something like this (I jot it down as pseudocode):

   

-Start DS component();

   

-send temperature request

   

-if data is ready then read temperature

   

-get the temperature thru gettemperatureasfloat and use sprint f to put it into a string

   

-use the USBUART module of the psoc to send the data to the PC

   

The output is always -256.00 !

   

Could you help finding the error?

   

Thanks,

   

Matteo

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        Matteo, The component was not designed to operate with DS18B20 in parasite mode. Never tested, so can't comment. Did you try the demo project provided with the component? Please post your project for review, select project name in Project Explorer window, then File->Create workspace bundle->minimal. Demo project was tested using PSoC5LP and PSoC4 (4200), but not on older PSoC3 / PSoC5 processors.   
0 Likes
Anonymous
Not applicable

Thanks for your reply. 

   

Actually the problem was on the pin input setting, now everything is working properly. Thanks for the component so well written and explained.

   

Matteo

0 Likes
        Matteo, I wander if you able to run it in parasite mode? Can you please share experience.   
0 Likes
Anonymous
Not applicable

how i can import new component?? i use psoc 3.1 sp3. help me, please. i started with CY8CKIT-059 PSoC 5LP

0 Likes

sftwmail,

In Creator with your project opened: select in Workspace explorer window the Components Tab.  

Then click right on Project and  select Import Component.

  

See instructions video

PSoC Creator Tutorial-Importing Components | Cypress Semiconductor 

 

0 Likes
lock attach
Attachments are accessible only for community members.
GrLe_1336286
Level 3
Level 3
25 replies posted 10 replies posted 5 replies posted

Thanks also for this OneWire component and great forum example projects!

   

OneWire works without any problems on CY8CKIT-049-42XX. I have moved this component into a similar project and used the serial port only. The Cypress 'tidbit' was included for resetting the 049 board, using SW1 to place the board into bootloader mode, after SW1 is pressed for 2 sec.

   

Greg

0 Likes
lock attach
Attachments are accessible only for community members.
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted

Attached below is updated project for PSoC5LP KIT-059 board. Last compiled using Creator 4.0. No changes to the component itself.

/odissey1

DS18x1_schematic_01.png

DS18x1_KIT-059_01.png

DS18x1_Terminal_01.png

Hi,

I just started this, I don't have the files in the "generated source" folder, where can I get them?

0 Likes

user_6029920,

I am not sure what the question about. The "Generated  source" folder should not be of any concern.

To add component to the project, please (1) download the library DS18x8.cylib.zip from the previous post and unzip it in any folder of your choice. (2) Open your project (or the demo project provided with the library). (3) follow this 1-minute video tutorial on how to add the library to the project (Project->Dependencies->Add...).

http://www.cypress.com/video-library/PSoC-Software/psoc-creator-tutorial-adding-library-dependency/1...

/odissey1

0 Likes

Hi,

I don't know if you are still monitoring this item, but I have a problem that perhaps you can help with.

Usine a CY8CKIT-059 - trying to interface with a DS18B20 using component 18x8

I've imported the 18x8 component from the project you posted and moved the *.c and *.h files to their appropriate folders.  I have set the component's number of sensors to '1' and tried to build.  The compile fails and says that the netting is looking for 8 inputs but there is only 1 connected.

the error says the 'fitter' failed because "sdb.M0024 - pin_1.io_0 with width=1 connecting to net_80[7:0] with width=8" and it says this needs to be changed.

How do I fix this?  I tried setting back to '8' and just connecting 1 input but that didn't work.  I looked at the .c and .h files to see if this is a setting in code but I don't see anything that suggests it might be the culprit.

Can you help?

Rich

0 Likes

Rich,

Based on your description I am a bit concerned how the component was imported into the project. Importing a component does not require adding *.c or *.h files (all is handled automatically by the Creator). Also, the component was provided as a library, which can be used without explicitly importing the component to the project.

The easiest way is to start with ready-to use project DS18x8_demo1.cyprj from thread #20 (above). The project already has DS18B20 component imported, you may further modify project for your needs.

Second option to import component from another project:

https://www.cypress.com/video-library/PSoC-Software/psoc-creator-tutorial-importing-components/10775...

The DS18B20 component is also available as a stand-alone library (DS18x8.cylib, see #20 above), which does not require importing component into the project. This is standard way of using components. Please follow the steps to add library into your project:

1. Unzip library DS18x8.cylib.zip in the folder of your choice.

2. In Creator: Project -> Dependencies->User dependencies->New entry (folder icon)  browse to the just unzipped library folder and open DS18x8.cyprj.

3. Done! Now DS18x8 component appears in Components panel (Default)

See demonstration here:

https://www.cypress.com/video-library/PSoC/psoc-creator-tutorialcomponent-creation-adding-library-de...

/odissey1

0 Likes

Hi odissey1,

Yes, I can see how my steps would be confusing.  When I began working on this I had tried importing the DS18x8 component into my own project from one of the bundled projects higher up the reply chain, and when the compile problem presented itself I tried bringing in the .c and .h files to see if that would correct it.

So thanks for pointing out the library, that is really the way to go I think.  I'll remove my previous attempts at doing this and import that library using the procedure you graciously listed out and.I'll let you know how it all comes out.

Thanks again

Rich

0 Likes

Odessy1,

Oops!  Problems with compiling with the library attached.  It complains about versions.

I'm using PSOC creator 4.2 and the target is a CY8CKIT-059.  All components are updated as of 10 minutes ago.  Library import went smoothly just as you described but the build fails.

Rich

Library Errors.jpg

0 Likes

Rich,

The project in post #20 was compiled with Creator 4.0. I will test it with Creator 4.2 in the evening. Should work.

/odissey1

0 Likes
lock attach
Attachments are accessible only for community members.

Rich,

Here is same demo from post #20 (with DS18x8 imported into the project). It was compiled using Creator 4.2, no problems detected.

/odissey1

0 Likes
lock attach
Attachments are accessible only for community members.

Rich,

Here is same demo as above, but now using DS18x8 component as an external library. Tested in Creator 4.2. No issues detected.

/odissey1

0 Likes

Odessy1,

I pulled in both the copy of the library you sent as well as the project you supplied.

The project compiled but gave me warnings about my clock tolerance, no biggie.

I then went to my project and imported 18x8 in from the demo you sent.  The errors changed a bit.  I compared settings for the component and the pin I'm using and they match.

Here are the errors.  Again, board CY8CKIT-059, Creator 4.22.  Using I2C and a UART for other functions.

Appreciate your help.

Rich

190425-18x8-error.JPG

0 Likes

Rich,

I believe that the difference in the Pin_1 settings. Please copy/paste Pin from the original project supplied above. Else you can post your project for review here: (1) Click project name in Creator's Project Explorer panel; (2) File->Create workspace bundle->minimal, (3) Inside created archive please delete "Generated_source" folder to reduce archive size.

/odissey1

0 Likes

Hello, Is it possible to read 8 DS18B20 sensors on one bi-directional pin? I am not very good at programming and it is necessary for further research. Can you help me with the software? I tried but unfortunately I can not understand it .. I'm using PSOC creator 4.2 and the target is a CY8CKIT-059. On eight pins, the previous example works but this is not the purpose of my further research ... I need to have communication using one pin ... I would be extremely grateful for the help I received.

Cordial greetings

Maciej111.PNG

0 Likes

Maciej,

DS18B20 has an option to connect multiple sensors on a single communication wire, but DS18x8 component does not support that feature. It was originally developed to monitor electronic equipment in the environmental chamber, where thermal conditions had to be sampled simultaneously troughout the system under test.

Did you run out of pins on the KIT-059 or there is some particular reason to use a single pin only? Can you simply switch to a kit with a larger pins count, e.g. Sparkfuns' FreeSoC2?

/odissey1

0 Likes

odissey1

Thank you for your comprehensive response. Ok Why I understand why this item does not work on a single pin... Yes, the reason is that I need to do any research for my work using these sensors and I have imposed that it must be a network connected by one bidirectional pin. Communication is done in this way.  I have the task to do the rest of the test, as the different wiring arrangement on the sensors or their topologies, the execution of various types of measurements, times, etc. But I can not set the program that these sensors work on one network and I do not have anyone who could help me in this.... Unfortunately I'm not a programmer and not too much on this so well I know to convert. From what I read it I understand that the proper order of reading them, saving and sending the appropriate commands must be implemented. My programming skill, however, is not so good that I remade it.

I would be immensely grateful for your help in this matter. Without this, I cannot proceed further to any further research.

Maciej

0 Likes

Maciej,

Communicating to multiple 1-Wire devices on a single line is rather cumbersome. I won't be able to help you at this time. For a detailed explanation please refer to the Book of iButton Standards:

https://www.maximintegrated.com/en/app-notes/index.mvp/id/937

0 Likes

Well,

thank you for your willingness.
I have already read this note. As I wrote earlier, I understand that it is necessary to set the reading, reset, bus readiness, etc., but I can not implement it in the program ... Although it seems very simple for others.


Greetings

0 Likes