ATtiny84- how to tur on AREF ?

Hi

ATtiny84 has the AREF pin = A0 (PB0, nr 13)
I use in the code option:
analogRefference(EXTERNAL);
but after conecting my Vref to A0, the result is the same as the Vref would be not connected at all.
I checked the same conections and code on Leonardo and it works.
What should I do on ATtiny84 to use AREF EXTERNAL??
Please, help.
Best Regards, Pawel

Which board definition package ("core") are you using?

I use:

http://static.nettigo.pl/tinybrd/package_nettigo.pl_index.json

http://static.nettigo.pl/tinyBrd-current.zip

because I bought ATtinny on small board with pins:

(preparation of this board for cooperation with radio module is not an issue for now).

I also tried to use the other core but it doesn't operate with Serial.print code. Nettigo core does.

Best regards, Pawel

If nettigo core provides a Serial object to work with, that means that it has it's own software serial implementation in it (my core does too - see the chip-specific doc page for details) - the tiny84 doesn't have a serial port (the very similar tiny841 has TWO fully functional hardware serial ports - it's existence and price point barely above the '84 is why I don't use the 84 very much!).

For the damellis core, or if you're using my core and want the serial on other pins, you need to use the SoftwareSerial library.

Taking a quick look at that core, I'm pretty sure it's got the same serial implementation as mine does - both mine and theirs is based on the ATTinyCore from days of yore. I just did way more with it than they did.

I'll see if mine works

Do you mean, the nettigo core has inside serial library installed and that's a reason, I can use Serial.print code and use usb-uart converter connected to D0 to leasten what Attiny says ?
And your core can do it too or should I install software serial additionally?
If yes, I will install your core of course. I use USBasp programmer to upload a sketch. I don't burn bootloader. Can I use your core just like that after installing?
And the last but the most important - AREF EXTERNAL? :slight_smile:

thanks for help and please advice.

Best regards. Pawel

Well, I wouldn't call it a library - it's built into the core. What's more important is that it's a software implementation. So, like SoftwareSerial, you can't receive characters while sending or vise-versa (and get/send gibberish if you try), unlike Serial on a board with hardware serial ports. This is an important difference between hardware and software serial. Software serial also often gets flaky at higher baud rates.

Pretty sure the Serial portion should work identically. Use SoftwareSerial only if you need to put it on different pins (the motivation for the builtin serial is to put the serial on pins such that it can use the analog comparator's interrupt so it leaves the more useful INT and PCINT interrupts available)

I have not had a chance to test external reference - I couldn't find my tiny84 testing board last night. Honestly, I've got so much on my plate this week I may not be able to test it myself until next week. If it doesn't work, that's a bug in my core that I would consider a priority for the next version.

You need to do "burn bootloader" once (with any core) on a virgin chip to set the fuses, even if not using a bootloader, even on a board for which no bootloader is supplied. (that's the only time the fuses get set - they don't get set when uploading the sketch). The boards you bought probably had this done by the manufacturer, but when you start getting bare chips, you'll need to do this.

This code was forged at Nettigo. Hope it will help you.

word ADCRead() {
// REF: External (PA0), Input: ADC1 (PA1)
ADMUX = _BV(REFS0) | _BV(MUX1);
// DISABLE ADC0 input
DIDR0 = _BV(ADC0D);
// ADC turn on, ADC start measurment
ADCSRA = _BV(ADEN) | _BV(ADSC);
// Wait for result
while ((ADCSRA & _BV(ADSC)) > 0);
// Read result into variable
word output = ADCL;
output |= ADCH << 8;
return output;
}

uint32_t REFVoltage() {
// REF: External (PA0), Input: Internal 1.1 V
ADMUX = _BV(REFS0) | _BV(MUX0) | _BV(MUX5);
// DISABLE ADC0 input
DIDR0 = _BV(ADC0D);
// ADC turn on, ADC start measurment
ADCSRA = _BV(ADEN) | _BV(ADSC);
// Wait for result
while ((ADCSRA & _BV(ADSC)) > 0);
// Read result into variable
uint32_t output = ADCL;
output |= ADCH << 8;
output = 1126400L / output;
return output;
}
void setup() {
// put your setup code here, to run once:
unsigned long referenceV = REFVoltage();
}
void loop() {
// put your main code here, to run repeatedly:
word value = ADCRead();
}

referenceV - voltage in mV connected to REF
value - value (0 to 1023) from ADC1 against reference voltage