Kamis, 04 Juni 2020

apa yang perlu disiapkan sebelum training "MEMBUAT ALAT MONITORING ARUS LISTRIK RUMAH DARI HANDPHONE"?



pertama komponen :
-Nodemcu + kabel data
-Sensor arus Split core
-PCB 5x7cm
-Resistor 33ohm
-Resistor 10Kohm #2
-Resistor 330ohm
-Elco 10uF 16v
-Led
-Pin header female 1x40
-Kabel Jumper

kedua alat :
- laptop/pc
- kabel usb micro
- handphone

yang perlu di instal :
PC/laptop : sofrware arduino IDE, serta library (blynk, esp8266, emonlib, timelib)


*klik tulisan buat download

software yang d gunakan saat training zoom / google meet. silahkan di siapkan di laptop atau handphone masing".


Selasa, 02 Juni 2020

modul kontrol relay 1 channel esp8266



1 – The power input terminals.
2 – The relay output terminals.
3 – IO input terminal.
4 – Enter the status indicator, IO input high when lit, blue light.
5 – The relay output status indicator, the relay is turned on, the red light.
6 – TTL serial output.
7 – Boot mode selection jumper.

A: 7-30V+ DC power supply
B: Power supply ground
C: Normally closed (NC) relay contact
D: Common (COM) relay contact
E: Normally open (NO) relay contact
F: 5V+ out
G: ESP8266 GPIO5 Optocoupler Input
H: Ground (isolated optocoupler input)

scematic

script Blynk
/*************************************************************************
* Title: Simple ESP-8266 blynk/yunshan wifi relay control
* File: esp8266_yunshan_relay.ino
* Author: James Eli
* Date: 12/25/2016
*
* This program controls a Yunshan wifi relay module communicating through
* the onboard esp-8266-12e module. The module is controlled from the
* internet via the Blynk cloud app.
*
* Notes:
* (1) Requires the following arduino libraries:
* ESP8266
* Blynk
* (2) Compiled with arduino ide 1.6.12
* (3) Uses three Blynk app widgets:
* V0: button configured as a switch.
* V1: led.
* V2: led.
*************************************************************************
* Change Log:
* 12/25/2016: Initial release. JME
* 12/31/2016: Added input pin status. JME
* 01/15/2017: Added volatile. JME
*************************************************************************/
#include <ESP8266WiFi.h>
#include <BlynkSimpleEsp8266.h>

// Esp8266 pins.
#define ESP8266_GPIO2 2 // Blue LED.
#define ESP8266_GPIO4 4 // Relay control.
#define ESP8266_GPIO5 5 // Optocoupler input.
#define LED_PIN ESP8266_GPIO2
// Blynk app authentication code.
char auth[] = "***";
// Wifi SSID.
const char ssid[] = "***";
// Wifi password.
const char password[] = "***";
// Flag for sync on re-connection.
bool isFirstConnect = true;
volatile int relayState = LOW; // Blynk app pushbutton status.
volatile int inputState = LOW; // Input pin state.

void setup() {
pinMode( ESP8266_GPIO4, OUTPUT ); // Relay control pin.
pinMode( ESP8266_GPIO5, INPUT_PULLUP ); // Input pin.
pinMode( LED_PIN, OUTPUT ); // ESP8266 module blue LED.
digitalWrite( LED_PIN, LOW ); // Turn on LED.
Blynk.begin( auth, ssid, password ); // Initiate Blynk conection.
digitalWrite( LED_PIN, HIGH ); // Turn off LED.
}

// This function runs every time Blynk connection is established.
BLYNK_CONNECTED() {
if ( isFirstConnect ) {
Blynk.syncAll();
isFirstConnect = false;
}
}

// Sync input LED.
BLYNK_READ( V2 ) {
CheckInput();
}

// Blynk app relay command.
BLYNK_WRITE( V0 ) {
if ( param.asInt() != relayState ) {
relayState = !relayState; // Toggle state.
digitalWrite( ESP8266_GPIO4, relayState ); // Relay control pin.
Blynk.virtualWrite( V1, relayState*255 ); // Set Blynk app LED.
}
}

