Embedded Sensor – DHT11
Aosong DHT11 is a low cost humidity and temperature sensor with a single wire digital interface. The sensor includes a resistive sense of wet components and an NTC temperature measurement devices, and connected with a high–performance 8–bit microcontroller. DHT11 uses a simplified single-bus communication. The sensor is calibrated and doesn’t require extra components so you can get right to measuring relative humidity and temperature.
DHT11 output calibrated digital signal. It utilizes exclusive digital-signal-collecting-technique and humidity sensing technology, assuring its reliability and stability. Its sensing elements are connected with 8-bit single-chip computer. Every sensor of this model is calibrated in accurate calibration chamber and the calibration-coefficient is saved in type of programmer in OTP memory, when the sensor is detecting, it will cite coefficient from memory. for more details about data sheet of DHT11 sensor click here.
Workshop : 20170807-Internet Of Things Using ESP8266
“Internet of things using ESP8266 Workshop”
“If you think that the internet has changed your life, think again. The IoT is about to change it all over again!” –
— Brendan O’Brien, Aria systems
Contents
Reviews
Karthikeyan
https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2Fkarthikeyan.kka.1111%2Fposts%2F1941846072763036%3A0&width=500
Workshop: Internet Of Things using ESP8266
ESP8266 is a popular Wi-Fi chip, and the Internet of Things (IoT) is one of the fastest-growing technologies. Therefore, we are organizing a technical workshop focused on IoT using ESP8266. In this workshop, you’ll gain knowledge about the basic concepts and features of IoT and learn to build projects using the ESP8266 NodeMCU platform.
Topics Covered:
- Basic concepts and features of the Internet of Things
- Building projects using the ESP8266 NodeMCU platform
- Fundamental concepts of cloud computing
- Sensor reading and data acquisition
- Connecting ESP8266 to the Internet
- Wireless interfaces
- Controlling devices with Android phones
- Using popular open platforms for managing sensor data
- Triggering actuators remotely
- Reading information on Android smartphones
Benefits:
- Gain the ability to undertake IoT projects independently
- Opportunity to assist others in learning about IoT
Workshop Details:
- Duration: 7 hours per day
- Refer to the attached image for further details.
Who Should Attend:
Anyone interested in learning about IoT and building projects with the ESP8266 chip.
Interested participants can join this workshop for a comprehensive learning experience.
Feel free to make any adjustments as needed!
Session-1 (Morning)
- Overview of Internet of things.
- Get started with ESP8266 and development board.
- Basics interface : GPIO,Timer, File System, WiFi.
- Basic Experiments : LED, RGB LED, Buzzer, Button, Relay.
- Some More Experiments : PWM, WiFi, TCP, UDP, SNPT, RTC, MQTT.
Session-2 (Afternoon)
- Real time Project 1 : Smart Device Control with monitor (Home Automation devices-Online/Offline).
- Real Time Project 2 : Smart RGB Light (Online/Offline).
- Project 3 : Network Status Indicator.
- Project 4 : Data Logger.
Goal
- Workshop is to make the students skill full and efficient for Internet of things related concepts.
- The students to do their final year projects by them-self.
- Apply Internet of things application in your day-to-day.
Participation Prerequisites
To participate in the workshop, you will need the following:
- A laptop – Windows(Latest) and at least one free USB port with internet connection.
- A micro-USB cable with data lines that fits your USB port.
- A Mobile with WiFi, Host-spot feature and internet connection.
- A breadboard and arduino board with cable.(Optional)
- You will need a install this software( I will give at workshop)
- Keep on this below software’s
- ESPlorer
- Notepad++. : Windows Offline (32-Bit)
- Please note that the workshop will be in mostly English (Local Language-Prefers).
Participation will receive in additional, at the workshop!
- Wi-Fi development board,
- LED,
- RGB LED,
- Female-female connector cables,
- Piezoelectric speaker,
- Magnetic Reed Switch
- Magnet
- Certificate will provide end of the workshop to each participate,
- End of the session we will provide all kind of workshop materials like PPT, documents, videos and source code.
Venue
Department of Electronics and Communication Engineering,
Mahendra Engineering College
Salem – Thiruchengode Highway,
Mahendhirapuri, Namakkal District,
Mallasamudram, Tamil Nadu, India-637503.
Registration
This event was held. you can’t register. contact Mr.Arun.
Payment Method
Note : You can pay the workshop fee by two ways – Online/Offline. One we received your payment you will get a message to your registered mobile and e-mail.
Online : Pay using Paytm
- Pay workshop fee (money) to +918300026060 mobile number or scan QR code image
- In Optional description write “ArunEworld_Workshop_20170821” <space> “You_Name” (Ex : ArunEworld_Workshop_20170821 Raja)
Offline : Pay to Workshop organizer
Contact-Person: Mr.Giri.K , Assistant Professor, Mahendra College of Engineering,
Contact Number: +919003503908.
Contact Organizer
Mr. Giri. K (girik@mahendra.info, +919003503908)
Department of Electronics and Communication Engineering,
Mahendra Engineering College
Salem – Thiruchengode Highway,
Mahendhirapuri, Namakkal District,
Mallasamudram, Tamil Nadu, India-637503.
Photo Gallery
Workshop full details and resource
Click this below link to see the syllabus, contents, videos and more, etc..
ESP32 Lua-RTOS – IDE Setup and Firmware Flash
Lua RTOS is an open-source real-time operating system (RTOS) designed to run Lua applications on microcontrollers and other embedded systems. It aims to provide a lightweight and efficient platform for developing embedded applications with Lua scripting capabilities.Here will discuss ESP32 Lua RTOS Flash Firmware tutorial.
Overall, Lua RTOS is a versatile and lightweight operating system that empowers developers to build embedded applications with Lua scripting capabilities. Its integration with popular microcontroller platforms and active community support make it a compelling choice for IoT and embedded systems development. We tested with EPSressif ESP-Wroom-32 Dev Board and ESP32 Core firmware with the ESPressif Flash tool.
Read more: ESP32 Lua-RTOS – IDE Setup and Firmware FlashContents
Overview of Lua RTOS
Feature | Description |
---|---|
Language | Lua RTOS is built on Lua, a lightweight scripting language. Lua is known for its simplicity, ease of use, and flexibility, making it ideal for embedded systems development. |
Real-Time Operating System | Lua RTOS provides a real-time operating system (RTOS) environment for embedded systems. It offers task scheduling, inter-task communication, and synchronization mechanisms. |
Supported Hardware | Lua RTOS supports various microcontroller architectures, including ESP32, ESP8266, STM32, and others. It is highly portable and can be adapted to different hardware platforms. |
Multitasking | Lua RTOS enables multitasking, allowing multiple Lua scripts to run concurrently as separate tasks. Tasks can communicate and synchronize through message passing and semaphores. |
File System | Lua RTOS includes a file system API for accessing files on external storage devices such as SD cards or SPI flash memory. It supports file operations like reading, writing, and listing. |
Networking | Lua RTOS supports networking protocols such as TCP/IP, UDP, MQTT, and HTTP. It allows embedded devices to communicate over Ethernet, Wi-Fi, or other network interfaces. |
Peripheral Support | Lua RTOS provides APIs for interfacing with various peripherals such as GPIO, UART, SPI, I2C, ADC, DAC, and more. Developers can easily control and communicate with hardware components. |
Development Environment | Lua RTOS development can be done using lightweight text editors or integrated development environments (IDEs) with Lua support. It offers flexibility in choosing development tools. |
Community | Lua RTOS has an active community of developers and users who contribute to its development, share knowledge, and provide support through forums, mailing lists, and social media. |
This table summarizes the key features and characteristics of Lua RTOS, providing an overview of its capabilities and suitability for embedded systems development.
Setting up Lua RTOS
Step | Description |
---|---|
1. Obtain Lua RTOS | Download Lua RTOS from the official repository or source. |
2. Install prerequisites | Install any required dependencies, such as Git and GCC, according to Lua RTOS documentation. |
3. Set up development environment | Configure your development environment, including setting up a terminal and text editor. |
4. Initialize project directory | Create a new directory for your Lua RTOS project. |
5. Write your Lua code | Develop Lua scripts and application logic within the project directory. |
6. Configure Lua RTOS | Customize Lua RTOS configuration files to match your project requirements. |
7. Compile Lua RTOS | Use the provided build system to compile Lua RTOS for your target hardware platform. |
8. Flash Lua RTOS | Flash the compiled Lua RTOS image to your target hardware using tools like esptool.py. |
9. Test your application | Verify the functionality of your Lua RTOS application on the target hardware platform. |
10. Iterate and improve | Continuously refine your Lua RTOS application based on testing feedback and requirements. |
Firmware
Where to get Lua-RTOS firmware? (Pr-compiled binaries)
Flash Tool
The software and hardware resources required for downloading firmware to flash are
listed below.
- Hardware:
o 1 x module to which firmware is downloaded
o 1 x PC (Windows 7 [64 bits], Windows 10) - Software:
Download Tool: Flash Download Tool ESpressif Flash Download Tool,
This tool supports the following SOCs
- ESP32 series
- ESP8266 series
- ESP32-S2 series
- ESP32-C3 series
- ESP32-S3 series
- ESP32-C2 series
- ESP32-C6 series
- ESP32-H2 series
Steps to follow
Download the appropriate firmware for your ESP32 board from the provided link. Once you’ve downloaded the appropriate firmware, unzip the file anywhere on your machine. Similarly, download the Flash tool from the same link and unzip it. Next, open the flash tool designed for ESP32 and configure the following parameters:
- Baud rate: 921600
- Flash mode: “dio”
- Flash frequency: “40m”
For flashing the firmware, use the following addresses:
- Bootloader.WHITECAT-ESP32-N1.bin – Address: 0x1000
- lua_rtos.WHITECAT-ESP32-N1.bin – Address: 0x10000
- partitions_singleapp.WHITECAT-ESP32-N1.bin – Address: 0x8000
For flashing the file system, use:
- spiff_image.WHITECAT-ESP32-N1.Bin
Once the flashing process is complete, you’re all set.
Note: Make sure to adjust the “esp-idf path” and “usb path” as per your requirements.
Connect to the Console
Connect any UART Serial Tool to your device and configure the following parameters:
- Speed: 115200 bauds
- Data bits: 8
- Stop bits: 1
- Parity: None
- Terminal emulation: VT100
Ensure these settings are accurately configured for seamless communication between your devices.
after connecting esp32 to the PC you will see the following.
/\ /\ / \_____/ \ /_____________\ W H I T E C A T Lua RTOS beta 0.1 build 1479953238 Copyright (C) 2015 - 2017 whitecatboard.org cpu ESP32 at 240 Mhz spiffs0 start address at 0x180000, size 512 Kb spiffs0 mounted spi2 at pins sdi=012/sdo=013/sck=014/cs=015 sd0 is at spi2, pin cs=015 sd0 type II, size 1943552 kbytes, speed 15 Mhz sd0a partition type 0b, sector 227, size 1943438 kbytes fat init file system fat0 mounted redirecting console messages to file system ... Lua RTOS beta 0.1 powered by Lua 5.3.4 Executing /system.lua ... Executing /autorun.lua ... / >
ESP32 Lua RTOS Flash Firmware tutorial
ESP32 Lua-RTOS Modules- Basic Examples
In this “ESP32 Lua-RTOS Modules- Basic Examples” article we will explore the PIO Module (GPIO) and Interface LED as well as Buzzer, Wifi, MQTT, EEPROM I2C Code.
Embedded Interface – PCF8574 and PCF8574A I/O Expender
In this article we are discussing Embedded Interface – PCF8574 and PCF8574A I/O Expender.
The PCF8574 device provides general-purpose remote I/O expansion for most micro controllers
families by way of the I2C interface [serial clock(SCL), serial data (SDA)]. 8-bit 2.5- to 5.5-V I2C/SMBus I/O expander with interrupt
The device features an 8-bit quasi-bidirectional I/O port (P0–P7), including latched outputs with high current drive capability for directly driving LEDs. Each quasi-bidirectional I/O can be used as an input or output without the use of a data-direction control signal. At power on, the I/Os are high. In this mode,
only a current source to VCC is active.
Embedded Interface – LCD HD44780
- HD44780 compliant controllers 16×2 Character LCD is a very basic and low-cost LCD module that is commonly used in electronic products and projects.
- 16×2 means it contains 2 rows that can display 16 characters.
- Its other variants such as 16×1 and 16×4 are also available in the market.
- In these displays, each character is displayed using 5×8 or 5×10 dot matrix.
Experiments
- Change Cursor Location Based on Key Input
LCD4 Bit Mode Functions
void Lcd4_Clear() { Lcd4_Cmd(0x00); Lcd4_Cmd(0x01); } // clear screen 0x01 void Lcd4_DisplayOFF_BlinkON_CursorON() { Lcd4_Cmd(0x00); Lcd4_Cmd(0x0B); } // 0x0B void Lcd4_DisplayON_BlinkOFF_CursorOFF() { Lcd4_Cmd(0x00); Lcd4_Cmd(0x0C); } // 0x0C void Lcd4_DisplayON_BlinkOFF_CursorON() { Lcd4_Cmd(0x00); Lcd4_Cmd(0x0D); } // 0x0C void Lcd4_DisplayON_BlinkON_CursorOFF() { Lcd4_Cmd(0x00); Lcd4_Cmd(0x0E); } // 0x0E //void Lcd4_Shift_Left() { Lcd4_Cmd(0x01); Lcd4_Cmd(0x08); } // 0x18 //void Lcd4_Shift_Right() { Lcd4_Cmd(0x01); Lcd4_Cmd(0x0C); } // 0x1C
Next Topic
Embedded Interface 7 Segment (Add Soon) |
Embedded Interface ADC (Add Soon) |
Embedded Interface Button (Add Soon) |
Embedded Interface EEPROM (Add Soon) |
Embedded Interface LCD (Add Soon) |
Embedded Interface LCD HD44780 (Add Soon) |
Embedded Interface LED |
Embedded Interface MCP23017 |
Embedded Interface Motor (Add Soon) |
Embedded Interface PCF8574 and PCF8574A |
Embedded Interface RTC (Add Soon) |
Embedded Interface Switch |
Embedded Interface Touch Kypad |
Embedded Interface RGB LED (Add Soon) |
Embedded Protocol – UART
UART (Universal Asynchronous Receiver/Transmitter) is a standard communication protocol used for serial communication between devices. It’s commonly employed in embedded systems for communication between microcontrollers, sensors, and other peripheral devices.
In the context of embedded systems, UART is often used as a hardware communication protocol, enabling devices to transmit and receive data serially. The UART communication involves two pins: TX (transmit) and RX (receive).
- It’s is full-duplex communication
- UART contains a shift register
- which is the fundamental method of conversion between serial and parallel forms.
- Type of Communication: Asynchronous (No clock).
- Rule: The transmitter and receiver should same baud rate. Data format and transmission speed are configurable.
- UART Uses serial communication over a computer or peripheral device serial port. (Electronics Devices).
Embedded Protocol – SPI Communication
SPI is an abbreviation for Serial Peripheral Interface, which stands for Synchronous Serial Communication Interface. It is utilized for short-distance communication and was developed by Motorola in 1980, later becoming a de facto standard. SPI communication operates in full-duplex mode. It is also sometimes referred to as the Four-Wire Serial Bus (FWSB), distinguishing it from Three, Two, and One Wire Serial Bus protocols. The four-wire protocol includes SCL, SS, MISO, and MOSI. SPI operates as a single master protocol.
Embedded Protocol – MQTT
Message Queue Telemetry Transport (ISO/IEC PRF 20922), or MQTT, is a lightweight protocol designed for machine-to-machine (M2M) device communication using a Publish/Subscribe pattern. It was developed by Message Queue Telemetry Transport (ISO/IEC PRF 20922) and Lightweight protocol for (M2M) device communication using Publish/Subscribe. It was Developed By Andy Stanford-Clark (IBM) and Arlen Nipper (Eurotech; now Cirrus Link) in 1999. Unlike HTTP, which follows a request/response paradigm, It utilizes a publish/subscribe architecture. The central communication point in It is the Broker. It is available for implementation in C, C++, JavaScript, Lua, Python, and soon in C#.
Contents
Client functions
Field | Description |
---|---|
Host | Address of the MQTT broker. |
Port | Default: 1883. |
ClientID | Unique client identifier. |
Username | UTF-8 encoded string for authentication. |
Password | Client’s password if flag set. |
Keep Alive | Duration client stays connected (seconds). |
SSL | Indicates SSL/TLS encryption usage. |
Clean Session | If set, session clears subscriptions and messages. |
Last-will Topic | Topic for “Last Will” message on disconnect. |
Last-will QoS | Quality of Service for “Last Will”. |
Last-will Retain | Retain status for “Last Will” message. |
Last-will Message | Content of “Last Will” in case of disconnection. |
Topic | Message destination hierarchy. |
+ Plush sign | Single-level wildcard in subscriptions. |
# Hash Sign | Multilevel wildcard in subscriptions. |
Publish QoS | Quality of Service levels: |
QoS(0) – At most once | |
QoS(1) – At least once | |
QoS(2) – Exactly once | |
Retain | Message retention by broker. |
Subscriptions | List of subscribed topics. |
Message | Payload data transmitted. |
Broker | Server distributing messages. |
Client | Device or app connected to broker. |
Quality of Service | Message delivery guarantee. |
Retained Messages | Broker-stored messages for new subscribers. |
Persistent Session | Broker-maintained session after client disconnects. |
Last will and Testament and SYS topic | Client’s “Last Will” message and system topics interaction. |
PHP MQTT
Web Apps
WordPress Plugin
DIOT SCADA with MQTT By Ecava
Image Source
DIOT which stands for Decoupled IOT, has its SCADA functionalities decoupled into Host and Node for flexibility and scalability that catered for IoT era. This plugin functions as the SCADA Host to work with your device or system, which will be treated as SCADA Node. You just need to enter the broker/server into the configuration. You may then subscribe to the desired topic with a shortcode to display in any desired web page or post. [diot topic="building/floor/device/sensor"]
Or, if you have a JSON content, you may add dollar sign as JSON root: [diot topic="building/floor/device/sensor$json.data"]
. The content will be updated dynamically when the device publish any data. You may also choose to display your realtime data in trending chart. Check out Ecava DIOT online demo to see how easy things can be done now! For more see here : https://wordpress.org/plugins/ecava-diot-scada/
Image Source
WP-MQTT By Roy Tanck
Setting up Tthis is easy. Simply supply your MQTT broker’s details and configure which WordPress events should trigger messages. “MQTT is a machine-to-machine (M2M)/”Internet of Things” connectivity protocol. It was designed as an extremely lightweight publish/subscribe messaging transport.” (from mqtt.org) A number of events are predefined. Simply check the right checkbox and fill in the message’s subject and text.
- Pageview
- User login
- Failed user login
- Post published
- Page published
- New comment
Other events can be added using the “custom events” section. This allows you to use any WordPress hook (actions and filters) to trigger messages.
Image Source
Android App
Check this below name in Play-store
- Dashboard
- IOT Manager
- IOT
Broker Service Supporter
The following list of brokers may be used online or locally also giving free and paid service
Adafruit IO (Online – Free)
- Website : Adafruit IO
- Adafruit supporting online free service.
- You can use adafruit client libraries to Python, Node JS, Rubby and Arduino. see the client libraries section).
- The following details are to connect a client to Adafruit IO.
- Host : io.adafruit.com
- Port : 1883 or 8883
- Username : Your adafruit account username
- Password : Your adafruit IO Key
CloudMQTT (Online -Free and Paid)
- Website :
- CloudMQTT
- Online – Free Plans : Cute Cat and
- Paid Plans : Keen Kola, Loud Leopard, Power Pug)
- Using Amazon Web Service
- Type : mosquitto
HiveMQ (Online -Free and Paid)
Connect to Public Broker
- Dashboard
- Broker: broker.hivemq.com
- TCP Port: 1883
- Websocket Port: 8000
- Web socket Client : http://www.hivemq.com/demos/websocket-client/
- Broker: broker.mqttdashboard.com
- TCP Port: 1883
- Websocket Port: 8000
Setup local instance
- Genral Download HiveMQ
- Arun Requested : Downloaded Link
m2m
Free public broker service
- q.m2m.io
- Broker: q.m2m.io
- Port: 1883.
- Application : Facebook messenger
Mosquitto (Local and Online free)
Eclipse Mosquitto™ is an open source v3.1/v3.1.1 Broker.
Free public Service
- iot.eclipse.org
- Broker: iot.eclipse.org
- Port: 1883, 80(WebScoket), 443 (WebSockets+SSl)
- mosquitto
- Broker : test.mosquitto.org
- Port:
- 1883 : MQTT, unencrypted
- 8883 : MQTT, encrypted
- 8884 : MQTT, encrypted, client certificate required
- 8080 : MQTT over WebSockets, unencrypted
- 8081 : MQTT over WebSockets, encrypted
- 80(WebScoket), 443 (WebSockets+SSl)
rabbitMQ
- https://www.rabbitmq.com/
- Install on windows
- Download rabbit for windows :
- Installation guide
Free public broker service
- dev.rabbitmq.com
- Broker: dev.rabbitmq.com
- Port: 1883,
SimpleML
- Free MQTT service to evaluate Machine Learning models, documentation
Free public broker service
- simpleml
- Broker: mqtt.simpleml.com
- Port : 1883 (MQTT), 8883 (MQTT +SSl), 80(REST), 80(WebSockets), 5683 (CoAP)
Other free public broker service
- dioty.co
- Broker : dioty
- Port : 1883 (MQTT), 8883 (MQTT +SSl), 80(REST), 8080(WebSockets), 8880 (WebSocket +SSL)
- swifitch.cz
- Broker :mqtt.swifitch.cz
- Port : 1883 (MQTT)
Interview Questions
Reference
- hivemq
- wiki
- http://www.hivemq.com/ (Tutorials)
- https://github.com/mqtt/mqtt.github.io/wiki
- https://github.com/mqtt/mqttorg-graphics
- github
- http://mqtt.org/
- http://mosquitto.org/download/
- https://www.youtube.com/watch?v=fwb5YAPzPGk
Embedded Protocol – COAP
COAP, or Constrained Application Protocol, a specialized web transfer protocol, is designed for constrained devices and low-power, low-bandwidth networks commonly found in Internet of Things (IoT) and Machine-to-Machine (M2M) applications. CoAP is an application layer protocol similar to HTTP but optimized for constrained environments.
Read more: Embedded Protocol – COAPThis, designed to be simple and lightweight, is ideal for resource-constrained devices, operating over UDP instead of TCP to reduce complexity. It supports request/response interactions like HTTP and offers features such as multicast support and resource discovery. CoAP facilitates efficient communication between constrained devices and web servers, fostering the development of scalable IoT solutions.
Getting Started with Terminal by Br@y tool
- Terminal is a simple serial port(COM) terminal emulation program
- Used for communication with different devices (Modem, routers, embedded uC systems, GSM Phones. GPS Modules)
- Very useful debugging tool for serial communication applications
Embedded Protocol – I2C
I²C (Inter-Integrated Circuit) is a bi-directional two wires and serial data transmission communication protocol developed by Philips (Now NXP Semiconductor) in 1982. I2C is a Half-duplex communication protocol – (I2c can’t send and receive same time in the bus-data line). Multi-master can communicate with multi-salve. (Note: Communication is restricted between two masters; however, a single master can communicate with either a single slave or multiple slaves.) I2C is a Level Triggering. A device that sends data onto the bus is defined as a transmitter, and a device receiving data is defined as a receiver.
The bus must be controlled by a master device, responsible for generating the Start and Stop conditions. In contrast, certain devices such as LCDs, EEPROMs, and RTCs function as slaves. It’s important to note that both master and slave devices can operate as either transmitters or receivers. However, the master device plays a pivotal role in determining which mode is activated.
ESP32 Mongoose OS – Basic Examples
This article is about ESP32 Mongoose OS – Basic Examples, Let’s go through a basic example of using UART (Universal Asynchronous Receiver-Transmitter), Button and blinking an LED using an ESP32 by Mongoose OS.
Mongoose OS is an open-source IoT operating system designed for low-power, connected microcontrollers. Below is a basic example to get you started with Mongoose OS on an ESP32. This example demonstrates how to create a simple firmware that blinks an LED.
This is a basic example to help you get started with Mongoose OS on an ESP32. It blinks an LED using the GPIO capabilities provided by Mongoose OS. From here, you can explore additional features and libraries provided by Mongoose OS to build more sophisticated IoT applications. Refer to the Mongoose OS documentation for detailed information and advanced usage.
Contents
Setup Required
- PC
- UART Terminal (Putty, Visual Studio Serial Terminal, DockLight)
- LEDs
UART Serial
Print words, string, text, symbols
print('------------****************----------------'); print('ArunEworld');
ESP32 Mongoose OS – Basic Examples of UART Communication
// https://github.com/cesanta/mongoose-os/blob/master/fw/examples/mjs_uart/init.js // Load Mongoose OS API load('api_timer.js'); load('api_uart.js'); load('api_sys.js'); // Uart number used for this example let uartNo = 1; // Accumulated Rx data, will be echoed back to Tx let rxAcc = ""; let value = false; // Configure UART at 115200 baud UART.setConfig(uartNo, { baudRate: 115200, esp32: { gpio: { rx: 16, tx: 17, }, }, }); // Set dispatcher callback, it will be called whenver new Rx data or space in // the Tx buffer becomes available UART.setDispatcher(uartNo, function(uartNo, ud) { let ra = UART.readAvail(uartNo); if (ra > 0) { // Received new data: print it immediately to the console, and also // accumulate in the "rxAcc" variable which will be echoed back to UART later let data = UART.read(uartNo); print("Received UART data:", data); rxAcc += data; } }, null); // Enable Rx UART.setRxEnabled(uartNo, true); // Send UART data every second Timer.set(1000 /* milliseconds */, true /* repeat */, function() { value = !value; UART.write( uartNo, "Hello UART! " + (value ? 'Tick' : 'Tock') + " uptime: " + JSON.stringify(Sys.uptime()) + " RAM: " + JSON.stringify(Sys.free_ram()) + (rxAcc.length > 0 ? (" Rx: " + rxAcc) : "") + "\n" ); rxAcc = ""; }, null);
GPIO Module
- View On GitHub : api_gpio.js
ESP32 ArduinoCore Interface – Wi-Fi
The ESP32 ArduinoCore interface for Wi-Fi provides a straightforward and flexible way to enable Wi-Fi connectivity in projects developed using the ESP32 microcontroller platform with the Arduino IDE. With this interface, developers can easily incorporate Wi-Fi functionality into their projects, enabling devices to connect to wireless networks, access the internet, and communicate with other devices over Wi-Fi.
Features and Capabilities
- Access Point (AP) Mode: The ESP32 can act as an access point, allowing other devices to connect to it and access resources or services hosted by the ESP32.
- Station (STA) Mode: The ESP32 can connect to existing Wi-Fi networks as a client, enabling devices to access the internet or communicate with other networked devices.
- Soft Access Point (SoftAP) Mode: This mode enables the ESP32 to simultaneously act as both an access point and a station, allowing it to connect to an existing Wi-Fi network while also providing Wi-Fi access to other devices.
- Wi-Fi Protected Setup (WPS): The ESP32 supports WPS, a method for easily configuring Wi-Fi network security settings without needing to enter a password manually.
- Advanced Configuration Options: The interface provides access to advanced configuration options for fine-tuning Wi-Fi settings, such as specifying static IP addresses, setting up captive portals, and configuring Wi-Fi sleep modes to optimize power consumption.
- Event Handling: Developers can implement event handlers to respond to Wi-Fi-related events, such as successful connections, disconnections, or errors, allowing for more robust and responsive Wi-Fi functionality.
- Security Features: The ESP32 ArduinoCore interface supports various Wi-Fi security protocols, including WPA and WPA2, to ensure secure communication over Wi-Fi networks.
Overall, the ESP32 ArduinoCore interface for Wi-Fi simplifies the process of adding Wi-Fi connectivity to ESP32-based projects, making it easier for developers to create IoT devices, home automation systems, and other wireless applications.
Scan WiFi
Note: You can use Arduino example code instead of the below code because both are the same (File > Example > WiFi> WiFiScan)
/* https://aruneworld.com/embedded/espressif/esp32 * Tested By : Arun(20170429) * Example Name : AEW_WiFi_Scan.ino * This sketch demonstrates how to scan WiFi networks. * The API is almost the same as with the WiFi Shield library, * the most obvious difference being the different file you need to include: */ #include "WiFi.h" void setup() { Serial.begin(115200); // Set WiFi to station mode and disconnect from an AP if it was previously connected WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); Serial.println("Setup done"); } void loop() { Serial.println("scan start"); // WiFi.scanNetworks will return the number of networks found int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { // Print SSID and RSSI for each network found Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); delay(10); } } Serial.println(""); // Wait a bit before scanning again delay(5000); }
Serial Terminal Output
scan start scan done 5 networks found 1: ArunEworld (-34)* 2: Exuber_365 (-59)* 3: Bangalore Police (-66)* 4: Tagos-2.4 (-80)* 5: RRL_Internet (-93)*
Code Explanation
Certainly! Here’s the code with explanations provided as snippets:
#include "WiFi.h"
This line includes the WiFi library necessary for working with WiFi on the ESP32.
void setup() { Serial.begin(115200); WiFi.mode(WIFI_STA); WiFi.disconnect(); delay(100); Serial.println("Setup done"); }
In the setup()
function:
- The code initializes serial communication at a baud rate of 115200.
- The WiFi mode is set to station mode (
WIFI_STA
) and any previous connection is disconnected usingWiFi.disconnect()
. - The code adds a delay of 100 milliseconds.
- The code prints “Setup done” to the serial monitor.
void loop() { Serial.println("scan start"); int n = WiFi.scanNetworks(); Serial.println("scan done"); if (n == 0) { Serial.println("no networks found"); } else { Serial.print(n); Serial.println(" networks found"); for (int i = 0; i < n; ++i) { Serial.print(i + 1); Serial.print(": "); Serial.print(WiFi.SSID(i)); Serial.print(" ("); Serial.print(WiFi.RSSI(i)); Serial.print(")"); Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*"); delay(10); } } Serial.println(""); delay(5000); }
In the loop()
function:
- The code begins by printing “scan start” to the serial monitor.
- Next, the ESP32 scans for nearby WiFi networks using the
WiFi.scanNetworks()
function, storing the number of networks found in variablen
. - After completing the scan, the code prints “scan done” to the serial monitor.
- The code prints the number of networks found when it detects networks, followed by details of each network, including index, SSID (network name), RSSI (signal strength), and encryption type.
- If no networks are found (when
n == 0
), the message “no networks found” is printed. - When networks are found, the code prints the number of networks found, followed by details of each network, including index, SSID (network name), RSSI (signal strength), and encryption type.
- Finally, the code adds a delay of 5 seconds before initiating the next scan.
These snippets provide an overview of how the code initializes WiFi and continuously scans for nearby networks, printing details to the serial monitor.
ESP32 ArduinoCore Project – WiFi Web Server LED Blink
This article is a continuation of the series on the ESP32 ArduinoCore Project using the ESP32 Dev board and carries the discussion on WiFi Web Server LED Blink. This series aims to provide easy and practical examples that anyone can understand. In our previous tutorial, we saw how to use the inbuilt code to toggle the onboard LED. This is the ESP32 LED Blinky in Wifi Webserver In this tutorial
A simple web server that lets you blink an LED via the web.
Wifi Web Server Info
- This code will print the IP address of your WiFi Module (ESP32) (once connected) to the Serial monitor.
- From that IP Address, you can open that address in a web browser to turn on and off the LED on pin-5.
- If the IP address of your ESP32 is 192.168.1.143:
- http://192.168.1.143/H turns the LED on
- http://192.168.1.143/L turns it off
- This example is written for a network using WPA encryption.
- For WEP or WPA, change the Wifi.begin() call accordingly.
ESP32 ArduinoCore Interface – Basic Example
When programming the ESP32 using the Arduino IDE, you typically use the ESP32 Arduino core, which provides a set of libraries and APIs to facilitate development. In this tutorial, we can discuss ESP32 ArduinoCore Interface Basic Example of Serial, GPIO, Timer, etc
Explore the fundamental features of the ESP32 microcontroller through an introductory example utilizing the ArduinoCore interface. This tutorial covers Serial communication, GPIO configuration for digital input and output, and Timer usage for precise timing operations. Ideal for beginners and hobbyists, this basic example demonstrates how to implement essential functionalities such as blinking an LED, reading button inputs, and handling timer interrupts, providing a solid foundation for further exploration and development with the ESP32 platform.”
You must be logged in to post a comment.