Code for humidity sensor( moisture sensor)

hello everybody, i need to supprime the part in this code that include the I2C OLED because there is no OLED in my project
i use a nano also

this is the schema of the cabling

excuse my english

this is the code

/*
  commands 
  v = feedback request
 */
 
#include <SoftwareSerial.h> 
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
const int AirValue = 900;   
const int WaterValue = 660;  
int soilMoistureValue20 = 0;
int soilMoistureValue40 = 0;
float voltage20;
float vol_water_cont20;
 float voltage40;
float vol_water_cont40;
char inchar; 
 
SoftwareSerial SIM900(8, 7); 
 
String TextForSms ;
String humidity20 = "moisture20:  %";
String humidity40 = "moisture40:  %";
 
 
void setup() {
 
   Serial.begin(9600);
  SIM900.begin(9600); 
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C); 
  display.clearDisplay(); 


  SIM900.print("AT+CMGF=1\r");  
  delay(1000);
  SIM900.print("AT+CNMI=2,2,0,0,0\r"); 
  

  delay(1000);
     SIM900.println("AT+CMGD=1,4"); 
   delay(5000);
  Serial.println("Ready...");
  
}
 
 
 
 
void sendSMS(String message)
{
  SIM900.println("AT+CMGF=1\r");                     
  delay(1000);
 SIM900.println("AT+CMGS = \"+21652689171\"");  
 
  delay(1000);
  SIM900.println(message);                         
  delay(1000);
  SIM900.println((char)26);                        
  delay(1000); 
  SIM900.println();
  delay(1000);                                     
                                  
}
  
void loop() {
 
if(SIM900.available() == 0)
{
 
   
  delay(2000);
 
soilMoistureValue20 = analogRead(A0);  
Serial.println(soilMoistureValue20);

 
  voltage20 = (float(soilMoistureValue20)/1023.0)*3.3;
    vol_water_cont20 = ((-0.3051)*voltage20)+0.9937; 


soilMoistureValue40 = analogRead(A1);  
Serial.println(soilMoistureValue40);

 
  voltage40 = (float(soilMoistureValue40)/1023.0)*3.3;
    vol_water_cont40 = ((-0.3051)*voltage40)+0.9937; 
    
  
  if (isnan(vol_water_cont20) || isnan(vol_water_cont40)) {
    Serial.println("Failed to read from sensor!");
    return;
  }

 delay (100);

  Serial.print("humidity20 ="); 
  Serial.print(vol_water_cont20);
  Serial.print("humidity40 ="); 
  Serial.print(vol_water_cont40);

  display.setCursor(5,0); 
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("M20=");  
  display.setCursor(60,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println(vol_water_cont20);

  display.setCursor(5,15); 
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("M40="); 
 display.setCursor(60,15);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println(vol_water_cont40);
  display.display();
  
  delay(250);
  display.clearDisplay();
  
  TextForSms = TextForSms + "moisture20: ";
  TextForSms.concat(vol_water_cont20);
   Serial.println(TextForSms); 
   TextForSms = TextForSms + " moisture40: ";
  TextForSms.concat(vol_water_cont40);
  Serial.println(TextForSms); 
  delay(2000);
  TextForSms = " ";
 
  
}
  if(SIM900.available() >0)
  {
 
    inchar=SIM900.read(); 
  Serial.println(inchar);
    delay(20);
    if (inchar=='v')
    {
      delay(10);
 
   Serial.println(inchar);
    
  // Wait a few seconds between measurements.
  delay(2000);
soilMoistureValue20 = analogRead(A0);  
Serial.println(soilMoistureValue20);

 
  voltage20 = (float(soilMoistureValue20)/1023.0)*3.3;
    vol_water_cont20 = ((-0.3051)*voltage20)+0.9937; 

soilMoistureValue40 = analogRead(A1); 
Serial.println(soilMoistureValue40);

 
  voltage40 = (float(soilMoistureValue40)/1023.0)*3.3;
    vol_water_cont40 = ((-0.3051)*voltage40)+0.9937; 

  
  if (isnan(vol_water_cont20) || isnan(vol_water_cont40)) {
    Serial.println("Failed to read from sensor!");
    return;
  }
delay(100);
 Serial.print("humidity20 ="); 
  Serial.print(vol_water_cont20);
  Serial.print("humidity40 ="); 
  Serial.print(vol_water_cont40);
 
  display.setCursor(5,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("M20=");  
  display.setCursor(60,0);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println(vol_water_cont20);

  display.setCursor(5,15);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println("M40="); 
 display.setCursor(60,15);  
  display.setTextSize(2);
  display.setTextColor(WHITE);
  display.println(vol_water_cont40);
  display.display();
 
 
  delay(250);
  display.clearDisplay();
  
  TextForSms = TextForSms + "moisture20 ";
  TextForSms.concat(vol_water_cont20);
   Serial.println(TextForSms); 
  TextForSms = TextForSms + " moisture40 ";
  TextForSms.concat(vol_water_cont40);
   sendSMS(TextForSms);
 sendSMS(TextForSms);
  Serial.println(TextForSms);
  delay(2000);
  TextForSms = " ";
    }
 
}
 
 
}

and your question is ?

this code is for the schema in the photo and my project doesn't include a I2C OLED , i need to erase the lines that incluse the 12C OLED( the display)

this code is for the schema in the photo and my project doesn't include a I2C OLED , i need to erase the lines that incluse the 12C OLED( the display)

Just do it and test again

it doesn't work , i send a message to the sim in the gsm but i didn't have a response

he purpose of this project is to place two humidity sensors, one 20 cm deep and the other 40 cm.
the sensors are connected with an Arduino nano card and a gsm.
we will receive a message giving us the humidity when we send a message to the sim on gsm.
I forgot to say that he has a gsm connected with the nano and the sensors

If you want to delete/ignore/remove the display, it would be a good starting point to delete/remove all the code that invokes the display library…

the problem isthat i don't know much about arduino and i wouldn't like to delete some lines that are useful
can you help me and say what specific lines to remove

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