Project tutorial

Arduino/Genuino 101 BLE Thermometer With TMP102 and Blynk © GPL3+

Here is how to make an Arduino/Genuino 101 Bluetooth Low Energy thermometer with TMP102 and Blynk.

  • 5,805 views
  • 0 comments
  • 15 respects

Components and supplies

Apps and online services

About this project

Hello! Today I will show you how to make an Arduino/Genuino 101 Bluetooth Low Energy thermometer with TMP102 and Blynk.

Let's begin.

Connect the components

First, plug the sensor breakout on the breadboard. Then, with the 4 jumpers, connect the sensor with the 101 board.

  • GND to GND
  • VCC to 3.3v
  • SDA to SDA
  • SCL to SCL

Getting the Arduino IDE ready for 101

If you already have the Arduino IDE, then it's OK, otherwise download the Arduino IDE from here.

Download the 101's core package

Now, open the Arduino IDE and go to Tools => Board => Boards Manger. Click on "Boards manager", then type "Genuino 101" or "Arduino 101" (or you can just type "101" in the search bar) and you will get the package for Arduino/Genuino 101 board. Click on install and wait for it to download and install. Now you are done with it.

Download the Blynk library

Now go to Sketch => Include Library => Manage Libraries. Click on "Manage Libraries" and type Blynk in the search bar, then you will get the library. Click on install and wait. Once the library is installed, you are ready to move on the next step.

Setting the Blynk app

Open the Blynk app and tap on the QR scanner button, then scan the QR code from this step. The app will build itself.

Now you need to get the "Auth Token". Tap on the "Nut" icon, then on the device, and then tap on it again. Now, you should see your "Auth Token". E-mail or rewrite it, because you will need it in the next step!

Edit and upload the sketch

Open the sketch or copy it from here, then add your "Auth Token". Upload the sketch.

Note: CODE UPDATE 23.01.17 - You can now measure negative temps !

Connect the 101 with Blynk

In the Blynk app, tap on the Bluetooth button.

Then tap on "Connect BLE Device". Choose your 101 board, go back and deploy the app.

You are all done.

NOTE: The readings are on virtual pins: 0, 1, 2.

YOU CAN SUPPORT ME ON PATREON !

Code

101_BLE_Thermometer_TMP102.inoArduino
/**************************************************************
 * Blynk is a platform with iOS and Android apps to control
 * Arduino, Raspberry Pi and the likes over the Internet.
 * You can easily build graphic interfaces for all your
 * projects by simply dragging and dropping widgets.
 *
 * This sketch was created by Konstatin Dimitrov 
 * under GNU v3.0 Licence 
 * 
 * Based on example scetch: Arduino_101_BLE
 ***************************************************
 *
 * This scetch shows how to send data from TMP102 with 
 * Arduino/Genuino 101 BLE to Blynk.
 *
 * Note: This requires CurieBLE library
 *   from http://librarymanager/all#CurieBLE
 *
 * NOTE: BLE support is in beta!
 *
 **************************************************************/

//#define BLYNK_USE_DIRECT_CONNECT

#define BLYNK_PRINT Serial

#include <Wire.h>
#include <BlynkSimpleCurieBLE.h>
#include <CurieBLE.h>

// You should get Auth Token in the Blynk App.
// Go to the Project Settings (nut icon).
char auth[] = "AUTH_TOKEN";

//TMP102 I2C (TWI) address in HEX
int tmp102Address = 0x48;

BLEPeripheral  blePeripheral;

void setup() {
  Serial.begin(9600);
  Wire.begin();
  delay(1000);
  
  blePeripheral.setLocalName("BLE Thermometer");
  blePeripheral.setDeviceName("BLE Thermometer");
  blePeripheral.setAppearance(384);

  Blynk.begin(blePeripheral, auth);

  blePeripheral.begin();
  
  Serial.println("Waiting for connections...");
}

//Temperature readings in Celsius on V0
BLYNK_READ(0)
  {
  float celsius = getTemperature();
  Blynk.virtualWrite(0, celsius);
  }
//Temperature readings in Fahrenheit on V1
BLYNK_READ(1)
  {
  float celsius = getTemperature();
  float fahrenheit = (1.8 * celsius) + 32;
  Blynk.virtualWrite(1, fahrenheit);
  }

BLYNK_READ(2)
  {
  float celsius = getTemperature();
  float kelvin = 273.15 + celsius;
  Blynk.virtualWrite(2, kelvin);
  }
  
void loop() {
  Blynk.run();
  blePeripheral.poll();
  }

float getTemperature(){
  Wire.requestFrom(tmp102Address,2); 

  byte MSB = Wire.read();
  byte LSB = Wire.read();

  //it's a 12bit int, using two's compliment for negative
  int TemperatureSum = ((MSB << 8) | LSB) >> 4; 

  float celsius = TemperatureSum*0.0625;
   if (celsius > 128)
  { 
  celsius = celsius - 256; // for negative temperatures
  }
  else
    celsius;
  return celsius;
}

Comments

Similar projects you might like

Arduino Memory Game

Project showcase by MakerRobotics

  • 519 views
  • 0 comments
  • 15 respects

Retro Nokia Snake Game with Arduino

Project tutorial by circuito.io team

  • 2,291 views
  • 2 comments
  • 18 respects

Play Music With Your Remote

Project tutorial by Simone Adobs

  • 367 views
  • 8 comments
  • 3 respects

Arduino - Web-Based MP3 Player

Project tutorial by khanhhs

  • 1,406 views
  • 0 comments
  • 8 respects

Arduino Radar - Version 2.0

by MakerRobotics

  • 729 views
  • 8 comments
  • 15 respects

Arduino Dynamic Web Control

Project tutorial by phpoc_man

  • 14,801 views
  • 11 comments
  • 58 respects
Add projectSign up / Login