basic – Blog eTechPath https://blog.etechpath.com Tue, 03 Jan 2023 12:37:36 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.4 https://blog.etechpath.com/wp-content/uploads/2017/08/BrandLogo12-150x150.png basic – Blog eTechPath https://blog.etechpath.com 32 32 How to interface Nextion HMI with Arduino Mega2560 and learn how to use Nextion editor and program tags in Arduino https://blog.etechpath.com/how-to-interface-nextion-hmi-with-arduino-mega2560-and-learn-how-to-use-nextion-editor-and-program-tags-in-arduino/ https://blog.etechpath.com/how-to-interface-nextion-hmi-with-arduino-mega2560-and-learn-how-to-use-nextion-editor-and-program-tags-in-arduino/#comments Wed, 14 Feb 2018 07:00:18 +0000 https://blog.etechpath.com/?p=513 About:
Nextion is a smart hardware HMI (Human Machine Interface) solution published by ITEAD that provides visualization and control interface between human and machine. Nextion HMI comes with simple serial interface and can be easily communicate with Arduino, raspberry pi and other serial Interface compatible hardware’s.
In this post, I will explain how to draw basic HMI screens, setting tag names and reading tags using Arduino.



Circuit Diagram:

NextionHMI_Arduino Mega2560
Circuit Diagram



Nextion HMI Arduino Mega 2560
Prototype




Nextion HMI Designing:
Watch bellow video for complete tutorial on how to operate Nextion HMI graphic designing software.






Arduino Code:
Note: I am using common anode RGB LED for output testing purpose. So I have written this code to operate common anode LED as output. If you want to drive relays instead of LED, you will need to change the code a bit.

/***************************************************************************************************************
*    Nextion HMI Basic Example : Three Buttons
*    Version 1.0
*    Created By: Pranay Sawarkar
*         Email: admin@blog.etechpath.com
*    All Rights Reserved © 2018 www.etechpath.com
*    
*    Download necessary libraries from the links mentioned in download section in the post,
*    Post Link: https://blog.etechpath.com/how-to-interface-nextion-hmi-with-arduino-mega2560-and-learn-how-to-use-nextion-editor-and-program-tags-in-arduino
*
*************************************************************************************************************************/

#include "Nextion.h"
 
int S1 = 2, S2 = 3, S3 = 4;

NexDSButton bt0 = NexDSButton(0, 2, "bt0");
NexDSButton bt1 = NexDSButton(0, 3, "bt1");
NexDSButton bt2 = NexDSButton(0, 4, "bt2");
 
char buffer[100] = {0};
 
NexTouch *nex_listen_list[] = 
{
    &bt0, &bt1, &bt2,
    NULL
};
void setup(void)
{    
    pinMode(2,OUTPUT);
    pinMode(3,OUTPUT);
    pinMode(4,OUTPUT);
    digitalWrite(S1, HIGH);
    digitalWrite(S2, HIGH);
    digitalWrite(S3, HIGH);
    nexInit();
    bt0.attachPop(bt0PopCallback, &bt0);
    bt1.attachPop(bt1PopCallback, &bt1);
    bt2.attachPop(bt2PopCallback, &bt2);
    dbSerialPrintln("setup done"); 
}
void loop(void)
{   
    nexLoop(nex_listen_list);
}
 
void bt0PopCallback(void *ptr)
{
    uint32_t dual_state;
    NexDSButton *btn = (NexDSButton *)ptr;
    dbSerialPrintln("Callback");
    dbSerialPrint("ptr=");
    dbSerialPrintln((uint32_t)ptr); 
    memset(buffer, 0, sizeof(buffer)); 
    bt0.getValue(&dual_state);
    if(dual_state){digitalWrite(S1, LOW);}else{digitalWrite(S1, HIGH);}
}
void bt1PopCallback(void *ptr)
{
    uint32_t dual_state;
    NexDSButton *btn = (NexDSButton *)ptr;    
    dbSerialPrintln("Callback");
    dbSerialPrint("ptr=");
    dbSerialPrintln((uint32_t)ptr); 
    memset(buffer, 0, sizeof(buffer));   
    bt1.getValue(&dual_state); 
    if(dual_state){digitalWrite(S2, LOW);}else{digitalWrite(S2, HIGH);}
}
void bt2PopCallback(void *ptr)
{
    uint32_t dual_state;
    NexSButton *btn = (NexDSButton *)ptr;
    dbSerialPrintln("Callback");
    dbSerialPrint("ptr=");
    dbSerialPrintln((uint32_t)ptr); 
    memset(buffer, 0, sizeof(buffer));
    bt2.getValue(&dual_state);
    if(dual_state){digitalWrite(S3, LOW);}else{digitalWrite(S3, HIGH);}
}





