Mpression Uzuki sensor shield test program

Dependencies:   ADXL345_I2C Si114x Si7020 mbed

Committer:
MACRUM
Date:
Wed Mar 02 15:49:04 2016 +0000
Revision:
0:eaa7a09b51b3
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
MACRUM 0:eaa7a09b51b3 1 /* Mpression Uzuki sensor shield test program
MACRUM 0:eaa7a09b51b3 2 * Copyright (c) 2016 ARM Limited
MACRUM 0:eaa7a09b51b3 3 *
MACRUM 0:eaa7a09b51b3 4 * Licensed under the Apache License, Version 2.0 (the "License");
MACRUM 0:eaa7a09b51b3 5 * you may not use this file except in compliance with the License.
MACRUM 0:eaa7a09b51b3 6 * You may obtain a copy of the License at
MACRUM 0:eaa7a09b51b3 7 *
MACRUM 0:eaa7a09b51b3 8 * http://www.apache.org/licenses/LICENSE-2.0
MACRUM 0:eaa7a09b51b3 9 *
MACRUM 0:eaa7a09b51b3 10 * Unless required by applicable law or agreed to in writing, software
MACRUM 0:eaa7a09b51b3 11 * distributed under the License is distributed on an "AS IS" BASIS,
MACRUM 0:eaa7a09b51b3 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
MACRUM 0:eaa7a09b51b3 13 * See the License for the specific language governing permissions and
MACRUM 0:eaa7a09b51b3 14 * limitations under the License.
MACRUM 0:eaa7a09b51b3 15 *
MACRUM 0:eaa7a09b51b3 16 * Mpression Uzuki sensor shield test program
MACRUM 0:eaa7a09b51b3 17 *
MACRUM 0:eaa7a09b51b3 18 * @author Toyomasa Watarai
MACRUM 0:eaa7a09b51b3 19 * @version 1.0
MACRUM 0:eaa7a09b51b3 20 * @date 3-March-2016
MACRUM 0:eaa7a09b51b3 21 *
MACRUM 0:eaa7a09b51b3 22 * http://www.m-pression.com/ja/solutions/boards/uzuki-shield?p_auth=P2omuceK&p_p_id=82&p_p_lifecycle=1&p_p_state=normal&p_p_mode=view&_82_struts_action=%2Flanguage%2Fview&languageId=en_US
MACRUM 0:eaa7a09b51b3 23 *
MACRUM 0:eaa7a09b51b3 24 * ADXL345 : Accelerometer
MACRUM 0:eaa7a09b51b3 25 * Si7013 : Temperature & Humidity Sensor
MACRUM 0:eaa7a09b51b3 26 * Si1145 : Proximity, Luminescence & UV Level Sensor
MACRUM 0:eaa7a09b51b3 27 *
MACRUM 0:eaa7a09b51b3 28 */
MACRUM 0:eaa7a09b51b3 29
MACRUM 0:eaa7a09b51b3 30 #include "mbed.h"
MACRUM 0:eaa7a09b51b3 31 #include "ADXL345_I2C.h"
MACRUM 0:eaa7a09b51b3 32 #include "Si7020.h"
MACRUM 0:eaa7a09b51b3 33 #include "Si114x.h"
MACRUM 0:eaa7a09b51b3 34
MACRUM 0:eaa7a09b51b3 35 Serial pc(USBTX, USBRX);
MACRUM 0:eaa7a09b51b3 36 ADXL345_I2C adxl345(A4, A5);
MACRUM 0:eaa7a09b51b3 37 Si7020 si7013(A4, A5);
MACRUM 0:eaa7a09b51b3 38 Si114x si1145(A4, A5);
MACRUM 0:eaa7a09b51b3 39
MACRUM 0:eaa7a09b51b3 40 int main() {
MACRUM 0:eaa7a09b51b3 41 int buf[3];
MACRUM 0:eaa7a09b51b3 42 float humid, temp;
MACRUM 0:eaa7a09b51b3 43 float uv;
MACRUM 0:eaa7a09b51b3 44
MACRUM 0:eaa7a09b51b3 45 adxl345.setPowerControl(0x00);
MACRUM 0:eaa7a09b51b3 46 adxl345.setDataFormatControl(0x0B);
MACRUM 0:eaa7a09b51b3 47 adxl345.setDataRate(ADXL345_3200HZ);
MACRUM 0:eaa7a09b51b3 48 adxl345.setPowerControl(0x08);
MACRUM 0:eaa7a09b51b3 49
MACRUM 0:eaa7a09b51b3 50 while(si1145.verifyConnection() != 1);
MACRUM 0:eaa7a09b51b3 51
MACRUM 0:eaa7a09b51b3 52 while(1) {
MACRUM 0:eaa7a09b51b3 53 adxl345.getOutput(buf);
MACRUM 0:eaa7a09b51b3 54 pc.printf("ax: %-5d, ay: %-5d, az: %-5d\n", (int16_t)buf[0], (int16_t)buf[1], (int16_t)buf[2]);
MACRUM 0:eaa7a09b51b3 55
MACRUM 0:eaa7a09b51b3 56 si7013.getHumidity(&humid);
MACRUM 0:eaa7a09b51b3 57 si7013.getTemperature(&temp);
MACRUM 0:eaa7a09b51b3 58 pc.printf("Humidity: %6.2f%%, Temperature: %6.2fC\n", humid, temp);
MACRUM 0:eaa7a09b51b3 59
MACRUM 0:eaa7a09b51b3 60 uv = (float)si1145.getUVIndex()/100;
MACRUM 0:eaa7a09b51b3 61 pc.printf("Vis: %d, IR: %d, UV: %6.3f\n", si1145.getVisibleLight(), si1145.getIRLight(), uv);
MACRUM 0:eaa7a09b51b3 62
MACRUM 0:eaa7a09b51b3 63 pc.printf("\n");
MACRUM 0:eaa7a09b51b3 64 wait(1);
MACRUM 0:eaa7a09b51b3 65 }
MACRUM 0:eaa7a09b51b3 66 }