Selasa, 27 Februari 2024

Kamis, 15 Februari 2024

Loog Book 16 Feb 2024

 08.00 naik sepedah listrik rapat RIIM 4 Mas Rud

13.00 Rapat Bimbingan Akmet


Program ESP NOW

Perintah Pompa  

ROTCC 100

ROTCW 1000

SN

POS

SW1

SW2



ESP NOW

/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-esp32-arduino-ide/
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
 
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

#include <esp_now.h>
#include <WiFi.h>

// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};

// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
  char a[32];
  int b;
  float c;
  bool d;
} struct_message;

// Create a struct_message called myData
struct_message myData;

esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
 
void setup() {
  // Init Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);
 
  // Register peer
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;
 
  // Add peer        
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
}
 
void loop() {
  // Set values to send
  strcpy(myData.a, "THIS IS A CHAR");
  myData.b = random(1,20);
  myData.c = 1.2;
  myData.d = false;
 
  // Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
   
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
  delay(2000);
}
Perintah Pompa 
/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-esp32-arduino-ide/
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
 
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

#include <esp_now.h>
#include <WiFi.h>

// Structure example to receive data
// Must match the sender structure
typedef struct struct_message {
    char a[32];
    int b;
    float c;
    bool d;
} struct_message;

// Create a struct_message called myData
struct_message myData;

// callback function that will be executed when data is received
void OnDataRecv(const uint8_t * mac, const uint8_t *incomingData, int len) {
  memcpy(&myData, incomingData, sizeof(myData));
  Serial.print("Bytes received: ");
  Serial.println(len);
  Serial.print("Char: ");
  Serial.println(myData.a);
  Serial.print("Int: ");
  Serial.println(myData.b);
  Serial.print("Float: ");
  Serial.println(myData.c);
  Serial.print("Bool: ");
  Serial.println(myData.d);
  Serial.println();
}
 
void setup() {
  // Initialize Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
 
  // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_register_recv_cb(OnDataRecv);
}
 
void loop() {

}

logbook 15 vebruari (2) Rispro ESP8266 serial comunication ke Mega 2650

 ESP8266

TX danground ke Mega 2650 port serial 2 



void setup() {
  // put your setup code here, to run once:
    Serial.begin(115200);
    Serial2.begin(115200);
}

void loop() {
  // put your main code here, to run repeatedly:
   delay(500);
      char inChar[2];
     if (Serial.available()>0)
    {
     
     for (int i=0; i<2; i++)
     {
      inChar[i] = Serial.read();
      delay(10);
     }
     
          if (inChar[0] == 'x' && inChar[1] == '-' )
          {
            Serial.println("X- serial");
           
          }
         
          if (inChar[0] == 'x' && inChar[1] == '0')
          {
            Serial.println("X0 serila");
           // goto x_0;
          }
           if (inChar[0] == 'x' && inChar[1] == '+')
          {
            Serial.println("X+ serial");
            //goto x_plus;
          }

         
          if (inChar[0] == 'y' && inChar[1] == '-')
          {
            Serial.println("Y- serial");
            //goto y_minus;
          }
         
          if (inChar[0] == 'y' && inChar[1] == '0')
          {
            Serial.println("Y0 serial");
           //goto y_0;
          }
           if (inChar[0] == 'y' && inChar[1] == '+')
          {
            Serial.println("Y+ serial");
           // goto y_plus;
          }
         
         
          if (inChar[0] == 'z' && inChar[1] == '-')
          {
            Serial.println("Z- serial");
            //goto z_minus;
          }
         
          if (inChar[0] == 'z' && inChar[1] == '0')
          {
            Serial.println("Z0 serial");
           // goto z_0;
          }
           if (inChar[0] == 'z' && inChar[1] == '+')
          {
            Serial.println("z+ serial");
            //goto z_plus;
          }  
     }
     char inChar2[2];
     if (Serial2.available()>0)
    {
     
     for (int i=0; i<2; i++)
     {
      inChar2[i] = Serial2.read();
      delay(10);
     }
     
          if (inChar2[0] == 'x' && inChar2[1] == '-' )
          {
            Serial.println("X- serial");
           
          }
         
          if (inChar2[0] == 'x' && inChar2[1] == '0')
          {
            Serial.println("X0 serila");
           // goto x_0;
          }
           if (inChar2[0] == 'x' && inChar2[1] == '+')
          {
            Serial.println("X+ serial");
            //goto x_plus;
          }

         
          if (inChar2[0] == 'y' && inChar2[1] == '-')
          {
            Serial.println("Y- serial");
            //goto y_minus;
          }
         
          if (inChar2[0] == 'y' && inChar2[1] == '0')
          {
            Serial.println("Y0 serial");
           //goto y_0;
          }
           if (inChar[0] == 'y' && inChar[1] == '+')
          {
            Serial.println("Y+ serial");
           // goto y_plus;
          }
         
         
          if (inChar2[0] == 'z' && inChar2[1] == '-')
          {
            Serial.println("Z- serial");
            //goto z_minus;
          }
         
          if (inChar2[0] == 'z' && inChar2[1] == '0')
          {
            Serial.println("Z0 serial");
           // goto z_0;
          }
           if (inChar2[0] == 'z' && inChar2[1] == '+')
          {
            Serial.println("z+ serial");
            //goto z_plus;
          }  
     }

     
}


