Arduino Forum

Topics => Device Hacking => Topic started by: nucleaireqc on Dec 23, 2017, 03:08 am

Title: How to emulate a Dallas (DS2401)
Post by: nucleaireqc on Dec 23, 2017, 03:08 am
For some post, I found nothing.

I'm asking for help to emulate a DS2401 to replace the serial number with another one.

Someone told me that these possible!

Tank You
Title: Re: How to emulate a Dallas (DS2401)
Post by: Riva on Dec 23, 2017, 09:57 am
Maybe Mr Google can help you but a search for "arduino 1-wire emulator" gives this (https://github.com/orgua/OneWireHub) as the top result.
Title: Re: How to emulate a Dallas (DS2401)
Post by: nucleaireqc on Dec 23, 2017, 06:14 pm
Thank you, I did the test but I just want to change the serial number for another and he found me talking about temperature.
Title: Re: How to emulate a Dallas (DS2401)
Post by: Riva on Dec 24, 2017, 11:14 am
Thank you, I did the test but I just want to change the serial number for another and he found me talking about temperature.
Not quite following your reply. I think your saying you tested the code (did you remember to set the serial number to the one you need) but not sure what your referring to about temperature. The DS2401 example is not ideal but you can trim it down to it's bare essential. I cannot test the code here at work as I only have one spare Arduino today so cannot generate the serial and test reading it on another Arduino.
Code: [Select]
/*
 *    Example-Code that emulates a DS2401
*/

#include "OneWireHub.h"
#include "DS2401.h"  // Serial Number

constexpr uint8_t pin_led       { 13 };
constexpr uint8_t pin_onewire   { 8 };

auto hub    = OneWireHub(pin_onewire);
auto ds2401 = DS2401( DS2401::family_code, 0x00, 0xA0, 0x01, 0x24, 0xDA, 0x00 );    // Work - Serial Number


void setup()
{
    Serial.begin(115200);
    Serial.println("OneWire-Hub DS2401 Serial Number");

    // Setup OneWire
    hub.attach(ds2401); // always online

    Serial.println("config done");
}

void loop()
{
    // following function must be called periodically
    hub.poll();
}