I get error in 'Adafruit_SSD1306' does not name a type

I get error in 'Adafruit_SSD1306' does not name a type
this is a code
#include "thingProperties.h"

#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64

#define OLED_RESET -1
#define SCREEN_ADDRESS 0x3c

Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define DHTPIN 13
#define DHTTYPE DHT11
DHT dht(DHTPIN, DHTTYPE);

float temp;
float hum;

const int DryValue = 2650;
const int WetValue = 1800;
// Variables for soil moisture
int soilMoistureValue;
int soilMoisturePercent;

// Analog input port
#define SENSOR_IN 0

// Relay Port
#define RELAY_OUT 12

// Pump Status Text
String pump_status_text = "OFF";

// Variable for pump trigger
int pump_trigger = 30;

// IoT Cloud Thing Properties file
#include "thingProperties.h"
void setup() {
// Initialize serial and wait for port to open:
Serial.begin(9600);
// This delay gives the chance to wait for a Serial Monitor without blocking if none is found
delay(1500);

// Defined in thingProperties.h
initProperties();

// Connect to Arduino IoT Cloud
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you’ll get.
The default is 0 (only errors).
Maximum is 4
*/
setDebugMessageLevel(2);
ArduinoCloud.printDebugInfo();
// Initialize I2C display using 3.3 volts
display.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS);
display.clearDisplay();

// Initialize DHT11
dht.begin();

// Set ADC to use 12 bits
analogReadResolution(12);

// Set Relay as Output
pinMode(RELAY_OUT, OUTPUT);

// Turn off relay
digitalWrite(RELAY_OUT, LOW);

// Set Pump Status to Off
pump_Status = false;

}

void loop() {
ArduinoCloud.update();
// Get temperature and Humidity
temp = dht.readTemperature();
hum = dht.readHumidity();

// Pass temperature and humidity values to cloud variables
current_Temp = temp;
currrent_Humid = hum;

// Get soil mositure value
soilMoistureValue = analogRead(SENSOR_IN);

// Determine soil moisture percentage value
soilMoisturePercent = map(soilMoistureValue, DryValue, WetValue, 0, 100);

// Keep values between 0 and 100
soilMoisturePercent = constrain(soilMoisturePercent, 0, 100);

// Print raw value to serial monitor for sensor calibration
Serial.println(soilMoistureValue);

// Pass soil moisture to cloud variable
current_Moisture = soilMoisturePercent;

// See if pump should be triggered
// See if moisture is below or equal to threshold
if (soilMoisturePercent <= pump_trigger) {
// Turn pump on
pumpOn();

} else {
// Turn pump off
pumpOff();
}

// Cycle values on OLED Display
// Pump Status
printOLED(35, "PUMP", 40, pump_status_text, 2000);
// Temperature
printOLED(35, "TEMP", 10, String(temp) + "C", 2000);
// Humidity
printOLED(30, "HUMID", 10, String(hum) + "%", 2000);
// Moisture
printOLED(35, "MOIST", 30, String(soilMoisturePercent) + "%", 2000);

}
void onPumpStatusChange() {
// Turn pump off
digitalWrite(RELAY_OUT, LOW);
pump_status_text = "OFF";
pump_Status = false;

}

void printOLED(int top_cursor, String top_text, int main_cursor, String main_text, int delay_time){
// Prints to OLED and holds display for delay_time
display.setCursor(top_cursor, 0);
display.setTextSize(2);
display.setTextColor(WHITE);
display.println(top_text);

display.setCursor(main_cursor, 40);
display.setTextSize(3);
display.setTextColor(WHITE);
display.print(main_text);
display.display();

delay(delay_time);
display.clearDisplay();

}

void onTrrigerLevelChange() {
pump_trigger = trigger_Level;
}


a error message shown :slight_smile: in line 24

/tmp/149041514/Untitled_sep24a/Untitled_sep24a.ino: In function 'void onTrrigerLevelChange()':

/tmp/149041514/Untitled_sep24a/Untitled_sep24a.ino:176:19: error: 'trigger_Level' was not declared in this scope

pump_trigger = trigger_Level;

^

Error during build: exit status 1

code tags?

which OLED library will you be using?

@awab159 Installation and Troubleshooting is for Problems with the Arduino IDE itself NOT your project. It says so in the description of the section.

Therefore I have moved your post here. Please be more careful where you post in future.

You may want to read this before you proceed:-
how to get the best out of this forum

1 Like

Here is a thread of discussion regarding this error How to fix "Does not name a type" error?

1 Like

this all libraries are used:
// Adafruit GFX Library - Version: Latest
#include <Adafruit_GFX.h>
#include <Adafruit_GrayOLED.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

// Adafruit SSD1306 - Version: Latest
#include <Adafruit_SSD1306.h>
#include <splash.h>

// DHT sensor library - Version: Latest
#include <DHT.h>
#include <DHT_U.h>

// Wire Library for I2C

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.