Code Monkey home page Code Monkey logo

Comments (5)

DavidAntliff avatar DavidAntliff commented on September 20, 2024

If I assume you are talking about the DS18B20, take a look at the datasheet on page 8. There are two aspects to consider:

  1. The 64-bit ROM code - this is eight 8-bit bytes (octets), where the LSB is the family code, the next 48 bits (6 bytes) is the serial number, and the last 8 bits (eighth byte) is the CRC. The struct that you pasted is this ROM code.

  2. The scratchpad is nine bytes (see Figure 9) - and yes, the last byte is the CRC byte. But the code you pasted isn't the scratchpad struct, it's the ROM code struct.

The relevant struct is here:

typedef struct
{
    uint8_t temperature[2];    // [0] is LSB, [1] is MSB
    uint8_t trigger_high;
    uint8_t trigger_low;
    uint8_t configuration;
    uint8_t reserved[3];
    uint8_t crc;
} Scratchpad;

This has a size of nine bytes.

Please let me know if this isn't clear.

from esp32-owb.

povi2946 avatar povi2946 commented on September 20, 2024

I see. I am using AWS FreeRTOS which is compiled in C instead of C++, so I was using your library as reference and rewriting it for C and when adding CRC bit I checked OWB library portion.
And inside owb_read_rom() function there is a call for
if (owb_crc8_bytes(0, rom_code->bytes, sizeof(OneWireBus_ROMCode)) != 0)
where sizeof(OneWireBus_ROMCode is 8 and inside ds18b20_read_temp() function there is a line
if (owb_crc8_bytes(0, buffer, 9) != 0) which sets the data length to 9.
Since I was looking for CRC implementation example, I looked only at owb library and it confused me as in my code it works only with the length of 9. I am working with MAX31850K and I know all addresses of the devices I made a very simple implementation of the library and overlooked few things from DS18B20 library.
Thank you very much for helping to clarify things for me and thank you for your work on this library.

from esp32-owb.

DavidAntliff avatar DavidAntliff commented on September 20, 2024

Fair comment - I should get rid of that 9 and use the actual struct size. Thanks for pointing that out.

BTW, this library is written for C & FreeRTOS. It is not a C++ library, although I do have some header guards in case someone does try to compile with C++. Therefore it should work with AWS FreeRTOS out-of-the-box. Also I believe someone has successfully used my DS18B20 library with the MAX31850: DavidAntliff/esp32-ds18b20#4

EDIT: sorry, just noticed you're the same person as issue 4 :)

from esp32-owb.

povi2946 avatar povi2946 commented on September 20, 2024

Hi,
your demo worked perfectly for me, but when I was trying to include it into my AWS FreeRTOS demo I had issues compiling and when I was trying to debug I thought It was something because of C++. Anyways, it just shows how improficient I am. I remember it was something that it couldn't find definition for reset() function which was actually defined as _reset(). Anyways, I could have posted a proper debugging output but new AWS FreeRTOS got released with so many changes in their libraries, so I got occupied trying to migrate to new stuff. I hope in next couple days I will have a chance to give another try of adding your library. I really appreciate your help, thank you for your time.

from esp32-owb.

DavidAntliff avatar DavidAntliff commented on September 20, 2024

I'll address this here: DavidAntliff/esp32-ds18b20#5

Closing this issue for now.

from esp32-owb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.