Arduino Wireless Control http://blog.arduino.cn/

Source: Internet
Author: User

The article once introduced how to use the RF module to implement wireless control over Arduino. Its principle is very similar to that of remote control, which can implement RF wireless remote control with four buttons. However
This solution is not suitable for data transmission scenarios. For example, you need to transmit the value of the light sensor collected by Arduino to the PC end wirelessly. Technically
Wireless data transmission, or wireless data transmission for short. Currently there are many solutions to achieve wireless data transmission, but it is most likely to be connected to the Arduino using a serial port similar to apc220.
Data transmission: although the speed of data transmission may be slow (due to the baud rate of the serial port), it is indeed a simple and easy-to-use method. No wonder many netizens suggest adding such module support to Arduino.

Today, I found some time to play around with this apc220. The modules sent by the manufacturer do not have any instructions. Fortunately, some instructions can be found on the Internet, and I have to find my own. The first problem discovered is the factory
The Home USB adapter does not seem to match apc220 very well: the number of pins is different. Well, it seems hard to understand, maybe to be compatible with different products, or at least to say that this adapter is not
Apc220 is specially designed. The chip used by the USB adapter is cp2102, so we first download the corresponding driver from the Silicon Laboratories website.
The downloaded file is cp210x_vcp_win2k_xp_s2k3.zip.
Decompress the package into an EXE file. Execute the package directly and install the driver step by step as prompted.

After the driver is installed, insert the USB adapter into the USB interface of the PC. Windows will prompt you to find the corresponding hardware and install and configure it accordingly:

After windows prompts that the hardware is ready for use, you can find the virtual serial port cp2102 under "port (COM and LPT)" in the device manager:

Now you can connect an apc220 module to the USB adapter. because the number of pins of the USB adapter is inconsistent with that of apc220, pay attention to the insertion position during connection:

Open the setup RF-ANET provided by the apc220 manufacturer
, The default serial port found previously cp2102 is com87, but the RF-ANET does not seem to open this port normally.

After setting the serial port to com4 in Device Manager, re-insert the USB adapter and open the RF-ANET, click the "read R" button, everything works, and the status bar displays "read succeed !", It indicates that it can communicate with apc220 normally!

In this way, we recommend that you test the PC apc220 environment. Now let's look at the Arduino end. There are four connections between apc220 module and Arduino: 5 V,
Gnd,
TX and Rx, it should be noted that apc220 and Arduino are both independent serial port devices, so the send terminal TX on the Arduino should be connected to the receiving end Rx on apc220
Similarly, Rx on Arduino should be connected to TX on apc220:

The default baud rate of the apc220 module is set to 9600. Therefore, use the following code to test the SDK. Note that when downloading the program to aduino, the connection with the Tx and Rx of the apc220 module is broken first, otherwise, the download may fail.

int val = 0;
int ledPin = 13;
void setup()
{
Serial.begin(9600);
}

void loop()
{
val = Serial.read();
if (-1 != val) {
if ('A' == val || 'a' == val) {
Serial.println("Hello from Arduino!");
}else if ('B' == val || 'b' == val) {
digitalWrite(ledPin, HIGH);
delay(500);
digitalWrite(ledPin, LOW);
}
}
}

To sum up, we have connected an apc220 module on the PC and Arduino respectively, and have written the corresponding test code to the Arduino. Everything is ready
After that, let's perform the test. First of all, we must use an external power supply to power the Arduino. This is because if the USB cable is connected, the corresponding
The ftbench module will be activated, so that the serial port implemented by ftbench and the serial port on acp220 will cause abnormal communication due to conflicts:

After you put the powered Arduino in a corner of the room, configure the PC end. After the apc220 module uses its USB adapter, its principle is also equivalent to a serial port.
In this case, we can use the development environment provided by Arduino for testing. However, in this case, your PC is no longer connected to Arduino, but to apc220.
USB adapter. Connect the apc220 USB adapter, enable Arduino, and choose "Tools"> "serial ".
Under the ports menu, select the "com4" virtualized by the USB adapter (consistent with the previous settings ). Then open the "serial"
Monitor, send the character, and receive the "hello from" Message from Arduino.
Arduino !", Send B characters to light the led on Arduino 13 (lasting 0.5 seconds ):

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.