Simple sketch to communicate between attiny and raspberry pi

Hi,
I have a very old setup of tinytx3s - one is setup as receiver and I got some sensors that send data. The receiver is connected to a raspberry and so the data is forwarded.

Now I would like to change something in the setup but I cannot get the attiny to communicate with the raspberry anymore. The old programmed attiny works like always and minicom shows the communication with
sudo minicom -b 9600 -o -D /dev/ttyAMA0
but I seem not to have the old sketch anymore ...

A new sample code does not do anything besides that the LED indicates that the sketch runs continually. Any idea what is different in the old sketch compared to that simplified snippet? As far as I checked the pin setup is correct.

#include <SoftwareSerial.h>
#define SERIAL_BAUD     9600
// UART pins
#define rxPin 7 // D7, PA3
#define txPin 3 // D3, PA7. pin der an RXD vom PI geht.
// LED pin
#define LEDpin 8 // D8, PA2 - set to 0 to disable LED

int i;

// Initialise UART
SoftwareSerial mySerial(rxPin, txPin);

static void activityLED (byte mode) {
  pinMode(LEDpin, OUTPUT);
  digitalWrite(LEDpin, mode);
}

// init Setup
void setup() {
  pinMode(rxPin, INPUT);
  pinMode(txPin, OUTPUT);
  mySerial.begin(SERIAL_BAUD);
  mySerial.print("Test start\n\r");
  if (LEDpin) {
    activityLED(1); // LED on
    delay(500);
    activityLED(0); // LED off
    delay(500);
    activityLED(1); // LED on
    delay(500);
    activityLED(0); // LED off
  }
  i=0;
}

// Loop
void loop() 
{
  mySerial.println(i);
  i++;
  delay(500);
  activityLED(1); // LED on
  delay(100);
  activityLED(0); // LED off
  delay(500);
  activityLED(1); // LED on
  delay(20);
  activityLED(0); // LED off  
}

If the ATtiny is running on 5V, be sure to use bidirectional logic level shifters with the 3.3V RPi.

Hi,
the attiny is not running on 5V but on 3.3V plus: it is the same kind of arduino plugged in the same holder on the same tinytx3 board - all energy comes from the 3.3V of the rp
the original sketch communicates all the time with the rp - the sample code does not ...
regards

Great! Check wiring, and common ground.

That is a very odd end of line. typically it is \r\n or simply
mySerial.println("Test start");

That isn't your problem. It may be your pin assignments. If this chip is in the same holder as an older chip that works, then the only difference is the software. Are you sure you are using the correct pins? did you try swapping rx/tx?

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