Temp sensor and Alternate power source

I'm using a spark fun temp sensor(TMP117) and when I hook it up directly to my Arduino Due it works fine but when I use an alternate power source the code freezes when booting up.

I have a separate 3.3V power supply that I connect to the TMP117 sensor with the Pwr and Gnd and then connect the SDA to Due pin 20 and SCL to Due pin 21. I have tried connecting the Due ground to the TMP117 along with the ground from the power source together but still no luck.

The power LED on the TMP117 lights up with or without the ground from the Due.

I haven't attempted to connect multiple power sources to power separate devices before so I'm not sure if I'm doing it right.

Here's the code I'm using

/******************************************************************************
  Example2_AlertStatuses.ino
  Example for the TMP117 I2C Temperature Sensor
  Modified by: Ho Yun "Bobby" Chan @ SparkFun Electronics
  Date Modified: November 12, 2019
  Written by: Madison Chodikov @ SparkFun Electronics
  Date: May 29 2019
  ~

  This sketch sets the TMP117 temperature sensor's high limit,
  low limit, and alert function mode. Once set, we read the 
  temperature in °C and checks alert status. If we are outside
  of the boundary, we will output a message indicating
  that we are beyond the limit. The alert statuses is dependent
  on the mode so make sure to 
  

  Resources:
  Wire.h (included with Arduino IDE)
  SparkFunTMP117.h (included in the src folder) http://librarymanager/All#SparkFun_TMP117

  Development environment specifics:
  Arduino 1.8.9+
  Hardware Version 1.0.0

  This code is beerware; if you see me (or any other SparkFun employee) at
  the local, and you've found our code helpful, please buy us a round!

  Distributed as-is; no warranty is given.
******************************************************************************/

/*
  NOTE: For the most accurate readings:
  - Avoid heavy bypass traffic on the I2C bus
  - Use the highest available communication speeds
  - Use the minimal supply voltage acceptable for the system
  - Place device horizontally and out of any airflow when storing
  For more information on reaching the most accurate readings from the sensor,
  reference the "Precise Temperature Measurements with TMP116" datasheet that is
  linked on Page 35 of the TMP117's datasheet
*/

#include <Wire.h> // Used to establish serial communication on the I2C bus
#include <SparkFun_TMP117.h> // Used to send and recieve specific information from our sensor

// The default address of the device is 0x48 (GND)
TMP117 sensor; // Initalize sensor

byte AlertFlag = 0; //variable to hold high and low alert flags from configuration register
boolean H_AlertFlag = 0;  //variable to hold state of high alert flag
boolean L_AlertFlag = 0;  //variable to hold state of low alert flag

void setup()
{
  Wire.begin();
  Serial.begin(115200);    // Start serial communication at 115200 baud
  Wire.setClock(400000);   // Set clock speed to be the fastest for better communication (fast mode)
  Serial.println("TMP117 Example 2: Alert Statuses");
  if (sensor.begin() == true) // Function to check if the sensor will correctly self-identify with the proper Device ID/Address
  {
    Serial.println("Begin");
  }
  else
  {
    Serial.println("Device failed to setup- Freezing code.");
    while (1);
  }

  Serial.println("");
  Serial.println("Note: Make sure to configure the your High and");
  Serial.println("Low Temperature Limits. These values will");
  Serial.println("be cleared on power cycle since it is only");
  Serial.println("saved in the volatile registers. This code");
  Serial.println("sets it manually. You can look at Example 5");
  Serial.println("in the library for more ideas!");

  /*Note: Set the high and low limits. Make sure to set limits
    between -256°C and 255.99°C. For quick testing at room
    temperature that is about 20°C-25°C, we can use the heat
    from our hand or lightly breathing on the sensor. Adjust
    as necessary.*/
  sensor.setHighLimit(25.50); //set high limit to 25.50°C
  sensor.setLowLimit(25.00);  //set low limit to 25.00°C

  //Get High Temperature Limit
  Serial.println("");
  Serial.print("High Temperature Limit: ");
  Serial.print(sensor.getHighLimit());
  Serial.println("°C");

  //Get Low Temperature Limit
  Serial.print("Low Temperature Limit: ");
  Serial.print(sensor.getLowLimit());
  Serial.print("°C");
  Serial.println("");

  /*Note: Set to alert or therm mode. To change, simply adjust
    add or remove a `//` to the line.*/
  sensor.setAlertFunctionMode(0);//set to alert mode
  //sensor.setAlertFunctionMode(1);//set to therm mode

  /*Get "Alert Function Mode" Bit from configuration register
    Note: Depending on the mode, this affects the way HIGH and
    LOW Alert Fields behave in the Configuration Register. For more
    information, check out the following sections of the datasheet:
      7.4.4.1 Alert Mode (pg 14)
      7.4.4.2 Therm Mode (pg 16)
      7.6.1.2 Configuration Register (pg 26)
  */
  delay(500);//wait a little before grabbing current mode
  Serial.print("Alert Function Mode = ");
  Serial.println(sensor.getAlertFunctionMode());
  Serial.println("----------------------------------------"); //start checking temp and alert flags after this line
}

