Jumat, 22 September 2017

ruwet with sim800l v2



#include <gprs.h>
#include <SoftwareSerial.h>

#define TIMEOUT    5000
#define LED_PIN    13
#define ON HIGH
#define OFF LOW

//tx 2
//rx 4
const int Relay1 = 7;
const int Relay2 = 6;
const int Relay3 = 5;
const int Relay4 = 3;


const int DI1 = A0;                                      
const int DI2 = A1;                          

int buttonState1=0;
int lastButtonState1=0;

int buttonState2=0;
int lastButtonState2=0;                   


int StatRelay1;
int StatRelay2;
int StatRelay3;
int StatRelay4;

GPRS gprs;

void setup() {
  pinMode (Relay1 , OUTPUT); digitalWrite (Relay1, LOW);
  pinMode (Relay2 , OUTPUT); digitalWrite (Relay2, LOW);
  pinMode (Relay3 , OUTPUT); digitalWrite (Relay3, LOW);
  pinMode (Relay4 , OUTPUT); digitalWrite (Relay4, LOW);
 
  pinMode (DI1 , INPUT);
  pinMode (DI2 , INPUT);
 
 
 
  Serial.begin(9600);
  while(!Serial);

  Serial.println("Starting SIM800 Auto Read SMS");
  gprs.preInit();
  delay(1000);

  while(0 != gprs.init()) {
      delay(1000);
      Serial.print("init error\r\n");
  }

  //Set SMS mode to ASCII
  if(0 != gprs.sendCmdAndWaitForResp("AT+CMGF=1\r\n", "OK", TIMEOUT)) {
    ERROR("ERROR:CNMI");
    return;
  }
  
  //Start listening to New SMS Message Indications
  if(0 != gprs.sendCmdAndWaitForResp("AT+CNMI=1,2,0,0,0\r\n", "OK", TIMEOUT)) {
    ERROR("ERROR:CNMI");
    return;
  }

  Serial.println("Init success");
}

//Variable to hold last line of serial output from SIM800
char currentLine[500] = "";
int currentLineIndex = 0;

//Boolean to be set to true if message notificaion was found and next
//line of serial output is the actual SMS message content
bool nextLineIsMessage = false;

