echo '' ;

ESP8266 Mongoose-OS Module – WiFi

Welcome to the ESP8266 Mongoose-OS Module on WiFi. In this module, we will explore how to configure and utilize WiFi connectivity on the ESP8266 microcontroller using Mongoose-OS firmware.

The ESP8266 is a powerful microcontroller with built-in WiFi capability, making it a popular choice for IoT (Internet of Things) projects. Mongoose-OS is an open-source firmware for microcontrollers that provides a development environment for building IoT applications.

Read more: ESP8266 Mongoose-OS Module – WiFi

In this module, we will cover topics such as configuring WiFi settings, connecting to WiFi networks, handling WiFi events, and utilizing WiFi functionalities in IoT applications. Whether you’re a beginner or an experienced developer, this module will provide you with the knowledge and skills to effectively use WiFi on the ESP8266 with Mongoose OS.

Let’s dive into the world of WiFi connectivity with the ESP8266 and Mongoose-OS!

Scan all available networks

Wifi.scan(function(results) {
    print(JSON.stringify(results));
});

Configure Access Point (Hotpots)

By default when flashing the firmware after ESP8266 WiFi configured as a AP mode in the WiFI AP SSID name of Mongoose_?????  here ????  is the chip id and password is Mongoose .

FAQ

  • How to Set ESP8266 to AP mode?
  • How to Set ESP8266 as Hotpots?

