LCD – Blog eTechPath https://blog.etechpath.com Tue, 03 Jan 2023 12:40:09 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://blog.etechpath.com/wp-content/uploads/2017/08/BrandLogo12-150x150.png LCD – Blog eTechPath https://blog.etechpath.com 32 32 Interfacing TFT LCD ILI9163C & DHT11 Temperature Sensor with STM32F103 32bit Microcontroller https://blog.etechpath.com/interfacing-tft-lcd-ili9163c-dht11-temperature-sensor-with-stm32f103-32bit-microcontroller/ https://blog.etechpath.com/interfacing-tft-lcd-ili9163c-dht11-temperature-sensor-with-stm32f103-32bit-microcontroller/#respond Sat, 23 Feb 2019 08:21:48 +0000 https://blog.etechpath.com/?p=662 About:

In this project i will teach you how to interface ILI9163C TFT LCD  color display module with STM32F103 Arm cortex microcontroller to display DHT11 temperature sensor value.




ILI9163C : It is a 1.44″ color TFT display with SPI interface. This tft comes very cheap but has lot of impressive futures and support very high speed SPI transfer of about 40Mhz. Available in two variants in market, one with the  black pcb and other one with the red pcb. In this project we will use black pcb.

STM32F103: A 32bit arm cortex high speed microcontroller. This is a very cheap, fast & advanced alternative to Arduino and can be program using Arduino IDE with simple USB bootloader. In this project we will use Black Pill STM32F103 board with USB bootloader.

DHT11: A very famous and widely used temperature & humidity sensor. This sensor uses resistive type NTC temperature measurement component with high performance 8bit microcontroller to provide calibrated digital signal output. It has measurement range of 0 to 50 degree Celsius.




Circuit Diagram:

 



Code:

 /* 
* Project: Interfacing TFT LCD ILI9163C & DHT11 Temperature Sensor with STM32F103 32bit Microcontroller 
* Author: Pranay SS, eTechPath 
* Website: www.etechpath.com 
* Tutorial Link: 
* Video Link: 
*/
  
  
#include <SPI.h>
#include <Adafruit_GFX.h>
#include <TFT_ILI9163C.h>
#include <Fonts/FreeSerifItalic9pt7b.h>
#include <dht11.h>
#define RST PB5
#define DC PB6
#define CS PB7


dht11 DHT11;

#define DHT11PIN PC13

// Definition of colours
#define  BLACK   0x0000
#define BLUE    0x001F
#define RED     0xF800
#define GREEN   0x07E0
#define CYAN    0x07FF
#define MAGENTA 0xF81F
#define YELLOW  0xFFE0  
#define WHITE   0xFFFF

float xh = 0;
float yh = 0;
int zh; 


TFT_ILI9163C tft = TFT_ILI9163C(CS, DC, RST);  

void setup() {
  tft.begin();
  tft.drawRect(5,70,118,20,WHITE);
  tft.setCursor(22,79);
  tft.setFont(&FreeSerifItalic9pt7b);
  tft.setTextColor(RED);  
  tft.setTextSize(1);
  tft.print("eTechPath");
  tft.setFont();
  tft.setCursor(10,91);
  tft.setTextColor(WHITE);
  tft.print("www.etechpath.com");
  
}

