Hello Arduinoites!
I would love your help in figuring out how I can either fix, or work around an issue that I am running into with using the OneWire library.
I am creating a system to control the lights on my hydroponics system. I have a working program that integrates an RTC and a 64x128 LCD screen with some buttons that allow me to set the on and off times from the unit itself.
The problem that I am running into is that I now want to add some thermometers to the system. I got some onewire thermometers Vktech-Waterproof-Digital-Temperature and have got them working using the OneWire.h and DallasTemperature.h libraries using some of the example sketches.
However, when I combine integrate the example sketch into my original sketch I get an error that a particular function in the OneWire.h was not declared (more on this is a sec).
I did a lot of commenting out of my code and narrowed it down to two specific commands from the Adafruit_SSD1306.h and the RTClib.h.
Here is the relevant section of the code, it includes the top part of the sketch, along with the function that problem is occurring in
/////////////Time///////////
#include <Wire.h>
#include <RTClib.h>
#include <Time.h>
#include <TimeAlarms.h>
RTC_DS1307 RTC;
/////////LCD/////////////////////
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#define OLED_RESET 4
Adafruit_SSD1306 display(OLED_RESET);
////////Temp////////////////////////
#include <OneWire.h>
#include <DallasTemperature.h>
#define ONE_WIRE_BUS_PIN 8
OneWire oneWire(ONE_WIRE_BUS_PIN);
DallasTemperature sensors(&oneWire);
DeviceAddress Probe01 = { 0x28, 0xD7, 0x25, 0x89, 0x06, 0x00, 0x00, 0xEE };
DeviceAddress Probe02 = { 0x28, 0xCC, 0x92, 0x40, 0x04, 0x00, 0x00, 0xB6 };
////////////////////////////////////////////////////////////
void printTemperature(DeviceAddress deviceAddress)
{
float tempC = sensors.getTempC(deviceAddress);
if (tempC == -127.00)
{
Serial.print("Error getting temperature ");
}
else
{
Serial.print("C: ");
Serial.print(tempC);
Serial.print(" F: ");
Serial.print(DallasTemperature::toFahrenheit(tempC));
}
}
When I run this code as is I get this error:
Hydro-Control2.0:20: error: variable or field ‘printTemperature’ declared void
Hydro-Control2.0:20: error: ‘DeviceAddress’ was not declared in this scope
variable or field ‘printTemperature’ declared void
particularly it is the DeviceAddress that is giving me trouble, because it has been declared (at least I hope that it is).
The plot thickens when I comment out these parts of the above code
//RTC_DS1307 RTC;
//Adafruit_SSD1306 display(OLED_RESET);
when I comment out those lines it compiles just fine and the thermometers work well.
I have tried commenting out just one of the two lines but it still give me the same error, so it is not either one of them in particular.
I found someone else with a similar problem but their solution did not work for me.
Any advice would be amazing. at the moment I am assuming that the librarys do not play nice with each other and I should set up a two arduino solution.
Thanks!