Rabu, 14 Februari 2024

LogBook 15 Februari 2024 8 Chanel USB logic analizer

 

8-Channel USB Logic Analyzer 24Msps

 Untuk mempergunakan Logic annalizer bisa diboa mengunakan

https://support.saleae.com/logic-software/sw-download

Tested with PulseView (sigrok) and Logic2 (Saleae). Both tools are free to download. 
dicoba pake logic2  connect



Minggu, 11 Februari 2024

Logbook 12 Februari 2024 line folower DSB

 Logbook 12 Februari 2024

 

HY-S301 8-Channel Line Tracking Sensor Module

RM11.50

Out of stock

SKU: RBT-SEN-HYS301 Categories: , Tags: , , ,

Description

This module is a digital line tracking sensor you can use with Arduino to make a better line follower robot that can sense 8 way of black and white lines. The more ways it can sense, the more resolution the sensor gets!

This module works based on the reflection of infrared light. When following a line, the black line must therefore be able to absorb infrared light (approximately 950nm wavelength). The outputs of the sensors are high when enough light is reflected back.

Features

  • Voltage : 3.3 – 5V
  • Output Type : Digital
  • Two 3mm mounting holes
  • 8-way reflective optical sensors
  • Dimensions : 17 x 67 x 2 mm

 

Wiring

Label Meaning Connection
GND Ground Connect to GND of system
IR Infrared enable Connect to 3.3V or 5V of system (digital pin also will do)
D1 – D8 Sensor output pins Connect to any digital pins
VCC Power source Connect to 3.3V or 5V of system

 

Note : To run the module at 3.3V, connect the solder pads in the bottom left corner to brighten the IR LEDs.


Setelah mencoba keluaran Jika ada hambatan yang hampir menempel(jarah lebih kecil dari 5mm) adalah sekitar 4 Volt dari vcc 5 Volt

 

Senin, 05 Februari 2024

Log book 6 Feb 2024

 Rapat internal AM tentang distribusi SKP personel untuk tahun 2024

Kunjungan ke Kimia Maju ketemu dengan Pa Andreas

Kunjungan dari Benadus Sirenden membahas penelitian RIIM 4

 

 

 

 

 

 


Minggu, 04 Februari 2024

Logbook 5 Feb 2024 -ESP8266 SDcard

0730-0800 Absen Pagi hanya absen pagi

0800-0900 >>Buat presentasi untuk RIIM 4 bu Nazarina direncanakan 6-10 Halaman

(baru selesai 3 halaman) perlu ditambah kan program random nerd

0900-1200 Buat program ESP8266 sd card 

program untuk mengetes bukan pakai ESP8266 akan tetapi mengunakan ESP32

https://wokwi.com/projects/388854830688347137

 perlu diingat pin CS untuk komunikasi SPI adalah pada 5

program dicoba pada ESP8266 yang real sedangkan pin out yang dipergunakan  adalah

https://newbiely.com/tutorials/esp8266/esp8266-micro-sd-card

ingat pin CS biasanya mengunakann D8 (jika diarduino IDE akan error) sebenarnya d8 adalah GPIO15 jadi D8 di tulis angka 15 saja


