I can't find the problem, originally it's a normal program with my friend's pc
#include <EEPROM.h>
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <SoftwareSerial.h>
#include <dht.h>
#include <Keypad.h>
dht DHT;
#define DHT22_PIN 12
struct
{
uint32_t total;
uint32_t ok;
uint32_t crc_error;
uint32_t time_out;
uint32_t connect;
uint32_t ack_l;
uint32_t ack_h;
uint32_t unknown;
} stat = { 0,0,0,0,0,0,0,0};
SoftwareSerial sim(2, 3);
#define I2C_ADDR 0x3F // <<----- Add your address here. Find it from I2C Scanner
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'A','3','2','1'},
{'B','6','5','4'},
{'C','9','8','7'},
{'D','#','0','.'}
};
byte rowPins[ROWS] = {8, 9, 10, 11}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {7, 6, 5, 4}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
float suhu = 0.0f ;
//===============================> data batasan <=====================//
union data {
float dataF;
byte dataB[10];
} lembap_temp , suhu_temp ;
void writeLembap( float data ){
lembap_temp.dataF = data ;
for( int i = 0 ; i < 10 ; i++ ){
EEPROM.write( i , int(lembap_temp.dataB[i]) );
}
}
void writeSuhu( float data ){
suhu_temp.dataF = data ;
int count = 0 ;
for( int i = 20 ; i < 30 ; i++ ){
EEPROM.write( i , int(suhu_temp.dataB[count]) );
count++ ;
}
}
float readLembap(){
for( int i = 0 ; i < 10 ; i++ ){
lembap_temp.dataB[i] = byte(EEPROM.read( i ));
}
return lembap_temp.dataF ;
}
float readSuhu(){
int count = 0 ;
for( int i = 20 ; i < 30 ; i++ ){
suhu_temp.dataB[count] = byte(EEPROM.read( i ));
count++;
}
return suhu_temp.dataF ;
}
//====================================================================//
//========================================================//
String readSimm900A(){
String str = "" ;
while(sim.available()){
str += char(sim.read());
delay(5);
}
return str ;
}
String sendATComm( String msg ){
sim.print(msg);
sim.write(13);
Serial.print(msg);
Serial.write(13);
}
int levelair = 0;
void sendSms( bool isTest , bool isLembap){
sim.print("AT+CMGF=1");
sim.write(13);
delay(1000);
sim.print("AT+CMGS=");
sim.write(34);
sim.print("082231348593"); //========================> ganti nomor hp
sim.write(34);
sim.write(13);
delay(2000);
if(isTest)
sim.print("Test SMS");
else{
if( isLembap ){
sim.print("Tingkat Kelembapan naik, nilai kelembapan:");
sim.print(DHT.humidity );
sim.print("% ");
}else{
sim.print("Tingkat Temperatur naik, nilai Suhu:");
sim.print(DHT.temperature);
sim.print("*C");
}
}
delay(2000);
sim.write(26);
String msg = readSimm900A() ;
while( msg.length() == 0 ){
msg = readSimm900A() ;
delay(100);
}
Serial.println(msg);
}
void tesConnectWaveComm(){
//=================> sim900A <===========================//
lcd.clear();
lcd.setCursor(0,0);
lcd.print("access sim900a");
unsigned long tm = millis();
while( true ){
String msg = readSimm900A();
if( msg.indexOf("OK") > -1 ){
break ;
}
if((millis()-tm) > 1000 ){
tm = millis();
sim.print("AT+CMGF=1");
sim.write(13);
Serial.println("at-cmgf");
}
}
lcd.setCursor(0,1);
lcd.print("selesai");
}
//========================================================//
void setup()
{
Serial.begin(9600);
sim.begin(9600);
lcd.begin (16,2); // <<----- My LCD was 16x2
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
}
unsigned long tm = millis();
//========================================> parameter pengiriman data .
int countSendData_lembap = 0 ;
int countSendData_suhu = 0 ;
//========================================> parameter ketika suhu naik lagi .
float oldTemp = 0 ;
bool isAlreadySendSmsTwice = false ;
void loop()
{
//================================> baca sensor suhu
DHT.read22(12);
float data = analogRead(A1);
data = (data*5000)/1024 ;
suhu = data / 10 ;
//==============================> tampilkan data kelembapan dan suhu .
if( (millis()-tm) > 1000 ){
tm = millis();
showData();
Serial.println("lcd show");
}
//========================================> chek tombol keypad .
//========================================> saat ditekan akan mengaktifkan fungsi tertentu .
char customKey = customKeypad.getKey();
if( customKey ){
if( customKey == 'A' ){
Serial.println("button A");
saveDataLembap();
}
else if( customKey == 'B' ){
Serial.println("button A");
saveDataSuhu();
}
else if( customKey == '1' ){
tesConnectWaveComm();
}
else if( customKey == '2' ){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Tes SMS");
sendSms(true,false);
}
else if( customKey == '3' ){
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Tes SMS");
lcd.setCursor(0,1);
lcd.print("lembap");
sendSms(false,false);
}
}
//=====================================> chek apakah dht melewati batas .
if(
(DHT.temperature > readSuhu())
)
{
//=====================================> chek apakah belum mengirim data sms .
if( countSendData_suhu == 0 ){
//===================================> set untuk delay penngecekan di lakukan 3 detik kemudian .
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Suhu");
lcd.setCursor(0,1);
lcd.print("naik, suhu:");
lcd.print(DHT.temperature);
lcd.print("*C");
sendSms(false,false);
countSendData_suhu++ ;
oldTemp = DHT.temperature ;
}
}else{
countSendData_suhu = 0 ;
oldTemp = 0 ;
}
if( countSendData_suhu > 0 ){
if( DHT.temperature > (oldTemp+3) ){
oldTemp = DHT.temperature ;
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Suhu");
lcd.setCursor(0,1);
lcd.print("naik, suhu:");
lcd.print(DHT.temperature);
lcd.print("*C");
delay(1000);
sendSms(false,false);
}
}
if(
(DHT.humidity > readLembap())
)
{
//=====================================> chek apakah belum mengirim data sms .
if( countSendData_lembap == 0 ){
//===================================> set untuk delay penngecekan di lakukan 3 detik kemudian .
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Kelembapan");
lcd.setCursor(0,1);
lcd.print("naik, kelembapan:");
lcd.print(DHT.humidity );
lcd.print("% ");
sendSms(false,true);
countSendData_lembap++ ;
}
}else{
countSendData_lembap = 0 ;
}
}
//=================================================================> prosedure untuk smpan data kelembapan .
void saveDataLembap(){
unsigned long tmlcd = millis();
String keyPad = "" ;
bool exitNow = false ;
Serial.println("enter lembap mode");
while(!exitNow){
char customKey = customKeypad.getKey();
if( customKey ){
if( customKey == 'A' ){
char buff[keyPad.length()] ;
keyPad.toCharArray( buff , keyPad.length() + 1);
float temp = atof(buff);
writeLembap( temp );
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Data Disimpan");
lcd.setCursor(0,1);
lcd.print(readLembap());
lcd.print(" %");
delay(2000);
keyPad = "" ;
}
else if( customKey == 'B' ){
keyPad = "" ;
}
else if( customKey == 'D' ){
exitNow = true ;
softwareReset();
}
else{
keyPad += customKey ;
}
}
if( (millis()-tmlcd) > 500 ){
tmlcd = millis();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Lama:");
lcd.print(readLembap());
lcd.print(" %");
lcd.setCursor(0,1);
lcd.print("Baru:");
lcd.print(keyPad);
lcd.print(" %");
}
}
}
//=================================================================> prosedure untuk smpan data suhu .
void saveDataSuhu(){
unsigned long tmlcd = millis();
String keyPad = "" ;
bool exitNowtrue = false ;
Serial.println("enter suhu mode");
while(!exitNowtrue){
char customKey = customKeypad.getKey();
if( customKey ){
if( customKey == 'A' ){
char buff[keyPad.length()] ;
keyPad.toCharArray( buff , keyPad.length() + 1);
float temp = atof(buff);
writeSuhu( temp );
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Data Disimpan");
lcd.setCursor(0,1);
lcd.print(readSuhu());
lcd.print(" *C");
delay(2000);
keyPad = "" ;
}
else if( customKey == 'B' ){
keyPad = "" ;
}
else if( customKey == 'D' ){
exitNowtrue = true ;
softwareReset();
}
else{
keyPad += customKey ;
}
}
if( (millis()-tmlcd) > 800 ){
tmlcd = millis();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Lama:");
lcd.print(readSuhu());
lcd.print(" *C");
lcd.setCursor(0,1);
lcd.print("Baru:");
lcd.print(keyPad);
lcd.print(" *C");
}
}
}
void showData(){
//===============================================> tampilkan status pada lcd .
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Kelembapan:");
lcd.print(DHT.humidity,0);
lcd.print("%");
lcd.setCursor(0,1);
lcd.print("Suhu:");
lcd.print(DHT.temperature);
lcd.print(" *C");
lcd.setCursor(15,0);
if( DHT.humidity > readLembap() ){
lcd.print("1");
}else{
lcd.print("0");
}
lcd.setCursor(15,1);
if( DHT.temperature > readSuhu() ){
lcd.print("1");
}else{
lcd.print("0");
}
}
//=======================================> fungsi untuk membaca pesan dari serial <=================================================//
String readCompMessage(){
String buff = "" ;
while( Serial.available() > 0 ){
char chr = char(Serial.read());
buff += chr;
delay(3);
}
return buff ;
}
//=================================================================================================================================//
//=======================> reset code <==============================================================================================//
void softwareReset(){
asm volatile("jmp 0");
}
//=================================================================================================================================//
Error code
Arduino: 1.8.19 (Windows 10), Board: "Arduino Uno"
In file included from D:\SKRIPSI\COBA\COBA.ino:3:0:
C:\Program Files (x86)\Arduino\libraries\i2c_lcd/LCD.h:421:44: error: 'prog_uchar' does not name a type; did you mean 'getchar'?
void createChar(uint8_t location, const prog_uchar charmap[]);
^~~~~~~~~~
getchar
COBA:9:1: error: 'dht' does not name a type
dht DHT;
^~~
D:\SKRIPSI\COBA\COBA.ino: In function 'void sendSms(bool, bool)':
COBA:146:25: error: expected primary-expression before '.' token
sim.print(DHT.humidity );
^
COBA:150:25: error: expected primary-expression before '.' token
sim.print(DHT.temperature);
^
D:\SKRIPSI\COBA\COBA.ino: In function 'void tesConnectWaveComm()':
COBA:169:5: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\SKRIPSI\COBA\COBA.ino: In function 'void setup()':
COBA:206:3: error: 'lcd' was not declared in this scope
lcd.begin (16,2); // <<----- My LCD was 16x2
^~~
D:\SKRIPSI\COBA\COBA.ino: In function 'void loop()':
COBA:224:6: error: expected unqualified-id before '.' token
DHT.read22(12);
^
COBA:251:9: error: 'lcd' was not declared in this scope
Multiple libraries were found for "Adafruit_Sensor.h"
lcd.clear();
Used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Sensor
^~~
Not used: C:\Program Files (x86)\Arduino\libraries\Adafruit_Sensor1
COBA:257:9: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
COBA:270:14: error: expected primary-expression before '.' token
(DHT.temperature > readSuhu())
^
COBA:276:11: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
COBA:281:24: error: expected primary-expression before '.' token
lcd.print(DHT.temperature);
^
COBA:285:24: error: expected primary-expression before '.' token
oldTemp = DHT.temperature ;
^
COBA:294:14: error: expected primary-expression before '.' token
if( DHT.temperature > (oldTemp+3) ){
^
COBA:295:22: error: expected primary-expression before '.' token
oldTemp = DHT.temperature ;
^
COBA:296:9: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
COBA:301:22: error: expected primary-expression before '.' token
lcd.print(DHT.temperature);
^
COBA:312:14: error: expected primary-expression before '.' token
(DHT.humidity > readLembap())
^
COBA:318:11: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
COBA:323:24: error: expected primary-expression before '.' token
lcd.print(DHT.humidity );
^
D:\SKRIPSI\COBA\COBA.ino: In function 'void saveDataLembap()':
COBA:351:12: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\SKRIPSI\COBA\COBA.ino:351:12: note: suggested alternative: 'tmlcd'
lcd.clear();
^~~
tmlcd
COBA:377:9: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\SKRIPSI\COBA\COBA.ino:377:9: note: suggested alternative: 'tmlcd'
lcd.clear();
^~~
tmlcd
D:\SKRIPSI\COBA\COBA.ino: In function 'void saveDataSuhu()':
COBA:408:12: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\SKRIPSI\COBA\COBA.ino:408:12: note: suggested alternative: 'tmlcd'
lcd.clear();
^~~
tmlcd
COBA:434:9: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
D:\SKRIPSI\COBA\COBA.ino:434:9: note: suggested alternative: 'tmlcd'
lcd.clear();
^~~
tmlcd
D:\SKRIPSI\COBA\COBA.ino: In function 'void showData()':
COBA:451:5: error: 'lcd' was not declared in this scope
lcd.clear();
^~~
COBA:454:18: error: expected primary-expression before '.' token
lcd.print(DHT.humidity,0);
^
COBA:458:18: error: expected primary-expression before '.' token
lcd.print(DHT.temperature);
^
COBA:465:12: error: expected primary-expression before '.' token
if( DHT.humidity > readLembap() ){
^
COBA:472:12: error: expected primary-expression before '.' token
if( DHT.temperature > readSuhu() ){
^
exit status 1
'dht' does not name a type
This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.