Tag Archive | "receive"

Arduino, Android and Seeedstudio Bluetooth Bee

Introduction

In this article we examine the Seeedstudio “Bluetooth Bee” modules and how they can be used in a simple way in conjunction with Android devices to control the Arduino world.  Here is an example of a Bluetooth Bee:

For the curious, the hardware specifications are as follows:

  • Typical -80dBm sensitivity
  • Up to +4dBm RF transmit power
  • Fully Qualified Bluetooth V2.0+EDR 3Mbps Modulation
  • Low Power 1.8V Operation, 1.8 to 3.6V I/O
  • UART interface with programmable baud rate
  • Integrated PCB antenna.
  • XBee compatible headers

You may have noticed that the Bluetooth Bee looks similar to the Xbee-style data transceivers – and it is, in physical size and some pinouts, for example:

The neat thing with the BtB (Bluetooth Bee) is that it is compatible with Xbee sockets and Arduino shields. It is a 3.3V device and has the same pinouts for Vcc, GND, TX and RX – so an existing Xbee shield will work just fine.

In some situations you may want to use your BtB on one UART and have another for debugging or other data transport from an Arduino – which means the need for a software serial port. To do this you can get a “Bees Shield” which allows for two ‘Bee format transceivers on one board, which also has jumpers to select software serial pins for one of them. For example:

Although not the smallest, the Bees Shield proves very useful for experimenting and busy wireless data transmit/receive systems. More about the Bees Shield can be found on their product wiki.

Quick Start 

In the past many people have told me that bluetooth connectivity has been too difficult or expensive to work with. In this article I want to make things as simple as possible, allowing you to just move forward with your ideas and projects. One very useful function is to control an Arduino-compatible board with an Android-based mobile phone that has Bluetooth connectivity. Using the BtB we can create a wireless serial text bridge between the phone and the Arduino, allowing control and data transmission between the two.

We do this by using a terminal application on the Android device – for our examples we will be using “BlueTerm” which can be downloaded from Google Play – search for “blueterm” as shown below:

gplay1

In our Quick Start example, we will create a system where we can turn on or off four Arduino digital output pins from D4~D7. (If you are unsure about how to program an Arduino, please consider this short series of tutorials). The BtB is connected using the Bees shield. This is based on the demonstration sketch made available on the BtB Wiki page – we will use commands from the terminal on the Android device to control the Arduino board, which will then return back status.

As the BtB transmit and receive serial data we will have it ‘listen’ to the virtual serial port on pins 9 and 10 for incoming characters. Using a switch…case function it then makes decisions based on the incoming character. You can download the sketch from here. If you were to modify this sketch for your own use, study the void loop() section to see how the incoming data is interpreted, and how data is sent back to the Android terminal using blueToothSerial.println.

Before using it for the first time you will need to pair the BtB with your Android device. The PIN is set to a default of four zeros. After setting up the hardware and uploading the sketch, wait until the LEDs on the BtB blink alternately – at this point you can get a connection and start communicating. In the following video clip you can see the whole process:


Where to from here?

There are many more commands that can be set using terminal software from a PC with a Bluetooth adaptor, such as changing the PIN, device name and so on. All these are described in the BtB Wiki page along with installation instructions for various operating systems.

Once again I hope you found this article interesting and useful. The Bluetooth Bees are an inexpensive and useful method for interfacing your Arduino to other Bluetooth-compatible devices. For more information and product support, visit the Seeedstudio product pages.

Bluetooth Bees are available from Seeedstudio and their network of distributors.

Disclaimer – Bluetooth Bee products used in this article are promotional considerations made available by Seeedstudio.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in android, arduino, bluetooth, cellular, INT119B2P, lesson, seeedstudio, tutorial, WLS125E1P, xbee

RF Wireless Data with the Seeedstudio RFbee

Introduction

In this article we examine the Seeedstudio RFbee Wireless Data Transceiver nodes. An RFbee is a small wireless data transceiver that can be used as a wireless data bridge in pairs, as well as a node in mesh networking or data broadcasting. Here is an example of an RFbee:

You may have noticed that the RFbee looks similar to the Xbee-style data transceivers – and it is, in physical size and some pinouts, for example:

comparison

However this is where the similarity ends. The RFbee is in fact a small Arduino-compatible development board based on the Atmel ATmega168 microprocessor (3.3V at 8MHz – more on this later) and uses a Texas Instruments CC1101 low-power sub1-GHz RF transceiver chip for wireless transfer. Turning over an RFbee reveals this and more:

