PlatformIO Community

Adapt MCU UART to 1-wire devices (more reliable than bit-bang solutions)

MCUs have logic blocks with shift registers for serial such as I2C, SPI, and UART. However, there is no such support for 1-wire. Arduino and others use bit-bang solutions to support 1-wire devices such as DS18B20. This is ok for very simple projects but may be buggy for interesting MCU loads because of disabling interrupts and/or spinlocks.

An Maxim application note says that UART can drive 1-wire. Indeed it does and there is no tinkering with interrupts.

My project is found at https://github.com/bobmc-rmm/UartWire. The documentation is in the Changelog in plain text marked up for Doxygen which indexes and cross-references everything including a KiCad schematic.

The platformIO.ini has ESP32 and MEGA2560. There is a Bash script for each board with a menu loop to reduce retyping commands.

Questions or suggestions are welcome.

RMM

1 Like

I added NodeMcu8266 to the platformio.ini so now it is usable for 3 different MCUs. There is an optional menu script to select which MCU is updated.

[env:featheresp32]
platform = espressif32
board = featheresp32
framework = arduino
;; select the Adafruit Feather 32
build_flags =
   -D USE_MCU=1

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino
;; select the mega2560
build_flags =
   -D USE_MCU=2

[env:nodemcuv2]
platform = espressif8266
board = nodemcuv2
framework = arduino
;; select the NodeMcu8266ex
build_flags =
   -D USE_MCU=3
#!/bin/bash

BRD=nodemcuv2
BRD=megaatmega2560
BRD=featheresp32

PS3="Select option for ${BRD}..."

select opt in Init Upload Quit; do

case $opt in
   Init)
     echo "Init..."
     pio project init -b ${BRD}
     ;;

   Upload)
     echo "Upload..."
     pio run -e ${BRD} --target upload
     ;;

   Quit)
      echo "Goodbye..."
      break;
      ;;
      *)
   esac

done