Posted on

ESP8266 MQTT broker BONDAR.

Create an account

  • Create an account in here
  • Activate your iotcentral account

 

Download Bin FIle

 

Flash the Bondar Firmware

  • your ESP8266 starting from address 0x0. (Use esptool.py or ESP Flash Download Tool)
  • For Linus
    • sudo esptool.py -p /dev/ttyUSB0 --baud 9600 write_flash -fs 32m-c1 -fm dio -ff 40m 0x00000 bondar.bin

 

ESP8266 Configuration

  • ESP8266 will start as Access Point mode. and named as Bondar_XXXXXXXXX  . (Ex refer Below image : Bondar_2e3ae80cb19a ) and should use default password 12345678

  • Now connect that AP Network (Bondar_2e3ae80cb19a ) with your laptop or mobile.
  • Go to 192.168.4.1 in your browser and you will get a configuration page. Then enter your wifi Credential and your he user and password used on IoTCentral.eu

  • Reset the ESP8266 by Click button and also unplug and re-plug the power cable (I recommend you to unplug and then plug the power cable).
  • After Rest you can see when did soft web browser reset button

IoTCentral.eu Account Details

  • Login to your home page on IoTCentral.eu
  • You will see your allocated topic
  • Use allocated_topic/your_topics to connect to iotcentral.eu:1883 and /allocated_topic/your_topic to connect from your Wi-Fi network.

Note :   Always use your email address and the password used on IoTCentral.eu to publish and subscribe. In this way your data is protected and no one will get access to your data since the topic is secret and you are using your username and password to publish and subscribe to the cloud.


Important :  i was tried that on 20171005 but its not work so i need to check again  once if its work i will update everything whenever I’m free. feel free to contcat anything regard this demo @ +919047474939 and Arun9047474939@gmail.com.


 

Posted on

ESP8266 Arduino-Core Tutorial – Web Server

TCP Server Listener

The below Arduino code will also create a server and Access Point in ESP8266 which will continuously listen for a connection.

Code

After uploading this sketch, you can find a new Access Point named “test” from your Laptop or PC.

Result


 

Posted on

ESP8266 NodeMCU Interface – ADXL345

ADXL345 Means

A    – Analog

D    – Device

X

L

3

4

5

 


Example Code

  • Note

     

Next :

Previous :


 

Posted on

ESP8266 NodeMCU Module – NET

Functions

  • Constants Constants to be used in other functions: net.
  • net.createConnection()  – Creates a client.
  • net.createServer()  – Creates a server.
  • net.createUDPSocket()  – Creates an UDP socket.
  • net.multicastJoin()  – Join multicast group.
  • net.multicastLeave()  – Leave multicast group.
  • net.server:close()  – Closes the server.
  • net.server:listen()  – Listen on port from IP address.
  • net.server:getaddr()  – Returns server local address/port.
  • net.socket:close()  – Closes socket.
  • net.socket:connect()  – Connect to a remote server.
  • net.socket:dns()  – Provides DNS resolution for a hostname.
  • net.socket:getpeer()  – Retrieve port and ip of remote peer.
  • net.socket:getaddr()  – Retrieve local port and ip of socket.
  • net.socket:hold()  – Throttle data reception by placing a request to block the TCP receive function.
  • net.socket:on()  – Register callback functions for specific events.
  • net.socket:send()  – Sends data to remote peer.
  • net.socket:ttl()  – Changes or retrieves Time-To-Live value on socket.
  • net.socket:unhold()  – Unblock TCP receiving data by revocation of a preceding hold().
  • net.udpsocket:close()  – Closes UDP socket.
  • net.udpsocket:listen()  – Listen on port from IP address.
  • net.udpsocket:on()  – Register callback functions for specific events.
  • net.udpsocket:send()  – Sends data to specific remote peer.
  • net.udpsocket:dns()  – Provides DNS resolution for a hostname.
  • net.udpsocket:getaddr()  – Retrieve local port and ip of socket.
  • net.udpsocket:ttl()  – Changes or retrieves Time-To-Live value on socket.
  • net.dns.getdnsserver()  – Gets the IP address of the DNS server used to resolve hostnames.
  • net.dns.resolve()  – Resolve a hostname to an IP address.
  • net.dns.setdnsserver()  – Sets the IP of the DNS server used to resolve hostnames.

Examples

 

Example :1 TCP Connection in local

  • Create a TCP connection and communicate with TCP server
  • Set IP of Server


