Haptic Feedback Example Applications: Wireless Temperature Warning

Haptic Feedback Example Applications: Wireless Temperature Warning


These examples are provided as guides to using the Haptic Feedback Evaluation Kit for potential real-world applications. As discussed at the end, these are not full real-world solutions, but a useful starting step!

They outline the approach taken to solve the problem. They are not a guide to programming on the Arduino, therefore some prior knowledge of the Arduino language will be useful. Try the Arduino Learning or Reference pages for help with specific functions.


RF Transmitter and Receiver Kit

RF Transmitter and Receiver Kit

There are many dangerous situations where workers can have their senses impeded. As an example, fire services suffer from reduced vision (masks), hearing (noise and masks), and a sense of heat due to the thick fire retardant clothing.

These are extreme cases, where the level of heat could exceed the maximum operating temperature of the electronics. However, it serves as a good basis for discussing the monitoring of ambient levels and alerting a user when something is not right.

Toxic gas in mines, moisture in the air, the temperature in an incubator, even noise in a library! These are all examples that could use the same approach we have outlined below. Simply change the sensor type to suit your needs.

Definition And Scope

To provide haptic feedback to a user depending on the temperature, measured remotely, with a manual override to provide additional warnings.

  • Monitor the ambient temperature
  • Wirelessly send a haptic warning when the temperature rises above a certain level
  • Include option for manually sending wireless haptic feedback warning


  • 1 x Haptic Feedback Evaluation Kit

With this setup, we only need one spare digital pin. To connect to this pin you can either solder wires to the top of the Haptic Shield (not recommended) or remove the shield and use simple jumpers to the required pins.

  • 1 x Arduino Uno R3

This is in addition to one included with the haptic kit! We need a microcontroller both at the measurement unit to perform the temperature readings and wireless transmission, and with the haptic kit to receive the signals and drive the actuator. You can easily use a different controller, or a different Arduino board if desired.

  • 1 x Temperature Sensor (Analog Devices TMP36)

This sensor has an extremely wide range, we obviously won’t use all of it in our test as we are working in an office/lab environment.

  • 1 x Wireless Transmitter (FS1000A or XD-FST)
  • 1 x Wireless Receiver (XD-RF-5V or XY-MK-5V)

A very inexpensive RF transmitter and receiver was used, these are often sold as a pair and can vary in markings. Both operate at 5V and have no problem with the software (see next section), the range can be easily improved by soldering a length of wire to the antenna holes marked ANT.


This software is built from the Development Mode. You can download the code used in this example here:

We have also made use of the VirtualWire Arduino library created by Mike McCauley, you can download the code in the top right.

VirtualWire library from Mike McCauley


The entire application is really split into two main sub-systems, the transmitter (Tx) and receiver (Rx):

Temperature Warning System Diagram

Temperature Warning System Diagram

We need a microcontroller to handle the transmission interface, however even if it wasn’t a requirement it has a couple of advantages that warrant its inclusion:

  1. It gives us the ability to include several inputs. In this example, we’ve included the temperature sensor and the push button, with the microcontroller we can choose to play different haptic effects for each input.
  2. We can print out information to help with debugging and operation analysis. For example, we can visibly monitor the measured temperature to check we are receiving haptic commands at the right time.
  3. We can process the collected data locally and only send a play command when required. This simplifies the data being sent wirelessly, instead of a constant stream of readings from the temperature sensor we can now just send a couple of variables to play the haptic effect. It will also save on power and makes it easier to spot mistakes in the transmitted data.

Our flow of data will go like this:

Our flow of data through the system

Our flow of data through the system

We also want the user to differentiate between a temperature warning and the pushbutton warning. The pushbutton will be manually operated, so it might signify another urgent danger and be able to tell the difference will encourage the user to open dialogue with colleagues. So the pushbutton operator does not need to repeatedly press the button, we will play the effect 3 times in quick succession.