// Debounce input pin.
int DebouncePin( void ) {
// Read input pin.
if ( digitalRead( ESP8266_GPIO5 ) == HIGH ) {
// Debounce input.
delay( 25 );
if ( digitalRead( ESP8266_GPIO5 ) == HIGH )
return HIGH;
}
return LOW;
}

// Set LED based upon state of input pin.
void CheckInput( void ) {
if ( DebouncePin() != inputState ) {
Blynk.virtualWrite( V2, inputState*255 );
inputState = !inputState;
}
}

// Main program loop.
void loop() {
Blynk.run();
CheckInput();
//yield(); //Updated: 3/8/2017
}

Kamis, 21 Mei 2020

lanjutan dari Mobil Molen - modifikasi capit




#define BLYNK_PRINT Serial 
#include  <ESP8266WiFi.h>
#include  <BlynkSimpleEsp8266.h>
#include <Servo.h>
char auth[] = "6shj0yJKzVZnjYgH4H28kq9ww3UKfOai"; 
char ssid[] = "SIMOR#2019"; 
char pass[] = "simor123"; 
Servo servo;
Servo servo1;
int PWMA=5;//Right side 
int PWMB=4;//Left side 
int DA=0;//Right reverse 
int DB=2;//Left reverse 

void setup(){ 
 // Debug console 
 Serial.begin(9600); 
 Blynk.begin(auth, ssid, pass); 
 servo.attach(14); // 14 means D5 pin of ESP8266
 servo.write(0);
 servo1.attach(12); // 12 means D6 pin of ESP8266

 pinMode(PWMA, OUTPUT); 
 pinMode(PWMB, OUTPUT); 
 pinMode(DA, OUTPUT); 
 pinMode(DB, OUTPUT); 

void loop(){ 
Blynk.run(); 
  
BLYNK_WRITE(V3) {
int molen1 = param.asInt(); 

if(molen1 == 1 ){ 
   if(!servo1.attached())servo1.attach(12) ;     
     servo1.write(0);              
      
}else {        
     servo1.detach();   
}
}
BLYNK_WRITE(V2) {
int molen = param.asInt(); 

if(molen == 1 ){             
     servo.write(30);              
      
}else if(molen == 0){        
     servo.write(0);    
}
}
BLYNK_WRITE(V0) {
int capit = param.asInt(); 

if(capit == 1 ){             
      servo.write(65);              
      //delay(15);
}else if(capit == 0){        
     servo.write(0);    
}
}
// Handling Joystick data 
BLYNK_WRITE(V1){ 
int x = param[0].asInt(); 
int y = param[1].asInt();  
if(x==-1 && y==-1){             //Backward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH); 
}else if(x==-1 && y==0){        //Left Turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, HIGH); 
    
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, LOW); 
}else if(x==-1 && y==1){        //Forward and Left     
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==-1){        //Backward     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, HIGH);
}else if(x==0 && y==0){        //Stay 
     digitalWrite(PWMA, LOW); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==0 && y==1){        //Forward 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
    
     digitalWrite(PWMB, HIGH); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==-1){        //Backward and Right     
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, HIGH); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW); 
}else if(x==1 && y==0){        //Right turn 
     digitalWrite(PWMA, 450); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, 450); 
     digitalWrite(DB, HIGH); 
}else if(x==1 && y==1){        //Forward and Right 
     digitalWrite(PWMA, HIGH); 
     digitalWrite(DA, LOW); 
     
     digitalWrite(PWMB, LOW); 
     digitalWrite(DB, LOW);
 } 

Senin, 11 Mei 2020

cara merubah baudrate modul SIM900/SIM900A



muncul sharing ini berawal dari sebuah kasus sim900 konek ke server blynk cannot init dan kadang konek kadang diskonek

kali ini saya menggunakan arduino mega sebagai mikrokontrollernya

modul sim900nya konek ke serial1

sediakan power supply minim 12V 3A kemudian d step downkan menjadi 5v






