Go Down

Topic: AT TIny 84 Feasability (Read 440 times) previous topic - next topic

liv09

I am attempting to use an ATtiny84 to input serial data from a water flow sensor. This data will then be transmitted via bluetooth to an app on my phone which will then show the amount of water being used. Is the ATtiny 84 a good choice to accomplish this? I am starting to question my choice of chip from all of the forums I have already read through. Any guidance on where to start with this project would really help. I have found the same sensor being used directly with the arduino and similar bluetooth projects also using the arduino directly, but I would like to continue using the ardunio as an ISP to complete this project.

CrossRoads

Seems like a poor choice of chip.
Low on IO, only 9 pins -  need 4 for SPI, 2 for water sensor serial, 2 for bluetooth serial, only leaves 1 for anything else.
Low on serial ports, sorta has 1:
"The Universal Serial Interface (USI), provides the basic hardware resources needed for serial
communication. Combined with a minimum of control software, the USI allows significantly
higher transfer rates and uses less code space than solutions based on software only. Interrupts
are included to minimize the processor load."
Low on SRAM and flash memory, 512 bytes and 8 kbytes.

You could try it, and when you run out of memory, move to a bigger chip to continue your programming.

The 
Designing & building electrical circuits for over 25 years.  Screw Shield for Mega/Due/Uno,  Bobuino with ATMega1284P, & other '328P & '1284P creations & offerings at  my website.

jremington

#2
Sep 18, 2019, 01:44 am Last Edit: Sep 18, 2019, 01:46 am by jremington
If the water sensor is just a switch, for example counting liters or gallons, and you use a Bluetooth wireless serial module to transmit the data, then that chip would be fine. Even an ATtiny13 would work.

You can bit-bang TTL serial (i.e. use software serial). Total I/O pins required = 2 if transmit only.

DrAzzy

#3
Sep 18, 2019, 04:29 am Last Edit: Sep 18, 2019, 04:30 am by DrAzzy
Bad choice. Your application likely needs 2 serial ports (bluetooth and sensor), the tiny84 has none, and more than one software serial port is inadvisable.

The 841 might be what you want, assuming you write your code tightly enough to fit in 8k... it's a pin compatible part, but has better peripherals (2 serial ports, another 16-bit timer, more adc pins) (but isn't available in the throughhole package)
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

jremington

#4
Sep 18, 2019, 04:46 am Last Edit: Sep 18, 2019, 04:47 am by jremington
Few water flow sensors have a serial port (most are just a switch), but the OP needs to tell us what they have selected.

6v6gt

Interestingly, even with LTO enabled, the ATtiny841 appears to use 80bytes more RAM than the ATtiny84 for the same simple sketch:

Code: [Select]

void setup() {
  Serial.begin(9600) ;
  Serial.print(F("hello world") ) ;
}

void loop() {
}


ATtiny84:     79 Bytes
ATTiny841: 159 Bytes
Core: Spence Konde 1.1.4

DrAzzy

Will investigate why it's so much (assuming it reproduces on current version), thanks for bringing that to my attention.

That is an *ancient* version of my core though; we are up to 1.3.2... strongly suggest updating!
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

6v6gt

Will investigate why it's so much (assuming it reproduces on current version), thanks for bringing that to my attention.

That is an *ancient* version of my core though; we are up to 1.3.2... strongly suggest updating!
I've just done an upgrade Arduino IDE version 1.8.9 and your ATtinyCore 1.3.1 which I had been putting off for a long time. I thought I would lie low until the tales of segmentation faults etc. with the some newer IDE died down a bit.
Anyway, the results are better now but still perhaps enough to force someone to use the ATtiny84 instead of the ATtiny841
ATtiny84:     79 Bytes (as before)
ATTiny841: 128Bytes (was 159 Bytes with 1.1.4)
Core: Spence Konde 1.3.1

westfw

Presumably the 841 has at serial isr buffers for at least one UART...

DrAzzy

#9
Sep 19, 2019, 10:36 pm Last Edit: Sep 20, 2019, 04:23 am by DrAzzy
1.3.1?!

ARGH! I forgot to update the board manager json for 1.3.2! That will be available tonight. 1.3.2 is an important bugfix release - 1.3.0 and 1.3.1 were bad releases - they had problems with some attiny board defs.

Edit: 1.3.2 is now live in board manager.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

6v6gt

OK. I've tried 1.3.2. From the RAM usage, it makes no difference.

ATtiny84:     79 Bytes (as before)
ATTiny841: 128Bytes (was 159 Bytes with 1.1.4)
Core: Spence Konde 1.3.2

DrAzzy

As I said, I'll look into this.

My making a point of 1.3.2 vs 1.3.1 was more because I wanted to make sure you didn't stay on 1.3.1 and run into the bugs that made several board selections unusable.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

westfw

[ATtiny84]% avr-nm -S --size-sort /tmp/OldArduBuild/*.elf | grep -v ' '
008000aa 00000001 b millis_timer_fract
008000ab 00000004 b millis_timer_millis
008000a6 00000004 b millis_timer_overflow_count
00800060 00000010 d _ZTV18TinySoftwareSerial
00800094 00000012 b Serial
00800070 00000024 b rx_buffer
[ATtiny841] avr-nm -S --size-sort /tmp/OldArduBuild/*.elf | grep -v ' '
0080017b 00000001 b millis_timer_fract
0080017c 00000004 b millis_timer_millis
00800177 00000004 b millis_timer_overflow_count
00800100 00000010 d _ZTV14HardwareSerial
00800158 0000001f b Serial
00800134 00000024 b rx_buffer
00800110 00000024 b rx_buffer1


DrAzzy

#13
Sep 21, 2019, 11:14 pm Last Edit: Sep 21, 2019, 11:18 pm by DrAzzy
Thanks for the help (and the incantation - I wasn't aware of that one), westfw!

I've checked in a fix for this, it'll be in 1.3.3 and is in github version now. I just took the copout and pulled in the latest version of HardwareSerial from the official arduino AVR core, and tweaked the buffer size used on the 1634.
ATTinyCore for x4/x5/x61/x7/x8/x41/1634/828/x313 megaTinyCore for the megaavr ATtinies - Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts, mosfets, awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up