0
\$\begingroup\$

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?

\$\endgroup\$
3
  • \$\begingroup\$ go with a 3 or 4 wire system \$\endgroup\$
    – D.A.S.
    Commented Sep 20, 2017 at 23:51
  • 1
    \$\begingroup\$ If the serial monitor displays what you type, even with no external device connected, the serial monitor program may have "Local Echo" enabled. \$\endgroup\$ Commented Oct 17, 2018 at 22:01
  • \$\begingroup\$ I’m voting to close this question because it is a debugging question which has been abandoned for years without necessary follow up effort to identify the problem. No resolution is possible without such action by the asker. \$\endgroup\$ Commented Sep 4, 2020 at 16:00

2 Answers 2

1
\$\begingroup\$

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?

\$\endgroup\$
1
  • \$\begingroup\$ Thank you for the quick answer. Take a look at my code, everything is set to default, just for testing. The USB serial adapter using defaults too. If I send just "hello", the serial monitor shows nothing. If I enter "hello"in the serial monitor, it replies with "hello". \$\endgroup\$
    – Codebeat
    Commented Sep 20, 2017 at 23:16
0
\$\begingroup\$

you may want to consider this instead. ...........

enter image description here

The Tx/Rx on left is looped back. The Tx Rx on the right is isolated for no loopback.

Use twisted pair between the two ports as common mode noise can be an issue to tie the grounds.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ You may want to consider explaining why he may want to consider this. \$\endgroup\$ Commented Sep 21, 2017 at 0:22
  • \$\begingroup\$ thx Nick, solution added. \$\endgroup\$
    – D.A.S.
    Commented Sep 21, 2017 at 0:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.