But don’t let all this worry you, the RFbee is very simple to use once connected. As a transceiver the following specifications apply:

  • Data rate – 9600, 19200, 38400 or 115200bps
  • Adjustable transmission power in stages between -30dBm and 10 dBm
  • Operating frequency switchable between 868MHz and 915MHz
  • Data transmission can be point-to-point, or broadcast point-to-many
  • Maximum of 256 RFbees can operate in one mesh network
  • draws only 19.3mA whilst transmitting at full power

The pinout for the RFbee are similar to those of an Xbee for power and data, for example:

There is also the ICSP pins if you need to reprogram the ATmega168 direcly with an AVRISP-type programmer.

Getting Started

Getting started is simple – RFbees ship with firmware which allows them to simply send and receive data at 9600bps with full power. You are going to need two or more RFbees, as they can only communicate with their own kind. However any microcontroller with a UART can be used with RFbees – just connect 3.3V, GND, and the microcontroller’s UART TX and RX to the RFbee and you’re away. For our examples we will be using Arduino-compatible boards. If Arduino is new to you, consider our tutorials first.

If you ever need to update the firmware, or reset the RFbee to factory default after some wayward experimenting – download the firmware which is in the form of an Arduino sketch (RFBee_v1_1.pde) which can be downloaded from the repository. (This has been tested with Arduino v23). In the Arduino IDE, set the board type to “Arduino Pro or Pro Mini (3.3V, 8MHz) w/ATmega168”. From a hardware perspective, the easiest way to update the firmware is via a 3.3V FTDI cable or an UartSBee board, such as:

xbs4

You will also find a USB interface useful for controlling your RFbee via a PC or configuration (see below). In order to do this,  you will need some basic terminal software. A favourite and simple example is called … “Terminal“. (Please donate to the author for their efforts).

Initial Testing

After connecting your RFbee to a PC, run your terminal software and set it for 9600 bps – 8 – None – no handshaking, and click the check box next to “+CR”. For example:

term1

Select your COM: port (or click “ReScan” to find it) and then “Connect”. After a moment “OK” should appear in the received text area. Now, get yourself an Arduino or compatible board of some sort that has the LED on D13 (or substitute your own) and upload the following sketch:

Finally, connect the Arduino board to an RFbee in this manner:

  • Arduino D0 to RFbee TX
  • Arduino D1 to RFbee RX
  • Arduino 3.3V to RFbee Vcc
  • Arduino GND to RFbee GND
and the other RFbee to your PC and check it is connected using the terminal software described earlier. Now check the terminal is communicating with the PC-end RFbee, and then send the character ‘A’, ‘B’ or ‘C’. Note that the LED on the Arduino board will blink one, two or three times respectively – or five times if another character is received. It then reports back “Blinking completed!” to the host PC. For example (click to enlarge):
term2

Although that was a very simple demonstration, in doing so you can prove that your RFbees are working and can send and receive serial data. If you need more than basic data transmission, it would be wise to get a pair of RFbees to experiment with before committing to a project, to ensure you are confident they will solve your problem.

More Control

If you are looking to use your RFbees in a more detailed way than just sending data at 9600 bps at full power, you will need to  control and alter the parameters of your RFbees using the terminal software and simple AT-style commands. If you have not already done so, download and review the RFbee data sheet downloadable from the “Resources” section of this page. You can use the AT commands to easily change the data speed, power output (to reduce current draw), change the frequency, set transmission mode (one way or transceive) and more.

Reading and writing AT commands is simple, however at first you need to switch the RFbee into ‘command mode’ by sending +++ to it. (When sending +++ or AT commands, each must be followed with a carriage return (ASCII 13)). Then you can send commands or read parameter status. To send a command, just send AT then the command then the parameter. For example, to set the data rate (page ten of the data sheet) to 115200 bps, send ATBD3 and the RFbee will respond with OK.

You can again use the terminal software to easily send and receive the commands. To switch the RFbee from command mode back to normal data mode, use ATO0 (that’s AT then the letter O then zero) or power-cycle the RFbee.

RFbee as an Arduino-compatible board with inbuilt wireless

As mentioned previously the RFbee is based around an Atmel ATmega168 running at 8MHz with the Arduino bootloader. In other words, we have a tiny Arduino-compatible board in there to do our bidding. If you are unfamiliar with the Arduino system please see the tutorials listed here. However there are a couple of limitations to note – you will need an external USB-serial interface (as noted in Getting Started above), and not all the standard Arduino-type pins are available. Please review page four of the data sheet to see which RFbee pins match up to which Arduino pins.