So a summary of our system is as follows:

  • Tx constantly monitors the temperature and state of the pushbutton
  • If temperature rises above 18C send a command to play haptic effect to Rx
  • If pushbutton is pressed send a command to play 3 x haptic effect to Rx
  • Temperature warning effect will be “Strong Click 100%” (Effect ID 1) on library 3
  • Pushbutton warning effect will be “Transition Ramp Up Short Sharp 2 0-100%” (Effect ID 93) on library 1
  • Rx to constantly listen for a transmission from Tx
  • Rx to play a haptic effect on the 306-109 in Haptic Grip (motor ID 2)

Transmitter Wiring

There are three main components we need to connect to the Arduino:

  • Temperature Sensor (Input)
  • Pushbutton (Input)
  • Wireless Transmitter (Output)

We’ve used 5V and GND for the power connections on each, so we connected these pins from the Arduino to the power rail on a breadboard for easy access.

Our selected temperature sensor has (TMP36) has only 3 pins (Vs, GND, and Vout) which makes it very easy to connect to. The level Vout signifies the temperature measurement, as it is an analogue signal we need to connect it to one of the Arduino’s analogue inputs to read it. We selected A0.

Analog Devices TMP36 Temperature Sensor

Analog devises TMP36 Temperature Sensor

To improve the resolution of our temperature reading we also decided to make use of the Arduino’s AREF pin. The ADC on the analogue input pins measures from 0 - 5 V, and is limited to 1024 values. However, the TMP36 will not output beyond 1V in our test (1V = 50C !) so if we could use our 1024 values between 0 - 1V this would help us calculate the temperature more accurately. This is achieved by putting the reference voltage at the AREF pin, we will use a voltage divider to create a constant 1V from our 5V rail on the breadboard. There is an internal 32 kΩ resistor at the pin, so our calculation becomes:

Connect a 128kΩ resistor between 5V and the AREF pin, or create the resistance from a couple of resistors in series. The closest we could find were 27kΩ and 100kΩ resistors which we put in series to give us a reference voltage of 1.006V. We also need to include extra code in the transmitter, discussed in the later section.

The pushbutton is a simple connection, one pin to the 5V and the other pin to a digital input pin on the Arduino (e.g pin 2). Remember to include a pull-down resistor connected to GND in parallel with the digital pin connection.

The wireless transmitter has three pins, two for power (5V and GND from breadboard) and a data pin that is connected to a digital output pin on the Arduino, we chose pin 3. The range of the RF modules is pretty limited, to help increase the signal (so it reached from one end of the desk to the other) we soldered a section of wire ~10cm to the ANT hole. Increasing the range further is discussed at the end.

RF Transmitter XD-FST

RF Transmitter XD-FST

Receiver Wiring

It is best to remove the Haptic Shield from the Arduino and connect to the pins using jumper cables.

Use the Pin Mapping resource to easily see which pins are required. For this example, we’ll need connections for the DRV2605 (red) and the Haptic Grip (blue).

We connected pins 3V3, GND, A0, A1, A4, A5, 4, 6, 7, and 9 straight from the Arduino to the Haptic Shield. We connected the other GND and 5V to the breadboard, the wireless receiver also needs 5V. Note the DRV2605 also relies on the 5V connection so be sure to connect the Haptic Shield 5V pin to the breadboard too.

The receiver itself has two pins marked DATA, you can use either but you only need one. It should be connected to a spare digital input pin, we chose pin 2.

RF Receiver XD-RF-5V

RF Receiver XD-RF-5V

Transmitter Code

Download the code from the Software section above!

As mentioned earlier, we use the VirtualWire library for wireless communications - so we have used#include<VirtualWire.h> in line 1.

We have also declared the appropriate variables to help us transmit haptic effects and calculate the temperature from sensor readings. The VirtualWire library transmits the data using an array structure, so we have an array for the temperature warning effect and one for the pushbutton warning effect. The first entry is the effect ID and the second is the library, the receiver will take these two integers and pass them into the playFullHaptic(); function.

