Monday, September 24, 2018

membuat mobil remote kontrol dari handphone via wifi

langsung saja, kali ini saya akan share artikel cara membuat mobil remote kontrolvia wifi dengan hp android

pertama siapkan dahulu materialnya:
  • mobil" an anak yang gk kepakai
  • nodemcu
  • shield motor nodemcu
  • powerbank
  • motor gearbox + roda


aplikasi: wifi rc car esp8266


langkah pertama:
1. upload sketch ke nodemcu:


#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>

const char *ssid = "mobil thomas"; // SSID Name
const char *password = "12345678"; // SSID Password : Between 8 and 32 carateres

IPAddress ip(192, 168, 4, 1); // IP Address
IPAddress netmask(255, 255, 255, 0); // Netmask
const int port = 80; // Port
ESP8266WebServer server(port);

// Motors pins
static const uint8_t pwm_A = 5 ;
static const uint8_t pwm_B = 4;
static const uint8_t dir_A = 0;
static const uint8_t dir_B = 2;
static const uint8_t LAMPU = 13;

// Motor speed = [0-1024]
int motor_speed = 1024;


void stop_motors() {
  analogWrite(pwm_A, 0);
  analogWrite(pwm_B, 0);
}

void backward() {
  analogWrite(pwm_A, motor_speed);
  analogWrite(pwm_B, motor_speed);
  digitalWrite(dir_A, LOW);
  digitalWrite(dir_B, HIGH);
}

void forward() {
  analogWrite(pwm_A, motor_speed);
  analogWrite(pwm_B, motor_speed);
  digitalWrite(dir_A, HIGH);
  digitalWrite(dir_B, LOW);
}

void turn_left() {
  analogWrite(pwm_A, motor_speed);
  analogWrite(pwm_B, motor_speed);
  digitalWrite(dir_A, HIGH);
  digitalWrite(dir_B, HIGH);
}

void turn_right() {
  analogWrite(pwm_A, motor_speed);
  analogWrite(pwm_B, motor_speed);
  digitalWrite(dir_A, LOW);
  digitalWrite(dir_B, LOW);
}

void handleRoot() {
  if (server.hasArg("State")) {
    String command = server.arg("State");
    if (command.equals("F")) {
      forward();
      server.send(200, "text / plain", "Forward");
    }
    else  if (command.equals("B")) {
      backward();
      server.send(200, "text / plain", "Backward");
    }
    else  if (command.equals("L")) {
      turn_left();
      server.send(200, "text / plain", "Turn Left");
    }
    else  if (command.equals("R")) {
      turn_right();
      server.send(200, "text / plain", "Turn Right");
    }
    else  if (command.equals("S")) {
      stop_motors();
      server.send(200, "text / plain", "Stop");
    }
     else  if (command.equals("ON")) {
      digitalWrite(LAMPU, HIGH);
      server.send(200, "text / plain", "Switch on the light");
    }
      else  if (command.equals("OFF")) {
      digitalWrite(LAMPU, LOW);
      server.send(200, "text / plain", "Switch off the light");
    }
  }
}


void setup() {
  WiFi.mode(WIFI_AP); //Only Access point
  WiFi.softAPConfig(ip, ip, netmask);
  WiFi.softAP(ssid, password);

  // Declaration of motors
  pinMode(pwm_A, OUTPUT); // PMW A
  pinMode(pwm_B, OUTPUT); // PMW B
  pinMode(dir_A, OUTPUT); // DIR A
  pinMode(dir_B, OUTPUT); // DIR B
  pinMode(LAMPU, OUTPUT); // LAMPU

  // Start Server
  server.on("/", HTTP_GET, handleRoot);
  server.begin();






 }

void loop() {
  server.handleClient();
}




setelah selesai upload

2. rangkai motor ke shield motor dan tancapkan nodemcu ke shield motor

3. tancapkan kabel powerbank ke nodemcu

4. jalan kan aplikasi

5. konek wifi HP ke wifi nodemcu

readyyyy GOOOOOOOOOOOOOOOOO


Wednesday, September 12, 2018

upgrade car thomas from pull back to IOT

oprek kali ini tentang sebuah mobil pull back atau bahasa jowonya TARIK MUNDUR.
ada mainan anak saya yang sudah rusak.
saya mencoba untuk meng upgrade menjadi mobil yang KECE dan KEKINIAN bisa dikendalikan dari manapun berada.

langsung aja bahan yang dibutuhkan antara lain:
  • nodemcu
  • motor + roda
  • shield motor
  • powerbank
  • kabel 

software :
  • arduino IDE
  • blynk (instal di handphone)
rangkai seperti gambar dibawah ini:



desain HMI di aplikasi blink :



upload sketch dibawah ini:
#define BLYNK_PRINT Serial
#include  <ESP8266WiFi.h>
#include  <BlynkSimpleEsp8266.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "yourtoken";

// Your WiFi credentials.
// Set password to "" for open networks.
char ssid[] = "yourwifi";
char pass[] = "yourpassswordwifi";

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);
 pinMode(PWMA, OUTPUT);
 pinMode(PWMB, OUTPUT);
 pinMode(DA, OUTPUT);
 pinMode(DB, OUTPUT);
}

void loop(){
Blynk.run();
 
}

// Handling Joystick data
BLYNK_WRITE(V1){
int x = param[0].asInt();
int y = param[1].asInt(); 
if(x==-1 && y==0){        //Left Turn
     digitalWrite(PWMA, 450);
     digitalWrite(DA, HIGH);
   
     digitalWrite(PWMB, 450);
     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==0){        //Right turn
     digitalWrite(PWMA, 450);
     digitalWrite(DA, LOW);
    
     digitalWrite(PWMB, 450);
     digitalWrite(DB, HIGH);
}
}

Integrasi vamp40 to scada

Assalamu'alaikum puaks kali ini akan share bagaimana cara integrasi vamp40 to scada yang pertama harus setting komunikasiny...