If for some reason you just want to use your RFbee as an Arduino-compatible board, you can do so. However if you upload your own sketch you will lose the wireless capability. To restore your RFbee follow the instructions in Getting Started above.

The firmware that allows data transmission is also an Arduino sketch. So if you need to include RF operation in your sketch, first use a copy of the RFBee_v1_1.pde included in the repository – with all the included files. Then save this somewhere else under a different name, then work your code into the main sketch. To save you the effort you can download a fresh set of files which are used for our demonstration. But before moving forward, we need to learn about controlling data flow and device addresses…

Controlling data flow

As mentioned previously, each RFbee can have it’s own numerical address which falls between zero and 255. Giving each RFbee an address allows you to select which RFbee to exchange data with when there is more than two in the area. This is ideal for remote control and sensing applications, or to create a group of autonomous robots that can poll each other for status and so on.

To enable this method of communication in a simple form several things need to be done. First, you set the address of each RFbee with the AT command ATMAx (x=address). Then set each RFbee with ATOF2. This causes data transmitted to be formatted in a certain method – you send a byte which is the address of the transmitting RFbee, then another byte which is the address of the intended receipient RFbee, then follow with the data to send. Finally send command ATAC2 – which enables address checking between RFbees. Data is then sent using the command

Where data is … the data to send. You can send a single byte, or an array of bytes. length is the number of bytes you are sending. sourceAddress and destinationAddress are relevant to the RFbees being used – you set these addresses using the ATMAx described earlier in this section.

If you open the file rfbeewireless.pde in the download bundle, scroll to the end of the sketch which contains the following code:

This is a simple example of sending data out from the RFbee. The RFbee with this sketch (address 1) sends the array of bytes (testdata[]) to another RFbee with address 2.  You can disable address checking by a receiving RFbee with ATAC0 – then it will receive any data send by other RFbees.

To receive data use the following function:

The variable result will hold the incoming data, len is the number of bytes to expect, sourceAddress and destinationAddress are the source (transmitting RFbee) and destination addresses (receiving RFbee). rssi and lqi are the signal strength and link quality indicator – see the TI CC1101 datasheet for more information about these. By using more than two RFbees set with addresses you can selectively send and receive data between devices or control them remotely. Finally, please note that RFbees are still capable of sending and receiving data via the TX/RX pins as long as the sketch is not executing the sendTestData() loop.

I hope you found this introduction interesting and useful. The RFbees are an inexpensive and useful alternative to the popular Xbee modules and with the addition of the Arduino-compatible board certainly useful for portable devices, remote sensor applications or other data-gathering exercises.

For more information and product support, visit the Seeedstudio product pages.

RFbees are available from Seeedstudio and their network of distributors.

Disclaimer – RFbee products used in this article are promotional considerations made available by Seeedstudio.

In the meanwhile have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column? And join our friendly Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, education, lesson, RF, rfbee, seeedstudio, tutorial, wireless, WLS126E1P, xbee

Tutorial: Arduino and Infra-red control

Learn how to use Arduino and infra-red remote controls in chapter thirty-two of a series originally titled “Getting Started/Moving Forward with Arduino!” by John Boxall – A tutorial on the Arduino universe. The first chapter is here, the complete series is detailed here.

Updated 10/07/2013

In this article we will look at something different to the usual, and hopefully very interesting and useful – interfacing our Arduino systems with infra-red receivers. Why would we want to do this? To have another method to control our Ardiuno-based systems, using simple infra-red remote controls.

A goal of this article is to make things as easy as possible, so we will not look into the base detail of how things work – instead we will examine how to get things done. If you would like a full explanation of infra-red, perhaps see the page on Wikipedia. The remote controls you use for televisions and so on transmit infra-red beam which is turned on and off at a very high speed – usually 38 kHz, to create bits of serial data which are then interpreted by the receiving unit. As the wavelength of infra-red light is too high for human eyes, we cannot see it. However using a digital camera – we can. Here is a demonstration video of IR codes being sent via a particularly fun kit – the adafruit TV-B-Gone:

Now to get started. You will need a remote control, and a matching IR receiver device. The hardware and library used in this tutorial only  supports NEC, Sony SIRC, Philips RC5, Philips RC6, and raw IR protocols. Or you can purchase a matching set for a good price, such as this example:

irpackage

Or you may already have a spare remote laying around somewhere. I kept this example from my old Sony Trinitron CRT TV after it passed away:

sonyremote1

It will more than suffice for a test remote. Now for a receiver – if you have purchased the remote/receiver set, you have a nice unit that is ready to be wired into your Arduino, and also a great remote that is compact and easy to carry about. To connect your receiver module – as per the PCB labels, connect Vcc to Arduino 5V, GND to Arduino GND, and D (the data line) to Arduino digital pin 11.

Our examples use pin 11, however you can alter that later on. If you are using your own remote control, you will just need a receiver module. These are very cheap, and an ideal unit is the Vishay TSOP4138 (data sheet .pdf). These are available from element-14 and the other usual retail suspects. They are also dead-simple to use. Looking at the following example:

From left to right the pins are data, GND and Vcc (to Arduino +5V). So it can be easily wired into a small breadboard for testing purposes. Once you have your remote and receiver module connected, you need to take care of the software side of things. There is a new library to download and install, download it from here. Please note that library doesn’t work for Arduino Leonardo, Freetronics Leostick, etc with ATmega32U4. Instead, use this library (and skip the modification steps below). Extract the IRremote folder and place into the ..\arduinoxxx\libraries folder. Then restart your Arduino IDE if it was already open.

Using Arduino IDE v1.0 or greater? Open the file “IRRemoteInt.h” in the library folder, and change the line

Then save and close the file, restart the Arduino IDE and you’re set.

With our first example, we will receive the commands from our remote control and display them on the serial monitor:

Open the serial monitor box, point your remote control to the receiver and start pressing away. You should see something like this:

What have we here? Lots of hexadecimal numbers. Did you notice that each button on your remote control resulted in an individual hexadecimal number? I hope so. The number FFFFFFFF means that the button was held down. The remote used was from a yum-cha discount TV. Now I will try again with the Sony remote:

This time, each button press resulted in the same code three times. This is peculiar to Sony IR systems. However nothing to worry about. Looking back at the sketch for example 32.1, the

section is critical – if a code has been received, the code within the if statement is executed. The hexadecimal code is stored in the variable

with which we can treat as any normal hexadecimal number. At this point, press a few buttons on your remote control, and take a note of the matching hexadecimal codes that relate to each button. We will need these codes for the next example…

Now we know how to convert the infra-red magic into numbers, we can create sketches to have our Arduino act on particular commands. As the IR library returns hexadecimal numbers, we can use simple decision functions to take action. In the following example, we use switch…case to examine each inbound code, then execute a function. In this case we have an LCD module connected via I2C, and the sketch is programmed to understand fifteen Sony IR codes. If you don’t have an LCD you could always send the output to the serial monitor. If you are using the DFRobot I2C LCD display, you need to use Arduino v23.

Furthermore you can substitute your own values if not using Sony remote controls. Finally, this sketch has a short loop after the translateIR(); function call which ignores the following two codes – we do this as Sony remotes send the same code three times. Again. you can remove this if necessary. Note that when using hexadecimal numbers in our sketch we preced them with 0x:

And here it is in action:


You might be thinking “why would I want to make things appear on the LCD like that?”. The purpose of the example is to show how to react to various IR commands. You can replace the LCD display functions with other functions of your choosing.

At the start working with infra-red may have seemed to be complex, but with the previous two examples it should be quite simple by now. So there you have it, another useful way to control our Arduino systems. Hopefully you have some ideas on how to make use of this technology. In future articles we will examine creating and sending IR codes from our Arduino. Furthermore, a big thanks to Ken Shirriff for his Arduino library.

LEDborder

Have fun and keep checking into tronixstuff.com. Why not follow things on twitterGoogle+, subscribe  for email updates or RSS using the links on the right-hand column, or join our Google Group – dedicated to the projects and related items on this website. Sign up – it’s free, helpful to each other –  and we can all learn something.

Posted in arduino, control, DFR0107, dfrobot, education, infrared, IR, learning electronics, lesson, microcontrollers, remote, tronixstuff, tutorialComments (17)


Subscribe via email

Receive notifications of new posts by email.

The Arduino Book

Arduino Workshop

Für unsere deutschen Freunde

Dla naszych polskich przyjaciół ...

Australian Electronics!

Buy and support Silicon Chip - Australia's only Electronics Magazine.

Use of our content…

%d bloggers like this: