ESP8266 Breakout with TSL2591

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
futuretechguy
 
Posts: 10
Joined: Thu May 21, 2015 3:19 pm

ESP8266 Breakout with TSL2591

Post by futuretechguy »

I am new to the IoT world and trying to run a Temperature, Moisture and Light (tsl2591) sensor from an esp8266 breakout. I am uploading the script using the Arduino 1.64 IDE and I although I have added all the required libraries in the instructions, the compile fails even when using only the tsl2591 example sketch.

It appears to be looking for <avr/pgmspace.h>

Can the the TSL2591 work with the ESP8266?

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP8266 Breakout with TSL2591

Post by adafruit_support_mike »

I'm sure it's possible, but you'll probably need to port the TSL2591 library to the ESP8266.

The avr/pgmspace library is used to store static data in Flash memory on an Atmel microcontoller.

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: ESP8266 Breakout with TSL2591

Post by bbx10node »

I got the TSL2591 to work with two simple changes. This allows the libraries to work on the Uno as well as the esp8266. I will submit a pull request to update the libraries unless Adafruit beats me to it.

Code: Select all

diff --git a/Adafruit_Sensor.cpp b/Adafruit_Sensor.cpp
index ee59b27..203ed3d 100644
--- a/Adafruit_Sensor.cpp
+++ b/Adafruit_Sensor.cpp
@@ -1,2 +1,6 @@
 #include "Adafruit_Sensor.h"
+#if defined(ESP8266)
+#include <pgmspace.h>
+#else
 #include <avr/pgmspace.h>
+#endif

Code: Select all

     SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
 /**************************************************************************/
+#if defined(ESP8266)
+#include <pgmspace.h>
+#else
 #include <avr/pgmspace.h>
+#endif
+#if defined(__AVR__)
 #include <util/delay.h>
+#endif
 #include <stdlib.h>
 
 #include "Adafruit_TSL2591.h"

User avatar
futuretechguy
 
Posts: 10
Joined: Thu May 21, 2015 3:19 pm

Re: ESP8266 Breakout with TSL2591

Post by futuretechguy »

Hi bbx10node,

Thanks for that great work on the TSL2591 libraries , I did make the suggested changes to the Adafruit_Sensor.cpp and the Adafruit_TSL2591.cpp files and the example sketch successfully compiled. I uploaded the sketch and connected to GPI012 and GPI013 (SDA, SCL) but the Adafruit ESP8266 is not finding the TSL2591 sensor. I am thinking that maybe I did something incorrectly. When you got it to work, what pins did you use?

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: ESP8266 Breakout with TSL2591

Post by bbx10node »

I used the default configuration where GPIO#4 is SDA and GPIO#5 is SCL.

Here is the hook up.

Code: Select all

TSL2591     ESP8266
-------     -------
GND         GND
Vin         3V
SDA         GPIO#4
SCL         GPIO#5
I got the pin information from esp8266 Arduino.

User avatar
ctand
 
Posts: 16
Joined: Sun Jul 06, 2014 2:25 am

Re: ESP8266 Breakout with TSL2591

Post by ctand »

I am getting the test program to compile using the changes but the sensor reads 0 regardless of gain or timing settings... help? lol I know the sensor works because I just switched it over to a FIO to test it.

bbx10node - did you get this to work with the Huzzah board? Not that it should be different right?

I would like someone to please confirm that they can get the TSL2591 working with the above modifications to the library using the basic example sketch for the TSL2591 provided with the library.

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: ESP8266 Breakout with TSL2591

Post by bbx10node »

The TSL2591 board is working with the Huzzah board for me. Adafruit recently updated the Unified Sensor library to version 1.02 to make it ESP compatible so it is no longer necessary to modify Adafruit_Sensor.cpp. The modification to Adafruit_TSL2591.cpp is still needed. The tsl2591.ino sketch works with no other changes.
Currently running Arduino IDE 1.6.5 and ESP8266 board package 1.6.4-673-g8cd3697.

I have not been able to get the TCS34725 RGB light sensor to work. The SDA/SCL signals look OK on a logic analyzer so this one has me stumped. The TCS board works when connected to an Uno.

User avatar
ctand
 
Posts: 16
Joined: Sun Jul 06, 2014 2:25 am

Re: ESP8266 Breakout with TSL2591

Post by ctand »

Okay I'll have to get back to you on the board package. I just installed the IDE yesterday on this computer from the arduino site so I think it's the latest. (1.6.5)

All I get back is zero values from the sensor. I have another 8266 board so I'll get it soldered up tonight and report back to see if it's an issue with my particular board since I've ruled out the sensor.

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: ESP8266 Breakout with TSL2591

Post by bbx10node »

I just found the TSL2591 works only when my logic analyser is connected to SDA and SCL. When the logic analyser is turned off or disconnected, the TSL2591 does not work. Without the analyser, the device works connected to a Pro Trinket 3.3V so the TSL2591 works on 3.3V systems.

After reconnecting to the ESP without the analyser, I tried 1K and 10K pull up resistors but they do not help.

User avatar
ctand
 
Posts: 16
Joined: Sun Jul 06, 2014 2:25 am

Re: ESP8266 Breakout with TSL2591

Post by ctand »

Yeah okay now we're getting somewhere. I knew there was something going on. So where do we go from here? I'm definitely not an EE.

Did you try powering the sensor through the Pro Trinket and reading SDA/SCL with the 8266 to rule out power supply?

I'm going to try something similar.


Conclusion: After a bunch of testing (1) Fio, (2) 8266, and (2) TSL2591 I have discovered that it is the TSL2591 that are not all created equal. I have a new one that works fine with both of my 8266's and an older one that will only work with my Fio. The one that only works with the Fio also wont work when just powered using the Fio and using the 8266 to read SDA/SCL. Looks like an i2c issue to me. Bummer. We are going to need an adafruit EE to weigh in on this. The older one has 2614 printed on the back. The newer one is 0315.

User avatar
bbx10node
 
Posts: 147
Joined: Sun Feb 22, 2015 4:14 pm

Re: ESP8266 Breakout with TSL2591

Post by bbx10node »

bbx10node wrote:I just found the TSL2591 works only when my logic analyser is connected to SDA and SCL. When the logic analyser is turned off or disconnected, the TSL2591 does not work. Without the analyser, the device works connected to a Pro Trinket 3.3V so the TSL2591 works on 3.3V systems.

After reconnecting to the ESP without the analyser, I tried 1K and 10K pull up resistors but they do not help.
This turned out to be a defective breadboard. I noticed touching the jumper wires would make it work briefly. I switched to a different breadboard and the HUZZAH and sensor are working together. The date code on the back of the sensor is 26-14.

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

Return to “Microcontrollers”