Robojax

Arduino code for LM75A Temperature Sensor

دروس آردوینو به فارسی

Arduino code for LM75A Temperature Sensor

In this page you will get the code and library for LM75A Sensor. Watch video instruction on how to use LM75A


 /*
 * \brief Show temperature in degrees and fahrenheit every second
 *
 * \author Quentin Comte-Gaz <quentin@comte-gaz.com>
 * \date 8 July 2016
 * \license MIT License (contact me if too restrictive)
 * \copyright Copyright (c) 2016 Quentin Comte-Gaz
 * ersion 1.0
 * 
 * Video instruction by Ahmad Shamshiri on July 10 at 20:29 2018 for Robojax.com
 * in Ajax, Ontario, Canada
 * watch video instruction of this code: https://youtu.be/2gmkubeHUXw
For this sketch you need to connect:
VCC to 3.3V or 5V and GND to GND of arduino
SDA to A4 and SCL to A5

 */

#include <LM75A.h>

// Create I2C LM75A instance
LM75A lm75a_sensor(false,  //A0 LM75A pin state
                   false,  //A1 LM75A pin state
                   false); //A2 LM75A pin state
// Equivalent to "LM75A lm75a_sensor;"

void setup(void)
{
  Serial.begin(9600);
  Serial.println("Robojax LM75A Test");
  Serial.println("Temperatures will be displayed every second:");
}

void loop()
{
  // Robojax.com LM75A Test
  float temperature_in_degrees = lm75a_sensor.getTemperatureInDegrees();

  if (temperature_in_degrees == INVALID_LM75A_TEMPERATURE) {
    Serial.println("Error while getting temperature");
  } else {
    Serial.print("Temperature: ");
    Serial.print(temperature_in_degrees);
    Serial.print(" degrees (");
    Serial.print(LM75A::degreesToFahrenheit(temperature_in_degrees));
    Serial.println(" fahrenheit)");
  }

  delay(1000);
}