Copyright © https://mongoose-os.com

Mongoose OS Forum

frame
ATTENTION! This forum has moved to:

https://community.mongoose-os.com

Do not post any new messages.

onewire device id?

mtraxmtrax Canberra
Hi,
if I have two devices on the one-wire bus DS18B20 , how do I get device-id? what field is that?
have you an example of extracting and displaying that?

Comments

  • ruru
    edited May 2017
    1-Wire devices have a unique 64-bit address, which is also called the ROM number. The least significant 8 bits of the address give the family code of the device. The next least 48 bits give the serial number of the device. The next 8 bits give the CRC generated from the least 56 bits. You can read ROM numbers of devices with search() function.
  • mtraxmtrax Canberra
    Thanks for the reply,  can I call this from JavaScript program.

  • mtraxmtrax Canberra
    edited May 2017
    it would be great if a method in the onewire object would return a human readable device# so I can assign it to a location or do logic on the value etc..
    ie I'm using the mjs code to retrieve the temp which is great but a little complex for such a simple operation , I'm sure it was alot simpler in Arduino
  • ruru
    edited May 2017
    Yes, in a few days you'll can use some Arduino drivers for DS18B20. You'll can just call a getTemp() etc.
  • mtraxmtrax Canberra
    edited May 2017
    Excellent, can't wait ,thanks nice os
  • mtraxmtrax Canberra
    Btw I'm hoping this new code also returns device#, as I need get this to figure out which location or device as I have multiple.
  • The latest os release has api_onewire.js example.  I made a rough test using this example.  I convert the device's address into a hex string to represent device ID.  Here is the code snippet.
  • SergeySergey Dublin, Ireland
    @tomsim thank you for sharing the example!
  • mtraxmtrax Canberra
    thanks that helps a little, I will have to decide on what language to use? I was hoping to use mjs as its quicker and easier to write, as I what to use the RPC api to extract data via Web request.
    I wonder if its more efficient to use mjs for RPC and C for one-wire calls.
    anyway I will have a play with this on the weekend.
    thanks for all your help 
  • Hello,

    if I click on the link from here:
    The latest os release has api_onewire.js example. I made a rough test using this example. I convert the device's address into a hex string to represent device ID. Here is the code snippet.

    Only an empty screen with menu and header is displayed. No code is shown. I can display the list with all snippets, but I can´t see code.
    I testet chrome and firefox on ubuntu .

  • See the arduino-onewire example app

    Thanked by 1Capsicum
  • Thanks. It works.

Sign In or Register to comment.