Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Two Attiny85s NACKing 5 out of 10 times after turning the power on #27

Open
oomek opened this issue Apr 25, 2020 · 1 comment
Open

Two Attiny85s NACKing 5 out of 10 times after turning the power on #27

oomek opened this issue Apr 25, 2020 · 1 comment

Comments

@oomek
Copy link

oomek commented Apr 25, 2020

I've been trying to link 2 Attiny85s, but the connection is very unreliable. When I connect the power for both boards at the same time I always get NACK, when I connect Slave first, wait until it boots ( 5 seconds Digispark Attiny85 ) I get communication half the time. I have 2k pull up resistors.

Here is the sketch I'm using:

#include <Arduino.h>
#include "TinyWire.h"

#define MASTER 1

uint8_t array[32];
uint8_t address = 0x00;

void blink(int time, int n)
{
	for (int i = 0; i < n; i++)
	{
		digitalWrite(1, HIGH);
		delay(time / 2);
		digitalWrite(1, LOW);
		delay(time / 2);
	}
}

#if MASTER

void setup()
{
 	pinMode(1, OUTPUT);
	blink(200, 3);
	TinyWire.begin();
	for ( int i = 0; i < 32; i++)
		array[i] = i;
}

void loop()
{
	TinyWire.beginTransmission(0x46);
	TinyWire.send(address);
	for ( int i = 0; i < sizeof(array); i++)
		TinyWire.send(array[i]);

	if ( TinyWire.endTransmission() != 0)
		blink (200, 5);
	else
		blink(1000, 1);
}

#else //SLAVE

void receiveEvent(int howMany)
{
	byte c = 0;
	while (TinyWire.available() > 0)
		c = TinyWire.read();
	blink(500, 1);
}

void setup()
{
	pinMode(1, OUTPUT);
	blink(200, 3);
	TinyWire.begin(0x46);
	TinyWire.onReceive(receiveEvent);
}

void loop()
{
	delay(1);
}

#endif
@oomek oomek changed the title Two Attiny85s NACKing 5 out of 10 times on turning power on Two Attiny85s NACKing 5 out of 10 times after turning the power on Apr 25, 2020
@oomek
Copy link
Author

oomek commented Apr 25, 2020

It seems like the slave is causing that issue when begin() is called. It pulls down SCL and SDA for a moment for some reason.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant