unfortunatly, this code prints nothing on my serial monitor and the onboard led (pin13) blink each 1sec like if it would like to say me : “there is something wrong”.
if i comment out the part “get uncompassed temperature” i’am able to get and print the pressure (up);
if i comment out the part “get uncompassed pressure”, i’am able to get and print the temp (ut).
why i cannot get the both ?
i certainly did something wrong but what ?
It is a common mistake, and I see it in example code a lot. But it is wrong.
The Wire.available() returns the number of byte that is in a buffer (in the Wire library).
The I2C session has already ended. The Wire.requestfrom() handles the session, and places the incoming bytes into a buffer.
You should use Wire.availabe() only to check if there is still something is a buffer that should be taken from the buffer with Wire.read().
I just came to look at my code and Erdin is correct in his assessment. My code shows:
while(!Wire.available())
I was able to copy and paste the SparkFun code and it worked out of the gate. I only had to start making changes when I started adding more sensors to the mix; I had to make sure the pins didn't overlap, etc.
thanks for your replies.
i tried the adafruit library (and the seeeduino one, and the sparkfun code) but it did not work for me,
it’s like this i end up to try little pieces of code to try to see from where it comes.
i tried changing the Wire.available part but without success.