Steps to follow

  • Go to the Device files tab in a web browser using the mos tool. (IP address http://127.0.0.1:1992/#files )
  • Change the ap credential or set the credential in the conf0.json  file. (Refer Below Image)

Code Example

  • Enable AP Mode : “enable”: true, .
  • Disable AP Mode : “enable”: false, .
  • You can hide ESP8266 AP mode list using “hidden”: false,  (Not shown WiFi available list).
const wifiConfig = {
  wifi: {
    ap: {
      enable: true,
      ssid: "ArunEworld",
      pass: "info@aruneworld.com",
      hidden: false,
      channel: 6,
      max_connections: 10,
      ip: "192.168.4.1",
      netmask: "255.255.255.0",
      gw: "192.168.4.1",
      dhcp_start: "192.168.4.2",
      dhcp_end: "192.168.4.100",
      trigger_on_gpio: -1,
      disable_after: 0,
      hostname: "",
      keep_enabled: true
    }
  }
};

ESP8266 connects to WiFi Router

Here’s an example code snippet to connect an ESP8266 to a WiFi router using Mongoose OS:

load('api_config.js');     // Load the Mongoose OS configuration API
load('api_net.js');        // Load the Mongoose OS network API

// Configure WiFi settings
let ssid = 'YourWiFiSSID'; // Replace 'YourWiFiSSID' with your WiFi network SSID
let password = 'YourWiFiPassword'; // Replace 'YourWiFiPassword' with your WiFi network password

// Connect to WiFi
Net.connect({
  ssid: ssid,
  pass: password,
  auth: Net.AUTH_WPA2_PSK // Use WPA2 authentication (change if necessary)
});

// Event handler for WiFi connection status change
Net.setStatusEventHandler(function(ev, arg) {
  if (ev === Net.STATUS_DISCONNECTED) {
    print('WiFi disconnected');
  } else if (ev === Net.STATUS_CONNECTING) {
    print('WiFi connecting...');
  } else if (ev === Net.STATUS_CONNECTED) {
    print('WiFi connected');
  }
});

Replace 'YourWiFiSSID' with the SSID of your WiFi network and 'YourWiFiPassword' with the password of your WiFi network. This code will attempt to connect the ESP8266 to the specified WiFi network using the provided credentials. It also includes event handlers to print status messages when the WiFi connection status changes.

NEXT

MongooseOS
Mongoose-OS Interface
ESP8266 MongooseOS Interface LED
ESP8266 MongooseOS Interface Button
Mongoose OS Tutorials
ESP8266 MongooseOS Tutorials Web Server
Others
ESP8266 MongooseOS All Post
C Programming Language

C – Basic

Starting with C programming offers great opportunities! Let’s kick things off with a brief overview of the basics to get you started:

Remember, mastering programming requires time and practice, so don’t get discouraged if you face difficulties along the way. Keep coding and experimenting, and you’ll improve over time!

Read more: C – Basic

Get start

  1. Setup your environment: You need a compiler to write and run C programs. Popular choices include GCC (GNU Compiler Collection), Clang, and Visual Studio for Windows. Install one based on your operating system.
  2. Choose a text editor or IDE: You can write C code in any text editor, but using an Integrated Development Environment (IDE) can make your life easier. Some popular options include Visual Studio Code, Atom, Sublime Text, and Eclipse.
  3. Learn the basics: Familiarize yourself with basic C syntax, such as variables, data types, operators, loops (like for and while loops), conditional statements (if-else), functions, arrays, and pointers. These are the building blocks of any C program.
  4. Compile and run: Save your program with a “.c” extension (e.g., hello.c). Open a terminal or command prompt, navigate to the directory containing your program, and compile it using the compiler you installed. For GCC, the command would be: gcc hello.c -o hello This command compiles your code into an executable named “hello”. Then, run the executable: ./hello You should see “Hello, World!” printed to the screen.
  5. Practice: Once you’ve got the basics down, practice writing more complex programs. Try solving small programming challenges or work on projects that interest you.
  6. Learn from resources: There are plenty of online resources, tutorials, and books available to help you learn C programming. Websites like GeeksforGeeks, Tutorialspoint, and the C programming subreddit can be valuable learning resources.
  7. Debugging: Learn how to debug your programs when something goes wrong. Understanding concepts like breakpoints, stepping through code, and reading error messages will be immensely helpful.
  8. Explore more advanced topics: Once you’re comfortable with the basics, you can delve into more advanced topics like memory management, file handling, data structures, and algorithms.

Write your first program

A classic first program is the “Hello, World!” program. It simply prints “Hello, World!” to the screen. Here’s how you can write it:

#include <stdio.h>

int main() {
    printf("Arun E, World!\n");
    return 0;
}

Join a community

Participating in online forums or joining a local programming group can provide support, encouragement, and opportunities to learn from others.

Constants

  • (Two types : Primary, Secondary)
  • When the program execution time constants should not change their value (A constant is an entity that doesn’t change)
Constant TypeConstant Sub TypeTypeTypeDescriptionExample
Primary ConstantNumeric Constant (Three Type)IntegerDecimalDecimal constants are 0 to 9 numbers86 , 94 , -133
Primary ConstantNumeric Constant (Three Type)IntegerOctalOctal constants are 0 to 7 numbers. First number should be ‘00137 , -0567 , 034
Primary ConstantNumeric Constant (Three Type)IntegerHexadecimalHexadecimal constants are 0 to 9 and A to F. First number should be start with ‘0x’ or ‘0X’0X73A , 0x89FA
Primary ConstantReal or floating point Constant (Two types)Fractional formFractional formdot points are consider as fractional forms-0.567 , .64 , 24.0
Primary ConstantReal or floating point Constant (Two types)

Exponential formExponential formRules: May use mantissa and exponent symbols
Should not use .dot point in exponent
Should have at-least one digit in exponent
0.2571e-5, mantissa – 0.2571, exponent – -5
Primary ConstantCharacter ConstantCharacter ConstantCharacter ConstantCharacter constant are come with two single quotes ()‘A’ – (ASCII-65)
‘O’ – (ASCII-48, EBCDIC-240)
‘a’ – (ASCII-97, EBCDIC-129)
‘z’ – (ASCII-122, EBCDIC-269)
% – (ASCII-37, EBCDIC-108)
Primary ConstantString constantString constantString constantString constant are come with two double quotes ()“ARUN” – Valid
“2020” – Valid
“A” – Valid
“ABC – Invalid
‘sum’ – Invalid
Secondary ConstantArray
Secondary ConstantPointer
Secondary Constantstructure
Secondary Constantunion
Secondary Constantenum

Floating Points

  • floating points may contain . dot point.
  • Rule-1: Should use 0 to 9 numbers.
  • Rule-2: Dot point may come front or back
  • Rule-3: In the case of float numbers, place sign symbols in front of them.
  • Example : 537.36, -158.77

How does the system store a negative integer?

  • Usually, all the negative integers are store in computers in the form of the two’s complement of the same positive integer.
  • Eg: 1011 (-5) Step-1 − One’s complement of 5: 1010, Step-2 − Add 1 to above, giving 1011, which is -5.

Character Set

Typecharacter set
Alphabets A, B, …. Y, Z a, b, …. y, z
Digits0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Special symbols~ `! @ # $ % ^ & * ( ) _ - + = | \ { } [ ] : ; ” ’ < > , . ? /
White spaceBlank space, Horizontal tab, Carriage return, New line , Form feed.

Reserved Keywords

C89 Reserved Keywords

According to C89 standards c has 32 reserved keywords

autodogotosignedunsigned
breakdoubleifsizeofvoid
caseelseintstaticvolatile
charenumlongstructwhile
constexternregisterswitch
continuefloatreturntypedef
defaultforshortunion

Enum:

  • Enumeration (or enum) represents a user-defined data type in C. It primarily assigns names to integral constants, making programs easier to read and maintain
  • --  or ++  are can’t be done on enum value.

C99 Reserved Keywords

According to C99, C has 5 more reserved keywords

  • _Bool
  • _Complex
  • _Imaginary
  • inline
  • restrict

C11 Reserved Keywords,

According to C11, C has 7 more reserved keywords

  • _Alignas
  • _Alignof
  • _Atomic
  • _Generic
  • _Noreturn
  • _Static_assert
  • _Thread_local

Identifiers

Rules

  • Should not use keyword as a identifier.
  • First letter should be English word.
  • May use Uppercase and Lowercase letters.
  • Can use _ underscore as a first letter of Identifier.
  • Identifiers are case sensitive(below both identifiers are not same)

Example

  • Valid Identifiers: Sum, basic_pay, a1, Ab, ab.
  • Invalid Identifiers: 8a – First letter should not be numbers, auto auto is a keyword

Variables

  • When the program execution time variable may be change their value.(A variable is an entity that does change),
  • Example: Sum , average , basic_pay , basic-pay , A0 etc (valid variables)
  • Generally variables are store in different storage class types : automatic , static , extern , register

Declaring a variable

Rules

  • should be declared data type of variable.
  • data types name should be declared data type’s
  • if declare multiple variables in a single data type, separate each by, operator
  • Every declaration should end with ; semicolon

Syntax

  • datatype variable_1, variable_2, …..variable_n ;
  • Example-1: int a, b , c; //here a,b, c are integer variables
  • Example-2: float salary; //here salary is a floating type variable.

Use of variable declaration

  • Compiler can allocate a memory when we declared data type variable

Variable Initializing

  • Syntax: datatype variable_name = initial value;
  • Example: int sum = 1;

Assigning Value to Variable

Assigning Operator = equal is used to assign value to variable in

  • Syntax for value : Variable_name = value; Ex: x = 20;
  • Syntax for another variable: variable_name = variable; Ex: y = x;
  • Syntax for expressions: variable_name = expression; Ex: z = x+y;

Exercise

Q : Which of the following is not a valid variable name in C?
A. 1 a @
B. a 1 2
C. a b 123
D. a b c 123

Answer: Option A (Explanation: First character must be alphabet).

You cannot print (automagically) the type of a variable in C. Variables and their types are only known at compile time.

At runtime, there is no variables (only locations & values) and almost no types:


Data types

  • Data types in any of the language means that what are the various type of data the variables can have in that particular language.
  • Whenever a variable is declared it becomes necessary to define data type that what will be the type of data that variable can hold.
  • basic datatype: char , int , float and double.
  • type modifier (Qualifier) : short , long , signed and unsigned
  • Rules : Every variable should have any one of the following data type

Typesbit SizeByte SizeRange
char (or)
signed char
81127 to 127
unsigned char810 to 255
int (or)
signed int
162-32,767 to 32,767
unsigned int1620 to 65,535
short int (or)
signed short int
81-127 to 127
unsigned short int810 to 255
long int (or)
signed long int
324-2,147,483,647 to 2,147,483,647
unsigned long int3240 to 4,294,967,295
float3243.4E-38 to 3.4E+38
double6481.7E-308 to 1.7E+308
long double80103.4E-4932 to 1.1E+4932
unsigned sort162

The various general types of data are:

General typeGeneral Sub typeData Type
Number type dataInteger Typeint
Number type dataFloat type (Three Types)Float
Number type dataFloat type (Three Types)double
Number type dataFloat type (Three Types)long double
Character type datachar
String type data
Boolean type databool

C Programming Structure

  • Pr-processor Commands
  • Type definition
  • Function prototype – Declare function type and variable passed to functions
  • Variable – We must have a main function in every c programs
//pre processor command
#include <stdio.h>

//variable type definition ("a" is a variable and integer type)
int a; 

//Function prototype ("Func" is a integer type function name with arguments "a", "b" is a variables integer type)
int Func(int b, int c); 

//main function integer type
int main()
{
	//"E" Local variable integer type
    int E;
	
    C statements;
}


Hello World C program

Code

#include<stdio.h>

void main()
{
 
   printf("ArunEworld");
}

Output : ArunEworld

Note : All the programs are run in gnu gcc of linux.


Escape sequence

Escape sequence is a character constant or string constants, its a non graphical character or printable.

Escape sequenceExample
\a  – alarm character 
\b  – back space 
\f  – form feed 
\n  – new line 
\r  – carriage return

Carriage return is known as cartridge return and often shortened to CR, <CR> or return.

It is a control character or mechanism used to reset a device position to the beginning of a line of text.

It is closed associate with the line feed and newline concepts.
 
\t  – horizontal tab 
\v  – vertical tab 
\\  – back slash 
\?  – question mark 
\’  – single quote 
\”  – double quote 
\000  – character representation

\xbh – character representation
 
\0  – nul character

Difference between ‘/0’  and ‘\0’  in C programming?‘\0’ – Null terminator in array.
 

Header files (Two types)

Predefined Header files

  • Syntax : #include<file_name> (Stored in Specified directories).
  • If a header file is included with in < > then the compiler searches for the particular header file only with in the built in include path.

User defined Header files

  • Syntax : #include “file_name” (Stored in Locally saved programs).
  • If a header file is included with in “ “ , then the compiler searches for the particular header file first in the current working directory, if not found then in the built in include path.

Command Statements

  • /* Commands */ – Commands in paragraph
  • // commands – command in single line

Format specifier

SpecifierDescription
%iCan be used to input integer in all the supported format.
%csingle character
%ddecimal character
%efloating point value
%ffloating point value
%gfloating point value
%hshort integer
%ldlong integer
%ooctal integer
%sstring
%uunsigned decimal integer
%xhexa decimal integer
%pprint the address of the variable
[...] string which may include white spaces

Little Endian & Big Endian

Next Topic

C – Basic
C – Operator
C – Decision making, Branching, Looping
C – Functions
C – Storage Class
C – Extern
C – Array
C – Pointer
C – Memory Allocation
C – Structure
C – Union
C – Structure and Union
C – Macros
C – Preprocessor and Macros
C – File Management
C – Coding Standard
C – Compilers
C – Compiling Process
C File Management
C Library
C Example
C Programming Language

C – File management

File management in the C programming language involves operations related to reading from and writing to files. Here are some key concepts and functions for file management in C:

File Pointers

  • C uses a file pointer to keep track of the current position in a file.
  • FILE is a structure in C that represents a file stream. You declare a pointer to this structure to work with files.
  • Syntax: FILE *filePointer;

File Functions in C

Table File Functions Summary

Opening a File: Fopen() Function

Syntax: fopen(“file_name”,"mode”);

File Modes: generic file handling

  • r – Open an existing file for Read purpose
  • wOpen an existing file for Write purpose
  • a – Open a file for writing in append mode. If file not exist, then create new file.
  • r+ – Open a file for both Read and Write
  • w+ – Opens a file for Read and Write. If a file is not existing it creates one, else if the file is existing it will be over written.
  • a+

File Modes: Binary file handling

  • rb – Read (Binary file)
  • wb – write (Binary file)
  • ab – append (Binary file)
  • rb+
  • wb+
  • ab+
  • r+b – reading (Binary file)
  • w+b – (Binary file)
  • a+b – (Binary file)

Closing a File: fclose() Function

  • After using a file, it’s important to close it using the fclose function.
  • Syntax: fclose(filePointer);

Reading from a File

  • For reading from a file, you use functions like fscanf, fgets, or fread.
  • Syntax: fscanf(filePointer, "%s", buffer); // Read a string

Writing to a File:

  • For writing to a file, you use functions like fprintf, fputs, or fwrite.
  • Syntax: fprintf(filePointer, "Hello, World!\n");

Error Handling:

  • It’s important to check if file operations are successful. The functions usually return NULL on failure.
  • Syntax: if (filePointer == NULL) { // Handle error }

File Positioning:

  • fseek and ftell functions can be used to set the file position indicator and get the current position.

Syntax:

fseek(filePointer, 0, SEEK_SET); // Move to the beginning of the file long position = ftell(filePointer); // Get the current position

Removing a File:

  • The remove function can be used to delete a file.
  • Syntax: remove("example.txt");

These are basic file management operations in C. Remember to always handle errors and close files after using them to avoid data corruption or loss.

NEXT

C – Basic
C – Operator
C – Decision making, Branching, Looping
C – Functions
C – Storage Class
C – Extern
C – Array
C – Pointer
C – Memory Allocation
C – Structure
C – Union
C – Structure and Union
C – Macros
C – Preprocessor and Macros
C – File Management
C – Coding Standard
C – Compilers
C – Compiling Process
C File Management
C Library
C Example
C Programming Language

C – Storage Classes

Storage classes in C determine a variable’s scope, visibility, lifetime, and storage location. They include auto, extern, static, and register. The default initial value varies based on the storage class. Scope defines variable visibility, while lifetime dictates its persistence in memory.

Read more: C – Storage Classes
  • Scope: The extent to which different parts of a program have access to the variable, determining its visibility.
  • Lifetime refers to the duration for which the variable persists in memory, encompassing the allocation and deallocation of its storage. The scope also influences a variable’s lifetime.
  • variable types(Global variable)
Variable TypeLifetimeScope
Global VariableOnly destroyed when the program terminatesOnly the program
Local VariableAllocated memory when entering the function, destroyed when leavingLimited to the function
  • syntax: storage_class_specifier data_type variable_name;
SpecifiersLifetimeScopeDefault Initialize
autoBlock (inside function)BlockUninitialized
registerBlock (stack or CPU register)BlockUninitialized
staticProgramBlock or compilation unitZero
externProgramBlock or compilation unitZero
(none)Dynamic (heap)nilUninitialized

Auto Keyword

A variable declared inside a function without any specified storage class is termed an auto variable.

  • Only usable within functions.
  • Created and destroyed automatically upon function call and exit, respectively.
  • Compiler assigns them garbage values by default.
  • The stack memory stores local variables.
  • By default, every local variable in a function is of auto storage class.

Example:

void f() {
    int i;    // auto variable
    auto int j;   // auto variable
}

Global variable

  • A variable declared outside any function is a global variable.
  • Any function in the program can change its value.
  • initializing
    • int – 0
    • char – \0
    • float – 0
    • double -0
    • pointer – null

Register Keyword

The “register” keyword specifies that local variables are stored in a register for rapid access, particularly for counters. These variables offer quicker access than normal ones, but only a limited number can be placed in registers. While the compiler sees “register” as a suggestion, it ultimately decides. Typically, compilers optimize and determine variable allocation.

Register Note 1:

Attempting to access the address of a register variable results in a compile error. For instance:

int main() {
    register int i = 10;
    int *a = &i; // Compile error
    printf("%d", *a);
    getchar();
    return 0;
}

Register Note 2:

You can use the register keyword with pointer variables. Below is a valid example:

int main() {
    int i = 10;
    register int *a = &i;
    printf("%d", *a); // Output: 10
    getchar();
    return 0;
}

Resistor Note 3:

Register is a storage class, and C prohibits multiple storage class specifiers for a variable. Therefore, you cannot use register with static.

int main() {
    int i = 10;
    register static int *a = &i; // Error
    printf("%d", *a);
    getchar();
    return 0;
}

Register Note 4:

There’s no limit to the number of register variables in a C program. However, the compiler may choose to allocate some variables to registers and others not.


static keyword

  • static means its take only single or same memory.
  • static is initialized only once and remains into existence till the end of program
  • static assigned 0 (zero) as default value by the compiler.
  • A static local variables retains its value between the function call and the default value is 0.
  • If a global variable is static then its visibility is limited to the same source code.
  • Static variables stored in Heap(Not in Stack memory)
  • The following function will print 1 2 3 if called thrice.
  • Example
    • void f() { static int i; ++i; printf(“%d “,i); }
  • In “static int a[20];”, variable “a” is declared as an integer type and static. When a variable is declared as static, it is automatically initialized to the value ‘0’ (zero).

What is a static function?

  • A function prefixed with the static keyword is called a static function.
  • You would make a function static if it should only be called within the same source code or be visible to other functions in the same file.
  • static has different meanings in in different contexts.
  • When specified on a function declaration, it makes the function local to the file.
  • When specified with a variable inside a function, it allows the vairable to retain its value between calls to the function

storage class specifier

  • typedef – typedef is the storage class specifier.
    • It does not reserve the storage.
    • It is used to alias the existing type. Also used to simplify the complex declaration of the type.
  • reference links

volatile

  • The compiler omits optimization for objects declared as volatile because code outside the current scope can change their values at any time.

Advantages and Disadvantages

Storage ClassAdvantageDisadvantage
autoAutomatically allocated and deallocated within functionsGarbage values if not explicitly initialized
registerFaster access due to storage in CPU registersLimited availability of register space; Compiler-dependent
staticPersistent value across function callsGlobal scope may lead to namespace pollution; May increase memory usage
externAllows sharing of variables across multiple filesGlobal scope may lead to namespace pollution

Interview Questions

What are storage classes in ‘C’ language?

  • automatic class
  • static class

How many storage class specifiers in “C” language?

  • auto,
  • register,
  • static
  • extern

How many variables scopes are there in “C” language?

  • Body.
  • Function.
  • Program.
  • File.

NEXT

C Programming Language

C – Functions

In C programming, functions are essential building blocks for organizing and reusing code.

  • Rule: In C, you cannot define a function inside another function.
  • Rule: But you can call a function inside another function.
  • Rule: Functions cannot return more than one value at a time because, after returning a value, control is passed back to the calling function.
  • Any function, including main(), can call itself recursively.
  • C has two kinds of functions User Defined Functions,  Pr-Defined Libarary Functions.
Read more… →

Google – Blogger

 

How to add “Read More” of your post in main page?


How to add Facebook popup like box blogger widget?

  • Login Blogger account  –>Layout –>Add a Gadget –> HTML/JavaScript gadget -> “Paste the following code”
 <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js' type='text/javascript'></script>  
 <style type="text/css">  
 #fbox-background{display:none;background:rgba(0,0,0,0.8);width:100%;height:100%;position:fixed;top:0;left:0;z-index:99999}#fbox-close{width:100%;height:100%}#fbox-display{background:#eaeaea;border:5px solid #828282;width:540px;height:330px;position:absolute;top:32%;left:37%;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}#fbox-button{float:right;cursor:pointer;position:absolute;right:0;top:0}#fbox-button:before{content:"CLOSE";padding:5px 8px;background:#828282;color:#eaeaea;font-weight:700;font-size:10px;font-family:Tahoma}#fbox-link,#fbox-link a.visited,#fbox-link a,#fbox-link a:hover{color:#aaa;font-size:9px;text-decoration:none;text-align:center;padding:5px}  
 </style>  
 <script type='text/javascript'>  
 //<![CDATA[  
 jQuery.cookie=function(a,b,c){if(arguments.length>1&&"[object Object]"!==String(b)){if(c=jQuery.extend({},c),null!==b&&void 0!==b||(c.expires=-1),"number"==typeof c.expires){var d=c.expires,e=c.expires=new Date;e.setDate(e.getDate()+d)}return b=String(b),document.cookie=[encodeURIComponent(a),"=",c.raw?b:encodeURIComponent(b),c.expires?"; expires="+c.expires.toUTCString():"",c.path?"; path="+c.path:"",c.domain?"; domain="+c.domain:"",c.secure?"; secure":""].join("")}c=b||{};var f,g=c.raw?function(a){return a}:decodeURIComponent;return(f=new RegExp("(?:^|; )"+encodeURIComponent(a)+"=([^;]*)").exec(document.cookie))?g(f[1]):null};  
 //]]>  
 </script>  
 <script type='text/javascript'>  
 jQuery(document).ready(function($){  
 if($.cookie('popup_facebook_box') != 'yes'){  
 $('#fbox-background').delay(1000).fadeIn('medium');  
 $('#fbox-button, #fbox-close').click(function(){  
 $('#fbox-background').stop().fadeOut('medium');  
 });  
 }  
 $.cookie('popup_facebook_box', 'yes', { path: '/', expires: 7 });  
 });  
 </script>  
 <div id='fbox-background'>  
 <div id='fbox-close'>  
 </div>  
 <div id='fbox-display'>  
 <div id='fbox-button'>  
 </div>  
 <iframe allowtransparency='true' frameborder='0' scrolling='no' src='//www.facebook.com/plugins/likebox.php?  
 href=https://www.facebook.com/ArunEworld&width=539&height=355&colorscheme=light&show_faces=true&show_border=false&stream=false&header=false'  
 style='border: none; overflow: hidden; background: #fff; width: 539px; height: 300px;'></iframe>  
 <div id="fbox-link">Powered by <a style="padding-left: 0px;" href="https://www.facebook.com/ArunEworld" rel="nofollow">ArunEworld</a></div>  
 </div>  
 </div>

 

  •  Facebook Popup Like Box Customization
    • The widget will appear 5 seconds after the page finishes loading. if you want to change this delay, change the number 1000 to a greater or lessor number in this post 
      .delay(5000)
    •  By default, the like box only shows up the first time the user visit your page. if you world like the pfacebooj box to popup every time the page loads, then remove this line of ocde  $.cookie(‘popup_facebook_box’, ‘yes’, { path: ‘/’, expires: 7 });
    •  If you want to display only when visit your homepage, go to “Template”->Edit HTML->Serch by (CTRL+F) </body> then paste the facebook popup widget right abovethe body tag make sure to include the conditional tag below <b:if cond=’data:page.type == “index”‘>ADD THE FACEBOOK WIDGET CODE HERE </b:if> –>Save

 

Blogger Code For-matter


How to Disable Copy Paste In Blogger Blog?

Steps

  • Go to Blogger Account >>> Blogger Dashboard

  • After Selecting Layout Tab will Open. Click On”  Add a Gadget “.

  • Now a again a New Window will Open.Here select ” HTML/Java Script

  • Now Copy the Given Below Code and Paste it Here.

 

Code

<!- START disable copy paste -->
<script src='demo-to-prevent-copy-paste-on-blogger_files/googleapis.js'></script>

<script type='text/javascript'>
    if(typeof document.onselectstart!="undefined" )
    {
        document.onselectstart=new Function ("return false" );
    }
    else
    {
        document.onmousedown=new Function ("return false" );document.onmouseup=new Function ("return false");
    }
</script>
<!-- End disable copy paste -->

 

Reference

 



FQA

  • how to backup blogspot Automatically?
    • Answer will add soon.

 

C Programming Language

C – Compilers

Compilers are playing important role in software development. compilers are converting human-written code into another runnable software in machines.

CompilersDescriptions
Microsoft – Visual StudioVisual Studio is a free source from Microsoft. You can download and install from the visual studio side.

Supports in windows (offline).
Bortland   –  Turbo C, Turbo C++Supports in windows(offline).

You can download the portable version from this link
Dev C++Dev C++ compiler not support void in main function, main function should be mention int type and return type.

Supports in windows(offline).

you can download the portable version by here

you can do the debug of program refer the video
Gcc compilerSupport in Linux(offline).
C Compliers
Read more… →

Embedded Protocol ZigBee

ZigBee is a low-power, low-data-rate wireless communication embedded protocol based on the IEEE 802.15.4 standard. It is commonly used for creating networks of low-power devices in applications such as home automation, industrial control, and smart energy management.

ZigBee is designed to be simple, cost-effective, and reliable, making it ideal for use in battery-powered devices that need to communicate over short distances. It uses a mesh networking topology, allowing devices to communicate with each other directly or through intermediate nodes in the network.

ZigBee supports a range of applications including lighting control, HVAC control, security systems, and remote monitoring. It provides robust security features to ensure the confidentiality and integrity of data exchanged between devices.

Overall, ZigBee is a popular choice for building wireless sensor networks and other low-power, low-data-rate communication systems.

Advantages of ZigBee:

  1. Low power consumption: ZigBee is designed for low-power devices, making it ideal for battery-powered devices that need to operate for long periods without frequent battery replacements.
  2. Low data rate: ZigBee is optimized for applications that do not require high data transfer speeds, making it suitable for applications such as home automation and industrial control.
  3. Robust mesh networking: ZigBee’s mesh networking topology allows for reliable communication even in challenging environments with obstacles and interference.
  4. Cost-effective: ZigBee is a cost-effective solution for building wireless sensor networks and other low-power communication systems.
  5. Security features: ZigBee provides strong security features to protect data communication between devices, ensuring confidentiality and integrity.

Disadvantages of ZigBee:

  1. Limited data rate: ZigBee’s low data rate may not be suitable for applications that require high-speed data transfer, such as video streaming or large file downloads.
  2. Limited range: ZigBee’s range is typically limited to a few tens of meters, which may not be sufficient for applications that require long-range communication.
  3. Interference: ZigBee operates in the crowded 2.4 GHz frequency band, which can be prone to interference from other wireless devices operating in the same frequency range.
  4. Scalability: While ZigBee supports scalable networks, managing large networks with hundreds or thousands of devices can be challenging.
  5. Compatibility: ZigBee devices may not be compatible with devices using other wireless communication protocols, limiting interoperability in mixed-device environments.

Zigbee Protocol Analyzwer

Google – YouTube

YouTube is a popular video viewer tool. Its stored lot of videos from the user.

  • You can see your all Google Brand Accounts list using this link here.
  • In case if you struggled of this product you can contact the YouTube Help Center.
  • You can see the Advance Settings of your account using this link here.
  • You can see your all YouTube Channels  using this link here.

YouTube Subscribe button embed in website

Options
Channel Name or ID:
Layout:
Theme:
Subscriber count:

 

 

Layout: default, Theme: Default , Subscriber count: Default

Layout: full, Theme: Default , Subscriber count: Default

Layout: full, Theme: Dark, Subscriber count: Default


YouTube Video thumbnail image and video size

  1. YouTube Videos custom thumbnail image
    • Have a resolution of 1280×720 (with minimum width of 640 pixels).
    • Be uploaded in image formats such as .JPG, .GIF, .BMP, or .PNG.
    • Remain under the 2MB limit.
    • Try to use a 16:9 aspect ratio as it’s the most used in YouTube players and previews.
  2. Videos Size
    • Resolution    Name
      • 3840×2160    2160p
      • 2560×1440    1440p
      • 1920×1080    1080p
      • 1280×720    720p
      • 854×480        480p
      • 640×360        360p
      • 426×240        240p

FAQ

  • How to create a new YouTube channel?
  • How to Claim URL of my Channel?

 

 

ESP8266 NodeMCU Module – HTTP


This tutorial “ESP8266 NodeMCU HTTP Module” will discuss. The ESP8266 NodeMCU module is a popular microcontroller board based on the ESP8266 Wi-Fi chip. It’s widely used for IoT (Internet of Things) projects due to its low cost, built-in Wi-Fi capabilities, and ease of programming. One common use case of the ESP8266 NodeMCU is handling HTTP requests and responses, allowing it to communicate with web servers, APIs, and other devices over the internet.

Read more: ESP8266 NodeMCU Module – HTTP

HTTP (Hypertext Transfer Protocol) is the foundation of data communication on the World Wide Web. With the ESP8266 NodeMCU, you can leverage HTTP to send and receive data, control devices remotely, and interact with cloud services.

In this example, we’ll explore how to configure the ESP8266 NodeMCU to connect to a Wi-Fi network, monitor Wi-Fi events, and perform HTTP operations such as sending POST requests to a web server. Additionally, we’ll set up a GPIO pin to trigger an action when its state changes, showcasing how the ESP8266 NodeMCU can interact with external devices.

ESP8266 NodeMCU HTTP Module functions

http.delete()Executes a HTTP DELETE request.
http.get()Executes a HTTP GET request.
http.post()Executes a HTTP POST request.
http.put()Executes a HTTP PUT request.
http.request()Execute a custom HTTP request for any HTTP method.

http.delete()

  • Executes a HTTP DELETE request. Note that concurrent requests are not supported.
  • Syntax : http.delete(url, headers, body, callback
  • Parameters
    • url The URL to fetch, including the http:// or https:// prefix
    • headers Optional additional headers to append, including \r\n; may be nil
    • body The body to post; must already be encoded in the appropriate format, but may be empty
    • callback The callback function to be invoked when the response has been received or an error occurred; it is invoked with the arguments status_code, body and headers. In case of an error status_code is set to -1.
  • Returns : nil

HTTP Get Example

  • Read your thing-speak text file from the below code for ESP8266 NodeMCU Module HTTP.

Code

station_cfg={}
station_cfg.ssid="ArunEworld"     -- Enter SSID here
station_cfg.pwd="8300026060INDIA"  --Enter password here
server_link = "http://iot.aruneworld.com/httt-get.txt" -- set server URL

wifi.setmode(wifi.STATION)  -- set wi-fi mode to station
wifi.sta.config(station_cfg)-- set ssid&pwd to config
wifi.sta.connect()          -- connect to router

--Wifi Eent Monitoring file
wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
 print("\n\tSTA - CONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
 T.BSSID.."\n\tChannel: "..T.channel)
 
 end)

 wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
 print("\n\tSTA - DISCONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
 T.BSSID.."\n\treason: "..T.reason)
	tmr.stop(0)
 end)

 wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
 print("\n\tSTA - GOT IP".."\n\tStation IP: "..T.IP.."\n\tSubnet mask: "..
 T.netmask.."\n\tGateway IP: "..T.gateway)
 tmr.start(0)
 end)

 
function GetFromArunEworld()-- callback function for get data
http.get(server_link,'',
function(code, data)
    if (code < 0) then
     print("HTTP request failed")
    else
     print(code, data)
    end
  end)
end

-- call get function after each 5 second
tmr.alarm(1, 5000, 1, function() GetFromArunEworld() end)

Code Explanation

This code sets up a NodeMCU or similar device to connect to a Wi-Fi network, monitor Wi-Fi events, and periodically fetch data from a server over HTTP. It’s a good example of IoT device interaction with both Wi-Fi and web servers.

station_cfg={}
station_cfg.ssid="ArunEworld"     -- Enter SSID here
station_cfg.pwd="8300026060INDIA"  -- Enter password here
  • Here, a Lua table named station_cfg is defined, which contains the SSID and password for connecting to the Wi-Fi network.
server_link = "http://iot.aruneworld.com/httt-get.txt" -- set server URL
  • This line sets the URL of the server from which data will be fetched. It seems to be a text file containing data.
wifi.setmode(wifi.STATION)  -- set Wi-Fi mode to station
wifi.sta.config(station_cfg)-- set SSID and password to config
wifi.sta.connect()          -- connect to router
  • These lines configure the Wi-Fi module to operate in station mode, set the Wi-Fi station configuration to the values provided in station_cfg, and then initiate a connection to the specified router.
-- Wi-Fi Event Monitoring
wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
    print("\n\tSTA - CONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
    T.BSSID.."\n\tChannel: "..T.channel)
end)

wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
    print("\n\tSTA - DISCONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: "..
    T.BSSID.."\n\treason: "..T.reason)
    tmr.stop(0) -- Stop timer upon disconnection
end)

wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
    print("\n\tSTA - GOT IP".."\n\tStation IP: "..T.IP.."\n\tSubnet mask: "..
    T.netmask.."\n\tGateway IP: "..T.gateway)
    tmr.start(0) -- Start timer upon obtaining IP address
end)
  • These functions register event handlers for various Wi-Fi events like connection, disconnection, and obtaining an IP address. When any of these events occur, the code prints a message containing relevant information. Additionally, it starts or stops the timer depending on the event.
function GetFromArunEworld()-- callback function for fetching data
    http.get(server_link,'',
    function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
            print(code, data)
        end
    end)
end
  • This function GetFromArunEworld() is defined as a callback function to fetch data from the specified server. It makes an HTTP GET request to server_link and prints the response code and data.
-- call the fetch function every 5 seconds
tmr.alarm(1, 5000, 1, function() GetFromArunEworld() end)
  • Finally, a timer is set up to call the GetFromArunEworld() function every 5 seconds to fetch data from the server.

HTTP Post Example

Post Data to thinkspeak website

Code

station_cfg={}
station_cfg.ssid="ssid" -- Enter SSID here
station_cfg.pwd="password" -- Enter password here
server = "http://api.thingspeak.com/update" -- set server URL
count = 0 -- set initial count to 0

wifi.setmode(wifi.STATION) -- set wi-fi mode to station
wifi.sta.config(station_cfg) -- set ssid&pwd to config
wifi.sta.connect() -- connect to router

function PostToThingSpeak()
    -- callback function for post data
    local string = "api_key=1EYZIS5OCRJSKZHG&field1="..count
    http.post(server, '', string, function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
            print(code, data)
            count = count + 1 -- increment count after each successful post
        end
    end)
end

-- call post function after each 20 seconds for ThingSpeak server update
tmr.alarm(1, 20000, tmr.ALARM_AUTO, function() PostToThingSpeak() end)

Code Explanation

This script connects to the specified Wi-Fi network, sends data to a ThingSpeak channel at regular intervals, and increments the count each time data is successfully posted.

station_cfg={}
station_cfg.ssid="ssid" -- Enter SSID here
station_cfg.pwd="password" -- Enter password here
  • These lines define a Lua table station_cfg with keys ssid and pwd, representing the SSID and password of the Wi-Fi network you want to connect to.
server = "http://api.thingspeak.com/update" -- set server URL
  • This line sets the URL of the ThingSpeak server where you’ll send the data.
count = 0 -- set initial count to 0
  • Initializes a variable count to keep track of the number of data posts.
wifi.setmode(wifi.STATION) -- set Wi-Fi mode to station
wifi.sta.config(station_cfg) -- set ssid&pwd to config
wifi.sta.connect() -- connect to router
  • These lines configure the Wi-Fi module to work in station mode, set the Wi-Fi station configuration, and connect to the router using the provided SSID and password.
function PostToThingSpeak()
    -- callback function for posting data
    local string = "api_key=1EYZIS5OCRJSKZHG&field1="..count
    http.post(server, '', string, function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
            print(code, data)
            count = count + 1 -- increment count after each successful post
        end
    end)
end
  • Defines a function PostToThingSpeak() to send data to ThingSpeak.
  • Constructs a string containing the API key and the current value of the count variable.
  • Sends an HTTP POST request to the ThingSpeak server with the constructed string.
  • Prints the response code and data received.
  • Increments the count after each successful post.
-- call post function every 20 seconds for ThingSpeak server update
tmr.alarm(1, 20000, tmr.ALARM_AUTO, function() PostToThingSpeak() end)
  • Sets up a timer to call the PostToThingSpeak() function every 20 seconds automatically.

Post Data to Aruneworld website

code

station_cfg = {}
station_cfg.ssid = "ArunEworld"
station_cfg.pwd = "8300026060BLR"
wifi.sta.config(station_cfg)
wifi.sta.connect(1)

wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
    print("\n\tSTA - CONNECTED" ..
          "\n\tSSID: " .. T.SSID ..
          "\n\tBSSID: " .. T.BSSID ..
          "\n\tChannel: " .. T.channel)
end)

wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
    print("\n\tSTA - DISCONNECTED" ..
          "\n\tSSID: " .. T.SSID ..
          "\n\tBSSID: " .. T.BSSID ..
          "\n\treason: " .. T.reason)
end)

wifi.eventmon.register(wifi.eventmon.STA_AUTHMODE_CHANGE, function(T)
    print("\n\tSTA - AUTHMODE CHANGE" ..
          "\n\told_auth_mode: " .. T.old_auth_mode ..
          "\n\tnew_auth_mode: " .. T.new_auth_mode)
end)

wifi.eventmon.register(wifi.eventmon.STA_GOT_IP, function(T)
    print("\n\tSTA - GOT IP" ..
          "\n\tStation IP: " .. T.IP ..
          "\n\tSubnet mask: " .. T.netmask ..
          "\n\tGateway IP: " .. T.gateway)
end)

wifi.eventmon.register(wifi.eventmon.STA_DHCP_TIMEOUT, function()
    print("\n\tSTA - DHCP TIMEOUT")
end)

wifi.eventmon.register(wifi.eventmon.AP_STACONNECTED, function(T)
    print("\n\tAP - STATION CONNECTED" ..
          "\n\tMAC: " .. T.MAC ..
          "\n\tAID: " .. T.AID)
end)

wifi.eventmon.register(wifi.eventmon.AP_STADISCONNECTED, function(T)
    print("\n\tAP - STATION DISCONNECTED" ..
          "\n\tMAC: " .. T.MAC ..
          "\n\tAID: " .. T.AID)
end)

wifi.eventmon.register(wifi.eventmon.AP_PROBEREQRECVED, function(T)
    print("\n\tAP - PROBE REQUEST RECEIVED" ..
          "\n\tMAC: " .. T.MAC ..
          "\n\tRSSI: " .. T.RSSI)
end)

wifi.eventmon.register(wifi.eventmon.WIFI_MODE_CHANGED, function(T)
    print("\n\tSTA - WIFI MODE CHANGED" ..
          "\n\told_mode: " .. T.old_mode ..
          "\n\tnew_mode: " .. T.new_mode)
end)

local function D_Send()
    tmr.wdclr()
    http.post('https://aruneworld.com.com/post', 'Content-Type: text/plain\r\n', 'Hum=23&temp=24', function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
            print(code, data)
        end
    end)
end

local function pin1cb(level)
    D_Send()
end

gpio.trig(3, "down", pin1cb) -- GPIO 0 pin

Code Explanation

This code sets up a NodeMCU or similar device to connect to a Wi-Fi network, monitor various Wi-Fi events, and perform an action when a specific GPIO pin state changes. Let’s break it down:

Overall, this script configures the Wi-Fi connection, sets up event handlers for various Wi-Fi events, defines a function to send data via HTTP POST, and sets up a GPIO pin to trigger an action when its state changes.

  1. Wi-Fi Configuration and Connection Setup:
   station_cfg={}
   station_cfg.ssid= "ArunEworld"
   station_cfg.pwd= "8300026060BLR"
   wifi.sta.config(station_cfg)
   wifi.sta.connect(1)
  • This section sets up the Wi-Fi station configuration with the SSID and password provided in station_cfg and then connects to the Wi-Fi network.
  1. Wi-Fi Event Monitoring:
   wifi.eventmon.register(wifi.eventmon.STA_CONNECTED, function(T)
       print("\n\tSTA - CONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: ".. T.BSSID.."\n\tChannel: "..T.channel)
   end)
  • It registers a callback function to handle the event when the device connects to a Wi-Fi network.
   wifi.eventmon.register(wifi.eventmon.STA_DISCONNECTED, function(T)
       print("\n\tSTA - DISCONNECTED".."\n\tSSID: "..T.SSID.."\n\tBSSID: ".. T.BSSID.."\n\treason: "..T.reason)
   end)
  • It registers a callback function to handle the event when the device disconnects from the Wi-Fi network. (Similar registration for other Wi-Fi events like authentication mode change, obtaining IP address, DHCP timeout, station/AP connection/disconnection, etc.)
  1. HTTP Post Functionality:
   local function D_Send()
       tmr.wdclr()
       http.post('https://aruneworld.com.com/post', 'Content-Type: text/plain\r\n', 'Hum=23&temp=24', function(code, data)
           if (code < 0) then
               print("HTTP request failed")
           else
               print(code, data)
           end
       end)
   end
  • Defines a function D_Send() to perform an HTTP POST request to a server when called. In this case, it posts humidity and temperature data.
  1. GPIO Pin Interrupt Setup:
   local function pin1cb(level)
       D_Send()
   end
   gpio.trig(3,"down", pin1cb) --gpio-0 pin
  • Defines a callback function pin1cb to be triggered when the GPIO pin 3 (GPIO 0) goes from high to low.
  • Registers this callback function with gpio.trig() to handle the GPIO interrupt.

NEXT

NodeMCU Get Start
NodeMCU Build Firmware
NodeMCU Flash Firmware
NodeMCU IDE
ESP8266 NodeMCU Modules
NodeMCU Module–Firmware Info
NodeMCU Module – GPIO
NodeMCU Module – Node
NodeMCU Module – WiFi
NodeMCU Module – Timer
NodeMCU Module – I2C
NodeMCU Module – File
NodeMCU Module – NET
NodeMCU Module – HTTP
NodeMCU Module – MQTT
ESP8266 NodeMCU Interface
NodeMCU Interface LED
NodeMCU Interface Button
NodeMCU Interface 7 Seg
NodeMCU Interface LCD
NodeMCU Interface ADC
NodeMCU Interface DHT11
NodeMCU Interface MCP23008
NodeMCU Interface MCP23017
NodeMCU Interface ADXL345
NodeMCU Interface DS18B20
ESP8266 NodeMCU Tutorials
NodeMCU Tutorials Google Time
NodeMCU Tutorials WebServer
ESP8266 NodeMCU Projects
Imperial March Ringtone Play
WiFi Router Status Indicator
ESP8266 NodeMCU Project – Home Automation
Others
NodeMCU All Post
Sitemap

ESP8266 Arduino-core Tutorial – HTTP Post Data to Web Page

These various applications for sending data, especially in IoT projects. Below are some scenarios and use cases where sending data using an HTTP POST request can be beneficial. In this article will discuss about “ESP8266 Arduino-core Tutorial – HTTP Post Data to Web Page”.

Required

  • ESP8266 Any Module (Used NodeMCU Dev Kit Version 1.0)
  • Arduino IDE with ESP8266 Platform
  • Web Sever (Shared, Linux, Windows or Own Server like with any hosting providers: Amazon, GoDaddy, GlobeHost, BlueHost, HostingRaja and etc)
  • Cpanel Login Access and update index file contend

Cpanel index.php  code for web Server

Note I tested its code is working well.

<?php
    $age= $name = $TimeStamp = "";
    $Hum= $Temp =  "";
    $timezone = new DateTimeZone("Asia/Kolkata" );
        $date = new DateTime();
        $date->setTimezone($timezone );
        echo  $date->format('Ymd-H:i:s');
        $TimeStamp = $date;
        
    
     if( $_REQUEST["Hum"] ||  $_REQUEST["Temp"] ) 
    {
        echo " The Humidity is: ". $_REQUEST['Hum']. "%<br />";
        echo " The Temperature is: ". $_REQUEST['Temp']. " Celcius<br />";
        
        $Hum= $_REQUEST["Hum"];
        $Temp = $_REQUEST["Temp"];
        
        $myfile = fopen("arun.txt", "a") or die("Unable to open file!");
        fwrite($myfile, "TimeStamp : ".$date->format('Ymd-H:i:s')."\t | Hum : ".$Hum."\t | Temp : ".$Temp. " |\n");
        fclose($myfile);
        
    }
    
    if( $_GET["name"] || $_GET["age"] ) {
        echo "Welcome ". $_GET['name']. "<br />";
        echo "You are ". $_GET['age']. " years old.". "<br />";
        
        
        
        $age= $_GET["age"];
        $name = $_GET["name"];
        
        $myfile = fopen("arun.txt", "a") or die("Unable to open file!");
        fwrite($myfile, "TimeStamp : ".$date->format('Ymd-H:i:s')."\t | Name : ".$name."\t | Age : ".$age. " |\n");
        fclose($myfile);
    
        
        exit();
    }
    
    $myfile = fopen("arun.txt", "r") or die("Unable to open file!");
        echo "<table border='1' align ='center' >";
        while(!feof($myfile)) {
          echo "<tr><td border='1' align ='center' >";
          echo fgets($myfile) . "<br>";
          echo "</td></tr>";
        }
        echo "</table>";
        fclose($myfile);
?>

ESP8266 Arduino-Core Code for HTTP Post Data

//www.Aruneworld.com/embedded/esp8266/esp8266-arduino-core/

const char* hostGet = "iot.aruneworld.com/ESP8266/NodeMCU/HTTP-Post/"; 
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ESP8266WebServer.h>

const char* ssid="ArunEworld";
const char*password="8300026060INDIA";
WiFiClient client;

void postData() {

   WiFiClient clientGet;
   const int httpGetPort = 80;

   //the path and file to send the data to:
   String urlGet = "/index.php";

 
  // We now create and add parameters:
  String src = "12345";
  String typ = "6789";
  String nam = "temp";
  String vint = "92"; 

  urlGet += "?Hum=" + src + "&Temp=" + typ ;
   
      Serial.print(">>> Connecting to host: ");
      Serial.println(hostGet);
      
       if (!clientGet.connect(hostGet, httpGetPort)) {
        Serial.print("Connection failed: ");
        Serial.print(hostGet);
      } else {
          clientGet.println("GET " + urlGet + " HTTP/1.1");
          clientGet.print("Host: ");
          clientGet.println(hostGet);
          clientGet.println("User-Agent: ESP8266/1.0");
          clientGet.println("Connection: close\r\n\r\n");
          
          unsigned long timeoutP = millis();
          while (clientGet.available() == 0) {
            
            if (millis() - timeoutP > 10000) {
              Serial.print(">>> Client Timeout: ");
              Serial.println(hostGet);
              clientGet.stop();
              return;
            }
          }

          //just checks the 1st line of the server response. Could be expanded if needed.
          while(clientGet.available()){
            String retLine = clientGet.readStringUntil('\r');
            Serial.println(retLine);
            break; 
          }

      } //end client connection if else
                        
      Serial.print(">>> Closing host: ");
      Serial.println(hostGet);
          
      clientGet.stop();

}

void setup() {
    Serial.begin(115200); // Starts the serial communication
  WiFi.begin(ssid, password); //begin WiFi connection
  Serial.println("");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
    Serial.print(".");
  }
  Serial.println("");
  Serial.print("Connected to ");
  Serial.println("ArunEworld");
  Serial.print("IP address: ");
  Serial.println(WiFi.localIP());
}

void loop() {

  postData();

  delay(30000);

}

Make sure to replace the placeholders:

  • your-ssid and your-password with your WiFi credentials.
  • your-server-address with the address of your server.
  • /your-api-endpoint with the specific endpoint on your server that handles the incoming POST requests.

Applications and Uses

Security aspects & Encryption

When implementing HTTP POST requests in your application, consider security aspects such as using HTTPS for encrypted communication and implementing proper authentication mechanisms to protect sensitive data. Always follow best practices for secure communication, especially when transmitting data over the internet.

FAQ

if you have the following Questions and most of the repeated and same-meaning questions, then the Above article should help you

  • How send data to web page using ESP8266?
  • How to HTTP Post Data to Web Page using ESP8266 via Arduino-core Tutorial –
  • ESP8266 send data to website?
  • Send ESP8266 Data to Your Webpage – no AT Commands
  • Arduino-Esp8266-Post-Data-to-Website
  • ESP8266: HTTP POST Requests
  • Posting and getting data from ESP on Apache WebServer
  • How to Send Data from Arduino to Webpage using WiFi?
  • How to send data to a server using ESP8266 with Arduino?

NEXT

Arduino-Core IDE Setup
ESP8266 Arduino Core Interface
ESP8266 Interface LED
ESP8266 Interface Button
ESP8266 Interface ADC
ESP8266 Arduno Core Projects
ESP8266 Project WebServer
HTTP Post Data to Web Page
Arduino Based Platforms
Cayenne MyDevice Get Start
Others
ESP8266 Arduino-Core Sitemap
ESP8266 Arduino-Core All Post

ESP8266 NodeMCU Module – GPIO

 

ESP8266 NodeMCU Devkit GPIO Pin Map

 

 

IO index ESP8266 pin IO index ESP8266 pin
0 [*] GPIO16 7 GPIO13
1 GPIO5 8 GPIO15
2 GPIO4 9 GPIO3
3 GPIO0 10 GPIO1
4 GPIO2 11 GPIO9
5 GPIO14 12 GPIO10
6 GPIO12

 

 


 ESP8266 NodeMCU Module GPIO Functions

gpio.mode() Initialize pin to GPIO mode, set the pin in/out direction, and optional internal weak pull-up.
gpio.read() Read digital GPIO pin value.
gpio.serout() Serialize output based on a sequence of delay-times in µs.
gpio.trig() Establish or clear a callback function to run on interrupt for a pin.
gpio.write() Set digital GPIO pin value.
gpio.pulse This covers a set of APIs that allow generation of pulse trains with accurate timing on
multiple pins.
gpio.pulse.build This builds the gpio.
gpio.pulse:start This starts the output operations.
gpio.pulse:getstate This returns the current state.
gpio.pulse:stop This stops the output operation at some future time.
gpio.pulse:cancel This stops the output operation immediately.
gpio.pulse:adjust This adds (or subtracts) time that will get used in the min / max delay case.
gpio.pulse:update This can change the contents of a particular step in the output program.

 

Note : [*] D0(GPIO16) can only be used as gpio read/write. No support for open-drain/interrupt/pwm/i2c/ow.


 

Pr-Request

 

GPIO pin set as input

  • if you have questions like How set GPIO pin as input in ESP8266? then refer the below contents

 

Required

  • ESP8266 Any module or NodeMCU Development Kit(Any Version)
  • ESPlorer
  • Wires (Optional)

Note : if your using ESP8266 module only you need to know basic connection diagram of ESP8266

 

Code

 

-- set pin index 1 to GPIO mode, and set the pin to high.
pin=3 --gpio-0
gpio.mode(pin, gpio.INPUT)
while true do
print("GPIO Read PIN Status : "..gpio.read(pin))
end

 


GPIO pin set as output

  • Set GPIO pin as output using gpio.mode()  function.
  • Example : gpio.mode(pin, gpio.INPUT)

 

Code

pin = 3
gpio.mode(pin, gpio.OUTPUT)
gpio.write(pin,HIGH)
--gpio.write(pin, LOW)

 

Result

 

 


GPIO pin status monitor

  • GPIO pin monitor status is very useful, because if you wanna monitor the pin status based on do the some process can easily.
  • Example : continuously monitor the gpio input button pin and based on button pin low/high level trun on/off the led.

 

Required

  • ESP8266 Any module or NodeMCU Development Kit(Any Version)
  • ESPlorer
  • Wires (Optional)

Note : if your using ESP8266 module only you need to know basic connection diagram of ESP8266.

 

Basic connection Diagram

Note : this below diagram for flash nodeMCU Firmware to ESP8266. We use the same circuit. But GPIO-0 Should be High or float Mode

 

Code

--www.aruneworld.com/embedded/esp8266/esp8266-nodecmu

button_pin=3 --GPIO-0
gpio.mode(button_pin, gpio.INPUT)

while true do
    print("GPIO Read PIN Status : "..gpio.read(button_pin))
    tmr.delay(1000000)
end

 

 


 

ESP8266 NodeMCU – Flash Firmware

NodeMCU Flasher tool is flashing the NodeMCU Firmware to ESP8266 Easily. This tool is developed by NodeMCU. Flashing firmware to an ESP8266-based NodeMCU board involves updating the firmware on the microcontroller to enable it to execute the desired code. Here’s a step-by-step guide on how to flash firmware to an ESP8266 NodeMCU using the ESP8266Flasher tool. Please note that you’ll need a USB-to-Serial converter or USB-based development board for this process.

Read more… →

ESP8266 NodeMCU – Build Firmware

The ESP8266 NodeMCU is a versatile and affordable microcontroller board that has gained immense popularity in the maker community due to its built-in Wi-Fi capabilities and low cost. One of the key advantages of the NodeMCU is its flexibility, allowing developers to customize and build firmware tailored to their specific project requirements.

Read more: ESP8266 NodeMCU – Build Firmware

In this guide, we will walk through the process of building firmware for the ESP8266 NodeMCU. Whether you’re a beginner looking to get started with microcontroller programming or an experienced developer aiming to create advanced IoT applications, this tutorial will provide you with the necessary steps to compile and upload firmware to your NodeMCU board.

We’ll cover essential topics such as setting up the development environment, configuring the firmware, compiling the code, and uploading it to the NodeMCU. By the end of this tutorial, you’ll have the skills and knowledge to harness the full potential of your ESP8266 NodeMCU board by creating custom firmware tailored to your project’s needs. Let’s dive in!

What is firmware?

  • Firmware is a piece of code for small type of device. The firmware contains binaries, that can do all the works and process.

If you have questions like the following, you can learn all of this question’s solutions here.

  1. What is NodeMCU Firmware?
  2. What is the format of NodeMCU Firmware?
  3. What contains the NodeMCU Fimware?
  4. Build Firmware
    1. How to build the NodeMCU Firmware for ESP8266?
    2. How to compile the NodeMCU Firmware for ESP8266?
    3. How to build the NodeMCU firmware from source?
    4. How Build NodeMCU firmware for ESP8266 in Linux Machine?
    5. How Build NodeMCU firmware for ESP8266 using web based Cloud?
    6. how to build NodeMCU firmware on your own?
  5. What are the ESP8266 modules are support this NodeMCU Firmware?
  6. Which ESP8266 modules is best for NodeMCU Firmware?

NodeMCU Firmware

  • NodeMCU firmware is contains many lua modules.
  • Lua modules are contains many lua library files and calling functions.
  • You can select based on your requirement in custom firmware build page.

In Linux


Web-based Cloud Build Custom NodeMCU Firmware

Beginner Recommended Method*

Step-1: Go to this site https://nodemcu-build.com/

Step-2: Two times enter your e-mail address (You will get a status about building the firmware)

Step 3: Select branch to build from (Recommended choose master always)

Step-4: Select modules to include( More than 40+ NodeMCU Lua Modules are available, Select depends upon your application development)

Step-5: Miscellaneous options (Recommended for beginner : Don’t select any option )

Step-6: Click the Start Your Build button

Step-7: Open your email ID (What you gave before)

Step 8: you will get an email about firmware building started and finished notification. In the finished Notification mail, you can download float and integer type NodeMCU .bin  firmware file.


NEXT

NodeMCU Get Start
NodeMCU Build Firmware
NodeMCU Flash Firmware
NodeMCU IDE
ESP8266 NodeMCU Modules
NodeMCU Module–Firmware Info
NodeMCU Module – GPIO
NodeMCU Module – Node
NodeMCU Module – WiFi
NodeMCU Module – Timer
NodeMCU Module – I2C
NodeMCU Module – File
NodeMCU Module – NET
NodeMCU Module – HTTP
NodeMCU Module – MQTT
ESP8266 NodeMCU Interface
NodeMCU Interface LED
NodeMCU Interface Button
NodeMCU Interface 7 Seg
NodeMCU Interface LCD
NodeMCU Interface ADC
NodeMCU Interface DHT11
NodeMCU Interface MCP23008
NodeMCU Interface MCP23017
NodeMCU Interface ADXL345
NodeMCU Interface DS18B20
ESP8266 NodeMCU Tutorials
NodeMCU Tutorials Google Time
NodeMCU Tutorials WebServer
ESP8266 NodeMCU Projects
Imperial March Ringtone Play
WiFi Router Status Indicator
ESP8266 NodeMCU Project – Home Automation
Others
NodeMCU All Post
Sitemap

ESP8266 NodeMCU – How to know firmware information

If you have many custom NodeMCU firmware, but the firmware name does not contain the details of info about what the NodeMCU module libraries are present. This article explains ESP8266 NodeMCU – How to know firmware information?, if ESPlorer works fine means ESP8266 returns the firmware details, some times ESPlorer IDE does not auto-detect the firmware details. so you should note that your custom NodeMCU firmware details yourself. This post will help to firmware details list easily by using small code.

The NodeMCU firmware is designed to work with the Lua scripting language. Lua is a lightweight and powerful scripting language that is well-suited for embedded systems.

The firmware is often used in conjunction with the NodeMCU development kit, which includes the ESP8266 WiFi module and a USB-to-Serial converter. The kit simplifies the development process and makes it easy to upload Lua scripts to the ESP8266

Read more… →

ESP8266 NodeMCU – IDE

Three Different IDE’s are available from NodeMCU ESP8266 Platform

  • ESPlorer
  • Lua Loader
  • ESP8266 Web File Manager
  • ESP-IDF

This ESP8266 NodeMCU IDE tutorial Only discussed ESPlorer, You can use this ESPlorer tool as a UART Terminal Application. You can send and receive the data in terminal windows like Putty, DockLight

Read more… →

ESP32 Get Start


let Get Start with ESP32,

ESP32 Features

  • The ESP32 WiFi and Bluetooth chip is the generation of Espressif products.
  • It has a dual-core 32-bit MCU, which integrates WiFi HT40 and Bluetooth/BLE 4.2 technology inside.
  • It is equipped with a high-performance dual-core Tensilica LX6 MCU.
  • One core handles high-speed connection and the other for standalone application development.
  • The dual-core MCU has a 240 MHz frequency and a computing power of 600 DMIPS.
  • In addition, it supports Wi-Fi HT40, Classic Bluetooth/BLE 4.2, and more GPIO resources.
  •  ESP32 chip integrates a wealth of hardware peripherals, including Capacitive touch sensors, Hall sensors, low noise sensor amplifiers, SD card interfaces, Ethernet interfaces,  High-speed SDIO / SPI, UART,  I2S, and I2C, etc. Lets ESP32 get the Start
Read more… →

Arduino – Getting Started

Arduino is an electronic prototyping platform. It is an Open-source and users to create interactive electronic objects. Arduino is an open-source hardware and software company, project and user community that designs and manufactures single-board microcontrollers and microcontroller kits for building digital devices. It supports various CPUs like Atmel AVR (8-bit), ARM Cortex-M0+ (32-bit), ARM Cortex-M3 (32-bit), and Intel Quark (x86) (32-bit).

Read more… →