ESP32

ESP32 is a series of low-cost, low-power system on a chip microcontrollers with integrated Wi-Fi and dual-mode Bluetooth.


70 ₪

الناشر: متجر القطع الالكترونية

القسم: متحكمات

تاريخ النشر: 2021-11-20


Firebase with ESP32 & ESP8266

ربط الESP32 او ESP8266 مع قاعدة بيانات نوع Firebase

Json with ESP32

ارسال واستقبال بيانات على شكل json

get date time from NTP server

معرفة الوقت الحقيقي من خلال الاتصال مع سيرفر pool.ntp.org

install Esp32 board to arduino IDE

كيفية تثبيت القطعة على برنامج الاردوينو




How do two Device Communicate through UART?

On one end the transmitting UART converts parallel data from a CPU into serial form then transmits the data in serial form to the second UART which will receive the serial data and convert it back into parallel data. This data can then be accessed from the receiving device.



UART on ESP32 board:

By default, only UART0 and UART2 can be used. To use UART1, we have to redefine the pins because default pins of UART1 such as GPIO9 and GPIO10 are internally connected to the SPI flash memory. Also, on some ESP32 boards, they are even exposed on the pinout headers. Hence, we can not use UART1 directly without reassigning pins in Arduino IDE.



يمكن استخدام UART1 لكن يحتاج الى اعادة تعريف للمنافذ بدل من GPIO9 and GPIO10





how to use it by code in default case?

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <HardwareSerial.h> Serial.begin() //if using UART0 HardwareSerial SerialPort(1) //if using UART1 ==> but we need to define another gpio pin HardwareSerial SerialPort(2) //if using UART2 //re-define the gpio pin in setup(){} function like next //SerialPort.begin (BaudRate, SerialMode, RX_pin, TX_pin). //SerialPort.begin(15200, SERIAL_8N1, 4, 2);


If using UART2, we will initialize it as follows:

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <HardwareSerial.h> HardwareSerial SerialPort(2); // use UART2 void setup() { SerialPort.begin(15200, SERIAL_8N1, 16, 17); }


If using UART1, we will initialize it as follows:

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <HardwareSerial.h> HardwareSerial SerialPort(1); // use UART1 void setup() { SerialPort.begin(15200, SERIAL_8N1, 4, 2); }





ESP32 to ESP32 Serial Communication

Let us see an example of serial communication where the ESP32 master will send either ‘1’ or ‘0’ to the ESP32 slave. The slave will then receive that data and control an LED connected with its digital pin. We will use UART2 to communicate between the two boards.





important note:

Connect TX2 pin of master ESP32 board with RX2 pin of slave ESP32 board. Likewise, connect RX2 pin of master ESP32 board with TX2 pin of slave ESP32 board. Also make sure both ESP32 boards have their grounds in common.



Master ESP32 Arduino Sketch:

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <HardwareSerial.h> HardwareSerial SerialPort(2); // use UART2 void setup() { SerialPort.begin(15200, SERIAL_8N1, 16, 17); } void loop() { SerialPort.print(1); delay(5000); SerialPort.print(0); delay(5000); }


Slave ESP32 Arduino Sketch

code
نسخ
اقتباس
عرض
تنزيل
	
								
#include <HardwareSerial.h> HardwareSerial SerialPort(2); // use UART2 char number = ' '; int LED = 15; void setup() { SerialPort.begin(15200, SERIAL_8N1, 16, 17); pinMode(LED, OUTPUT); } void loop() { if (SerialPort.available()) { char number = SerialPort.read(); if (number == '0') { digitalWrite(LED, LOW); } if (number == '1') { digitalWrite(LED, HIGH); } } }




سلة المشتريات افراغ السلة