Trinket with TSL2591

Adafruit's tiny microcontroller platform. Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Trinket with TSL2591

Post by grysmith »

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

User avatar
Franklin97355
 
Posts: 23911
Joined: Mon Apr 21, 2008 2:33 pm

Re: Trinket with TSL2591

Post by Franklin97355 »

You need to use TinyWireM instead of wire https://github.com/adafruit/TinyWireM

grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

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.

grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

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.

User avatar
hiduino
 
Posts: 862
Joined: Sat Sep 01, 2012 7:05 pm

Re: Trinket with TSL2591

Post by hiduino »

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:

Code: Select all

//#include <Wire.h>
#ifdef __AVR_ATtiny85__
 #include <TinyWireM.h>
#else
 #include <Wire.h>
#endif
In the Adafruit_TSL2591.cpp file add this change:

Code: Select all

#include "Adafruit_TSL2591.h"

#ifdef __AVR_ATtiny85__
 #define Wire TinyWireM
#endif
Yes, the Trinket Pro has 4x more memory and should be able to handle them both.

grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

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

grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

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.

User avatar
hiduino
 
Posts: 862
Joined: Sat Sep 01, 2012 7:05 pm

Re: Trinket with TSL2591

Post by hiduino »

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.
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
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

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.
Last edited by grysmith on Tue Jul 14, 2015 6:58 pm, edited 1 time in total.

User avatar
hiduino
 
Posts: 862
Joined: Sat Sep 01, 2012 7:05 pm

Re: Trinket with TSL2591

Post by hiduino »

The statement,

#define Wire TinyWireM

Takes care of the replacement in the code.

grysmith
 
Posts: 19
Joined: Thu Jul 17, 2014 8:24 pm

Re: Trinket with TSL2591

Post by grysmith »

OK sorry to be so obtuse, missed that line, and I am less than familiar with C language.

Locked
Please be positive and constructive with your questions and comments.

Return to “Trinket ATTiny, Trinket M0”