Example :1 TCP Connection to  httpbin.org  site (Online

  • Note :

     

See also :


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Module – Timer

Functions

  • tmr.alarm()  – This is a convenience function combining tmr.
  • tmr.create()  – Creates a dynamic timer object.
  • tmr.delay()  – Busyloops the processor for a specified number of microseconds.
  • tmr.interval()  – Changes a registered timer’s expiry interval.
  • tmr.now() – Returns the system counter, which counts in microseconds.
  • tmr.register()  – Configures a timer and registers the callback function to call on expiry.
  • tmr.resume()  – Resume an individual timer.
  • tmr.resume_all()  – Resume all timers.
  • tmr.softwd()  – Provides a simple software watchdog, which needs to be re-armed or disabled before it expires, or the system will be restarted.
  • tmr.start()  – Starts or restarts a previously configured timer.
  • tmr.state()  – Checks the state of a timer.
  • tmr.stop()  – Stops a running timer, but does not unregister it.
  • tmr.suspend()  –  Suspend an armed timer.
  • tmr.suspend_all()  – Suspend all currently armed timers.
  • tmr.time()  – Returns the system uptime, in seconds.
  • tmr.unregister()  – Stops the timer (if running) and unregisters the associated callback.
  • tmr.wdclr()  – Feed the system watchdog.

 


Timer Example – 1

  • Do the specific file, once ESP8266 got  IP address from Router in station mode using timer alarm\

 


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Module – MQTT

Functions

  • mqtt.Client()  – Creates a MQTT client.
  • mqtt.client:close()  – Closes connection to the broker.
  • mqtt.client:connect() – Connects to the broker specified by the given host, port, and secure options.
  • mqtt.client:lwt( ) – Setup Last Will and Testament (optional).
  • mqtt.client:on()  – Registers a callback function for an event.
  • mqtt.client:publish()  – Publishes a message.
  • mqtt.client:subscribe()  – Subscribes to one or several topics.
  • mqtt.client:unsubscribe()  – Unsubscribes from one or several topics.

 

MQTT Example

  • MQTT subscribe and publish the data to

 


 Read and Write files using MQTT

  • transfer files over mqtt

 


 

MQTT to cloud

 

 

 


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Interface – ADC

ADC

ESP8266 with  ADC Interface

                    This the simple example of ADC with ESP8266. ESP8266 have a in-build ACD unit with 10 bit resolution(10bits-0 to 1024 steps), so no need to add a external ADC converter ICs. if your beginner try this below codes and understand the ADC with ESP8266. I used Ai-thinger’s ESP-12F module(not used NodeMCU Dev Board) wit USB to UART Programmer and NodeMCU firmware. but you can also use any other firmware like Arduino code, Man-goose OS to do this. In this experiment used 3 NodeMCU module libraries are UART (for printing), Timer(for looping), and ADC Module. So your NodeMCU firmware should have this modules. NodeMCU only support only one ACD pin. ADC bin converts voltage from 0 to 3.3 according to 0- 1024 values(10bit resolution)

  •  Required Hardware Components :  2x USB to UART converter programmer, 1x ESP8266 Module(Used Ai-Thinker’s ESP-12F module), 1x Variable resistor  (Pot-10k)
  • Required software tools : ESPlorer IDE Tool,

Note : if you use NodeMCU Dev board don’t need ESP8266 Ai-Thinkers Module and UART Programmer. Because NodeMCU Dev Board have already Programmer.

Circuit Diagram

 

Code

  • EX  : tmr.alarm(0,500,1, function printf(adc.read(0)) end)
  • tmr.alarm function is like a loop for 500microseconds, So every microseconds once that ESP read the ADC value from that pin
  • print function is the same as uart.write(0, adc.read(0).."\n") the value to terminal window
  • adc.read  read the ADC value.

Results

 


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Interface – DHT11

Now a days measuring temperature and humidity is not a difficult job. Because lot of sensor are available in the market. DHT11 and DHT22 are very familiar from others. DHT11 Module is very low cast and available in market long days. In this tutorial you will learn how to  interface DHT11 with ESP8266 module using NodeMCU Firmware

       In this project I’m used  Espressif’s ESP8266X of Ai-thinger’s ESP-12F module with  Aosong DHT11 module using NodeMCU DHT Module in windows system. You can also use any other ESP8266 Modules for this project.

Required

  • Required Hardware Components : ESP8266 Any Module( Used Ai-Thingers ESP-12F) – 1Nos, DHT11 Temperature and Humidity Sensor (eBay) – 1Nos, 4R7 Kilo Ohm Resistor-0.25W (eBay) – 1Nos, ESP8266 Programmer (FDTI chip or use your Arduino board) – 1Nos, Wires
  • Required Software and Tools :  NodeMCU Flasher , Any version of ESPlorer by 4refr0nt (Used v0.2.0-rc5), DHT11 Firmware (Build your custom firmware),
  • Save the code name as “AEW_DHT11.lua” in your system
  • Flash DHT11 NodeMCU Firmware to ESP8266 Module using NodeMCU firmware flasher, Follow below connection details

ESP8266 chip             –                     FDTI Programmer

Vcc                  –                                   3.3v

Gnd                  –                                   Gnd

TX                   –                                     Rx

Rx                    –                                     Tx

GPIO-0             –                                    Low

  • Connect ESP8266 Module GPIO-5 pin to DHT11 Data pin with 4.7K ohm pull-up resistor

ESP8266 chip             –                     FDTI Programmer

Vcc                  –                                   3.3v

Gnd                  –                                   Gnd

TX                   –                                     Rx

Rx                    –                                     Tx

  • Upload the above lua code to esp module using ESPlorer(Use baud rate 115000), follow above connection details
  • Do-file (AEW_DHT11.lua)

Circuit Diagram

 

Code

 

Result

 


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Module – Node

node.chipid()

 

node.flashid()

 

node.flashsize()

 

node.heap()

 

node.info()

node.restart() 

node.restore()

node.setcpufreq()

 

node.random()

node.task.post()

 

 


Next :

Previous :


 

Posted on

ESP8266 NodeMCU Module – File

File Modes

  •    – read mode (the default)
  • w   – write mode
  • a    – append mode
  • r+  – update mode, all previous data is preserved
  • w+– update mode, all previous data is erased
  • a+ – append update mode, previous data is preserved, writing is only allowed at the end of file

File Functions

  • file.open() – Open a file (Create a new file when write mode)
    • file.open(filename, mode)
      • Eg :  file.open("New_File", "r")
      • returns nil if file not open, else file opened returns true
  • file.remove() – Remove a file.
    • file.remove(filename)
      • Eg: file.remove(“New_File”)
      • return nil (nothing)
  • file.rename() – Rename the file.
    • file.rename(oldname, newname)
      • Eg: file.rename(“Old_File”, “New_File”)
      • return true if success, false if error.

Create a New file

  • file.open(“File_Name”, “Mode”) 

File – Hello world Program

 


Next :

Previous :