Trinket + SoftwareSerial + Bluetooth = CODE TOO BIG

I have a couple adafruit trinkets i purchased. And I got a hold of a JY-MCU bluetooth adapter. Using my UNO I have been able to get this bluetooth working with software serial so I can talk to my microcontroller over bluetooth.

So in an effort to go miniature I wanted to put that sketch on the adafruit trinket. But the code is too big!!

I am sure its in the softwareserial.h since that is 4k by itself.

So I am curious, what is the best way to work with the trinkets? Or should I be looking at something like the arduino mini that has 32k flash? Since the trinket only has 6k?

I am pretty new to this, but have been spending HOURS each day getting up to speed. So I am curious how others are working with the tiny devices. (Tiny Core 2, Stripped down libraries, ect)

But the code is too big!!

What code would that be?

Read this before posting a programming question

How to use this forum

I apologize. The code in question that makes my program too large is when I include the softwareserial.h

Thats quite a lot, I’ve tested out a hc-06 bluetooth module, where everything is set up on that, which I found cheap on eBay, so not sure if that could help making your code smaller.
I don’t know if this is possible, but it would be interesting to see if you could remove or reduce some softwareserial.h code and just keep the ones your personally utilising.
Or is there a hardware UART you can use to send data too? Then I don’t think you need to import anything which would definitely reduce your code as well?

Of course it's easiest to just throw money at the problem. Just buy a controller with more flash.

Or...... find out exactly what' s making your code big and fix it. It's a great little puzzle. With some optimization, I'm sure getting BT to work on a Trinket in 6k or less is absolutely no problem. Not sure where it's located on Windows/iOS, but "avr-size" is your friend.

You'll have to decide for yourself if you're more the puzzling kind or the throw money at the problem kind. Both are valid approaches.

iseeall: I apologize. The code in question that makes my program too large is when I include the softwareserial.h

I was trying to hint that you should post the "code in question" but I must have been too subtle.

I'll move this to project guidance as there is no code to analyze.

I have been developing a short piece of code to send / receive serial data on an Attiny. As far as I can see it is much smaller than SofwareSerial.

I suspect it may not be suitable for large quantities of data - but then an Attiny can't do large quantities. Can you explain what your project does. If my code is suitable you are welcome to a copy.

...R

So I am curious, what is the best way to work with the trinkets?

The "best way" to work with the Trinket, IMO, is to either use the Digispark bootloader (same V-USB configuration) and get back a bit of flash too since the Digispark bootloader is smaller. Or, simply do not use the bootloader at all. Or, as I did move to a DIP configuration for development and then on to the real device for the project. The Trinket is extremely simple to buildout on breadboard of stripboard: http://forum.arduino.cc/index.php?PHPSESSID=2gg3rg0sqlgl3a2vmmd8cq2re7&topic=187444.0

The other nice thing about the Digispark is that their libraries work unchanged on the Trinket. So you can have Keyboard and Mouse HID, etc. Personally, I like the Trinket hardware and the Digispark software... and with opensource, you can have 'em both.

You will definitely want to check out Nick's send-only version of SoftwareSerial. http://forum.arduino.cc/index.php?topic=112013.0

Ray

The new Adafruit bluetooth module does not take up any additional code. The software serial library or Nick Gammon's excellent SendOnlySoftwareSerial does not bloat the code unless your user code is huge.

@TheKitty:

The new Adafruit bluetooth module does not take up any additional code. The software serial library or Nick Gammon’s excellent SendOnlySoftwareSerial does not bloat the code unless your user code is huge.

Well, it was I who made the Trinket forum knowledgable of Nick’s one-way library. And I had a good play with the toys.

Bloat is a relative term, especially on the Attiny85[/b]. Here is the actual overhead numbers for use of SoftwareSerial.h in a send-only Trinket example published as part of the referenced Bluetooth article.
Readers, you can make your own determination. (1.5.6r2)

Empty setup() and loop() // minimum sketch

  • 444 flash bytes
  • 9 Bytes SRAM
    Send CR to SoftwareSerial object // minimum use
  • 2,662 flash bytes used
  • 123 Bytes SRAM
#include <Streaming.h>  // Imparts no overhead in code size
#include <SoftwareSerial.h>  // Software serial library (standard in Arduino 1.x +)
SoftwareSerial mySerial(2,0); 

void setup() {
  mySerial << "\r" ;

}

void loop() {
  // put your main code here, to run repeatedly:

}

All of the Bluetooth code referenced: Code | Trinket Bluetooth Alarm System | Adafruit Learning System

I appreciate your opinion and experience with the Trinket, but it is simply a nice t85 breakout board that supports V-USB and is a pain in the butt (my experience) to use under the Arduino GUI. The Adafruit Trinket forum has many, many posts from users who have similar Arduino GUI issues. Additionally, there is no support for Trinket on Linux:
https://forums.adafruit.com/viewtopic.php?f=52&t=46960

Ray