BLE_HTS_Demo

This BLE_HTS_Demo program enables you to collect Temperature and Humidity data reading from sensor and transmit to collector device such as smartphone.

Below documents teach you how to install app that can connect and read data from our DELTA-DFCM-NNN40 development board. There are two versions, Android and iPhone.

/media/uploads/Marcomissyou/ios_app_for_environment_sensor_0518.pdf

/media/uploads/Marcomissyou/android_app_for_environment_sensor.pdf

Committer:
silviaChen
Date:
Tue Jul 18 09:48:42 2017 +0000
Revision:
10:5220f45c8ec1
Parent:
9:2ff66a3d164a
Modify SDA/SCL configured pin to support NQ620 and NNN50 platform

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Marcomissyou 0:ef0f188a6fdd 1 /* Copyright (c) 2009 Nordic Semiconductor. All Rights Reserved.
Marcomissyou 0:ef0f188a6fdd 2 *
Marcomissyou 0:ef0f188a6fdd 3 * The information contained herein is property of Nordic Semiconductor ASA.
Marcomissyou 0:ef0f188a6fdd 4 * Terms and conditions of usage are described in detail in NORDIC
Marcomissyou 0:ef0f188a6fdd 5 * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
Marcomissyou 0:ef0f188a6fdd 6 *
Marcomissyou 0:ef0f188a6fdd 7 * Licensees are granted free, non-transferable use of the information. NO
Marcomissyou 0:ef0f188a6fdd 8 * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
Marcomissyou 0:ef0f188a6fdd 9 * the file.
Marcomissyou 0:ef0f188a6fdd 10 *df
Marcomissyou 0:ef0f188a6fdd 11 */
Marcomissyou 0:ef0f188a6fdd 12
Marcomissyou 0:ef0f188a6fdd 13 #include <stdbool.h>
Marcomissyou 0:ef0f188a6fdd 14 #include <stdint.h>
Marcomissyou 0:ef0f188a6fdd 15
Marcomissyou 0:ef0f188a6fdd 16 #include <mbed.h>
Marcomissyou 0:ef0f188a6fdd 17 #include "uvis25.h"
Marcomissyou 0:ef0f188a6fdd 18
silviaChen 10:5220f45c8ec1 19 I2C i2c_uvi(SDA, SCL); //SDA, SCL
Marcomissyou 0:ef0f188a6fdd 20
Marcomissyou 0:ef0f188a6fdd 21 static const char uvis25_expected_who_am_i = 0xCAU; //!< Expected value to get from WHO_AM_I register.
Marcomissyou 0:ef0f188a6fdd 22
Marcomissyou 0:ef0f188a6fdd 23 bool uvis25_init(void)
Marcomissyou 0:ef0f188a6fdd 24 {
Marcomissyou 0:ef0f188a6fdd 25 bool transfer_succeeded = true;
Marcomissyou 0:ef0f188a6fdd 26
Marcomissyou 0:ef0f188a6fdd 27 i2c_uvi.frequency(400000);
Marcomissyou 0:ef0f188a6fdd 28 uvis25_register_write(0x20 , 0x01);
Marcomissyou 0:ef0f188a6fdd 29
Marcomissyou 0:ef0f188a6fdd 30 // Read and verify product ID
Marcomissyou 0:ef0f188a6fdd 31 transfer_succeeded &= uvis25_verify_product_id();
Marcomissyou 0:ef0f188a6fdd 32
Marcomissyou 0:ef0f188a6fdd 33 return transfer_succeeded;
Marcomissyou 0:ef0f188a6fdd 34 }
Marcomissyou 0:ef0f188a6fdd 35
Marcomissyou 0:ef0f188a6fdd 36 bool uvis25_verify_product_id(void)
Marcomissyou 0:ef0f188a6fdd 37 {
Marcomissyou 0:ef0f188a6fdd 38 char who_am_i[1];
Marcomissyou 0:ef0f188a6fdd 39 uvis25_register_read(UVIS25_ADDRESS_WHO_AM_I, &who_am_i[0], 1);
Marcomissyou 0:ef0f188a6fdd 40 if (who_am_i[0] != uvis25_expected_who_am_i) return false;
Marcomissyou 0:ef0f188a6fdd 41 else return true;
Marcomissyou 0:ef0f188a6fdd 42 }
Marcomissyou 0:ef0f188a6fdd 43
Marcomissyou 0:ef0f188a6fdd 44 void uvis25_register_write(uint8_t register_address, uint8_t value)
Marcomissyou 0:ef0f188a6fdd 45 {
Marcomissyou 0:ef0f188a6fdd 46 char w2_data[2];
Marcomissyou 0:ef0f188a6fdd 47
Marcomissyou 0:ef0f188a6fdd 48 w2_data[0] = register_address;
Marcomissyou 0:ef0f188a6fdd 49 w2_data[1] = value;
Marcomissyou 0:ef0f188a6fdd 50 i2c_uvi.write(UVIS25_WriteADDE, w2_data, 2);
Marcomissyou 0:ef0f188a6fdd 51
Marcomissyou 0:ef0f188a6fdd 52 }
Marcomissyou 0:ef0f188a6fdd 53
Marcomissyou 0:ef0f188a6fdd 54 void uvis25_register_read(char register_address, char *destination, uint8_t number_of_bytes)
Marcomissyou 0:ef0f188a6fdd 55 {
Marcomissyou 0:ef0f188a6fdd 56 i2c_uvi.write(UVIS25_WriteADDE, &register_address, 1, 1);
Marcomissyou 0:ef0f188a6fdd 57 i2c_uvi.read(UVIS25_WriteADDE, destination, number_of_bytes);
Marcomissyou 0:ef0f188a6fdd 58 }
Marcomissyou 0:ef0f188a6fdd 59
Marcomissyou 0:ef0f188a6fdd 60
Marcomissyou 0:ef0f188a6fdd 61 uint8_t UVIS25_ReadUVI(void)
Marcomissyou 0:ef0f188a6fdd 62 {
Marcomissyou 0:ef0f188a6fdd 63 char UVI_reading;
Marcomissyou 0:ef0f188a6fdd 64 uvis25_register_read(0x28, &UVI_reading, 1);
Marcomissyou 0:ef0f188a6fdd 65 return (uint8_t) UVI_reading;
Marcomissyou 0:ef0f188a6fdd 66 }