Go Down

Topic: can anybody please help me. im stuck for this for a week. its shown error. (Read 165 times) previous topic - next topic

nasri

#include <Adafruit_GFX.h>
#include <Adafruit_SPITFT.h>
#include <Adafruit_SPITFT_Macros.h>
#include <gfxfont.h>

#include <DHT.h>
#include <DHT_U.h>

#include <Adafruit_SSD1306.h>



#include <ESPert.h>
ESPert espert;

const char *host = "www.espert.io";
String smartphone_key = "5415112476196864";
const char *ssid = "nasrizal";
const char *password = "nasrizal";

const int led1 = 2;
const int ir = 14;
const int switch1 = 12;
int value = 0;
int x = 0;               
int clearLCD = 0;       
int prev_state = 0;           
int calibrationTime = 10;
bool currentSwitch = true;

void setup()
{
  WiFi.begin(ssid,password);
  pinMode(ir, INPUT_PULLUP);
  pinMode(switch1, INPUT_PULLUP);
  pinMode(led1, OUTPUT);
  espert.init();
  espert.oled.init();
  delay(2000);
  espert.oled.clear();
  espert.oled.println(espert.info.getId());
  espert.oled.println();

  int mode = espert.wifi.init();

  if (mode == ESPERT_WIFI_MODE_CONNECT) {
    espert.println(">>> WiFi mode: connected.");
    espert.oled.println("WiFi: connected.");
    espert.oled.print("IP..: ");
    espert.oled.println(espert.wifi.getLocalIP());
  }
  else if (mode == ESPERT_WIFI_MODE_DISCONNECT) {
    espert.println(">>> WiFi mode: disconnected.");
    espert.oled.println("WiFi: not connected.");
  }
  else if (mode == ESPERT_WIFI_MODE_SMARTCONFIG) {
    espert.println(">>> WiFi mode: smart config.");
  }
  else if (mode == ESPERT_WIFI_MODE_SETTINGAP) {
    espert.println(">>> WiFi mode: access point.");
  }
}

void loop()
{
  espert.loop();
  int state = digitalRead(switch1);
  value = analogRead(ir);
  Serial.println(value);
  if (prev_state != state){clearLCD = 0;}
  if (state == HIGH) {
    if (x == 0) {
      x = 1;
      clearLCD = 0;
      espert.oled.clear();
      delay(2000);
      espert.oled.println("calibrating sensor... ");
      delay(10000);
      espert.oled.println(" done");
      espert.oled.println("SENSOR ACTIVE");
      delay(2000);
    }
    if (value < 1023) {
      value = analogRead(ir);
      Serial.println(value);
      clearLCD = 0;
      String message = "INTRUDER!" ;
      message.replace(String(" "), String("%20"));
      String path = "/MySmartphone/send?key=" + smartphone_key + "&message=" + message;
      espert.println(">>" + espert.wifi.getHTTP(host, path.c_str()) + "<<");
      espert.oled.println("INTRUDER!");
      digitalWrite(led1, HIGH);
      delay (2000);
    }

    else {
      if (clearLCD == 0) {
        digitalWrite(led1, LOW);
        espert.oled.clear();
        espert.oled.println("Nobody");
        clearLCD = 1;
      }
    }
  }
  else {
    if (value > 1023) {
      if (clearLCD == 0) {
        digitalWrite(led1, LOW);
        espert.oled.clear();
        espert.oled.println("OFF");
        clearLCD = 1;
      }
    }
    else {
      clearLCD = 0;
    }
  }

  prev_state = state;
  delay(10);
}


DrAzzy

Post the full contents of any and all error messages (you should always do this when asking for help with any technical issue).

Don't ask people to download your code, install the half dozen libraries it needs, and attempt to compile it, just to figure out what error message you get so we can help you for free...
ATtiny core for 841+1634+828 and x313/x4/x5/x61/x7/x8 series Board Manager:
http://drazzy.com/package_drazzy.com_index.json
ATtiny breakouts (some assembled), mosfets and awesome prototyping board in my store http://tindie.com/stores/DrAzzy

Go Up