langkah pertama cek dahulu baudratenya menggunakan example dari library tinyGSM yaitu AT_debug

  • /
  • // Select your modem:
  • #define TINY_GSM_MODEM_SIM800
  • // #define TINY_GSM_MODEM_SIM900
  • // #define TINY_GSM_MODEM_SIM808
  • // #define TINY_GSM_MODEM_SIM868
  • // #define TINY_GSM_MODEM_UBLOX
  • // #define TINY_GSM_MODEM_M95
  • // #define TINY_GSM_MODEM_BG96
  • // #define TINY_GSM_MODEM_A6
  • // #define TINY_GSM_MODEM_A7
  • // #define TINY_GSM_MODEM_M590
  • // #define TINY_GSM_MODEM_MC60
  • // #define TINY_GSM_MODEM_MC60E
  • // #define TINY_GSM_MODEM_ESP8266
  • // #define TINY_GSM_MODEM_XBEE
  • // Set serial for debug console (to the Serial Monitor, speed 115200)
  • #define SerialMon Serial
  • // Set serial for AT commands (to the module)
  • // Use Hardware Serial on Mega, Leonardo, Micro
  • #define SerialAT Serial1
  • // or Software Serial on Uno, Nano
  • //#include <SoftwareSerial.h>
  • //SoftwareSerial SerialAT(2, 3); // RX, TX
  • #define TINY_GSM_DEBUG SerialMon
  • #include <TinyGsmClient.h>
  • // Module baud rate
  • uint32_t rate = 0; // Set to 0 for Auto-Detect

  • void setup() {
  •   // Set console baud rate
  •   SerialMon.begin(115200);
  •   delay(3000);
  • }

  • void loop() {
  •   if (!rate) {
  •     rate = TinyGsmAutoBaud(SerialAT);
  •   }

  •   if (!rate) {
  •     SerialMon.println(F("***********************************************************"));
  •     SerialMon.println(F(" Module ora ngeRespon "));
  •     SerialMon.println(F("   Check wiringanmu. wes bener opo durung"));
  •     SerialMon.println(F("   Check power supplyne ojo sampe kurang arus e. soale arus e butuh guede"));
  •     SerialMon.println(F("***********************************************************"));
  •     delay(30000L);
  •     return;
  •   }

  •   SerialAT.begin(rate);

  •   // Access AT commands from Serial Monitor
  •   SerialMon.println(F("***********************************************************"));
  •   SerialMon.println(F(" awakmu wes iso kirim  AT commands, "));
  •   SerialMon.println(F(" ketik AT+CSQ lalu enter, untuk cek signal"));
  •   SerialMon.println(F(" select \"Both NL & CR\" in Serial Monitor"));
  •   SerialMon.println(F("***********************************************************"));

  •   while(true) {
  •     if (SerialAT.available()) {
  •       SerialMon.write(SerialAT.read());
  •     }
  •     if (SerialMon.available()) {
  •       SerialAT.write(SerialMon.read());
  •     }
  •     delay(0);
  •   }
  • }
cek d serial monitor mana baudrate yang replay

contoh hasil serial monitor yang sim900 tidak merespon:

kemungkinan kabel salah wiring atau power kurang joss



contoh hasil serial monitor yang sim900 merespon sesuai baudratenya


setelah diketahui...

contoh baudratenya 57600

dan mau dirubah ke 9600

maka upload koding selanjutnya
  • unsigned long cur_time, old_time;

  • void setup() {
  •   // put your setup code here, to run once:
  •   delay(2000);
  •   Serial.begin(115200);
  •   Serial1.begin(57600);
  •  
  •   delay(1000);
  •   Serial1.println("AT+IPR=9600");delay(100);
  •   wRespon(2000);
  •   Serial1.begin(9600);
  •   Serial1.println("AT&W");
  •   wRespon(2000); 
  • }

  • void loop() {
  •   // put your main code here, to run repeatedly:
  •   Serial.println("AT");
  •   Serial1.println("AT+IPR?");
  •   wRespon(1000);
  •   delay(1000);
  • }
  • void wRespon(long waktu){
  •   cur_time = millis();
  •   old_time = cur_time;
  •   while(cur_time - old_time < waktu ){
  •     cur_time = millis();
  •     while(Serial1.available()>0){
  •     Serial.print(Serial1.readString());
  •     } 
  •   }
  • }
sekian tutorial malam ini..
hasil belajar dengan bang jimmi kardo sitepu

Salam
SIMOR

cara blok value di Node red

 ambil node filter dan edit seperti di bawah ini