NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

//#include <SoftwareSerial.h>
//SoftwareSerial Serial1(10, 11);

const String wifiAdi = "emrah";
const String wifiSifresi = "emrah1234";
const int toprakSensoruPort = A0;

int BasDeger;
int SonDeger;
int istenilenNem;
String YeniVeri;
int nemDegeri;
void setup()
{
Serial.begin(9600);
Serial1.begin(9600);
pinMode(22, OUTPUT);
delay(500);

if(!interneteBaglan()){
Serial.println("internete baglanilamadi");
}
else {
Serial.println("Modul internete baglandi");
}
digitalWrite(22, HIGH);
}

void loop()
{
digitalWrite(22, HIGH);
// String At = wifi();
String istek;
//istek = "GET /B2BService.svc/Category/List HTTP/1.0rnConnection: closernHost: b2bapp.azurewebsites.netrnrn";
String q = "Name=atkafasi&Description=asadasdsadasd&Status=1";
istek = "GET /Service.svc/urun/current HTTP/1.0rnConnection: closernHost: ats.yurttutan.netrnContent-Type:application/x-www-form-urlencodedrnContent-Length:"+String(q.length())+"rnrn";
Serial1.print("AT+CIPSTART="TCP","ats.yurttutan.net",80rn");
Serial1.find("OK");

Serial.println("Baglanti istegi yollandi");
delay(1000);

Serial1.print("AT+CIPSEND=");
Serial1.find(">");
Serial1.println(String(istek.length()));
Serial.println("HTTP istegi yollandi");
delay(1000);

Serial1.print(istek);
Serial1.find("SEND OK");
Serial.println("Baglanti kuruldu");

String alinanVeri = "";
char k;
long zaman = millis();

while(alinanVeri.indexOf("CLOSED") == -1){
if(millis() - zaman > 3000){
break;
}
while(Serial1.available())
{
k = Serial1.read();// modülden gelen cevaplar kaydediliyor
alinanVeri+=k;
alinanVeri.trim();
BasDeger = alinanVeri.indexOf("close");
SonDeger = alinanVeri.indexOf("CLOSED");
YeniVeri = alinanVeri.substring(BasDeger+5,SonDeger);
istenilenNem = YeniVeri.toInt();
}
}
Serial.print(YeniVeri);


nemDegeri = analogRead(toprakSensoruPort);
delay(10);
Serial.print("İstenen Nem ");
Serial.println(YeniVeri);
Serial.print("Nem ");
Serial.print(nemDegeri);
if(istenilenNem!=0){
if (YeniVeri.toInt() <= nemDegeri){
digitalWrite(22, LOW);
Serial.println("motor açıldı ");
}else if (YeniVeri.toInt() >= nemDegeri){
digitalWrite(22, HIGH);
Serial.println("motor kapatıldı ");
}
delay(5000);
}else {
delay(50);
}

}

String wifi(){
String istek;
//istek = "GET /B2BService.svc/Category/List HTTP/1.0rnConnection: closernHost: b2bapp.azurewebsites.netrnrn";
String q = "Name=atkafasi&Description=asadasdsadasd&Status=1";
istek = "GET /Service.svc/urun/current HTTP/1.0rnConnection: closernHost: ats.yurttutan.netrnContent-Type:application/x-www-form-urlencodedrnContent-Length:"+String(q.length())+"rnrn";
Serial1.print("AT+CIPSTART="TCP","ats.yurttutan.net",80rn");
Serial1.find("OK");

Serial.println("Baglanti istegi yollandi");
delay(1000);

Serial1.print("AT+CIPSEND=");
Serial1.find(">");
Serial1.println(String(istek.length()));
Serial.println("HTTP istegi yollandi");
delay(1000);

Serial1.print(istek);
Serial1.find("SEND OK");
Serial.println("Baglanti kuruldu");

String alinanVeri = "";
char k;
long zaman = millis();

while(alinanVeri.indexOf("CLOSED") == -1){
if(millis() - zaman > 3000){
break;
}
while(Serial1.available())
{
k = Serial1.read();// modülden gelen cevaplar kaydediliyor
alinanVeri+=k;
alinanVeri.trim();
BasDeger = alinanVeri.indexOf("close");
SonDeger = alinanVeri.indexOf("CLOSED");
YeniVeri = alinanVeri.substring(BasDeger+5,SonDeger);
istenilenNem = YeniVeri.toInt();
}
}
Serial.println(YeniVeri);
return YeniVeri;
}
String ATKomuduYolla(String ATKomudu, int zamanAsimi, boolean debug)
{
Serial1.print(ATKomudu); // AT komudu modüle gönderildi
long int zaman = millis();
String cevap = "";
while( (zaman+zamanAsimi) > millis()) // Zaman aşımına kadar bekle
{
while(Serial1.available())
{
char k = Serial1.read(); // modülden gelen cevaplar kaydediliyor
cevap+=k;
}
if(cevap.indexOf("OK") != -1)
break;
}
if(debug)
Serial.print(cevap); // modülden gelen cevaplar ekrana yazdırılıyor
return cevap;
}

boolean interneteBaglan(){
ATKomuduYolla("AT+CWMODE=1rn",1000,true); // internete bağlanacağımız için 1. moda alıyoruz
ATKomuduYolla("AT+CWJAP="" + wifiAdi + "",""+ wifiSifresi + ""rn",10000,true); // wifi bağlantısı yapılıyor
String durum = "";
durum = ATKomuduYolla("AT+CIFSRrn",8000,true); // bağlantı bilgileri
if(durum.indexOf("FAIL") != -1 ){ // bağlantı başarı durumu test ediliyor
return false;
}
return true;
}

     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.