#include <SD.h>
#define CS_PIN  15
String inputSTR,User,Password;
char buf[10] ;

void setup() {
  // put your setup code here, to run once:
 Serial.begin(115200);
 Serial.print("Inisialisasi SD Card..");
 
  if (!SD.begin(CS_PIN)) {
    Serial.println("Gagal load SD card.");
    return;
  }
   Serial.println("OK.");

  File textFile = SD.open("/Hello.txt");
  if (textFile) {
    Serial.print("Hello.txt: ");
    while (textFile.available()) {
     
      inputSTR=textFile.readString();

       User = "           ";
       Password = "                    ";
      Serial.println(inputSTR);
      Serial.println(inputSTR.length());
      Serial.println(inputSTR.indexOf(' '));
      for (int i = 0; i < inputSTR.indexOf(' '); i++)
      {
               User.setCharAt(i,inputSTR.charAt(i));
              //buf[i] = inputSTR.charAt(i);
             // reportString.setCharAt(colonPosition, '=');
             //Serial.println(User.charAt(i));
             
      }
        for (int i = inputSTR.indexOf(' '); i < inputSTR.length(); i++)
      {
               Password.setCharAt(i,inputSTR.charAt(i));
              Serial.println(Password.charAt(i));
      }
      Password.trim();
      Serial.println(User);
      Serial.println(Password);
    }
    textFile.close();
  } else {
    Serial.println("error opening wokwi.txt!");
  }

}

void loop() {
  // put your main code here, to run repeatedly:

}

file diatas ada di ESP8266_sdcard2.uno

untuk aplikasi RISPRO2024 program  AMH_ver4_2_ESP8266_ino.ino


#include <ESP8266WiFi.h>
#include <Servo.h>

Servo servo;
int angle = 10;
String kasus = "";
String azum = "ada";



//const char* ssid     = "BSN-Trial";
//const char* password = "bsntrial1";

const char* ssid     = "GalaxyM126A21";
const char* password = "uhuy";



const char* host = "www.remotecal.com";

WiFiClient client;
const int httpPort = 80;
String url;

unsigned long timeout;



#include <SD.h>
#define CS_PIN  15
String inputSTR,User,Password;
char buf[15] ;


unsigned long previousMillis = 0;
unsigned long interval = 1000;

void setup() {
  Serial.begin(115200);
  delay(1000);

  servo.attach(2); //GPIO2
  servo.write(angle);

  //pinMode(stepPin,OUTPUT);
  //pinMode(dirPin,OUTPUT);

  //pinMode(stepPink,OUTPUT);
  //pinMode(dirPink,OUTPUT);
 
 Serial.print("Inisialisasi SD Card..");
 
  if (!SD.begin(CS_PIN)) {
    Serial.println("Gagal load SD card.");
    return;
  }
   Serial.println("OK.");

   File textFile = SD.open("/WIFI.txt");
  if (textFile) {
    Serial.print("WIFI.txt: ");
    while (textFile.available()) {
     
      inputSTR=textFile.readString();

       User = "                 ";
       Password = "                          ";
      Serial.println(inputSTR);
      Serial.println(inputSTR.length());
      Serial.println(inputSTR.indexOf(' '));
      for (int i = 0; i < inputSTR.indexOf(' '); i++)
      {
               User.setCharAt(i,inputSTR.charAt(i));
              //buf[i] = inputSTR.charAt(i);
             // reportString.setCharAt(colonPosition, '=');
             //Serial.println(User.charAt(i));
             
      }
        for (int i = inputSTR.indexOf(' '); i < inputSTR.length(); i++)
      {
               Password.setCharAt(i,inputSTR.charAt(i));
              Serial.println(Password.charAt(i));
      }
      User.trim();
      Password.trim();
      Serial.println(User);
      Serial.println(Password);
    }
    textFile.close();
  } else {
    Serial.println("error opening WIFI.txt!");
  }

 // ssid = "GalaxyM126A21";
  //password="Salsa3349";
  WiFi.mode(WIFI_STA);
 //WiFi.begin(ssid, password);
   WiFi.begin(User,Password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.println(".");
  }

  Serial.println("");
  Serial.println("WiFi connected");  
  ////Serial.printlnln("IP address: ");
  ////Serial.printlnln(WiFi.localIP());
}