/* Alert statuses below for high or low temperature reading
   possibilities: High Alert = 256°C, Low Alert = -256°C*/
void loop()
{
  // Data Ready is a flag for the conversion modes - in continous conversion the dataReady flag should always be high
  if (sensor.dataReady() == true) // Function to make sure that there is data ready to be printed, only prints temperature values when data is ready
  {
    /*Note: If you are in Alert Mode (T/nA = 0), the high and low alert
      flags will clear whenever you read the configuration register. You
      can add a delay to to perform another temperature conversion to trigger the
      flags again. The delay depends on the conversion cycle time so make
      sure to adjust as necessary to check the if the flags are triggered.
    */
    Serial.println("");
    Serial.print("Current Temperature: ");
    Serial.print(sensor.readTempC());
    Serial.println("°C");
    /*Note: Add short delay before reading the again configuration register
      adjust this value as necessary based on your conversion cycle time.
      Default conversion time for AVG = 1 and CONV = 4 about 1 second. Therefore,
      a value of between 1-3 seconds should be sufficient.*/
    delay(1500);//wait a little before grabbing

    AlertFlag = sensor.getHighLowAlert(); //read the alert flags from the configuration register
    H_AlertFlag = bitRead(AlertFlag, 1); //grab the high alert field using bitwise operator and save current to H_AlertFlag
    L_AlertFlag = bitRead(AlertFlag, 0); //grab the low alert field using bitwise operator and save current L_AlertFlag

    //output byte and bits, Arduino will not output leading 0's toward the MSB
    Serial.print("High and Low Alert Flags = ");
    Serial.println(AlertFlag, BIN);
    Serial.print("High Alert Flag = ");
    Serial.println(H_AlertFlag, BIN);
    Serial.print("Low Alert Flag = ");
    Serial.println(L_AlertFlag, BIN);

    if (H_AlertFlag == true)
    {
      /*Alert when the temperature is over the HIGH limit:
         - In Alert Mode (T/nA = 0) this flag will clear
        when the configuration register is read.
         - In Therm mode (T/nA = 1), this flag will clear ONLY
         when we have reached the lower limit. This high and
         low limits act as a hystersis.
      */
      Serial.println("High Alert");
    }
    else if (L_AlertFlag == true)
    {
      /*Alert when the temperature is over the LOW limit:
         - In Alert Mode (T/nA = 0) this flag will clear
        when the configuration register is read.
         - In Therm mode (T/nA = 1), this flag is always 0
      */
      Serial.println("Low Alert");
    }
    else
    {
      Serial.println("No Alert");
    }
    delay(500); // Delay for a 1/2 second before printing again if the data is ready
  }
}

Ok, leave it like that. You need that common ground. I hope you didn't blow up either the sensor or the Arduino by not connecting GND's on both devices. Does the setup still work if you connect the sensor back to the 3v3 from the Arduino?

Please post a schematic; that's always a good idea...sorry, that's always essential when it comes to hardware questions.

I haven't hurt any of the components, I hooked up the sensor directly to the Due and they both work properly but when I power from the buck converter it freezes the code but the LED power light on the TMP117 lights up wether it is directly connected or connected to the alternate power source.

I will upload a wiring diagram.

The Due has the wrong pullup resistors on the board. They are 1k5 and sometimes 1k, but they should be 10k or no pullup resistors.
Sparkfun has 2k2 pullup resistors on the module, it should be 10k.

The sink current for SDA may not be above 3mA.
3.3V / 1k5 + 3.3V / 2k2 = 3.7 mA

A sensor needs to be powered by the Arduino board.
Use the GND and 3.3V from the Due for the sensor, and don't use those wires for something else. Only for one or more sensors.

I thought I had everything unhooked but I forgot to unhook my TFT screen that also uses the SDA/SCL connections, once I unhooked it the sensor worked as coded.

That suggests @Koepel's post is worth looking into, wouldn't you say?

Thanks Koepel, I missed your post but was looking into this on my searches.

