Author Topic: Weirdness with SoftSerial  (Read 203 times)

bar0n

  • Newbie
  • *
  • Posts: 2
Weirdness with SoftSerial
« on: September 14, 2018, 09:24:31 am »
Been fighting with a HM-10 module for some time and as i test i tried SoftSerial_INT0 (https://github.com/J-Rios/Digispark_SoftSerial-INT0) with DigiKeyboard to see the data being passed.

when I print through the keyboard and the serial (show in the code below). it works fine (see image sc01)
Code: [Select]
#include "DigiKeyboard.h"
#include <SoftSerial_INT0.h>

SoftSerial mSerial(2, 1); // Rx, Tx

void setup() {
  mSerial.begin(9600);

void loop() {
  static char cmd;
  if(mSerial.available())
  {
    cmd = mSerial.read();
   
    DigiKeyboard.print(cmd);
    mSerial.write(cmd);
   
    if (cmd == '\n') {
      DigiKeyboard.println("OK");
      mSerial.write("OK\n");
    }
  }
  DigiKeyboard.update();
}

however if I just write through the serial by commenting out the keyboard.print lines, the characters get skewed (see image sc02)
Code: [Select]
//    DigiKeyboard.print(cmd);
    mSerial.write(cmd);
   
    if (cmd == '\n') {
//      DigiKeyboard.println("OK");
      mSerial.write("OK\n");

Can anyone explain to me why this happens and how I can get SoftSerial to work with DigiKeyboard?

Also, note I was getting the same issue when using the original SoftSerial and TinyPinChange.

Other Details:
android App: Serial Bluetooth Terminal by Kai Morich
Wiring: see image wiring.jpg

bar0n

  • Newbie
  • *
  • Posts: 2
Re: Weirdness with SoftSerial
« Reply #1 on: September 14, 2018, 09:31:56 am »
Just realized the wiring diagram was wrong. here's the correct one.