1-wire and SD-Card

  • Hello,
    I have the problem that I can no longer address 1-Wire DS18B20 sensors when I have accessed the SD card. I have already tried connecting the sensors to different pins (2, 5 and 26). Without accessing the SD card, I can query the sensors without any problem.
    What can be the reason for this?
    I have used several libraries for the DS18B20 sensors in combination with the oneWire library from Paul Stoffregen

  • Hi @hague is there any way you can paste your code here so we can take a look? also, are you using Arduino IDE / UIFlow or MicroPython?

  • @zontex Haha you say UIFlow, there is no 1-wire support!
    To my knowledge the "stack" is not really stackable because of a design flaw, using pins for addressing modules, and not a bus!

  • @zontex OK, you're right, without code it's hard to help. Sorry, my mistake.
    In the meantime, I tried a little more to understand the problem better. It's not that the 1-Wire connection doesn't work anymore at all. It's just that the devices are no longer found immediately on the bus after a lot of data has been written to the SD card.
    In detail, this call does not find any devices after I have previously written a large block of data to the SD card:

    device_count = DS18B20.getDS18Count();

    But if I call DS18B20.begin() twice, all devices are found. Therefore I have placed the function in a loop:

    int trial_count = 0;
    int device_count = 0;
      device_count = DS18B20.getDS18Count();
    } while (device_count == 0 && trial_count < 10);
    M5.Lcd.printf("\nDevices found: %i\nafter %i tries\n\n", device_count, trial_count);

    Now all devices are found after one call, if I did not write any data to the SD card before. However, if I write a larger amount of data to the SD card in between, then 2 attempts are needed until all devices are found.

    I think the 1-Wire bus is somehow disturbed by the transfer of the large amounts of data. This does not happen with small data. Anyway, the solution is OK and makes sense.

  • God day Hague!
    I would appreciate if you can explain how to get DS18B20 (multiple sensor on 1 wire) to work in UIFLOW. Tryed for days to find anything about it on web but get only one fantastic way to get it work only for one sensor.
    Please share your knowledge :)

    Best regards Dario