How could I creat a lib for DS18b20 temperature sensor?

Issue #315 resolved
Tom Ming created an issue

Hi @John Maloney ,

I would like to use DS18b20 temperature sensor with MicroBlocks.

How could I creat a lib for DS18b20 temperature sensor? Could I use MicroBlocks IDE to do it?

Thanks.

Comments (4)

  1. John Maloney repo owner

    The timing for the 1-wire signals is very tight: a 15 usec low pulse for a 1 and 60 usec for a 0. That's right on the edge of what you can do in MicroBlocks code without the help of C code baked into the virtual machine. It might work, but it is likely to be unreliable, especially when multiple tasks are running.

    If you just want to measure temperature, I'd suggest using a DHT-11/DHT-22 or an I2C temperature sensor instead. MicroBlocks already has low-level support for the DHT-11/DHT-22 and I2C libraries are usually easy to write in MicroBlocks.

    Or, if you're interested in how low-cost devices communicate with a microcontroller, you could try to implement the 1-wire signals described in the DS18B20 datasheet.

    Longer term, we might consider adding support for 1-wire to MicroBlocks to make it possible to write libraries to support 1-wire devices like this one.

  2. John Maloney repo owner

    I've created an proposal proposing to add 1-wire support to MicroBlocks.

    Meanwhile, I see that C WEIB has been added support for the DS18B20 to the ESP32 VM here.

  3. Log in to comment