I am using PlatformIO to program and debug an ATTiny85 script, connecting using an usbASP programmer to upload and a USB to serial board (CP2102 USB-UART) to read serial output from the script. SendOnlySoftware serial is used to send output to pin PB3.
As no output was detected I loaded the simple SendOnlySoftware example script to the Arduino IDE (2.3.2), which worked as expected. The output is seen when the monitor’s baud rate matches that specified in the code.
Upon loading the same script into PlatformIO, it didn’t work. After some detective work, I found that I had to specify the serial rate in the script to be 1/2 that specified for the serial monitor in the platformio.ini file.
The same behaviour is seen whether monitoring via serial monitor in the IDE or using cat /dev/ttyUSB0 in a terminal window. The serial port seems to be running at twice the rate of the specified output from SendOnlySoftwareSerial.
While this works, it seems odd, so I was wondering if anyone has an explanation and a better solution.
The working script and ini files are below. Notice that the value passed to begin() is 1/2 monitor_speed.
Then some clock setting is wrong. WIth your current config, the standard value of
applies so PlatformIO and the Arduino framework think the chip runs at 8MHz. Different fuse settings or crystal oscillator though might have the chip running at 16MHz, at twice the speed, thus producing the serial signal at twice the speed, causing you to have to compensate for it by dividing by two.
What is the clock speed setting in the Arduino IDE? (Arduino IDE → Tools). Add