Sunday, July 15, 2018

Preserving pins, auto-transmit RS485 with Lora32_Wifi

This is a story of the always helpful NE555 (in this case its 3.3v cousin the TLC555). I have been designing more and more complex DIN rail energy monitors. The last one is 3-unit DIN rail oeuvre with the following features:
  • Lora, Wifi and Bluetooth thanks to Lora32_Wifi
  • 128x64 SSD1306 Oled screen
  • Three ATM90E36 3-phase energy monitor IC's
  • 3.3V differential line driver for RS485 bus driver
  • Some GPIO's for triggering relays or receiving inputs.
With all these features consuming pins on the ESP32 module I eventually ran out of pins to attach to the RTS line for the RS485 line driver. I could have added many more pins by using an I2C ioexpander and solved my issues, however the RS485 bus on this thing is half-duplex, so there is a much easier way to do this which does not involve any code.

The trick is to use the NE555 in one shot mode, trigger it for a transmit, then let it fall-back to receive after a set period of time. The NE555 is useful in so many ways.