DB1820 does not work anymore

Just loaded the updated DB1820 library (with OneWire) and it does not work anymore. Back to the previous one. Any idea what is changed yesterday? Platform: STM32H743VIT6 with mbed-os 6.6.0 into Mbed Studio.

Alain

Hello,

for sure, please be so kind and share here a link to the library what you use.

Did you test it also on a different board?

BR, Jan

It is the library from Zoltan Hudak updated yesterday.
No detected sensor. Part of the code not changed for a while:

OneWire oneWire(PB_2);
DS1820* ds1820[SENSORS_COUNT];
int sensors_found = 0; // counts the actually found DS1820 sensors

//Enumerate (i.e. detect) DS1820 sensors on the 1-wire bus
sensors_found = 0;
for(i = 0; i < SENSORS_COUNT; i++)
{
sensors_found = i;
ds1820[i] = new DS1820(&oneWire);
if(!ds1820[i]->begin())
{
delete ds1820[i];
break;
}
}

if (sensors_found == 0)
{
sprintf ( &a_out[0], “No DS1820 sensor found!\r\n” );
rs232_tx ( &a_out[0] );
return -1;
}

Hello Alain,

Thank you for reporting the issue. I added implementation of 1-wire bus using UART hardware and it seems I have modified also something I shouldn’t. Sorry for the inconvenience, I’ll try to fix it as soon as possible.

Best regards,

Zoltan

Try this for now, I’m using this on a F767 and H743.

I had problems on early OS6 particularly if using TCP socket functions.
Best practice is to use the temperature conversion that does not wait to complete.

probe[0]->convertTemperature(0, DS1820::all_devices);

This will NOT block while the sensor(s) are converting, however allow 750ms before reading.

I’m using 5 sensors on one project, some are on 15 meter cable length.

If you get more than two errors on any one sensor you may need to adjust the ‘onewire_bit_in’ timing.
For some reason when connecting to a TCP socket and server functions (Ethernet) you may find errors, so use something like in the example to take a second reading, that fixed my problem, a second read is fast and you do not need to do a temperature conversion to read a second time.

Hello Guys,

The OneWire and the DS1820 libraries should work again also when a GPIO pin is used as 1-wire :slight_smile:
There are now two constructors available to create a OneWire object.

  • If you’d like to bit-banging a microcontroller’s GPIO for 1-wire bus then use the constructor which takes one parameter - the pin name of the GPIO you want to use for the 1-wire line.
/**
 * @brief   Constructs a OneWire object.
 * @note    GPIO is configured as output and an internal pull up resistor is connected.
 *          An addition 4.7k Ohm resistor can connected between the 1-wire data bus/line
 *          and the +3.3V pin,
 *
 *           ----------------
 *          |                |   ----------------------->  +3.3V
 *          |   MBED BOARD   |  |
 *          |                |  |   ------
 *          |          +3.3V |--o--| 4.7k |-------
 *          |                |      ------        |
 *          |                |                    |
 *          |                |                    |
 *          |                |                    |
 *          |                |                    |
 *          |           GPIO |--------------------o----->  1-wire bus/line
 *          |                |
 *          |                |
 *          |            GND |-------------------------->  GND
 *          |                |
 *           ----------------
 *
 * @param   gpioPin GPIO pin to be used as 1-wire bus/line
 * @retval
 */
OneWire(PinName gpioPin, int samplePoint_us = 13);
  • When you’d like a UART to drive the 1-wire bus then create a OneWire object with a constructor which takes two parameters - the pin name of the UART’s Tx pin and the pin name of the UART’s Rx pin.
/**
 * @brief   Constructs a OneWire object.
 * @note    UART is used to implement a 1-Wire Bus Master according to Maxim Integrated application note
 *
 *          https://www.maximintegrated.com/en/design/technical-documents/tutorials/2/214.html
 *
 *          In addition to the 4.7k Ohm resistor between the 1-wire data bus/line and the +3.3V pin,
 *          a 470 Ohm resistor shall be tied to the UART's tx and rx pin. UART's rx pin is then used
 *          as 1-wire data bus/line.
 *
 *           ----------------
 *          |                |   ----------------------->  +3.3V
 *          |   MBED BOARD   |  |
 *          |                |  |   ------
 *          |          +3.3V |--o--| 4.7k |-------
 *          |                |      ------        |
 *          |                |      ------        |
 *          |        UART TX |-----|  470 |---    |
 *          |                |      ------    |   |
 *          |                |                |   |
 *          |        UART RX |----------------o---o----->  1-wire bus/line
 *          |                |
 *          |                |
 *          |            GND |-------------------------->  GND
 *          |                |
 *           ----------------
 *
 * @param   txPin   UART's Tx pin name
 * @param   rxPin   UART's Rx pin name
 * @retval
 */
OneWire(PinName txPin, PinName rxPin, int baud = 115200);

The remaining part of an application program is identical in both cases.

As Maxim Integrated explains it in the related application note, the main advantage of driving the 1-wire with UART is that the burden of bit timing and byte framing operations are offloaded from the main processor to the UART peripheral.

Both interfaces worked for me OK on my LPC1768 and NUCLEO-F446RE boards.
If you happen to experience any problems please let me know.

With best regards,

Zoltan

Hi Zoltan,
It works, thanks!
Regards,
Alain
NB: Happy New Year.