在当今的现代世界中,我们都依赖手机作为无线通信的主要手段。但是,我们都遇到过可能无法接听电话的情况,这些电话可能是重要的个人电话或改变生活的商务电话,您可能错过了那个机会,因为您无法在那个特定时间接听该电话。
该项目旨在通过使用arduino和gsm模块创建自动呼叫应答机来解决此问题。下次当您更换新电话号码或外出进行长途朝圣旅行或享受当之无愧的假期时,只需使用此机器录制您的声音,说明缺席的原因,您的所有电话将自动由这台机器接听,您录制的声音将播放给他们。这也可用于您的业务号码,以便在非办公时间接听客户的呼叫。听起来很有趣吧?所以让我们构建它..
所需材料:
该项目可能听起来有点复杂,但它真的很容易构建,你只需要以下组件
arduino uno
gsm 模块 – 飞鳞 sim 900
isd 1820 语音模块
12v 适配器为 gsm 模块供电
9v 电池为 arduino 供电
连接线
在我们实际进入项目之前,让我们熟悉gsm模块和isd 1820语音模块
飞秤 sim900 gsm 模块:
gsm模块使用起来非常吸引人,尤其是当我们的项目需要远程访问时。这些模块可以执行我们普通手机可以执行的所有操作,例如拨打/接听电话,发送/接收短信,使用gprs连接到互联网等。您还可以将普通麦克风和扬声器连接到此模块,并在移动通话中交谈。
如下图所示,gsm模块带有一个usart适配器,可以使用max232模块直接连接到计算机,或者可以使用tx和rx引脚将其连接到微控制器。您还可以注意到可以连接麦克风或扬声器的其他引脚,如mic +,mic-,sp+,sp-等。该模块可以通过普通的直流桶形插孔由12v 适配器供电。
将sim卡插入模块插槽并打开电源,您应该注意到电源指示灯亮起。现在等待一分钟左右,您应该会看到红色(或任何其他颜色)led 每 3 秒闪烁一次。这意味着您的模块能够与您的sim卡建立连接。现在,您可以继续将模块与手机或任何微控制器连接。
isd1820 语音模块:
isd 1820语音模块确实是一个很酷的模块,可以通过语音公告为您的项目增添趣味。该模块能够录制音频剪辑 10 秒,然后在需要时播放。模块本身带有麦克风和扬声器(8欧姆0.5瓦),它应该看起来像下面显示的那样。
该模块工作在+5v电压下,可以使用左侧的操纵杆供电。它在底部还有三个按钮,分别是rec.按钮,playe。按钮和播放l。按钮。您可以通过按录制按钮录制您的声音,并使用 playe 按钮播放。只要您按住按钮,playl 就会播放语音。与mcu接口时,我们可以使用左侧的引脚。这些引脚可承受 3v-5v,因此可由 arduino/esp8266 直接驱动。在我们的项目中,我们使用arduino模块的d8引脚控制playe引脚。这样我们就可以在gsm模块检测到并接听呼叫时播放录制的语音。
电路图及说明:
上面给出了该自动语音呼叫应答机项目的完整电路图。如您所见,连接非常简单。我们使用 12v 1a 适配器为 gsm 模块供电,使用 9v 电池为 arduino 供电,isd 语音模块由 arduino 的 +5v 引脚供电。众所周知,我们可以通过按下rec按钮在语音模块上录制任何内容,这将在按下p-e时播放,此音频必须发送到gsm模块的麦克风。因此,我们将语音模块的扬声器引脚连接到gsm模块的麦克风引脚。
这里,arduino和gsm模块串行连接,arduino的tx引脚连接到引脚9,rx引脚连接引脚10。这将有助于arduino收听gsm模块。当呼叫到达gsm模块时,arduino将收听它并要求gsm模块应答呼叫。arduino 确保呼叫处于活动状态,然后通过使引脚 8(连接到语音模块的 p-e)高电平 200 毫秒,在语音模块上播放录制的语音消息。
对 arduino 进行编程:
从上面的段落中我们知道arduino在这里的作用是什么;现在让我们看一下执行相同操作的代码。该项目的完整arduino代码在本页底部给出,在这里我将代码分成小垃圾来解释它。
在我们进一步安装 gsm 库之前,请单击此 github gsm 库链接以下载此项目中使用的库。您将获得一个zip文件,该文件必须通过sketch -> include librarey -> add添加到arduino库中。压缩文件。
下面显示的代码的前三行用于将库包含在我们的代码中。我们使用串行库和线库,因为我们没有使用 arduino 的默认 rx 和 tx 引脚与 gsm 模块通信。
#include //download librarey from https://github.com/seeed-studio/gprs_sim900
#include //default librarey
#include //default library
我们使用以下线路在引脚 9 和 10 上启用串行通信。这是我们上面包含的软件串行库实现的。
softwareserial gprs(9,10);//tx,rx
在我们的设置函数中,我们以 9600 波特率初始化串行监视器,gsm 模块也使用 9600 波特率初始化。触发语音的引脚 8 被声明为输出引脚。
void setup(){
serial.begin(9600); //serial monitor works on 9600 baudrate for debugging
sim900_init(&gprs, 9600); //gsm module works on 9600 baudrate
pinmode(8, output); //pin to turn on voice
serial.println(arduino - automatic voice machine);
}
接下来,我们必须创建一个函数,该函数可以通过其串行端口读取和理解gsm模块所说的内容。如果我们使用简单的串行读取行(如“gprs.read()”来读取消息,我们将以 ascii 十进制值的形式获取它们,这对我们来说毫无意义。
因此,以下函数用于使用字符串对象将这些十进制值转换为字符串,然后将它们连接起来形成字符串。最终的字符串值存储在变量 fdata 中,该变量为字符串类型,可用于与任何字符串值进行比较。
void check_incoming()
{
if(gprs.available()) //if gsm is saying something
{
incomingch = gprs.read(); // listen to it and store in this variable
if (incomingch == 10 || incomingch ==13) //if it says space (10) or newline (13) it means it has completed one word
{serial.println(data); fdata =data; data = ; } //print the word and clear the variable to start fresh
else
{
string newchar = string (char(incomingch)); //convert the char to string by using string objects
data = data +newchar; // after converting to string, do string concatenation
}
}
}
以下行用于调试,使用这些调试器行,您可以将任何at命令从arduino的串行监视器发送到gsm,还可以查看串行监视器上的响应。
if(serial.available()){ //used for debugging
gprs.write(serial.read()); //used for debugging
} //used for debugging
如前所述,arduino必须检查gsm模块是否正在接收任何呼叫。这可以通过使arduino检查“ring”来完成,因为gsm模块将根据at命令列表在呼叫时输出ring。当它找到呼叫时,它将等待 5 秒钟并将命令“ata”发送到 gsm 模块,这将使 gsm 模块接听呼叫,接听后它将响应“确定”。arduino再次等待“ok”确认,然后将引脚8调高200ms,以播放来自语音模块的录制语音。
if (fdata == ring) //if the gsm module says ring
{
delay(5000); //wait for 5sec to create 3 ring delay.
gprs.write (atarn); //answer the call
serial.println (placed received); //used for debugging
while(fdata != ok) //until call successfully answered
{check_incoming(); //read what gsm modue is saying
serial.println (playing recorded message); //used for debugging
//play the recored voice message
delay(500);
digitalwrite(8, high); //go high
delay(200); // wait for 200 msec
digitalwrite(8, low); //go low
}
加工:
一旦您的代码和硬件准备就绪,就该找点乐子了。打开两个模块的电源,然后按语音模块上的rec按钮并录制消息。此消息的长度只能为 10 秒。
现在使用以下给定的代码对arduino进行编程,并将sim卡插入gsm模块,您应该等待至少2分钟,以便gsm模块可以与您的网络服务提供商建立连接。完成后,您应该会看到一个红色 led 每 3 秒闪烁一次,这表明您的 sim 卡已准备好接听电话。您现在可以尝试从任何号码拨打此sim卡,并且您应该会在连续响铃三次后听到录制的消息。
/*
automatic voice machine using arudino and gsm900
created by: aswinth raj b
coded on: 22-9-2017
website: www.circuitdigest.com
*/
#include //download library from https://github.com/seeed-studio/gprs_sim900
#include //default library
#include //default library
int incomingch;
string data,fdata;
//connect tx pin of gsm to 9 of arduino
//connect rx pin of gsm to 10 of arduino
softwareserial gprs(9,10);//tx,rx
void setup(){
serial.begin(9600); //serial monitor works on 9600 baudrate for debugging
sim900_init(&gprs, 9600); //gsm module works on 9600 baudrate
pinmode(8, output); //pin to turn on voice
serial.println(arduino - automatic voice machine);
}
/*function to read incoming data from gsm to arduino*/
void check_incoming()
{
if(gprs.available()) //if gsm is saying something
{
incomingch = gprs.read(); // listen to it and store in this variable
if (incomingch == 10 || incomingch ==13) //if it says space (10) or newline (13) it means it has completed one word
{serial.println(data); fdata =data; data = ; } //print the word and clear the variable to start fresh
else
{
string newchar = string (char(incomingch)); //convert the char to string by using string objects
data = data +newchar; // after converting to string, do string concatenation
}
}
}
/*##end of function##*/
void loop(){
check_incoming(); //read what gsm module is saying
if(serial.available()){ //used for debugging
gprs.write(serial.read()); //used for debugging
} //used for debugging
if (fdata == ring) //if the gsm module says ring
{
delay(5000); //wait for 5sec to create 3 ring delay.
gprs.write (atarn); //answer the call
serial.println (placed received); //used for debugging
while(fdata != ok) //until call successfully answered
{check_incoming(); //read what gsm module is saying
serial.println (playing recorded message); //used for debugging
//play the recorded voice message
delay(500);
digitalwrite(8, high); //go high
delay(200); // wait for 200 msec
digitalwrite(8, low); //go low
}
}
}
苹果新专利:85-160mm范围内的可折叠相机 超强变焦!
FPGA硬件电路的调试必备原则和技巧
微星RTX 2060 Super与2080 Ti光追性能测试 实时光线追踪是无法绕过的技术
TCL宣布已与JOLED合作开发喷墨印刷OLED电视
电池已成电动汽车瓶颈,企业对国网推广信心不足
如何使用Arduino和GSM模块制作一个自动呼叫应答机
从"精益思想"看机器人的开发与应用:一场科技与效率的完美融合
电动汽车被颠覆,无人驾驶时代触手可及
智能监控技术的新一轮超越
!!% E4404B Agilent E4404B E440
快充时代下,苹果面对Type-C和雷电接口将如何选择?
互联网+固定资产管理系统实施方案
为避免被特斯拉超车 现代研发电动车专用平台
软件定义无线电(SDR)技术推动测试仪器的发展[图]
一文了解步进电机的工作原理
通过能量收集降低智能照明的成本
51单片机对μC/OS-II实时操作系统的移植
微型水质多参数在线监测站概述、功能、参数、组成及应用
AT89C52跟AT89S52有什么区别?
CNNIC报告显示,我国网民规模达8.02亿,其中手机网民达7.88亿