SINAU PROGRAMMING
SINAU PROGRAMMING
  • Home
  • Source Code
  • Social
  • CONTROL
    • Internet of Think (IoT)
    • ESP
      • NodeMcu
      • Lora
      • WeMos
      • Esp 32 Dev
      • Node 32s
    • Arduino
    • Raspberry
    • Proteus
  • MATLAB
    • MATLAB PROJECT
    • PLC
      • Omron
      • Mitsubishi
      • Siemens
      • Schneider
      • ArduinoPLC
    • Arduino
    • Basic & Doc
  • Contact Us

 



Konfigurasi pin :
Pin SDA dihubungkan ke pin D2
Pin SCL dihubungkan ke pin D1
GND dihubungkan ke GND
VCC dihubungkan ke VU atau dihubungkan ke supply eksternal

Dalam proyek ini, Anda akan menghubungkan esP8266 ke komputer lain dan mempelajari cara memprogramnya menggunakan WEB SERVICE .


Dengan Menggunakan ARDUINO IDE pemrograman tampilan sangat mudah hanya beberapa baris kode.

partikan sdh menginstall library bh1750 dan lcd i2c


#include <ESP8266WiFi.h>



const char* ssid = "Stri-X";
const char* password = "111111";
float suhu;

WiFiServer server(80);
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
#include <BH1750_WE.h>
#define BH1750_ADDRESS 0x23

BH1750_WE myBH1750(BH1750_ADDRESS);
// You may also pass a TwoWire object like wire2
// BH1750_WE myBH1750(&wire2, BH1750_ADDRESS);

void setup(){
  Serial.begin(9600);
  Wire.begin();
  myBH1750.init(); // sets default values: mode = CHM, measuring time factor = 1.0
  // myBH1750.setMode(CLM);  // uncomment if you want to change the default values
  // myBH1750.setMeasuringTimeFactor(0.45); // uncomment for selection of value between 0.45 and 3.68
   lcd.begin();
 lcd.clear();
 lcd.backlight();
 lcd.setCursor(3, 0);
 lcd.print("LUX meter");
 delay(1000);
 lcd.clear();
   // Connect ti WiFi netwwork
  Serial.println();
  Serial.println();
  Serial.print("Connecting to ");
  Serial.println(ssid);

  WiFi.begin(ssid, password);

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

  // Start the server
  server.begin();
  Serial.println("Server Started");

  // Print the IP address
  Serial.print("Use this URL to Connect: ");
  Serial.print("http://");
  Serial.print(WiFi.localIP());
  Serial.println("/");
 
}

void loop(){

WiFiClient client = server.available();
  if (!client) {
    return;
  }

  // Wait until the client sends some data
  Serial.println("new client");
  while(!client.available()){
    delay(1);
  }

  // Read the first line of the request
  String request = client.readStringUntil('\r');
  Serial.println(request);
  client.flush();



  float lightIntensity = myBH1750.getLux();
  Serial.print(F("Light intensity: "));
  Serial.print(lightIntensity);
  Serial.println(F(" Lux"));
 
  lcd.setCursor(0,0);
 
  lcd.print(lightIntensity);lcd.print("   ");lcd.setCursor(11,0);lcd.print(" LX");
  delay(50);
  client.println("HTTP/1.1 200 OK");
   client.println("Content-Type: text/html");
   client.println("Refresh: 1");
   client.println(""); // do not forget this one
   client.println("<!DOCTYPE HTML>");
   client.println("<html>");

   client.println("<center>");
   client.println("<h1>");
   client.println("Monitoring LUX");
   client.println("</h1>");
   client.println("<br>");
   client.println("<br>");
   client.println("<h3>");

   client.println("LuxMeter = ");
   client.println(lightIntensity);
   client.println(" LX ");
   client.println("<br>");
   
   client.println("</h3>");
   client.println("</center>");
   client.println("</html>");

   delay(1);
   Serial.println("Client disconnected");
   Serial.println("");
   delay(500);

}



PEMBAHASAN PROGRAM


const char* ssid = "Stri-X";
const char* password = "111111";


Merupakan ssid wifi punyamu atau hotspot portablemu agar esp8266 terhubung dengan wifi


float lightIntensity = myBH1750.getLux();


Merupakan list mengambil data lux dari sensor

 




Dalam proyek ini, Anda akan menghubungkan Raspberry Pi Pico ke komputer lain dan mempelajari cara memprogramnya menggunakan MicroPython.


