PlatformIO Community

ATTiny84 Serial communication issue

Hi folks,
I slowly get comfortable with PlatformIO.
For debugging my ATTiny84, I connected PB0 to another Arduino’s RX pin and installed the SoftwareSerial library.
For the first test, I’m sending a heartbeat to the serial port every second:

void loop() {
  count++;
  mySerial.print("Count: ");
  mySerial.println(count);
  delay(1000);
}

(I’m sorry, only one screenshot for new users :wink: )
As I can see on the Arduino’s onboard RX LED, the Arduino successfully receives those serial prints.
Now, my problem is that I dont see any output in either the PlatformIO serial monitor or even the ArduinoIDE’s serial monitor.
I set the monitor_port to the Arduino’s COM port and set the monitor_speed according to my SoftwareSerial definition:
image

Is there any step that I’m missing?
Thanks in advance!

Hi @roycinger

Can you please post your complete sketch code for the Arduino (the receiver) and the ATtiny84 (the sender). There might be a problem in how you’ve set up the code in the setup() function, maybe.

When posting code, like your sketch or platformio.ini file, post it as plain text, not screenshots. It’s easier to copy and paste into a test sketch! :wink:

To post as code, wrap it in triple back tick characters, like this:

```
void loop() {
  count++;
  mySerial.print("Count: ");
  mySerial.println(count);
  delay(1000);
}
```

That’s a back tick character, not a single quote, by the way.

Thanks.

Cheers,
Norm.

Hi Norman,
I tried to format the code snippet as code with the button in the edit, but it didnt work.
Back to your questions:
The “receiver” sketch is just an empty Arduino sketch (empty setup(), empty loop()), so nothing fancy here.
The sender code looks like this (I hope the formatting works now):

#include <Arduino.h>
#include <SoftwareSerial.h>

int RX_pin = PIN_B1;
int TX_pin = PIN_B0;

int count = 0;

SoftwareSerial mySerial(RX_pin,TX_pin);

void setup() {
  
  mySerial.begin(9600);
  delay(2000);

}

void loop() {
  count++;
  mySerial.print("Count: ");
  mySerial.println(count);
  delay(1000);
}

This is my platformio.ini:

[env:attiny84]
platform = atmelavr
board = attiny84
framework = arduino
upload_protocol = stk500v1
upload_flags = 
	-P$UPLOAD_PORT
	-b$UPLOAD_SPEED
upload_speed = 19200
upload_port = COM3
lib_deps = 
	thomasfredericks/Bounce2@^2.70
	featherfly/SoftwareSerial@^1.0
monitor_port = COM10
monitor_speed = 9600

Thanks for the support already!

If the Arduino is the receiver and has no sketch running, just the empty one, then the serial output you are hoping to see should be that of the ATtiny84 as that’s the device that’s writing to the Software Serial port.

I think you need to change the monitor port to be the same as the upload port in platformio.ini. COM3 according to your first screenshot.

HTH

Cheers,
Norm.

So the COM10 port / serial adapter’s RX connection is connecetd to PB0, just as the other Arduino’s RX connection? Can you share your schematic?

@NormanDunbar that’s exactly what I want to achieve, seeing the serial output of the ATTiny. I’m just abuse the Arduino as the receiver.of the serial communication.
The upload port is an entirely different Arduino (UNO, with a programming shield on top) to actually program the the ATTiny off-board.

@maxgerhardt
basically like this:
image
I also tried without the resistor and cap (on the Arduino), still the same outcome

Per schematic the SAMD11’s (which is the flasher and serial to usb chip on the nano every) RX pin is connected to the TX pin of the Mega4809 (PB05). So the serial monitor will show the UART content of what’s on the TX1 pin of your schematic. Not RX1.

If you want to see it on your serial monitor you’ll need to have a loop that prints out the received content again so that’s on the TX1 signal.

void loop() {
   while(Serial.available()) Serial.write(Serial.read());
} 
1 Like

I’m using a regular Arduino Nano (not an every, that was just the one available im KiCad :D).
I flashed the Arduino Nano (receiver) with the snippet you provided and tried again.
As before, the RX LED on the Nano blinks every second (so it’s indeed receiving “something” on its RX pin) but the output in the serial monitor stays empty:
image

What’s the full sketch you’re running on the NanoEvery?

I just noticed there’s no Serial.begin in the Arduino’s sketch.
For future reference (and other people that might look for this issuet, that’s the entire sketch on the Nano:

#include <Arduino.h>

void setup() {
  Serial.begin(9600);
}

void loop() {
  while(Serial.available()) Serial.write(Serial.read());
}

Which finally leads to the following output in my Serial Monitor:
image

Thank you very much gentlemen, you were of great help, I really appreciate it!

1 Like