void loop() {
 
  //Serial.println("connecting to ");
  ////Serial.printlnln(host);

  if (!client.connect(host, httpPort)) {
    ////Serial.printlnln("connection failed");
    //return;
  }

// We now create a URI for the request
  url = "http://www.remotecal.com/index.php/cekperintah?idse=1&idst=2&idstk=3";
 
  //Serial.println("Requesting URL: ");
  ////Serial.printlnln(url);

// This will send the request to the server
  client.print(String("GET ") + url + " HTTP/1.1\r\n" +
               "Host: " + host + "\r\n" +
               "Connection: close\r\n\r\n");
  timeout = millis();
  while (client.available() == 0) {
    if (millis() - timeout > 5000) {
      ////Serial.printlnln(">>> Client Timeout !");
      client.stop();
      return;
    }
  }
//  while(client.available()){
//    String line = client.readStringUntil('\r');
//    //Serial.println(line);
    int size;
    int ang;
    int ang2;
    int ang3;
    int jumlahsisa;
    int jumlahsisa2;
    int jumlahsisa3;
    while ((size = client.available()) > 0) {
      uint8_t* msg = (uint8_t*)malloc(size);
      size = client.read(msg, size);
     // Serial.write(msg, size);
      azum = (char*)msg;
      //////Serial.printlnln(azum.substring(213));
      //azum = azum.substring(213);
      ang = azum.lastIndexOf('Z');
      azum = azum.substring(ang);
      azum = azum.substring(0,2);
      ////Serial.printlnln(azum);
      free(msg);
        if(azum == "ZN"){
          ////Serial.printlnln("servo nyala");
          for(angle = 10; angle < 90; angle++)  
          {                                  
          servo.write(angle);              
          delay(15);                  
          }
          // now scan back from 180 to 0 degrees
          for(angle = 90; angle > 10; angle--)    
          {
          servo.write(angle);          
          delay(15);      
          }
        }else if(azum == "ZM"){
          ////Serial.printlnln("servo dan stepper mati");
          servo.write(10);          
          delayMicroseconds(100);
        }else if(azum == "ZF"){
          ////Serial.printlnln("stepper maju");
          //maju dan mundur
           Serial.println("x-");
           //   digitalWrite(dirPin,LOW); // Enables the motor to move in a particular direction
          // Makes 200 pulses for making one full cycle rotation
         /*
          for(int x = 0; x < 1000; x++) {
            digitalWrite(stepPin,HIGH);
            delayMicroseconds(500);
            digitalWrite(stepPin,LOW);
            delayMicroseconds(500);
          }
          */
          delay(200); // 200 ms delay
        }else if(azum == "ZU"){
          ////Serial.printlnln("stepper mundur");
          //maju dan mundur
           Serial.println("x+");
            //  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
          // Makes 200 pulses for making one full cycle rotation
          /*
          for(int x = 0; x < 1000; x++) {
            digitalWrite(stepPin,HIGH);
            delayMicroseconds(500);
            digitalWrite(stepPin,LOW);
            delayMicroseconds(500);
          }
          */
          delay(200); // One second delay
        }else if(azum == "ZA"){
          ////Serial.printlnln("stepper kanan");  
           Serial.println("y-");        
          //kanan dan kiri
            //  digitalWrite(dirPink,LOW); // Enables the motor to move in a particular direction
          // Makes 200 pulses for making one full cycle rotation
          /*
          for(int x = 0; x < 1000; x++) {
            digitalWrite(stepPink,HIGH);
            delayMicroseconds(500);
            digitalWrite(stepPink,LOW);
            delayMicroseconds(500);
          }
          */
          delay(200); // One second delay
        }else if(azum == "ZI"){
          ////Serial.printlnln("stepper kiri");
          Serial.println("y+");
          //kanan dan kiri
           //   digitalWrite(dirPink,HIGH); // Enables the motor to move in a particular direction
          // Makes 200 pulses for making one full cycle rotation
         /*
          for(int x = 0; x < 1000; x++) {
            digitalWrite(stepPink,HIGH);
            delayMicroseconds(500);
            digitalWrite(stepPink,LOW);
            delayMicroseconds(500);
          }
          */
          delay(200); // One second delay
        }else{
          ////Serial.printlnln("servo dan stepper mati");
          servo.write(10);          
          delayMicroseconds(100);
        }
      delay(50);
    }
   
 
 
}