Raspberry Pi Pico adalah perangkat mikrokontroler berbiaya rendah. Mikrokontroler adalah komputer kecil, tetapi mereka cenderung kekurangan penyimpanan volume besar dan perangkat periferal yang dapat Anda colokkan (misalnya, keyboard atau monitor).


Raspberry Pi Pico memiliki pin GPIO, seperti komputer Raspberry Pi, yang berarti dapat digunakan untuk mengontrol dan menerima input dari berbagai perangkat elektronik.


Dengan Menggunakan Sofware Thonny IDE pemrograman tampilan sangat mudah hanya beberapa baris kode.

from machine import Pin, Timer
led = Pin(25, Pin.OUT)
timer = Timer()
def blink(timer):
led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)


Tampilan pada thonny seperti gambar dibawah ini.


dan coba ganti lokasi pin nya dan gunakan resistor dan led

pada pin 16 

from machine import Pin, Timer
led = Pin(16, Pin.OUT)
timer = Timer()
def blink(timer):
led.toggle()

timer.init(freq=2.5, mode=Timer.PERIODIC, callback=blink)


hasilnya kira-kira seperti dibawah ini




 

 


To  convert TXT from edit text to Variable value on nextion . you need command on nextion editor

Covx

Convert variable from numeric type to text, or text to numeric type

– text must be text ASCII representation of an integer value.
– source and destination types must not be of the same type
– when source is numeric, hex format and length not 0 and <4.
ie: (len 2) positive significant (byte 0 to 3), 123 = 0000007B = 007B
ie: (len 2) negative significant (byte 3 to 0), -123 = FFFFFF85 = FF85
– value is more than allowed space results in a truncation
– it is recommended to ensure handling source length in user code before covx
– in v0.53, covx is deemed undefined if source is larger than length or
dest txt_maxl is smaller than requested length.
(some of these undefines, can be exploited)
ie: src numeric value of 123 with length 0, result is dest text “123”
– when length is fixed and value is less, leading zeros will be added
ie: src numeric value of 123 with length 4, result is dest text “0123”
– when value is larger than length, .txt truncated to least significant digits
ie: src numeric value of 23425 with length 4 result is dest text “3425”
usage: covx <src>,<dest>,<length>,<format>
    <src> is text attribute (or numeric attribute when <dest> is text)
    <dest> is numeric attribute (or text attribute when <src> is numeric)
    <length> will determine if leading zeros added to conversion to text
    <format> 0: integer, 1: Comma separated 1,000s, 2: Hex
    covx h0.val,t0.txt,0,0 // convert value of h0 into t0.txt without leading zeros
    covx t0.txt,h0.val,0,0 // convert t0.txt into integer in h0.val <length> ignored.
    covx h0.val,t0.txt,4,0 // convert value of h0 into t0.txt with exactly 4 digits
    covx h0.val,t0.txt,4,1 // convert value of h0 into t0.txt with commas
    covx h0.val,t0.txt,4,2 // convert value of h0 into t0.txt in 2 bytes of hex digits
    Invalid: covx h0.val,va0.val,0,0 or covx t0.txt,va0.txt,0,0 // src & dest same type.

Cov  

Depreciated. Convert from numeric type to text, or text to numeric type


– text must be text ASCII representation of an integer value.
– source and destination types must not be of the same type
– when length is fixed and value is less, leading zeros will be added
ie: src numeric value of 123 with length 4, result is dest text “0123”
– dest txt_maxl and length needs be large enough to accommodate conversion.
ie: src numeric value of 123 with length 0, result is dest text “123”
– when value is larger than length, .txt results in a truncation
– it is recommended to handle source length in user code before cov
    Note:v0.53 changed behaviour from previous pre/post v0.53 behaviours.
    cov is deemed undefined if source is larger than length or the dest txt_maxl is
    smaller than the requested length. Some undefines are exploitable.
    usage: cov <src>,<dest>,<length>
    <src> is text attribute (or numeric attribute when <dest> is text)
    <dest> is numeric attribute (or text attribute when <src> is numeric)
    <length> will determine if leading zeros added to conversion to text
    cov h0.val,t0.txt,0 // convert value of h0 into t0.txt without leading zeros
    cov t0.txt,h0.val,0 // convert integer into t0.txt from h0.val <length> ignored.
    cov h0.val,t0.txt,4 // convert value of h0 into t0.txt with exactly 4 digits
    Invalid: cov h0.val,va0.val,0 or cov t0.txt,va0.txt,0 // src & dest same type.

Example HMI File Nextion here 

Video Example Here 




Programming languages



