Trinket doesn't have a serial port emulation in its USB implementation, in order to do my project with linking the TSL2591 with a neopixel strand, I wanted to pluck out the commands from the serial port responses, so I could get access to the lux meter and display it using the neopixel strand. But without the serial port stuff it fails to compile due to lack of definition of terms like SDA, SCL, and so on in the Wire.h library.
The pinout map clearly shows SDA and SCL support on pins 0 and 2 but this doesn't seem available through wire.h
Trinket with TSL2591
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- Franklin97355
- Posts: 23911
- Joined: Mon Apr 21, 2008 2:33 pm
Re: Trinket with TSL2591
You need to use TinyWireM instead of wire https://github.com/adafruit/TinyWireM
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
OK, it took a while to debug the CPP and h files to get rid of all the references to wire, and replace them with TinyWireM, but once I was done and stripped out the serial stuff, the TSL2591 example compiled. I saved the originals in an "Originals" folder so that I can revert when I am ready to try again with the flora. If you want I can upload the modified files for your interest.
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
I ran into problems when I tried to integrate both the 2591 library and the Neopixel library I think I ran out of room on the chip.
I finally figured out that I need two separate trinkets for this circuit, 1 to connect to the neopixels and one to connect to the 2591 Note that this was before the trinket pro, so I don't know if it would make a difference.
I finally figured out that I need two separate trinkets for this circuit, 1 to connect to the neopixels and one to connect to the 2591 Note that this was before the trinket pro, so I don't know if it would make a difference.
- hiduino
- Posts: 862
- Joined: Sat Sep 01, 2012 7:05 pm
Re: Trinket with TSL2591
For the TSL2591 library, there are some simple edits that will allow it to work both the TinyWireM and Wire libraries.
Restore the original library files and make these simple edits near the beginning of each file. These are the only changes needed and this should allow it to compile for both the Trinket boards and Uno or similar boards.
In the Adafruit_TSL2591.h header file add this change in:
In the Adafruit_TSL2591.cpp file add this change:
Yes, the Trinket Pro has 4x more memory and should be able to handle them both.
Restore the original library files and make these simple edits near the beginning of each file. These are the only changes needed and this should allow it to compile for both the Trinket boards and Uno or similar boards.
In the Adafruit_TSL2591.h header file add this change in:
Code: Select all
//#include <Wire.h>
#ifdef __AVR_ATtiny85__
#include <TinyWireM.h>
#else
#include <Wire.h>
#endif
Code: Select all
#include "Adafruit_TSL2591.h"
#ifdef __AVR_ATtiny85__
#define Wire TinyWireM
#endif
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
I tried that but at the time, the example code demanded Wire.* and I had to go through and convert all the references to wire to TinyWireM
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
What we would need for your idea to work is for the creation of a library Alias so that we could address tinyWireM as if it was Wire.
- hiduino
- Posts: 862
- Joined: Sat Sep 01, 2012 7:05 pm
Re: Trinket with TSL2591
That's exactly what I did in the changes I explained above. Those changes will allow the TSL2591 library to work with both the Wire or the TinyWireM libraries depending on which board you select in the IDE.grysmith wrote:What we would need for your idea to work is for the creation of a library Alias so that we could address tinyWireM as if it was Wire.
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
It only works if the designer of the software didn't insist on Wire.* as the library reference in the actual code.
The number of compiler errors was prodigitous.
The number of compiler errors was prodigitous.
Last edited by grysmith on Tue Jul 14, 2015 6:58 pm, edited 1 time in total.
- hiduino
- Posts: 862
- Joined: Sat Sep 01, 2012 7:05 pm
Re: Trinket with TSL2591
The statement,
#define Wire TinyWireM
Takes care of the replacement in the code.
#define Wire TinyWireM
Takes care of the replacement in the code.
-
- Posts: 19
- Joined: Thu Jul 17, 2014 8:24 pm
Re: Trinket with TSL2591
OK sorry to be so obtuse, missed that line, and I am less than familiar with C language.
Please be positive and constructive with your questions and comments.