I put a 10K resistor on each pin (SDA/SCL) but it didn't change my outcome. I tied the TFT and TMP117 wires together with the 10K and SCL/SDA but I'm not sure I did it right. The web said to just tie everything (all components using I2c) with there respective pins(SDA or SCL) and attach a 10K resistor. I wasn't sure if I needed to cut the onboard pullup on the TMP117 so I left it alone but looking at your sink current equation it shouldn't have bothered it.

I will switch how the TMP117 is wired with GND and 3.3V coming from the Due.

Could you read the value on this component ?
Does it say "102" or "152" ?
With "102" the pullups are 1kΩ, that is too low.
With "152" it might work, but that depends if the TFT shield has pullup resistors as well and how strong the signals are of each device connected to the I2C bus.
You could remove that component.

I have the "152" on my Due.

The TFT touch controller is the STMPE610 which has horrible documentation and I can't find anything to let me know. Adafruit sends you to one of their 2.8TFT screens for info on the Touch controller and in there it states there are 10K resistors on the SDA/SCL so I'm guessing it is there on the breakout of the STMPE610 that I'm using.

I have tried to use the internal pullups on the Due SDA/SCL by calling pinMode(20, INPUT_PULLUP) and the corresponding call for PIN 21 also but it didn't help.

The I2C bus could be on the edge of working because of too many pullup. Let's worry about that later.

The 3.3V pin on the Due is for sensors. You should use it. You should also use the GND from the Due board for the sensors.

Everything on the I2C bus should power up at the same time. If the I2C bus is already used and something is turned on after that, then the I2C bus could go wrong.

What problem are you trying to solve by using another power supply for TMP117 sensor ? It does not make sense.
Is it a very cheap DC/DC-converter ?

By the way, the I2C bus has three things: SDA, SCL and GND.

1 Like

I will move the 3.3v and GND for the TMP117 to the Due.

Everything powers up at the same time, with the power on button, I don't know if something power's up faster than other devices though.

I have a couple different power supplies. I have a 48V to power stepper motors and a 12V to power cooling fans for my enclosure. I was going to power the Due from the 12V supply and was told that was a bad idea as it will make the Due overheat trying to dissipate the heat from the extra voltage so I bought a buck converter that had 4 different voltages to choose from.

I was also told I shouldn't really power anything from the Due and since I had multiple voltage sources with the buck converter I power all devices from it.( the buck convert has 3.3V, 5V, 9V and a variable voltage on it)

I have six steppers, 2 cooling fans, 3 proximity sensors, 2 IR sensors, 7" TFT screen and the TMP117 to power up so I was trying to limit the amount of work the Due had to do.

I know all the sensors have GND on them but I don't know anything other than how each respective devices wiring diagram wants it to be hooked up.

Thanks for the help.

Who told you that ?

Arduino Due: https://store.arduino.cc/products/arduino-due
It has already a step-down converter. A MPM3610 makes 5V from VIN. A normal linear voltage regulator NX1117 makes 3.3V from the 5V.

That means you can use up to 12V and it will not get hot. The 5V and 3.3V output can deliver 800mA. In my opinion, the 5V can deliver 800mA, but the 3.3V with 800mA might be too much for the voltage regulator.

Is the backlight of the TFT screen using a lot of power ?

Somebody on here told me that, I can't remember who.

The TFT screen seem to run fine on the bench when I wired it directly to another Due when I was writing code for what to display on the screen so I don't know if the backlight will draw to much for other devices to operate properly.

Screen used

The Due should be able to provide the 5V 125-150mA for that display. Most other boards would not be able to provide that current.

I moved the 3v3 and GND wires to the Due for the TFT and TMP117, connected all the SDA/SCL wires and connected them to the Due without any PULLUP resistors and it still wouldn't start the TMP117. The TMP117 loads first in the code so it stops everything from booting up after power up.

I also tried it with the internal PULLUPS on pins 20,21 with no change in the results.

How about removing those 1k5 pullup resistors ?
If you heat it up with a big blob of solder, it will fall off.

That might not solve the problem, I only want to reduce the things that are not right step by step.

You could run a I2C Scanner sketch and let it run for a while. It should never show a problem.

Do you mean the 152 component you mentioned in post #8?

I have run the I2c scanner from the library and it only finds the TMP117, if I unhook it the scanner finds the TFT.

Yes, the "152" of post #8.

Your I2C bus is so bad, I have only read on this forum about such things with a OLED display. Removing the "152" pullup resistors is the first step, but something might be broken.

The whole problem stems from the STMPE610, I have had nothing but troubles using it with the RA8875 and the only reason I bought the STMPE610 is because Adafruit recommends you use it with the RA8875(I see now they have discontinued the STMPE610).

I have removed it from the equation and using just the RA8875, which doesn't use I2C, everything works fine now.

I really appreciate your help with this Koepel.