Comments (8)
Because ESP doesn't have hardware I2C there are very small differences between what the chip and library expect and what the ESP is doing. Thanks for bringing up the issue! I'll see if I can get some time to pin down what's going wrong in the coming days.
from qwiic_spectral_sensor_as726x.
Do I need to add a resistor to the SDA , SCL Data lines or something? What am I missing?
from qwiic_spectral_sensor_as726x.
Thank you so much!
If you need more information, let me know!
from qwiic_spectral_sensor_as726x.
For clarification:
It's likely not an error regarding the esp8266, because I tried the Arduino Leonardo and Micro (both have the ATmega32U4). JP1 is closed with solder and JP2 is open, so I2C communication should be available. Maybe my board is just faulty and I should return it?
from qwiic_spectral_sensor_as726x.
Hey @kevinunger , I have been troubleshooting this and I think I found something. A delay of 700ms before calling the sensor.begin() seems to work every time on my setup. Without the delay, I see "I2C Error" messages or sometimes nothing at all.
I think the root of the issue is the fact that the AS7263 chip needs to wake up and read it's firmware. If you try and talk to it too soon, then it's not ready to talk I2C and the micro sees it as an I2C communication error.
I tried this with an ESP8266 Thing Dev and it needed a delay of at least 700ms.
I tried this with a Pro Micro and it needed a delay of at least 1000ms.
Here is my modified Example1_BasicReadings for reference. Note, we plan on including these delays into the examples in the library soon.
#include "AS726X.h"
AS726X sensor;
void setup() {
delay(700); // give a time for the sensor to wake up and load it's firmware.
sensor.begin();
}
void loop() {
sensor.takeMeasurements();
sensor.printMeasurements();
}
I should also note, each time I was testing this, I was killing power to my entire system (e.i. unplug USB from pro micro or turn my Thing Dev OFF). Then powering up both the micro and the sensor board at the same time. Meaning, I left the qwiic connector connected from controller board to sensor board, throughout the entire cycle. This is important, because if there is a failure with the communication to the sensor, then it, too, will require a power cycle to ever work again.
If your sensor still shows "I2C Error", then it could still be a faulty sensor board or bad connections. But please give delay(1000) a try and let us know how it goes.
Good luck!
-Pete
from qwiic_spectral_sensor_as726x.
Hey @kevinunger ,
I looked into this a little further and I think my theory still stands. I couldn't find much in the data sheet about power up sequences with this sensor (or time it takes to load it's firmware from the external memory), so I broke out my logic analyzer to see if I could see what was going on.
Channel 0 = reset (from the sensor) NET NAME "RST" in schematic. Used as a reference to know when power up happens.
Channel 1 = sck (between sensor and external memory)
Channel 2 = miso (between sensor and external memory)
Channel 3 = I2C CLK (between pro micro and sensor)
Channel 4 = I2C SDA (between pro micro and sensor)
Power up with a delay of 1000ms works. Here's the readings:
As you can see, right after power up happens, there is some action on the sck and miso lines. This is when the sensor is loading it's firmware. I'm guessing that the gap on the miso line is probably active on the MOSI line, and the sensor is sending some data back to the memory, or it could be doing something else entirely.
Next, I recorded in what it looks like with a 700ms delay. This does NOT work with the pro micro.
In this 700ms delay example, you can see that the pro micro is trying to talk to the sensor a bit earlier. I put some markers (A1 and A2) in there to check it out. It looks like after bootup, the micro is actually not communicating until 766ms, so I'm guessing that the extra 66ms is probably the 32u4 doing whatever else it needs to do on power up before actually getting to the delay function in my setup.
Next up I tried 710ms, it didn't work. Then I tried 720ms and it did. Here's what 720ms looks like:
So, when using a pro micro, 720ms seems to be the magic number to add into the setup before calling sensor.begin().
Hope this helps and I hope you get your system up and running soon!
-Pete
from qwiic_spectral_sensor_as726x.
Hi,
I really thank you for your help and your work!
I was able to send the board back to the shop, where I ordered it and they replaced it. It's now working with your added delay. Thank you so much!
Now I need to find out how to evaluate the data that the sensor gives me for my project. That will be hard, bc I realised that only a few people have done that.
-Kevin
from qwiic_spectral_sensor_as726x.
I am running on a D1 Mini Lite clone, esp8285. Tried this, still getting nothing but the I2C error from my sparkfun AS7263
from qwiic_spectral_sensor_as726x.
Related Issues (7)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from qwiic_spectral_sensor_as726x.