Hello, my project is calling for multiple temperature readings. I have two DS18B20 temp sensors with the grove connectors going into a lotus v1 seeeduino. I am able to get one working, but it looks like all the examples online assume you are able to link up the two sensors data cable. with the grove setup i am plugging one into D2 and the other into D6. This code is just a variation of an example I found. Does anyone have any suggestions?
The error i am getting is
error: 'TempF1' was not declared in this scope
Serial.print(TempF1);
^~~~~~
This is the code i am using.
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into port 2 on the Arduino
#define ONE_WIRE_BUS_1 2
#define ONE_WIRE_BUS_2 6
// Setup a oneWire instance to communicate with any OneWire devices
OneWire oneWire_1(ONE_WIRE_BUS_1);
OneWire oneWire_2(ONE_WIRE_BUS_2);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensor1(&oneWire_1);
DallasTemperature sensor2(&oneWire_2);
void setup(void)
{
// start serial port
Serial.begin(9600);
// Start up the library
sensor1.begin();
sensor2.begin();
// locate devices on the bus
}
void loop(void)
{
sensor1.requestTemperatures();
float tempF1=sensor1.getTempFByIndex(0);
sensor2.requestTemperatures();
float tempF2=sensor2.getTempFByIndex(0);
Serial.print("sensor1: ");
Serial.print(TempF1);
Serial.print(" ")
Serial.print("sensor2: ");
Serial.print(TempF2);
}