I connected in the same way as it is described there and used the code. (of course with some modifications - no function for calculating temp - it runs into loop) I want to put the output on a Serial 7 Segment display. I have no problem in writing the output there, but i dont seem to have good readings from the I2C sensor.
Is there any other way to connect the sensor to SparkCore or the problem is with the software?
So do you know for sure that the problem is with the sensor and not with the firmware code etc? If you deliberately assign a different value (eg. 12345) to the same variable in firmware, overwriting the value from the sensor, do you see that new value when read over the internet?
Do you have an Arduino you could use to test the sensor?
I have not yet, but my core will arrive soon (maybe today!) and I have an i2C sensor. Its a BMP085 which measures atmospheric pressure and temperature. I have it working correctly with Arudino. I will try that with the Spark Core. However, I will have some learning and configuring to do first - you are a little way ahead of me at the moment!
Do you have any other i2C devices to try? an RTC perhaps?
I have the same problem with the TMP102, running at the Spark Core it always return the same value “result”: “255.94”, using the sensor at the Arduino it have a correct value.
I tried the daves​panton suggestion that use the address 0x90 but the result is the same, anyone have any idea about it?
Hello,
I have the exact same problem. The value returned is always 255.94. However the same code with same board is working with my old Arduino.
I have tried both 0x48 and 0x90 to no avail.
No pull up resistors needed, as the TMP102 has 1k pull-ups already. 3.6V max on V+!
If you connect ADD0 pin to ground, the 7-bit address is 0x48, but the Spark Core currently uses 8-bit addressing so change the address to 0x90. Important that ADD0 is grounded though, or the address changes.
Yes the circuit is pretty basic. And it is working when connected to the Arduino. But I can't get anything from the Spark. I tried both 0x48 and 0x90, behavior seems to be the same. Serial returns "Celsius: 255.94
".
Here is my code, anything different in yours, Marcio?
Just to say that the problem has been solved today after the firmware update for I2C (link to timb’s post). I can now use adress 0x48 to adress the TMP102.
The only problem remaining is to export the data through spark.variable. I can get it with a string but not a double… Still some way to go!
I tried to use your code with the TMP102 breakout board, and I was seeing the same 255.94 issue.
I followed the instructions on thesepages to manually build the firmware including the app code posted by Fabien (put it into src/application.cpp). Here are the changes I had to make to it work:
// add:
#include <application.h>
// and a forward declaration for:
float getTemperature();
// and use this address:
int tmp102Address = 0x48;
//also, change:
float celsius=0;
// to:
double celsius=0;
// and update the datatype in:
Spark.variable("temperature", &celsius, DOUBLE);
Thank you all for posting useful hints in this thread!
EDIT: I was earlier suspecting that the cloud IDE was giving me the v0.1.0 firmware rather than 0.2.0, but now I’m not sure that was the case.
I just wanted to make sure you have pull-ups on your TMP102 i2c lines. If you are using the Sparkfun breakout board, it has them built-in, but other boards might not. Another thing to check is the i2c address jumper.
The value you are getting makes me think that you are not transferring any data.
One other quick point:
int TemperatureSum = ((MSB << 8) | LSB) >> 4;
can produce negative numbers on Arduino but not on Spark due the the 16-bit versus 32-bit integers. A better way would be:
Thanks for the reminder. I’m using the breakout board that came with the spark.io devices. I do have a Sparkfun version so maybe I’ll give it a try on that board just to see.
So I’ve tried to add the pull-ups, but I’m still having the same issue. Is there a good tutorial on how to use pull-ups? I’m sure that this is just user error, I’m pretty much a newb.