Author Topic: SoftSerial does not work (with clones)  (Read 1309 times)

feklee

  • Newbie
  • *
  • Posts: 3
SoftSerial does not work (with clones)
« on: February 07, 2018, 08:26:35 am »
Disclaimer: This is with two Digispark clones (ATtiny85).

I realized that there are issues when I tried serial communication with a Teensy 3.2, as documented in the Teensy forum: Serial communication: Teensy 3.2 received junk from Digispark clone (ATtiny85)

Then I tried again with two Digispark clones, connected at pin 0 for half duplex unidirectional communication. See attached photo.

The sender sends a character x about every two seconds. The receiver does receive something, but it does not match an x.

Who is to blame? I, the hardware, SoftSerial, the Digispark design, or something else?

What follows is the code, compiled and uploaded with Digispark (16 Mhz - No USB) selected in the Arduino IDE.

sender.ino:
Code: [Select]
#include <SoftSerial.h>
#include <TinyPinChange.h>

const uint8_t ledPin = 1;
const uint8_t txRxPin = 0;

SoftSerial mySerial(txRxPin, txRxPin); // RX, TX

void setup() {
  mySerial.begin(4800);
  mySerial.txMode();
  pinMode(ledPin, OUTPUT);
}

void flashLed() {
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
}

void loop() {
  mySerial.write("x");
  flashLed();
  delay(2000);
}

receiver.ino: (play with commenting out the if clause)
Code: [Select]
#include <SoftSerial.h>
#include <TinyPinChange.h>

const uint8_t ledPin = 1;
const uint8_t txRxPin = 0;

SoftSerial mySerial(txRxPin, txRxPin); // RX, TX

void setup() {
  mySerial.begin(4800);
  mySerial.rxMode();
  pinMode(ledPin, OUTPUT);
}

void flashLed() {
  digitalWrite(ledPin, HIGH);
  delay(100);
  digitalWrite(ledPin, LOW);
}

void loop() {
  if (mySerial.available()) {
    char c = mySerial.read();
    if (c == 'x')
      flashLed();
  }
}

feklee

  • Newbie
  • *
  • Posts: 3
Re: SoftSerial does not work (with clones)
« Reply #1 on: February 07, 2018, 08:58:46 am »
Who is to blame? I, the hardware, SoftSerial, the Digispark design, or something else?

To answer my own question:

☑ the hardware

I tried with another board as the sender, and then it worked. Also communication with the Teensy does work now.