Quantcast
Channel: LinkSprite Learning Center
Viewing all articles
Browse latest Browse all 562

Teach you how to use “Call ID Module”

$
0
0

图片1

 

The core IC of this module is HT9032D,when someone is calling ( current telephone must show the calling number), model serial port(TTL level) will output hexadecimal data,the data include date/time/phone number ect important information. Data indicate: have call, the serial output hexadecimal will appear ox55 for more than ten times, then appear ox04, after the data of ox04 is the data length/date/time/phone number/BCC byte.

  • Arduino UNO  x1
  • Call ID Module  x1
  • LCD1602 A Shield  x1
  • Screw Shield  x1(If it is LCD1602 B Shield,can not need it)
  • Male – female Dupont Line  x3

图片2

Call ID Module +5V  –>  Arduino 5V

Call ID Module GND  –>  Arduino GND

Call ID Module RXD  –>  Arduino RXD

 

图片3

图片4

#include <LiquidCrystal.h>
#define LCD_BACKLIGHT_PIN 10
LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);
 
static int Ht9032_flag=0;
static int Ht9032_i=0;
static char Ht9032_code[25];
static int Ht9032_codeleng=0;
char SBUF0 = 0;
 
void setup()
{
  pinMode(10,OUTPUT);
  digitalWrite( LCD_BACKLIGHT_PIN, LOW ); 
  delay(200);
  lcd.begin(16, 2);
  lcd.clear();
  digitalWrite( LCD_BACKLIGHT_PIN, HIGH); 
  lcd.setCursor(0,0);
  lcd.print("Test Code V1.0"); 
  lcd.setCursor(0,1);
  lcd.print("Waiting Caller..");
 
  Serial.begin(1200);
  delay(100);
}
 
void loop()
{
  Ht9032_get();
}
 
void Serial_display()
{
  for(int i=1;i<Ht9032_codeleng+1;i++)
  {
    Serial.print(char(Ht9032_code[i]));
    Serial.print("/");
  }
}
 
void lcd_display()
{
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("DATE:");
  lcd.print(char(Ht9032_code[1]));
  lcd.print(char(Ht9032_code[2]));
  lcd.print('/');
  lcd.print(char(Ht9032_code[3]));
  lcd.print(char(Ht9032_code[4]));
  lcd.print(" ");
  lcd.print(char(Ht9032_code[5]));
  lcd.print(char(Ht9032_code[6]));
  lcd.print(':');
  lcd.print(char(Ht9032_code[7]));
  lcd.print(char(Ht9032_code[8]));
 
  lcd.setCursor(0,1);
  lcd.print("NO.:");
 
  for(int i=9;i<Ht9032_codeleng+1;i++)
  {
     lcd.print(char(Ht9032_code[i]));
  }
}
 
void Ht9032_get()
{
  while (Serial.available() > 0)  
  {
  Serial.flush();
  SBUF0 = Serial.read();  
  switch(Ht9032_flag)
  {
    case 0x00:if (SBUF0==0x55)  
               {
                 Ht9032_flag=0x01;
                 Ht9032_i=0x01;
               }break;
 
    case 0x01:if (SBUF0==0x55) 
               {
                 Ht9032_i++;
               }                        
               else
               {
                 Ht9032_flag=0x00;
                 Ht9032_i=0x00;
        }
               if(Ht9032_i==0x0a)
               {
                 Ht9032_flag=0x02;
                 Ht9032_i=0x00;
               }break;
 
    case 0x02:if(SBUF0==0x04) 
          {
                Ht9032_flag=0x03;
              }
              else if(SBUF0==0x80)
              {
                Ht9032_flag=0x03;
               }break;
 
     case 0x03:Ht9032_codeleng = SBUF0; 
               Ht9032_i=0;
               Ht9032_code[Ht9032_i++]=Ht9032_codeleng;
               Ht9032_flag=0x04;                                        
               break;
 
    case 0x04:Serial.print(Ht9032_code[Ht9032_i-1],HEX);
              Ht9032_code[Ht9032_i++]=SBUF0;  
              if( Ht9032_i > Ht9032_codeleng+1 ) 
         {  
                //Serial_display();
                lcd_display();
            Ht9032_flag=0x00;
        Ht9032_i=0x00;                              
          }
              else
              { Ht9032_flag=0x04; }
          break;
     default:break;
   }
  }
}

1. First finish the connection of the wire according to the wire diagram.

2. Then copy the test code to Arduino IDE, then download the code

图片5

3. If someone is calling, it will show the data,time and phone number, the effect will show below:

图片6图片7


Viewing all articles
Browse latest Browse all 562

Trending Articles