HMI with Arduino working video:

https://www.youtube.com/watch?v=2RTYilN8xvs



Downloads :

Nextion Library

Nextion HMI file

Nextion TFT file

HMI Images

Arduino Code

 

 

]]>
https://blog.etechpath.com/how-to-interface-nextion-hmi-with-arduino-mega2560-and-learn-how-to-use-nextion-editor-and-program-tags-in-arduino/feed/ 7
Getting Started with ESP8266 WiFi Module https://blog.etechpath.com/getting-started-with-esp8266-wifi-module/ https://blog.etechpath.com/getting-started-with-esp8266-wifi-module/#respond Thu, 31 Aug 2017 01:59:00 +0000 https://blog.etechpath.com/?p=100 ESP8266 :

ESP8266 is advance WiFi chip with complete and standalone networking capabilities. This can be use ether as a standalone or the slave to a host microcontroller. ESP8266 is integrated with advance Tensilica’s L106 diamond series 32 bit micro-processor and on-chip SRAM with CPU clock speed 80MHz. We can also interface external input devices with this chip though provided GPIO’s (general purpose input/output).

For detailed information you can download ESP8266 datasheet here.

 

ESP8266 Modules:

There are several esp8266 modules available in market but only some of them are famous and commonly used. The most commonly used esp modules are ESP-01, ESP-07ESP-12  & ESP-32. Nowadays  ESP-32 is most famous module amongs all of them because ESP-32 is the only version  of ESP which combines WiFi and Bluetooth in single module. You can download datasheets of these modules from attachments.

 

ESP-01 Basic Circuit:

 

ESP-01 Pinout

ESP-01 Pinout

 

How to flash ESP-01 using Flash tools:

  1. Gather all component shown in above circuit and wire your esp to serial module as shown.
  2. Download ESP flash download tool from  the link given at the bottom of the page. You will not need to install this tool in your system, this tool will run directly without installation.
  3. Extract the rar file which we have downloaded in last step and run application file in it and select ESP8266 form selection buttons.
    ESP-flash-tools
    ESP-flash-tools
  4. After selecting ESP8266 download tool button, Flash tool screen will appear like bellow picture.
    ESP-flash-tools2
    ESP-flash-tools
  5. Now go back to your circuit and put jumper JP1 on. For setting ESP-01 into programming mode, you have to short GPIO0 to ground terminal of connected source.
  6. Connect serial module to your computer USB port and check the COM port for this device in device manger. You will need the correct COM port number of the connected device which you want to flash.   ( learn how to check COM port )
  7. That’s it, You are ready to go. Now select the bin files you want to burn into your ESP, select com port at the bottom of the flash tool and hit START. Ongoing process and success message will show in download panel dialog box.
  8. For beginner level you can burn NodeMCU firmware in your ESP-01 for general use.

 

How to Flash NodeMCU firmware in ESP-01:

  1. Download ESP8266 Flasher form the link given bellow at the bottom of this page.
  2. Run the flasher application file. You will see the tool as shown in bellow picture,
    ESP_flasher
    ESP_flasher
  3. Now setup your ESP-01 in programming mode as i described in previous steps. and select the COM port of your serial module.
  4. Do not change any other settings in flasher, setting right port is enough.
  5. Now hit Flash button provided just beside com port and your ESP will start receiving data from flasher. At the same time  AP MAC and STA MAC will appears on flasher as shown in picture bellow,
    NodeMCU flasher
    Programming ESP….
  6.  After successfully completing flashing process green indication will appear at the bottom, This means your ESP is programmed successfully and ready to use.

 

 



Downloads:

  1. ESP Flash Download Tools
  2. ESP Flasher win32
  3. ESP Flasher win6

 

]]>
https://blog.etechpath.com/getting-started-with-esp8266-wifi-module/feed/ 0