Remote DATV station parameters monitoring (PART 3)

Integrating temperature sensors

Temperature measurements (in this case ambiend and heatsink) I will use DS18B20 sensors.

The DS18B20 is a temperature sensor taht supplies 9-bit to 12-bit readings of temperature.The communication of this sensor can be done through a one-wire bus protocol which uses one data line to communicate with an inner microprocessor.

Fisrt thing to be done is to find the adresses of all sensors connected to the one wire bus (each one having a unique hardware coded address).

This is done after connecting the sensor to the Arduino Nano (including a 4k7 resistor between data and 5V line) and running below sketch.

#include <OneWire.h>
int datapin = 8;
void setup()
  Serial.print("Start Searching OneWire Devices connected to pin ");
  Serial.println(" devices found");
  Serial.println("Search Completed");
void loop(){}

uint8_t findDevices(int pin){
  OneWire ow(pin);
  uint8_t address[8];
  uint8_t count = 0;
  if (
    do {
      for (uint8_t i = 0; i < 8; i++)
        if (address[i] < 0x10) Serial.print("0");
        Serial.print(address[i], HEX);
        if (i < 7) Serial.print(", ");
    } while (;
  return count;

Console Output

We will now use these 2 adresses in the following sketch to get the temperature from each separate sensor.

// Include the libraries we need
#include <OneWire.h>
#include <DallasTemperature.h>

// Data wires of both sensors are connected to port 8 on the Arduino
#define ONE_WIRE_BUS 8

int temperature_ambient;
int temperature_heatsink;

// Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);

// Pass our oneWire reference to Dallas Temperature.
DallasTemperature Dallas_temperature_sensors(&oneWire);

// arrays to hold device addresses
DeviceAddress Ambient_Air_Temperature_Sensor = { 0x28, 0x2A, 0x6B, 0x96, 0xF0, 0x01, 0x3C, 0xBA };
DeviceAddress Heatsink_Temperature_Sensor   = { 0x28, 0x9B, 0xDE, 0x19, 0x00, 0x00, 0x00, 0x00 };

void setup(void)
  // start serial port

  // Start up the library
  // check if senosrs are on line (for debufgging purposes only)
  if (!Dallas_temperature_sensors.getAddress(Ambient_Air_Temperature_Sensor, 0)) Serial.println("Unable to find address for Device 0");
  if (!Dallas_temperature_sensors.getAddress(Heatsink_Temperature_Sensor, 1)) Serial.println("Unable to find address for Device 1");
  // set the resolution to 12 bit per device
  Dallas_temperature_sensors.setResolution(Ambient_Air_Temperature_Sensor, TEMPERATURE_PRECISION);
  Dallas_temperature_sensors.setResolution(Heatsink_Temperature_Sensor, TEMPERATURE_PRECISION);

void loop(void)
  // call sensors.requestTemperatures() to issue a global temperature

  Serial.println("Sensor: Ambient Air (x10)");
  temperature_ambient = 10 * (get_temp_from_Sensor(Ambient_Air_Temperature_Sensor));
  Serial.println("Sensor: Heatsink    (x10)");
  temperature_heatsink = 10 * (get_temp_from_Sensor(Heatsink_Temperature_Sensor));

// function to return temperature values
float get_temp_from_Sensor(DeviceAddress deviceAddress)
  float tempC = Dallas_temperature_sensors.getTempC(deviceAddress);
    Serial.println("Error: Could not read temperature data");
    return 0;
  return tempC;

Console Output

Go to Part 4