It is fully compatible with the Arduino nano-v3.0 pin and its usage method BLE chip:TI CC2540 Work channel: 2.4G Transmission distance: 50m Supports AT directive to configure BLE Support USB virtual serial port, hardware serial port,BLE three-way transparent transmission Support master and slave switch.
In this tutorial, we'll learn how to set up BLE GATT services to make a thermometer using Intel's Arduino 101
- 43,079 views
- 0 comments
- 26 respects
- Bluno integrates a TI CC2540 BT 4.0 chip with the Arduino UNO development board. TI CC2540 USB CDC Serial Port COM24 - there are 1 drivers found for the selected device, which you can download from our website for free. Document Includes User Manual CC2540 USB Evaluation Kit QSG.
- Note: the FTDI USB Drivers are from Arduino. But when you install drivers for other Controllers, such as Xadow Main Board, Seeeduino Clio, Seeeduino Lite, you need to download corresponding driver file and save it. And select the driver file you have downloaded. The below dialog boxes automatically appears if you have installed driver successfully.
- 3.1 Associate Driver with USB Dongle After the software installation is complete, the USB Dongle driver must be associated with the device in. Texas InstrumentsBLE-CC2540-1.1AccessoriesDrivers. SWRU270B Page 7 of 35 Figure 5 Click the “Next” button. This should install the dr iver. It will take a few seconds for the file to load.
- Please use Arduino IDE 1.8.6 or higher version. First, install the CC2540 driver,then follow this selection path in Arduino IDE:Tools - Board“Arduino Nano” Processor “ATmega328P', otherwise you'll find that you can't burn any program. Please refer to our github link,it can help you to slove any problem.
Components and supplies
| × | 1 | |
| × | 1 | |
| × | 1 |
Apps and online services
About this project
Introduction
This project covers what bluetooth low energy is and how to use it with the Arduino 101. We'll go over services, characteristics, and how to control inputs and outputs on the Arduino via the LightBlue app on our phone.
Fun fact: bluetooth gets its name from a viking king, Harold Bluetooth, and the bluetooth logo is a combination of two runes.
What is Bluetooth?
A Bluetooth product, like a headset or watch, contains a tiny computer chip with a Bluetooth radio and software that makes it easy to connect to other bluetooth devices. When two Bluetooth devices want to talk to each other, they need to pair. Because bluetooth can't connect at long distances, bluetooth networks are called 'pico-nets' (pico means tiny).
As you might have guessed, there are different types of Bluetooth. The kind you use to stream high quality audio or video (for instance, in your wireless headphones) is called BR/EDR (basic rate/enhanced data rate). BR/EDR and Bluetooth Low Energy (BLE) are fundamentally different. Bluetooth with low energy functionality is built on an entirely new development framework using Generic Attributes, or GATT. Today, we're exploring BLE, since that's what Arduino 101 and most IoT devices use.
Control a Button and an LED from your phone via BLE
- Attach a button and an LED to Arduino pins 4 and 13 respectively (see diagram)
- Connect the Arduino 101 to your computer
- Upload the sketch 'Arduino 101 Button LED' to your Arduino 101.
- Install either LightBlue for iOS or nRF Control Panel for Android on your phone. I'll be using screenshots from LightBlue on my iphone, but nRF is easy to figure out!
- Turn bluetooth on on your phone.
- When you open the app, you'll probably see a device called 'ARDUINO 101-XXXX.' Click on it.
Once you're connected, you can see the advertisement data, including its Local Name (ButtonLED gets cut short to ButtonLE since the General Advertising Profile uses the Shortened Local Name, which only allows 8 characters). You can also see the service UUIDs and characteristic UUIDs (in this case they're the same). UUIDs are the randomly generated 128-bit characters that identify a unique Bluetooth service. All this data together is called the GAP, or General Advertising Profile.
The profile is created within the setup on lines 25-28 of the sketch:
You can think of your Arduino 101, or any BLE Peripheral, as a newspaper publisher, say, the New York Times. The Arduino 101 prints 'news', called a service, every now and then. Readers or Central Devices like your phone can subscribe to the news.
Just as the New York Times prints both the Times and The Boston Globe, the Arduino 101 can have multiple services. Each service, in turn, can have multiple characteristics. These are like the different sections in the newspaper.
Services and characteristics are defined in the sketch here:
In our case, we have an LED characteristic and a button characteristic.
On your phone, you can choose which characteristics you wish to subscribe to via a mechanism called notify. If you're subscribed to a characteristic, then every time the value of that characteristic changes, you get a notification. In this case, the characteristic you can subcribe to is whether or not our button was pressed.
Click on the UUID that has 'Read Notify' properties and try pressing the button a few times
:
Do you see the value changing from 0x00 to 0x01?
There's another property, called 'indicate,' which is the same as notify except that your reader sends back a response to let the peripheral know that they got the notification. We won't be using it in this sketch, but some reader devices require their peripherals to use indicate rather than notify, so it's good to be aware of it.
Characteristics can also be 'write' accessible. To extend the New York Times metaphor, this is kind of like letters to the editor, where the subscriber can send something to the publication. In this case, we're going to write a value to our light to tell it to turn on.
You can turn it to on by sending any value other than zero, and turn it back off by sending zero:
Rad! So now you can receive data from your peripheral (the Arduino 101) on your reader (your phone), as well as turn an LED off and on.
You also learned about read, write, notify and indicate properties, and how to combine them in characteristics to create services.
But guess what? You won't always need to create your own custom services or characteristics, because any service you can imagine has already been defined as a GATT service. Remember that GATT stands for General Attributes? Yeah, I have no idea how they came up with that acronym either. Anyway, GATT is the layer that defines services and characteristics and enables read/write/notify/indicate operations on them. Check out these long lists of predefined services and characteristics.
Let's set up a temperature monitor to test out one of these predefined services.
Setting up the temperature monitor
- Plug your grove temperature sensor into A0 of your grove shield attached ro your Arduino 101 as shown in 'the circuit' above.
- Note: I used grove parts to simplify this, but you can easily use another temperature sensor - just be sure to include the appropriate library in your code!
- Open the BLE_Thermometer_blank sketch
I've left some of the values out of this sketch and given them placeholders (written in CAPS).
Each service and each characteristic that is predefined in the General Attributes has an ID. We'll need to find the documentation for the temperature service, choose the characteristics that we need, and find their IDs.
Go to the Gatt specifications page on bluetooth.com. Find the Health Thermometer Service.
On the service page, each characteristic is noted as being mandatory or optional. In the Temperature service, the mandatory one is called 'Measurement.'
Click on the blue text, and you'll be taken to the Temperature Measurement page. Here you can find the ID for the Measurement Characteristic. Add this to your code.
Now your code should look more like the BLE_Thermometer_final sketch. Upload it to your Arduino and run it! Connect your phone to your arduino with the Light Blue app. Hey look, we're getting data! But why does it say 0x0016? It's the temperature in hexadecimal.
In the Light Blue app, there's a list of data types that you can use. Hexadecimal is the default, but you can choose binary, bytes, integers, and signed integers, and you can choose big endian or little endian and how many bytes to include. We could spend all day playing with these, but we'll leave the discussion of data types for another day:
Unfortunately, the data in the LightBlue app isn't available to me in decimal, so I need to convert it to get the temperature in thei format that I'm used to. I pull out my handy hexadecimal converter and convert 0x0016 to decimal. I get 22. Hey look! The temperature showing in the serial monitor is also 22!
Nice work! Hopefully you understand slightly better how bluetooth communication is structured. Need an extra challenge? Try converting the temperature from Celcius to Farenheit.
Further reading:
Examples from the Arduino 101 page
Definitely try these out!
Code
BLE_Thermometer
Custom parts and enclosures
BLE Thermometer
Schematics
Author
Monica Houston
- 9 projects
- 301 followers
Published on
March 8, 2017Members who respect this project
and 18 others
Ti Cc2540 Dongle Driver
See similar projectsyou might like
Table of contents
Cc2540 Driver Arduino Programming
As part of my University Final Year Project (FYP), I needed to interface a digital weighing scale. This is something that has definitely been done before but there’s not too much documentation available on it. Therefore, I humbly present my guide to interfacing a digital weighing scale with a microcontroller.
Firstly, an overview of the main component (or components, in some scales) of any digital weighing scale – the load cell. Wikipedia has a pretty good article on load cells, but essentially these are transducers that convert force into an electrical signal. The load cell in a a typical digital scale typically takes the form of either an aluminium bar with a white epoxy blob with four wires coming out of it, or an aluminium fitting with the same epoxy blob but only three wires (there are other types, including a flat piece of metal with a U
shape cutout. These are usually found in scales with more than one load cell, making them far more complicated to interface). These different types correspond to full- and half- Wheatstone Bridges respectively. I’ll focus on the former as this is what I worked with.
The device I have was taken from an Argos Value Range weighing scale I bought for around five euro. It’s a basic scale with a range of 0-5 KG in 1 gram increments, that I chose due to the type of load cell it contained. This device was chosen as (a) it was cheap and (b) it used a single, four-wire cantilever-style load cell rather than four three-wire load cells with one on each foot of the device (more on this later). An image of the device with the load cell fitted is given below, but load cell aside, this scale is probably no different to any other digital scales on the market and any scale with a similar type of load-cell will do.
The Argos Value weighing scales with the load cell visible
Usb Cc2540 Hid Driver
Upon cracking it open, it is possible to four-wire load cell. This is the aluminium bar with the white blob of epoxy that protects the strain gauges that the system relies on from the elements.
Proceed to open it up even more until the PCB (circuit board) is accessible.
The PCB in closer detail
Once you can get to the PCB, unsolder all the wires from the PCB and leave it to one side – it isn’t needed anymore. While doing so pay attention to the names of each solder point. In the case of this scale, the wires of particular import are those on the top right corner: E+
(red), E-
(black), S+
(green) and S-
(white); or excite+,
excite-,
sense+and
sense-“. These should be the four wires coming from the load cell and the names tell you the function of each wire (needed later).
At this point, I’d advise soldering solid-core wire or jumper cables to the load cell wires. This will make it easier to work with on a breadboard.
There are four wires coming from the cell – red, black, green and white – that correspond to the excite positive
and excite negative
(power), and sense positive
and sense negative
(sensor) wires respectively. These wires correspond to the varying points in a Wheatstone bridge and this is illustrated below.
Before beginning any real circuit work, you must first find out what you’re working with. In my case, I connected the device in the manner seen below – connecting a 5v supply to excite+
(red), 0v/ground to excite-
and a multimeter to sense+
(green) and sense-
(white) at different intervals. By doing this, it became evident that, while the scale was at rest, the voltages from both outputs were almost identical at half the input voltage (2.5v). As explained above, and hence as expected, the voltage level on the green sense+ wire increased with pressure while the voltage level decreased on the other white sense-. However, what was worth noting was the level of voltage change. Despite apply as much pressure as possible with my thumb I could only get each wire to register a voltage change of roughly +/-6mV. This is a trait of load cells and, more specifically, strain gauges – their resistance changes with stress and strain, but only slightly.
Ti Cc2540
The voltage differences seen across the sense wires are obviously too minimal to be recorded by a typical ADC. A 12 bit ADC has 2^12 possible levels, meaning each level corresponds to a 5v/(2^12) increase/decrease in voltage, or ~1.22mV. Any change in voltage across the sense wires is more likely to be measured in a fraction of millivolt (the precise change in voltage is usually given in the datasheet when you buy a load cell by itself but it is quite easy to calculate through some experimentation, if you so wish). However, in any case your typical ADC is not going to have any accuracy when reading values that change as little as these do – they’re just too small. What we need to do is amplify (a.k.a. increase the voltage level of) the signals or, more precisely, the difference between the two.
This can be done a number of ways but the two that spring to mind are the differential op-amp (a.k.a. subtracting op-amp) or an instrumentation amplifier. There are plenty of guides available on the internet for how to build a differential op-amp circuit using chips like the LM358
, and this will allow you to multiply the difference in two voltage levels by a set amount (the gain). However, while they will work for larger signals, they typically won’t be all that precise for signals this small. A much better option is to purchase an instrumentation amplifier IC (chip), as these offer high precision, high input impedance and a simple method for changing gain.
The Analog Devices AMP04 is one such example. (Note: Do NOT try this with the AMP02. This is a dual supply op-amp meaning it expects a voltage on the V+ pin and the negative of that voltage on the V- pin (i.e. +15v and -15v). This probably isn’t what you want here. The AMP04 is a single-supply/single-rail op-amp and is suitable for a 5v – ground setup)
AMP04 Pinout, taken from the Analog Devices datasheet
You’ll want to wire this as follows:
Arduino Uno Driver Windows
- Connect ground to the
v-
pin - Connect the 5v supply to the
v+
pin - Connect a suitable resistor between the two
Rgain
inputs hence controlling the gain. The formula to calculate the value of this resistor can be found in AMP04 datasheet - Connect the green wire of the load cell to the
+In
input - Connect the white wire of the load cell to the
–In
input - Connect the
Vout
pin to the ADC input of your ADC port microcontroller (i.e. Arduino)
Cc2540 Driver Arduino
Following this, you should be able to interface the load cell using your microcontrollers ADC, like any other analog sensor. In the case of the Arduino – by using the analogRead()
function. I’ll leave this as an exercise for the reader!