Before deciding when to transmit the haptic effects, we need to calculate the temperature from our sensor. We do this in the tempSense(); function. There’s a lot of information printed to the serial monitor to help with debugging, but excluding these instructions there are only three steps:

  • Read the analogue signal from the sensor (line 71), which returns a value between 0 and 1023 where 0 = 0V and 1023 = Vref = 1V
  • Change the value of reading to a voltage represented by the variable outputVoltage
  • Calculate the temperature based on the value of outputVoltage. Note this calculation is dependant upon the sensor you use, this particular calculation is derived from the equation of the line in the Output Voltage vs Temperature graph in the TMP36 datasheet (page 5, figure 6).
Tx Serial Monitor

Tx Serial Monitor

As a note, to use the reference voltage we connected to the AREF pin we need to include the commandanalogReference(EXTERNAL); in line 35.

Now that we are monitoring the temperature, we also need to check if the pushbutton is pressed. This is a simple digital read of the pin that is connected to the pushbutton.

Deciding whether to send the haptic effect is handled by an if comparison for the pushbutton then an ifcomparison for the temperature. In either case, if the result is true (i.e. the button is pressed or the temperature is above 18C) we send the haptic effects.

The sendButtonEffect(); and sendTempEffect(); functions are effectively the same sets of code, but one uses thebuttonEffect array and the other uses the tempEffect[] array. We have also repeated the transmission of thebuttonEffect[] three times as outlined in the Guide section above. The delay(500); is included to give the receiver enough time to play the previous haptic effect.

Opening the serial monitor with SHIFT + CRTL + M will help with debugging and provide information during operation. You may also need to change the value of 18C to a more suitable temperature depending on your climate! Make sure all the variables used in your temperature calculation are declared as andfloat, all the numbers are entered as floats (e.g. with a decimal place, 18.0 and not 18) otherwise your result will be an int which may be incorrect / less accurate.

Receiver Code

Rx Serial Monitor

Rx Serial Monitor

Download the code in the Software section above!

This is built on our familiar Development Mode code and may look more complicated but the sections that we add are much simpler than the Tx code we built from scratch.

First, remember to include the VirtualWire library again so we can use its receive functions. We also need to build an array to receive the effect ID and library values. effect[] will suffice as the array name, we don’t need to split them into tempEffect[] and buttonEffect[] because we pass the values straight to playFullHaptic();. The receiver isn’t concerned what set off the alarm - it just plays the effect it is told to.

Remember to change the motorID in selectMotor(); to your desired motor, we’ve used 1 for the 306-109. We’ve also entered a new line in the setupPins(); function, setting pin 2 to an input to receive data from the RF module.

The main loop constantly checks to see if vw_get_message(); is true, this is the receiver listening for a valid message from the transmitter. The received values are stored in the effect[] array in the same order we entered them in on the transmitter, i.e. effectID then effectLIB.

All that is left is to pass these values into our payFullHaptic(); function and feel the results on the Haptic Grip! Open the serial monitor on this COM channel to see debugging information printed onscreen.

Future Work

In its current form, the transmission is non-discriminatory - that is any Rx listening at right frequency will pick up Tx. Similarly, Rx will pick up any Tx that is sending data. This may be an advantage, but there could easily be situations where the pushbutton operator wanted to alert a specific user. Or there may be multiple Tx who only want to connect to their own Rx if you have your own temperature sensor you may not want somebody else's warning playing haptic effects on your kit.

What happens if the connection is lost? In fact, in this application, we have not implemented any polling or connection checking. With the selected hardware we have a simplex connection, to check connections we would need at least a half duplex connection which would require a change in hardware or communications standard. This neatly leads us onto our next suggestion...

Other wireless standards exist and could be explored. RF has several benefits including low cost, simplicity (no pairing required), low power consumption, and good range. It was certainly the best choice for this tutorial, but could your application benefit from increased security or functionality? Many existing devices make use of wireless standards that have APIs, like Bluetooth on Android. You may also wish to upgrade each RF component to a transceiver to enable two-way communications (half duplex).

Contact Us

1.07 Canterbury Court
1-3 Brixton Road, London, SW9-6DE
[email protected]
+44 (0) 1932 252 482
(English / FR / DE / ES / IT)
+44 (0) 1932 325 353
Precision Microdrives
Mon. – Fri. 9:00 – 18:00 (BST / UTC)
* Charges vary depending on service provider and country