Electrical – Serial bi-directional (one-wire half-duplex) digispark device works however answers itselfs

1-wirearduinoattiny85cserial

I followed this guide to create an one wire bi-directional (debug) device for a Digispark (Attiny85):

https://digistump.com/wiki/digispark/tutorials/debugging (see section Bi-directional Serial Debugging with a single I/O) or see schematic in sourcecode below:

/*
  https://digistump.com/wiki/digispark/tutorials/debugging

                        SERIAL SINGLE I/O
                         DEBUGGING CABLE
            ___________________/\__________________
           /                                       \
                                              ____
 .--------.                                  |    \
 |    GND |--------------------------------+---o5  \
 |        |                           47K  | |   9o |
 |        |                        .--###--' | o4   |
 |  DEBUG |                  4.7K  |         |   8o |
 |  TX_RX |-------------------###--+--|<|------o3   |    ---> To regular RS232 SubD 9 pins Male of PC
 |   PIN  |        ^               | 1N4148  |   7o |         or to RS232/USB adapter
 |        |        |               '-----------o2   |         Connector PIN 2: RX (receive) 
 '--------'        |                         |   6o |         Connector PIN 3: TX (transmit)
  ATtiny85       Single                      | o1  /
 (Digispark)      I/O                        |____/
                                          SubD 9 pins
                                            Female


 Note:

    Trick to be less intrusive: use a �high� data rate (38400 is fine)
      -> less time wasted in ISR and for transmitting each character.
    You can still upload your sketch modifications through the USB interface
    whilst the additionnal serial port is selected as Serial port in the IDE.

*/


#include <TinyPinChange.h>
#include "SoftSerial.h"

#define DEBUG_TX_RX_PIN         3 //Adjust here your Tx/Rx debug pin

SoftSerial MyDbgSerial(DEBUG_TX_RX_PIN, DEBUG_TX_RX_PIN, true); //true allows to connect to a regular RS232 without RS232 line driver

void setup()
{
  MyDbgSerial.begin(9600); //After MyDbgSerial.begin(), the serial port is in rxMode by default
  MyDbgSerial.txMode(); //Before sending a message, switch to txMode
  MyDbgSerial.println(F("\nDebug enabled"));
  MyDbgSerial.rxMode(); //switch to rxMode to be ready to receive some commands
}

void loop()
{
  if(MyDbgSerial.available())
  {
    MyDbgSerial.txMode();
    MyDbgSerial.print(F("\nReceived: "));MyDbgSerial.write(MyDbgSerial.read());MyDbgSerial.print(F("\n"));
    MyDbgSerial.rxMode();
  }
}

The 'device' I created looks like this:
The device #1 - top
The device #2 - bottom
The device #3 - With usb serial COM port


Doublechecking this pinout to be sure (female -> male):
female-to-male


The 'device' works but answers itselfs, there is something wrong (schematic?). For example: When you enter "hello" in the serial monitor, it replies directly with the same "hello" also without a Digispark attached/connected. When Digispark attached/connected, the Digispark seems to receive nothing.


So what could be wrong, is the schematic correct?

Best Answer

Based on that schematic, that's exactly how it will react on your pc console program with or without something attached at the other end. You tied the tx to the rx, essentially a loop back device. Ignore the "echo".

As for your digispark not responding, have you set your console at the right speed and parity and stop settings?