在the previous tutorial,我们已经了解了Attiny85如何与蓝牙模块HC05串行通信并从智能手机蓝牙发送/接收命令
This tutorial also involves the role Bluetooth module HC05. But instead of receiving commands from a smartphone, it sends sensor data values to the smartphone. The sensor is connected to an analog input pin of ATtiny85. It can be any analog sensor like LDR or temperature sensor (LM35), soil moisture sensor, etc. ATtiny85 will read analog voltage output from the sensor, convert it into a digital value, and transmit it to the smartphone using the HC05 module. So it becomes a wireless sensor data transmitter. Let’s see how it is done.
假设您从一开始就不会关注这个教程系列。在这种情况下,要求您通过以下两个教程来解释并演示如何使用Attiny85和逐步指南以构建“ Hello World”(LED闪烁)应用程序。
如何work with ATtiny85
LED blinking using ATtiny85
电路连接
该电路仅使用3-4个组件HC05模块,一个LED,ATTINY85和一个三针传感器模块(此处显示的任何传感器模块,例如电位器,LM35温度传感器模块,LDR传感器模块和土地水分传感器模块)。HC05(蓝牙模块)具有四个接口引脚(1)VCC(2)GND(3)TX和(4)Rx。TX引脚与PB2连接(引脚7),Rx引脚与PB3连接(引脚2)。VCC引脚与5V连接,GND引脚连接到连接到地面的引脚4。传感器模块具有三个接口引脚(1)VCC(2)和(3)信号。VCC引脚与5V连接,GND引脚连接到Attiny85的引脚4。传感器的模拟输出的信号引脚连接到Attiny85的模拟输入引脚A2。上面的电路显示了5 V电源。
Note: Almost all analog sensors have a three-pin interface. A potentiometer is connected in this circuit, but any other sensor that operates on 5V can also be connected in place of this potentiometer.
Circuit operation
- 当给电路提供5V电源时,HC05模块将开始眨眼,以表明它正在搜索将配对的另一个蓝牙设备(连接)
- 阅读传感器数据的人将首先开放Android应用程序,并在其智能手机中具有蓝牙通信设施。(您可能会在Google Play商店中获得许多此类应用程序。只需搜索“ Arduino的蓝牙控制”)。该应用程序将搜索并与HC05模块配对(用于配对1sttime, it must enter Bluetooth passkey for the HC05 module, which is by default 1234). When the smartphone get connected with the HC05 module, its blinking rate will be slow
- 现在,手机中的Android应用已准备好接收传感器数据
- ATtiny85 will read analog voltage output from the sensor and convert it into digital
- 然后通过HC05模块将此值传输到智能手机。它只是串行将此值发送到HC05模块,该模块将无线传输到智能手机
- the android app uses the phone’s Bluetooth and gets this sensor data, and display it on the smartphone screen
Program
该程序使用C编程语言用Arduino IDE软件编写。它是编译的,并创建了一个十六进制文件,该文件已下载到Attiny的内部闪光灯中
Program logic
有四种不同类型的传感器的程序有四个不同的程序。该程序主要相同,但是发送数据值格式几乎没有变化。
在itially, the program sends a message to the user’s smartphone that Bluetooth is connected with HC05 and sends sensor data.
电位计的程序
LDR的程序
Program for LM35
Program for soil moisture
然后,程序连续读取传感器数据,以适当的格式转换它,然后将其连续传输到手机。每当传输新的传感器数据时,它会闪烁LED,并且每1秒后重复一次。
This is the last tutorial of this series. In this tutorial series, we have learned about the ATtiny85 microcontroller from the basic to the application level and interesting applications.
You can also build any small and simple application using an ATtiny85 microcontroller, especially when there are fewer IO pins and you want to build a tiny and compact device with a small form factor.
You may also like:
提交以下:354manbetx
与本文有关的问题?
Ask and discuss onedaboard.com和Electro-Tech-online.com论坛。
告诉我们你的想法!!
You must be登录发表评论。