ESP32 - Onewire library

Posted on
  • Any ideas how I can debug onewire library?

    I think my wiring is ok, however ow.search() is not returning anything.

    Would the onewire lib be using timer functions that might not be implemented properly yet?

    I added this to get around an error, but have not got any futher:

     case JSHPINSTATE_GPIO_OUT_OPENDRAIN_PULLUP:
        mode = GPIO_MODE_OUTPUT_OD;
       pull_mode=GPIO_PULLUP_ONLY;
        break;
    
  • Personally I'd say you probably want to put a logic analyser on it and compare with a board that does it properly.

    The OneWire library itself should be pretty good now (i mean, it's worked fine on pretty much every architecture) and the only external things it uses are:

    • out_opendrain_pullup
    • the delay function
    • disabling IRQs

    You found the first two, so if they work fine then about the only thing it could be is IRQs jumping in and causing problems.

    Of course if it's like the ESP8266 then it actually 'caches' flash data in RAM and executes from that. If the OneWire + GPIO + delay code isn't in the correct section, it may end up having to be loaded on demand, which would mess up the timings.

  • Thanks @Gordon

    Ok. Maybe time to justify/invest in a logic analyser! Any recommendations? (cheap)

    Using a poorman's Led on the signal line, I can see it glowing dimly.

    The disable/enable interrupts are just stubs at the moment, as the espruino was pinned to a core I was wondering if that was not important - but probably is!

    Time to read the sparse documentation again!

  • I tried a few things to disable interupts but no cigar at this point

  • I'm having trouble communicating with a DS18B20 Temp sensor, the code works on the 8266 but not on the 32. Also for some reason since setting up the wifi, Espruino IDE wont connect via usb to the board, only over wifi.

  • a. One wire

    Which build are you using? Please try the latest binary:
    http://www.espruino.com/binaries/travis/­5e9489ee5936f24d2684588ff42393b76105cb23­/espruino_esp32.bin

    Please post you script and describe your wiring - Are you using a pull up resistor? Which pin?

    I have had success with using D22 and so has @JumJum

    b. I have had issues with the IDE on serial too.

    i. Is this just after flashing or all the time?
    ii. which OS?
    I have success connecting with putty (serial on windows) and then disconnect that and the connect ok with IDE

    I have a theory that after flashing, the USB port is left in a strange state.

  • I've downloaded the firmware above and flashed with that:

    process.env
    ={
      "VERSION": "1v91.374",
      "BUILD_DATE": "Mar  4 2017",
      "BUILD_TIME": "13:37:12",
      "GIT_COMMIT": "5e9489ee5936f24d2684588ff42393b76105cb2­3",
      "BOARD": "ESP32",
      "CHIP": "ESP32",
      "CHIP_FAMILY": "ESP32",
      "FLASH": 0, "RAM": 524288,
      "SERIAL": "240ac400-2f90",
      "CONSOLE": "Serial1",
      "EXPORTS": { "jsvLock": 1074761212, "jsvLockAgainSafe": 1075125944, "jsvUnLock": 1074763152, "jsvSkipName": 1074778216,
        "jsvMathsOp": 1074787824, "jsvMathsOpSkipNames": 1074791308, "jsvNewFromFloat": 1074773388, "jsvNewFromInteger": 1074773300, "jsvNewFromString": 1074772312,
        "jsvNewFromBool": 1074773360, "jsvGetFloat": 1074782172, "jsvGetInteger": 1074776600, "jsvGetBool": 1074782920, "jspeiFindInScopes": 1074800584,
        "jspReplaceWith": 1074800352, "jspeFunctionCall": 1074809836, "jspGetNamedVariable": 1074802216, "jspGetNamedField": 1074802600, "jspGetVarNamedField": 1074802708,
        "jsvNewWithFlags": 1074772040 }
     }
    

    Using:

    var p;
    if ( process.env.CHIP_FAMILY == 'ESP8266' ) p=NodeMCU.D4;
    else p = D23;
    var ow = new OneWire(p);
    ow.reset();
    var d=require("DS18B20");
    var sensor = d.connect(ow);
    console.log(sensor.getTemp());
    console.log(sensor.getTemp());
    console.log(ow.search());
    

    I have two sensors connected and see:

     _____                 _
    |   __|___ ___ ___ _ _|_|___ ___
    |   __|_ -| . |  _| | | |   | . |
    |_____|___|  _|_| |___|_|_|_|___|
              |_| http://espruino.com
     1v91.374 Copyright 2016 G.Williams
    Espruino is Open Source. Our work is supported
    only by sales of official boards and donations:
    http://espruino.com/Donate
    >24.9375
    24.9375
    [
      "28cc2e230500006b",
      "283260dc04000001"
     ]
    =undefined
    > 
    
  • Thanks, I have it working now, I was using 1v91.381 firmware before which didn't work.
    The putty trick also seems to work though is not ideal, having to reconnect each time..

  • If your join the esp32 to wifi, you can then enter it's pi address in
    settings->communications, and then connect to it via wifi.

    Upload of code is much faster too!

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

ESP32 - Onewire library

Posted by Avatar for Wilberforce @Wilberforce

Actions