void loop(){

    int chk = DHT11.read(DHT11PIN);
  if(zh != chk)
  {tft.fillRect(00,15,128,8,BLACK);}
  tft.setCursor(5, 5);
  tft.setTextColor(WHITE);  
  tft.setTextSize(1);
  tft.println("Sensor Status");
  Serial.print("Read sensor: ");
  switch (chk)
  {
    case DHTLIB_OK:
        tft.setCursor(10, 15);
        tft.println("OK");
        Serial.println("OK ");
        break;
    case DHTLIB_ERROR_CHECKSUM:
        tft.setCursor(10, 15);
        tft.println("Checksum Error");
        Serial.println("Checksum error");
        break;
    case DHTLIB_ERROR_TIMEOUT:
        tft.setCursor(10,15);
        tft.println("Time out error");
        Serial.println("Time out error");
        break;
    default:
        tft.setCursor(10,15);
        tft.println("Unknown error");
        Serial.println("Unknown error");
        break;
  }

  float x = DHT11.humidity;
  float y = DHT11.temperature; 

  if (xh != x)
  {tft.fillRect(70,30,30,8,BLACK);
  tft.setCursor(5,30);
  tft.print("Humidity = ");
  tft.print(x);
  tft.println(" (%)");}
  if (yh != y)
  {tft.fillRect(46,50,30,8,BLACK);
  tft.setCursor(5,50);
  tft.print("Temp = ");
  tft.print(y);
  tft.print(" (C) ");}
  Serial.print("Temperature = ");
  Serial.print((float)DHT11.temperature);
  Serial.print(" (C) ");
  delay(500);
  xh = x;
  yh = y;
  zh = chk;
}





Project Images:

Note: Follow bellow tutorial if you want to know, how to burn USB bootloader in STM32 black-pill board.




 

]]>
https://blog.etechpath.com/interfacing-tft-lcd-ili9163c-dht11-temperature-sensor-with-stm32f103-32bit-microcontroller/feed/ 0
Digital distance measuring device using ultrasonic sensor SR04, OLED display and Arduino https://blog.etechpath.com/digital-distance-measuring-device-using-ultrasonic-sensor-sr04-oled-display-and-arduino/ https://blog.etechpath.com/digital-distance-measuring-device-using-ultrasonic-sensor-sr04-oled-display-and-arduino/#respond Sat, 05 May 2018 14:48:07 +0000 https://blog.etechpath.com/?p=573 About:

In this project i will explain how to interface SR04 ultrasonic sensor module with Arduino and display result on OLED display.




Components:

Arduino

SR04 Ultrasonic sensor module

OLED display i2c

Wires and basic tools




Circuit Diagram:

Description: 

  1. Connect SR04 ultrasonic sensor power to arduino +5v and GND also connect Trigger and Echo pin to arduino pin 9 and pin 8 as shown in above circuit diagram.
  2. In same way connect OLED power to arduino and connect SCL & SDA of oled display to arduino pin A5 and pin A4.
  3. Download arduino code and all libraries form download section, compile the code and upload it to your arduino.
  4. If you are new to ultrasonic sensors, do visit this post for basic study “SR04 Ultrasonic Sensor Module Basics”





Code:

/******************************************************************
 * Project: Printing utrasonic sensor data on OLED display
 * Author: Pranay Sawarkar
 * Website: www.etechpath.com
 *
 * This example is for a 128x32 pixel monocrome display using i2c
 *
 *****************************************************************/
#include <Ultrasonic.h>
#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
Ultrasonic ultrasonic(9, 8);
#define OLED_RESET 4   //(optional)
Adafruit_SSD1306 display(OLED_RESET);
#if (SSD1306_LCDHEIGHT != 32)     // change it to 64 if you are using 128x64 pixel OLED
#error("Height incorrect, please fix Adafruit_SSD1306.h!");
#endif
void setup()
{
  Serial.begin(9600);
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
  //display.display();
  //delay(2000);
  display.clearDisplay();
}
void loop ()
{
  display.setTextSize(1);
  display.setTextColor(WHITE);
  display.setCursor(0,0);
  display.print("Distance: ");
  display.println(ultrasonic.distanceRead());
  display.setCursor(80,0);
  display.print("cm");
  display.display();
  delay(1000);
  display.clearDisplay();
}

 



Downloads:

SR04 Ultrasonic Sensor Module Basics

SR04 Ultrasonic Module Library 

Adafruit GFX Library

Adafruit_SSD1306 OLED Library

Arduino Code

]]>
https://blog.etechpath.com/digital-distance-measuring-device-using-ultrasonic-sensor-sr04-oled-display-and-arduino/feed/ 0
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