Warning About SendOnlySoftwareSerial

I've been using Nick Gammon's most excellent SendOnlySoftwareSerial on some of my small ATtiny85 / ATtiny84 projects to enable some serial debug output without loosing an unused Rx pin.

The original post is way old and closed but I struggled with the library on a current project and thought my findings might save others some debug time.

The original post is below:
(Using only TX of SoftwareSerial, leaving RX pin free)

My current project uses an RF receiver to collect commands and then controls the driving of a motor and some delay timings.

Things were going swimmingly until I started to use the SendOnlySoftwareSerial to output some debug information - specifically in this case, a count down variable used to control a command entry timeout.

The use of the count down timer debug print out worked whilst I was driving my motor (with the PCI for RF data feed disabled) but when I was just waiting for another RF command, strange things started happening - it seemed that the print statement was corrupting the variable being printed but not all the time or in any predictable way - just adding another line of code in seemingly a random location might fix - or move the problem.

It worked mostly OK but sometimes when I was waiting for an RF command, it would misbehave. I spent ages looking into the RAM used by all my debug print statements, the scoping of my variables, declaring them static or not, tried making them global, jumped about between unsigned char and int and got myself into a real muddle.

The real problem was the PCI on the RF receive data pin - I had no issues when I disabled PCI on this pin whilst driving the motor but had odd behaviour with the same PCI enabled to capture and process RF commands.

I have a working solution now whereby I do not attempt to print variables whilst I have PCI on the RF data receive pin. Not such informative debug but more predictably stable. Printing literal strings seems to be OK.

This is probably not news for anyone and Nick may have re done his excellent library on a more up to date version of the base SoftwareSerial library - it doesn't matter to me as I can use what I have knowing its limitations but it may save someone else a few days of head scratching.

Which core are you using for ATtiny84/85 MCUs ?

The ones that ship with PlatformIO - I use that as IDE

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.