Hello. I am trying to compile a program but receive a error message regarding the oled part.
I have tested the oled and it works fine with other programs.
I have tried to arrange this program/edit, but receive error message regarding oled.
Can someone please help? Thanks , in advance.
The program should be ok, could it be a problem with something else?
There is also a program part for sensors, and one part for functions. I did not add them in this message.
Error message:
Redifinition of `void oledstart()`
In file included from C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\ArduFarmBot2_Local_Manual_Ctrl_V1.ino:24:0:
C:\Users\krist\OneDrive\Dokumenter\Arduino\libraries\ACROBOTIC_SSD1306/SPI.h: In function 'void oledStart()':
C:\Users\krist\OneDrive\Dokumenter\Arduino\libraries\ACROBOTIC_SSD1306/SPI.h:8:20: error: 'clearOledDisplay' was not declared in this scope
clearOledDisplay();
^
C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\oledDisplay.ino: In function 'void oledStart()':
oledDisplay:4: error: redefinition of 'void oledStart()'
void oledStart(void)
^
In file included from C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\ArduFarmBot2_Local_Manual_Ctrl_V1.ino:24:0:
C:\Users\krist\OneDrive\Dokumenter\Arduino\libraries\ACROBOTIC_SSD1306/SPI.h:4:6: error: 'void oledStart()' previously defined here
void oledStart(void)
^
C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\oledDisplay.ino: In function 'void displayData()':
oledDisplay:22: error: redefinition of 'void displayData()'
void displayData(void)
^
In file included from C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\ArduFarmBot2_Local_Manual_Ctrl_V1.ino:24:0:
C:\Users\krist\OneDrive\Dokumenter\Arduino\libraries\ACROBOTIC_SSD1306/SPI.h:22:6: error: 'void displayData()' previously defined here
void displayData(void)
^
C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\oledDisplay.ino: In function 'void clearOledDisplay()':
oledDisplay:50: error: redefinition of 'void clearOledDisplay()'
void clearOledDisplay()
^
In file included from C:\Users\krist\OneDrive\Dokumenter\Arduino\8\ArduFarmBot2_Local_Manual_Ctrl_V1\ArduFarmBot2_Local_Manual_Ctrl_V1.ino:24:0:
C:\Users\krist\OneDrive\Dokumenter\Arduino\libraries\ACROBOTIC_SSD1306/SPI.h:50:6: error: 'void clearOledDisplay()' previously defined here
void clearOledDisplay()
^
exit status 1
redefinition of 'void oledStart()'
The tab/program for main program:
#include "stationDefines.h" // Project definitions
/* ESP */
#include <ESP8266WiFi.h>
/* TIMER */
#include <SimpleTimer.h>
SimpleTimer timer;
/* OLED */
#include <ACROBOTIC_SSD1306.h> // library for OLED: SCL ==> D1; SDA ==> D2
#include <SPI.h>
#include <Wire.h>
/* DHT22*/
#include "DHT.h"
DHT dht(DHTPIN, DHTTYPE);
/* DS18B20 Temperature Sensor */
#include <OneWire.h>
#include <DallasTemperature.h>
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature DS18B20(&oneWire);
void setup()
{
Serial.begin(115200);
delay(10);
Serial.println("ArduFarmBot 2");
Serial.println(".... Starting Setup");
Serial.println(" ");
pinMode(PUMP_PIN, OUTPUT);
pinMode(LAMP_PIN, OUTPUT);
pinMode(PUMP_ON_BUTTON, INPUT_PULLUP);
pinMode(LAMP_ON_BUTTON, INPUT_PULLUP);
pinMode(SENSORS_READ_BUTTON, INPUT_PULLUP);
pinMode(soilMoisterVcc, OUTPUT);
oledStart();
dht.begin();
DS18B20.begin();
digitalWrite(PUMP_PIN, LOW);
digitalWrite(LAMP_PIN, LOW);
digitalWrite (soilMoisterVcc, LOW);
waitButtonPress (10); // Wait 10 seconds for Sensor Button to be pressed
oled.clearDisplay();
startTimers();
}
void loop()
{
timer.run(); // Initiates SimpleTimer
}
/****************************************************************
* Read local commands (Pump and Lamp buttons are normally "HIGH"):
****************************************************************/
void readLocalCmd()
{
boolean digiValue = debounce(PUMP_ON_BUTTON);
if (!digiValue)
{
pumpStatus = !pumpStatus;
aplyCmd();
}
digiValue = debounce(LAMP_ON_BUTTON);
if (!digiValue)
{
lampStatus = !lampStatus;
aplyCmd();
}
digiValue = debounce(SENSORS_READ_BUTTON);
if (!digiValue)
{
turnOffOLED = !turnOffOLED;
if (!turnOffOLED)
{
oled.setTextXY(0,0); oled.putString("UPDATING SENSORS");
getDhtData();
getSoilMoisterData();
getSoilTempData();
oledStart();
displayData();
}else oled.clearDisplay();
}
}
/***************************************************
* Receive Commands and act on actuators
****************************************************/
void aplyCmd()
{
if (pumpStatus == 1)
{
digitalWrite(PUMP_PIN, HIGH);
if (!turnOffOLED) displayData();
}
else
{
digitalWrite(PUMP_PIN, LOW);
if (!turnOffOLED) displayData();
}
if (lampStatus == 1)
{
digitalWrite(LAMP_PIN, HIGH);
if (!turnOffOLED) displayData();
}
else
{
digitalWrite(LAMP_PIN, LOW);
if (!turnOffOLED) displayData();
}
}
The tab/program for oled:
/***************************************************
* Start OLED
**************************************************/
void oledStart(void)
{
Wire.begin();
oled.init(); // Initialze SSD1306 OLED display
clearOledDisplay();
//oled.setFont(font5x7); // Set font type (default 8x8)
oled.clearDisplay(); // Clear screen
oled.setTextXY(0,0);
oled.putString(" ArduFarmBot 2 ");
oled.setTextXY(1,0);
oled.putString(String(SW_VERSION));
oled.setTextXY(7,0);
oled.putString("Sensor Key ==>>");
}
/***************************************************
* Display data at Serial Monitora & OLED Display
**************************************************/
void displayData(void)
{
oled.setTextXY(3,0); oled.putString("AirTmp [C] ");
oled.setTextXY(3,11); oled.putString(" ");
oled.setTextXY(3,11); oled.putString(String(airTemp));
oled.setTextXY(4,0); oled.putString("AirHum [%] ");
oled.setTextXY(4,11); oled.putString(" ");
oled.setTextXY(4,11); oled.putString(String(airHum));
oled.setTextXY(5,0); oled.putString("SoilTmp[C] ");
oled.setTextXY(5,11); oled.putString(" ");
oled.setTextXY(5,11); oled.putString(String(soilTemp));
oled.setTextXY(6,0); oled.putString("SoilHum[%] ");
oled.setTextXY(6,11); oled.putString(" ");
oled.setTextXY(6,11); oled.putString(String(soilMoister));
oled.setTextXY(7,0); oled.putString("PUMP: ");
oled.setTextXY(7,6); oled.putString(String(pumpStatus));
oled.setTextXY(7,7); oled.putString(" LAMP: ");
oled.setTextXY(7,15); oled.putString(String(lampStatus));
}
/***************************************************
* Clear OLED Display
**************************************************/
void clearOledDisplay()
{
oled.setFont(font8x8);
oled.setTextXY(0,0); oled.putString(" ");
oled.setTextXY(1,0); oled.putString(" ");
oled.setTextXY(2,0); oled.putString(" ");
oled.setTextXY(3,0); oled.putString(" ");
oled.setTextXY(4,0); oled.putString(" ");
oled.setTextXY(5,0); oled.putString(" ");
oled.setTextXY(6,0); oled.putString(" ");
oled.setTextXY(7,0); oled.putString(" ");
oled.setTextXY(0,0); oled.putString(" ");
}
stationDefines.h:
/* TIMER */
#define READ_BUTTONS_TM 1L // definitions in seconds
#define READ_SOIL_TEMP_TM 2L
#define READ_SOIL_HUM_TM 10L
#define READ_AIR_DATA_TM 2L
//#define DISPLAY_DATA_TM 5L
/* OLED */
boolean turnOffOLED = 1;
/* DHT22*/
#define DHTPIN D3
#define DHTTYPE DHT22
float airHum = 0;
float airTemp = 0;
/* Soil Moister */
#define soilMoisterPin A0
#define soilMoisterVcc D8
int soilMoister = 0;
/* DS18B20 Temperature Sensor */
#define ONE_WIRE_BUS 14 // DS18B20 on NodeMCU pin D5 corresponds to GPIO 014 on Arduino
float soilTemp;
/* Relays */
#define PUMP_PIN D6 //PUMP (Red LED)
#define LAMP_PIN D7 //LAMP (Green LED)
boolean pumpStatus = 0;
boolean lampStatus = 0;
/* Buttons */
#define PUMP_ON_BUTTON D9 //push-button PUMP (Red)
#define LAMP_ON_BUTTON D10 //push-button LAMP (Green)
#define SENSORS_READ_BUTTON D4 //push-button SENSOR (yellow)