temperature sensor

hi everyone
i have two temperature sensor
how can i do to use two temperature sensor on the same arduino

my code only use one temperature sensor
this is my code

#include <OneWire.h>
#include <DallasTemperature.h>

#define ONE_WIRE_BUS 2

OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

void setup(void)
Serial.println(“Temperature Sensor”);

void loop(void)


how can i modify the code to conform it.
please help me :~

Hi dapingQ,

with the code of the library come several examples, including a multi-sensor example called “multiple”. check that code…

I found the best resource was Hacktronics


A simple way would be to wire up another sensor on the bus, connecting the three legs of the new sensor to the same three legs on the old. Then add this code:


You won't know without experimenting which sensor is which, so ultimately you'll need to work with sensor addresses. Some additional prints to indicate which sensor's temp is being displayed would be nice too, but the above will get you started with multiples.