Or often termed computer languages or computer programming languages, are standard instructions for governing computers. This programming language is a set of syntax and semantic rules used to define computer programs.

What is a Program Language?

Program language is a set of instructions given to the computer to be able to carry out certain tasks in solving a problem. Program language serves to command the computer so that it can process data according to the completion steps that have been determined by the programmer. This language allows a programmer to specify exactly which data will be processed by the computer, how this data will be stored/forwarded, and what kinds of steps will be taken in various situations exactly.

Program Language Functions

The main function of a programming language is as a tool to give commands to the computer so that it can move to process words according to what you want. The output of the program language itself can be in the form of an application or a special program. The development of the language of this program certainly creates various technological innovations that help people in their daily lives. For example, traffic light programs on the road, cash registers, game applications, anti-virus, web, social media, and so on.

Program Language Level

1. Low-Level Program Language

Low-level programming language contains instructions addressed to the computer using binary code (binary). The codes will be directly translated by the computer without having to go through the compilation process.

2. Intermediate Program Language (Mid-Level)

Middle-level programming languages are instructions in the form of mnemonic codes such as ADD, SUB, DIV, STOLOD, JMP and others. However, the language in this intermediate level must be translated into machine language first, because the computer only understands the use of machine language.

3. High-Level Program Language

This high-level programming language contains instructions that use natural languages that humans understand, such as English or mathematics. This level was created to overcome the shortcomings of the middle and low levels.

Program Language Example

  1. HTML/CSS: The foundation of a web program. To create a static website, you need HTML/CSS language.
  2. JavaScript: One of those languages that is quite easy to learn and can be used for anything like validating form data to developing games. JavaScript is a very popular way to add interactive features in web pages and applications.
  3. PHP: The programming language used to develop dynamic web pages. Learning PHP will be very useful for website owners because PHP can shorten the code in a web page so that it can fit into a set of rules.
  4. C++: C++ is now widely used in a wide variety of applications. C++ also has the advantage that it is easier to learn other C languages such as C# and C. All C languages are generally viewed as mid-level programming languages.

Program Language Generation

  • First Generation: Is a programming language that was first created in the 1940s and early 1950s namely Machine Language or Machine Language. Machine language is an internal computer program that performs commands directly without translation.

  • Second Generation: In this generation, computers have been used commercially and produce Assembly Language which is the successor of the first generation.

  • Third Generation: Because the use of machine language and assembly language is too difficult, then third-generation languages ​​(3GLs) are born which are considered easier to program and portable. This programming language is called a high-level programming language because it is easy to learn and there is a fairly complicated computer translation process. Examples of third generation programming languages ​​such as FORTRAN, Cobol, Pascal, Basic, etc.

  • Fourth Generation: Program languages ​​in the fourth generation are also easy to understand and learn and are suitable for accessing databases. This programming language focuses on maximizing human productivity and is available in software packages that are useful for developing desired applications. Examples such as SQL, LISP, and Prolog.

  • Fifth Generation: The programming language is Programing Language Based Object Oriented and Web Development. Often used to access databases and create expert systems or knowledge-based systems.


Newer Posts Older Posts Home





POPULAR POSTS

  • Skema Power Supply Switching SMPS
  • Proteus 8.5 Full Version Professional
  • Serial Communication UART Raspberry Pico (SoftSerial)
  • Artificial Neural Network for Identification MATLAB
  • Tutorial ILI9341 TFT SPI LCD touch Screen
  • Pulse Oxymetry (SPO2) + Raspberry Pi
  • Menampilkan Text Pada LCD 16x2 I2C Arduino

ABOUT ME

cobabaru

Sinau Programming

SUBSCRIBE & FOLLOW

Training


Contact Form

Name

Email *

Message *

Categories

  • alkes 1
  • Android 4
  • Arduino 35
  • Basic & Doc 12
  • centrifuge 1
  • ESP32 8
  • Internet of Things (IoT) 23
  • LCD TFT SPI 2
  • MATLAB 6
  • Metode kendali 1
  • Modul Charger 1
  • Nextion 4
  • NodeMcu 8
  • oled 1
  • Pattern Recognition 2
  • Pemrograman 2
  • Perbaikan 1
  • PID 2
  • PLC HMI VTSCADA ARDUINO 3
  • PRIVACY POLICY 1
  • Proteus 11
  • Python 1
  • raspberry 5
  • Teknik Elektromedik 2
  • Thingsboard 1
  • Video 5
  • Wemos 4

sinau_programming

Sinau Programming Distributed by Sinau Programming