void loop() {
   int buttonState1=digitalRead(DI1);
 
  int buttonState2=digitalRead(DI2); 
  int teg =analogRead (A2);
  {
    if (buttonState1!= lastButtonState1)
    {
  if (buttonState1 == HIGH)
  {
    gprs.sendSMS("085853830668", "1 2 1");
    Serial.println("\nDI 1ON");
    }
  else {
   gprs.sendSMS("085853830668", "1 2 0");
    Serial.println("\nDI 1OFF");
  }
    }
    lastButtonState1=buttonState1;
  delay(300);
  }
 
  //Write current status to LED pin
  digitalWrite(Relay1, StatRelay1);
  digitalWrite(Relay2, StatRelay2);
  digitalWrite(Relay3, StatRelay3);
  digitalWrite(Relay4, StatRelay4);
  
  //If there is serial output from SIM800
  if(gprs.serialSIM800.available()){
    char lastCharRead = gprs.serialSIM800.read();
    //Read each character from serial output until \r or \n is reached (which denotes end of line)
    if(lastCharRead == '\r' || lastCharRead == '\n'){
        String lastLine = String(currentLine);
        
        //If last line read +CMT, New SMS Message Indications was received.
        //Hence, next line is the message content.
        if(lastLine.startsWith("+CMT:")){
          
          Serial.println(lastLine);
          nextLineIsMessage = true;
          
        } else if (lastLine.length() > 0) {
          
          if(nextLineIsMessage) {
            Serial.println(lastLine);
            

// ########## MEMBACA KONTEN SMS DAN MENCARI+MENGARTIKAN KONTEN SMS KE PROGRAM #########
            //Kendali Relay
              if(lastLine.indexOf("1 1 1") >= 0){
              StatRelay1 = ON;
              Serial.println("DO1 ON");
              gprs.sendSMS ("085853830668","1 1 1");}
              else if(lastLine.indexOf("1 1 0") >= 0) {
              StatRelay1 = OFF;
              Serial.println("DO1 OFF");
              gprs.sendSMS ("085853830668","1 1 0");}
           
             
              if(lastLine.indexOf("1 5 1") >= 0){
              StatRelay2 = ON;
              Serial.println("Relay2 DINYALAKAN");
              gprs.sendSMS ("085853830668","1 5 1");}
              else if(lastLine.indexOf("1 5 0") >= 0) {
              StatRelay2 = OFF;
              Serial.println("Relay2 DIMATIKAN");
              gprs.sendSMS ("085853830668","1 5 0");}

              if(lastLine.indexOf("Relay3 ON") >= 0){
              StatRelay3 = ON;
              Serial.println("Relay3 DINYALAKAN");
              gprs.sendSMS ("081555305255","Relay3 DINYALAKAN");}
              else if(lastLine.indexOf("Relay3 OFF") >= 0) {
              StatRelay3 = OFF;
              Serial.println("Relay3 DIMATIKAN");
              gprs.sendSMS ("081555305255","Relay3 DIMATIKAN");}

              if(lastLine.indexOf("Relay4 ON") >= 0){
              StatRelay4 = ON;
              Serial.println("Relay4 DINYALAKAN");
              gprs.sendSMS ("081555305255","Relay4 DINYALAKAN");}
              else if(lastLine.indexOf("Relay4 OFF") >= 0) {
              StatRelay4 = OFF;
              Serial.println("Relay4 DIMATIKAN");
              gprs.sendSMS ("081555305255","Relay4 DIMATIKAN");}
           
              if(lastLine.indexOf("update") >= 0){
              Serial.println("update analog");
              gprs.sendSMS ("085853830668", teg);}
             
           
            
            nextLineIsMessage = false;
          }
          
        }
        
        //Clear char array for next line of read
        for( int i = 0; i < sizeof(currentLine);  ++i ) {
         currentLine[i] = (char)0;
        }
        currentLineIndex = 0;
    } else {
      currentLine[currentLineIndex++] = lastCharRead;
    }
  }
}

pengukuran baterai per cell dengan arduino


eksperimen kali ini tentang penguukuran baterai percell. yang dimonitoring dari arduino.
ini rencananya monitoring tegangan baterai rectifier di sebuah substation.

berikut sketchnya:

int BT1 = A5;   
int BT2 = A4;

int Bat1 = 0; 
int Bat2 = 0;
int BatT = 0;

void setup() {
    Serial.begin(9600);
}

void loop() {
   float Bat1 = analogRead(BT1)*0.01437;
   float Bat2 = analogRead(BT2)*0.02517;
   float BatT = analogRead(BT2)*0.05028;
   Serial.print("Baterai 1 = " );
  Serial.print(Bat1);
  Serial.print("     Baterai 2 = ");
  Serial.print(Bat2);
  Serial.print("     Baterai Total  = ");
  Serial.println(BatT);

   delay(1000);
}


komponen yang dibutuhkan
1. resistor 4 buah yang d rangkai voltage divider.
2. dtambah kapasitor2 buah sebagai filter






Kamis, 14 September 2017

integrasi epm5500 to SIMOR

bagi yang membutuhkan addres modbus power meter epm5500P multilin
bisa download disini




percobaan integrasi power meter multilin epm 5500P to rtu simor.
data yang di ambil tegangan arus dan frekwensi
data yang dikirim sisi primer.
sperti contoh :
saya injek arus 1A,
ratio CT  400/5
tampilan LCD menunjukan 80, akan tetapi yang keluar di data modbus 1000
jadi agar datanya sama tampilan LCD di faktor kalikan 0,8 (sesuai ratio CT.


berikut videonya



thanks

Cara membuat datalogger blynk di spreadsheet / googlesheet menggunakan akun versi Free

  silahkan video di atas. semoga bermanfaat. jika masih kurang jelas bisa kontak saya