Buat RAB buat RISPRO 2024 dan sudah dikirim ke Adit

 Komunikasi ESP NOW

ESPNOW adalah komunikasi nirkabel untuk chip ESP untuk lebih detail dapat dilihat dari CHIP


ini adalah pin out dari Weemos D1 mini clone 



 Di Arduino IDE pergunakan ESP32 WROOM perlu dipencet boot kalau ESP32 tidak perlu

Untuk ESP NOW bisa dipergunakann ESP32 sebagai sender dan ESP8266 reciever 

 

 

/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-esp32-arduino-ide/
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
 
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

#include <esp_now.h>
#include <WiFi.h>

// REPLACE WITH YOUR RECEIVER MAC Address
uint8_t broadcastAddress[] = {0x40, 0xF5, 0x20, 0x29, 0x1F, 0xB5};

// Structure example to send data
// Must match the receiver structure
typedef struct struct_message {
  char a[10];
  char b[10];
  char c[10];
  char d[10];
} struct_message;

// Create a struct_message called myData
struct_message myData;

esp_now_peer_info_t peerInfo;

// callback when data is sent
void OnDataSent(const uint8_t *mac_addr, esp_now_send_status_t status) {
  Serial.print("\r\nLast Packet Send Status:\t");
  Serial.println(status == ESP_NOW_SEND_SUCCESS ? "Delivery Success" : "Delivery Fail");
}
 
void setup() {
  // Init Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != ESP_OK) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }

  // Once ESPNow is successfully Init, we will register for Send CB to
  // get the status of Trasnmitted packet
  esp_now_register_send_cb(OnDataSent);
 
  // Register peer
  memcpy(peerInfo.peer_addr, broadcastAddress, 6);
  peerInfo.channel = 0;  
  peerInfo.encrypt = false;
 
  // Add peer        
  if (esp_now_add_peer(&peerInfo) != ESP_OK){
    Serial.println("Failed to add peer");
    return;
  }
}
 
void loop() {
  // Set values to send
  strcpy(myData.a, "pp 100");
  strcpy(myData.b, "pread 10");
  strcpy(myData.c, "loop 100");
   strcpy(myData.d, "pp 200");
 
  // Send message via ESP-NOW
  esp_err_t result = esp_now_send(broadcastAddress, (uint8_t *) &myData, sizeof(myData));
   
  if (result == ESP_OK) {
    Serial.println("Sent with success");
  }
  else {
    Serial.println("Error sending the data");
  }
  delay(2000);
}


 

 

 

 

 Untuk reciever ESP8266

/*
  Rui Santos
  Complete project details at https://RandomNerdTutorials.com/esp-now-esp8266-nodemcu-arduino-ide/
 
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files.
 
  The above copyright notice and this permission notice shall be included in all
  copies or substantial portions of the Software.
*/

#include <ESP8266WiFi.h>
#include <espnow.h>

// Structure example to receive data
// Must match the sender structure
typedef struct struct_message {
    char a[10];
    char b[10];
    char c[10];
    char d[10];
   
} struct_message;

// Create a struct_message called myData
struct_message myData;

// Callback function that will be executed when data is received
void OnDataRecv(uint8_t * mac, uint8_t *incomingData, uint8_t len) {
  memcpy(&myData, incomingData, sizeof(myData));
  Serial.print("Bytes received: ");
  Serial.println(len);
  Serial.print("Char: ");
  Serial.println(myData.a);
  Serial.print("Int: ");
  Serial.println(myData.b);
  Serial.print("Float: ");
  Serial.println(myData.c);
  Serial.print("String: ");
  Serial.println(myData.d);

  Serial.println();
}
 
void setup() {
  // Initialize Serial Monitor
  Serial.begin(115200);
 
  // Set device as a Wi-Fi Station
  WiFi.mode(WIFI_STA);

  // Init ESP-NOW
  if (esp_now_init() != 0) {
    Serial.println("Error initializing ESP-NOW");
    return;
  }
 
  // Once ESPNow is successfully Init, we will register for recv CB to
  // get recv packer info
  esp_now_set_self_role(ESP_NOW_ROLE_SLAVE);
  esp_now_register_recv_cb(OnDataRecv);
}

void loop() {
 
}