Exosite Collaberation ALS variable.
Dependencies: MbedJSONValue mbed mtsas
Fork of VVV_MultiTech_Dragonfly_ATT_Dallas by
main.cpp@7:dd550a829ece, 2015-12-11 (annotated)
- Committer:
- BlueShadow
- Date:
- Fri Dec 11 16:00:08 2015 +0000
- Revision:
- 7:dd550a829ece
- Parent:
- 6:7946b5c2376a
- Child:
- 8:e78dcfad254b
Dragonfly Class in Dallas 12/11/2015. Rohm Sensor board AT&T SIM
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mfiore | 0:a44e71488e1f | 1 | /************************************************************************* |
mfiore | 0:a44e71488e1f | 2 | * Dragonfly Example program for 2015 AT&T Government Solutions Hackathon |
BlueShadow | 6:7946b5c2376a | 3 | * |
mfiore | 0:a44e71488e1f | 4 | * The following hardware is required to successfully run this program: |
mfiore | 0:a44e71488e1f | 5 | * - MultiTech UDK2 (4" square white PCB with Arduino headers, antenna |
mfiore | 0:a44e71488e1f | 6 | * connector, micro USB ports, and 40-pin connector for Dragonfly) |
mfiore | 0:a44e71488e1f | 7 | * - MultiTech Dragonfly (1"x2" green PCB with Telit radio) |
mfiore | 0:a44e71488e1f | 8 | * - Seeed Studio Base Shield |
mfiore | 0:a44e71488e1f | 9 | * - Grove moisture sensor (to connect to Base Shield) |
mfiore | 0:a44e71488e1f | 10 | * - Grove button (to connect to Base Shield) |
mfiore | 0:a44e71488e1f | 11 | * - MEMs Inertial and Environmental Nucleo Expansion board (LSM6DS0 |
mfiore | 0:a44e71488e1f | 12 | * 3-axis accelerometer + 3-axis gyroscope, LIS3MDL 3-axis |
mfiore | 0:a44e71488e1f | 13 | * magnetometer, HTS221 humidity and temperature sensor and LPS25HB |
mfiore | 0:a44e71488e1f | 14 | * pressure sensor) |
mfiore | 0:a44e71488e1f | 15 | * |
mfiore | 0:a44e71488e1f | 16 | * What this program does: |
mfiore | 0:a44e71488e1f | 17 | * - reads data from all sensors on MEMs board and moisture sensor on a |
mfiore | 0:a44e71488e1f | 18 | * periodic basis |
mfiore | 0:a44e71488e1f | 19 | * - prints all sensor data to debug port on a periodic basis |
mfiore | 0:a44e71488e1f | 20 | * - optionally send a SMS containing sensor data when the Grove Button |
mfiore | 5:a946ef74a8c4 | 21 | * is pushed |
mfiore | 5:a946ef74a8c4 | 22 | * - you need to set the "phone_number" field |
mfiore | 4:730b61258422 | 23 | * - optionally sends sensor data to AT&T M2X cloud platform (user must |
mfiore | 4:730b61258422 | 24 | * create own M2X account and configure a device) |
mfiore | 5:a946ef74a8c4 | 25 | * - you need to set the "m2x_api_key" field and the "m2x_device_id" |
mfiore | 5:a946ef74a8c4 | 26 | * field based on your M2X account for this to work |
mfiore | 5:a946ef74a8c4 | 27 | * - you need to set the "do_cloud_post" flag to true for this to |
mfiore | 5:a946ef74a8c4 | 28 | * work |
mfiore | 0:a44e71488e1f | 29 | * |
mfiore | 0:a44e71488e1f | 30 | * Setup: |
mfiore | 0:a44e71488e1f | 31 | * - Correctly insert SIM card into Dragonfly |
mfiore | 0:a44e71488e1f | 32 | * - Seat the Dragonfly on the UDK2 board |
mfiore | 0:a44e71488e1f | 33 | * - Connect an antenna to the connector on the Dragonfly labled "M" |
mfiore | 0:a44e71488e1f | 34 | * - Stack the Base Shield on the UDK2 Arduino headers |
mfiore | 0:a44e71488e1f | 35 | * - Connect the Grove button to the D8 socket on the Base Shield |
mfiore | 0:a44e71488e1f | 36 | * - Connect the Grove moisture sensor to the A0 socket on the Base |
mfiore | 0:a44e71488e1f | 37 | * Shield |
mfiore | 3:f6bceb9e5e1a | 38 | * - Make sure the reference voltage selector switch (next to the A0 |
mfiore | 3:f6bceb9e5e1a | 39 | * socket) is switched to 5V so you get accurate analog readings |
mfiore | 0:a44e71488e1f | 40 | * - Stack the MEMs board on top of the Base Shield |
mfiore | 0:a44e71488e1f | 41 | * - Plug in the power cable |
mfiore | 0:a44e71488e1f | 42 | * - Plug a micro USB cable into the port below and slightly to the |
mfiore | 0:a44e71488e1f | 43 | * left of the Dragonfly (NOT the port on the Dragonfly) |
mfiore | 0:a44e71488e1f | 44 | * |
mfiore | 0:a44e71488e1f | 45 | * Go have fun and make something cool! |
mfiore | 0:a44e71488e1f | 46 | * |
mfiore | 0:a44e71488e1f | 47 | ************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 48 | /* |
BlueShadow | 6:7946b5c2376a | 49 | Sample Program Description: |
BlueShadow | 6:7946b5c2376a | 50 | This Program will enable to Multi-Tech Dragonfly platform to utilize ROHM's Multi-sensor Shield Board. |
BlueShadow | 6:7946b5c2376a | 51 | This program will initialize all sensors on the shield and then read back the sensor data. |
BlueShadow | 6:7946b5c2376a | 52 | Data will then be output to the UART Debug Terminal every 1 second. |
BlueShadow | 6:7946b5c2376a | 53 | |
BlueShadow | 6:7946b5c2376a | 54 | Sample Program Author: |
BlueShadow | 6:7946b5c2376a | 55 | ROHM USDC |
BlueShadow | 6:7946b5c2376a | 56 | |
BlueShadow | 6:7946b5c2376a | 57 | Additional Resources: |
BlueShadow | 6:7946b5c2376a | 58 | ROHM Sensor Shield GitHub Repository: https://github.com/ROHMUSDC/ROHM_SensorPlatform_Multi-Sensor-Shield |
BlueShadow | 6:7946b5c2376a | 59 | */ |
BlueShadow | 6:7946b5c2376a | 60 | |
BlueShadow | 6:7946b5c2376a | 61 | |
BlueShadow | 6:7946b5c2376a | 62 | |
mfiore | 0:a44e71488e1f | 63 | #include "mbed.h" |
mfiore | 0:a44e71488e1f | 64 | #include "mtsas.h" |
mfiore | 0:a44e71488e1f | 65 | #include "MbedJSONValue.h" |
mfiore | 5:a946ef74a8c4 | 66 | #include "HTTPJson.h" |
mfiore | 0:a44e71488e1f | 67 | #include <string> |
mfiore | 0:a44e71488e1f | 68 | |
mfiore | 0:a44e71488e1f | 69 | // Debug serial port |
mfiore | 0:a44e71488e1f | 70 | static Serial debug(USBTX, USBRX); |
mfiore | 0:a44e71488e1f | 71 | |
mfiore | 0:a44e71488e1f | 72 | // MTSSerialFlowControl - serial link between processor and radio |
mfiore | 1:a049d113e250 | 73 | static MTSSerialFlowControl* io; |
mfiore | 0:a44e71488e1f | 74 | |
mfiore | 0:a44e71488e1f | 75 | // Cellular - radio object for cellular operations (SMS, TCP, etc) |
mfiore | 0:a44e71488e1f | 76 | Cellular* radio; |
mfiore | 0:a44e71488e1f | 77 | |
mfiore | 0:a44e71488e1f | 78 | // APN associated with SIM card |
mfiore | 4:730b61258422 | 79 | // this APN should work for the AT&T SIM that came with your Dragonfly |
mfiore | 4:730b61258422 | 80 | //static const std::string apn = ""; |
BlueShadow | 7:dd550a829ece | 81 | static const std::string apn = ""; |
mfiore | 0:a44e71488e1f | 82 | |
mfiore | 0:a44e71488e1f | 83 | // Phone number to send SMS messages to |
mfiore | 5:a946ef74a8c4 | 84 | // just change the x digits - the 1 needs to stay! |
mfiore | 2:955a63247721 | 85 | static const std::string phone_number = "1xxxxxxxxxx"; |
mfiore | 0:a44e71488e1f | 86 | |
mfiore | 5:a946ef74a8c4 | 87 | // see https://m2x.att.com/developer/documentation/v2/overview for M2X API documentation |
mfiore | 5:a946ef74a8c4 | 88 | // M2X device ID |
mfiore | 4:730b61258422 | 89 | static const std::string m2x_device_id = ""; |
mfiore | 5:a946ef74a8c4 | 90 | |
mfiore | 5:a946ef74a8c4 | 91 | // M2X primary API key |
mfiore | 5:a946ef74a8c4 | 92 | static const std::string m2x_api_key = ""; |
mfiore | 5:a946ef74a8c4 | 93 | |
mfiore | 5:a946ef74a8c4 | 94 | // set to true if you want to post to the cloud |
mfiore | 5:a946ef74a8c4 | 95 | // you need to have you M2X account set up properly for this to work? |
mfiore | 5:a946ef74a8c4 | 96 | //bool do_cloud_post = false; |
mfiore | 5:a946ef74a8c4 | 97 | bool do_cloud_post = true; |
mfiore | 5:a946ef74a8c4 | 98 | |
mfiore | 5:a946ef74a8c4 | 99 | std::string url = "http://api-m2x.att.com/v2/devices/" + m2x_device_id + "/update"; |
mfiore | 4:730b61258422 | 100 | |
mfiore | 0:a44e71488e1f | 101 | |
mfiore | 0:a44e71488e1f | 102 | // variables for sensor data |
mfiore | 0:a44e71488e1f | 103 | float temp_celsius; |
mfiore | 0:a44e71488e1f | 104 | float humidity_percent; |
mfiore | 0:a44e71488e1f | 105 | float pressure_mbar; |
mfiore | 0:a44e71488e1f | 106 | float moisture_percent; |
mfiore | 0:a44e71488e1f | 107 | int32_t mag_mgauss[3]; |
mfiore | 0:a44e71488e1f | 108 | int32_t acc_mg[3]; |
mfiore | 0:a44e71488e1f | 109 | int32_t gyro_mdps[3]; |
mfiore | 0:a44e71488e1f | 110 | |
mfiore | 0:a44e71488e1f | 111 | // misc variables |
mfiore | 0:a44e71488e1f | 112 | static char wall_of_dash[] = "--------------------------------------------------"; |
mfiore | 0:a44e71488e1f | 113 | bool radio_ok = false; |
BlueShadow | 6:7946b5c2376a | 114 | static int thpm_interval_ms = 5000; |
BlueShadow | 6:7946b5c2376a | 115 | static int motion_interval_ms = 5000; |
BlueShadow | 6:7946b5c2376a | 116 | static int print_interval_ms = 5000; |
BlueShadow | 6:7946b5c2376a | 117 | static int sms_interval_ms = 60000; |
mfiore | 5:a946ef74a8c4 | 118 | static int post_interval_ms = 30000; |
mfiore | 0:a44e71488e1f | 119 | int debug_baud = 115200; |
mfiore | 0:a44e71488e1f | 120 | |
BlueShadow | 6:7946b5c2376a | 121 | |
BlueShadow | 6:7946b5c2376a | 122 | |
BlueShadow | 6:7946b5c2376a | 123 | |
BlueShadow | 6:7946b5c2376a | 124 | /**************************************************************************************************** |
BlueShadow | 6:7946b5c2376a | 125 | |
BlueShadow | 6:7946b5c2376a | 126 | ****************************************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 127 | |
BlueShadow | 6:7946b5c2376a | 128 | //Macros for checking each of the different Sensor Devices |
BlueShadow | 6:7946b5c2376a | 129 | #define AnalogTemp //BDE0600 |
BlueShadow | 6:7946b5c2376a | 130 | #define AnalogUV //ML8511 |
BlueShadow | 6:7946b5c2376a | 131 | #define HallSensor //BU52011 |
BlueShadow | 6:7946b5c2376a | 132 | #define RPR0521 //RPR0521 |
BlueShadow | 6:7946b5c2376a | 133 | #define KMX62 //KMX61, Accel/Mag |
BlueShadow | 6:7946b5c2376a | 134 | #define COLOR //BH1745 |
BlueShadow | 6:7946b5c2376a | 135 | #define KX022 //KX022, Accel Only |
BlueShadow | 6:7946b5c2376a | 136 | #define Pressure //BM1383 |
BlueShadow | 7:dd550a829ece | 137 | //#define SMS //allow SMS messaging |
BlueShadow | 7:dd550a829ece | 138 | //#define Web //allow M2X communication |
BlueShadow | 6:7946b5c2376a | 139 | |
BlueShadow | 6:7946b5c2376a | 140 | |
BlueShadow | 6:7946b5c2376a | 141 | //Define Pins for I2C Interface |
BlueShadow | 6:7946b5c2376a | 142 | I2C i2c(I2C_SDA, I2C_SCL); |
BlueShadow | 6:7946b5c2376a | 143 | bool RepStart = true; |
BlueShadow | 6:7946b5c2376a | 144 | bool NoRepStart = false; |
BlueShadow | 6:7946b5c2376a | 145 | |
BlueShadow | 6:7946b5c2376a | 146 | //Define Sensor Variables |
BlueShadow | 6:7946b5c2376a | 147 | #ifdef AnalogTemp |
BlueShadow | 6:7946b5c2376a | 148 | AnalogIn BDE0600_Temp(PC_4); //Mapped to A2 |
BlueShadow | 6:7946b5c2376a | 149 | uint16_t BDE0600_Temp_value; |
BlueShadow | 6:7946b5c2376a | 150 | float BDE0600_output; |
BlueShadow | 6:7946b5c2376a | 151 | #endif |
BlueShadow | 6:7946b5c2376a | 152 | |
BlueShadow | 6:7946b5c2376a | 153 | #ifdef AnalogUV |
BlueShadow | 6:7946b5c2376a | 154 | AnalogIn ML8511_UV(PC_1); //Mapped to A4 |
BlueShadow | 6:7946b5c2376a | 155 | uint16_t ML8511_UV_value; |
BlueShadow | 6:7946b5c2376a | 156 | float ML8511_output; |
BlueShadow | 6:7946b5c2376a | 157 | #endif |
BlueShadow | 6:7946b5c2376a | 158 | |
BlueShadow | 6:7946b5c2376a | 159 | #ifdef HallSensor |
BlueShadow | 6:7946b5c2376a | 160 | DigitalIn Hall_GPIO0(PC_8); |
BlueShadow | 6:7946b5c2376a | 161 | DigitalIn Hall_GPIO1(PB_5); |
BlueShadow | 6:7946b5c2376a | 162 | int Hall_Return1; |
BlueShadow | 6:7946b5c2376a | 163 | int Hall_Return0; |
BlueShadow | 6:7946b5c2376a | 164 | int32_t Hall_Return[2]; |
BlueShadow | 6:7946b5c2376a | 165 | #endif |
BlueShadow | 6:7946b5c2376a | 166 | |
BlueShadow | 6:7946b5c2376a | 167 | #ifdef RPR0521 |
BlueShadow | 6:7946b5c2376a | 168 | int RPR0521_addr_w = 0x70; //7bit addr = 0x38, with write bit 0 |
BlueShadow | 6:7946b5c2376a | 169 | int RPR0521_addr_r = 0x71; //7bit addr = 0x38, with read bit 1 |
BlueShadow | 6:7946b5c2376a | 170 | char RPR0521_ModeControl[2] = {0x41, 0xE6}; |
BlueShadow | 6:7946b5c2376a | 171 | char RPR0521_ALSPSControl[2] = {0x42, 0x03}; |
BlueShadow | 6:7946b5c2376a | 172 | char RPR0521_Persist[2] = {0x43, 0x20}; |
BlueShadow | 6:7946b5c2376a | 173 | char RPR0521_Addr_ReadData = 0x44; |
BlueShadow | 6:7946b5c2376a | 174 | char RPR0521_Content_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 175 | int RPR0521_PS_RAWOUT = 0; //this is an output |
BlueShadow | 6:7946b5c2376a | 176 | float RPR0521_PS_OUT = 0; |
BlueShadow | 6:7946b5c2376a | 177 | int RPR0521_ALS_D0_RAWOUT = 0; |
BlueShadow | 6:7946b5c2376a | 178 | int RPR0521_ALS_D1_RAWOUT = 0; |
BlueShadow | 6:7946b5c2376a | 179 | float RPR0521_ALS_DataRatio = 0; |
BlueShadow | 6:7946b5c2376a | 180 | float RPR0521_ALS_OUT = 0; //this is an output |
BlueShadow | 6:7946b5c2376a | 181 | float RPR0521_ALS[2]; // is this ok taking an int to the [0] value and float to [1]??????????? |
BlueShadow | 6:7946b5c2376a | 182 | #endif |
BlueShadow | 6:7946b5c2376a | 183 | |
BlueShadow | 6:7946b5c2376a | 184 | #ifdef KMX62 |
BlueShadow | 6:7946b5c2376a | 185 | int KMX62_addr_w = 0x1C; //7bit addr = 0x38, with write bit 0 |
BlueShadow | 6:7946b5c2376a | 186 | int KMX62_addr_r = 0x1D; //7bit addr = 0x38, with read bit 1 |
BlueShadow | 6:7946b5c2376a | 187 | char KMX62_CNTL2[2] = {0x3A, 0x5F}; |
BlueShadow | 6:7946b5c2376a | 188 | char KMX62_Addr_Accel_ReadData = 0x0A; |
BlueShadow | 6:7946b5c2376a | 189 | char KMX62_Content_Accel_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 190 | char KMX62_Addr_Mag_ReadData = 0x10; |
BlueShadow | 6:7946b5c2376a | 191 | char KMX62_Content_Mag_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 192 | short int MEMS_Accel_Xout = 0; |
BlueShadow | 6:7946b5c2376a | 193 | short int MEMS_Accel_Yout = 0; |
BlueShadow | 6:7946b5c2376a | 194 | short int MEMS_Accel_Zout = 0; |
BlueShadow | 6:7946b5c2376a | 195 | double MEMS_Accel_Conv_Xout = 0; |
BlueShadow | 6:7946b5c2376a | 196 | double MEMS_Accel_Conv_Yout = 0; |
BlueShadow | 6:7946b5c2376a | 197 | double MEMS_Accel_Conv_Zout = 0; |
BlueShadow | 6:7946b5c2376a | 198 | |
BlueShadow | 6:7946b5c2376a | 199 | short int MEMS_Mag_Xout = 0; |
BlueShadow | 6:7946b5c2376a | 200 | short int MEMS_Mag_Yout = 0; |
BlueShadow | 6:7946b5c2376a | 201 | short int MEMS_Mag_Zout = 0; |
BlueShadow | 6:7946b5c2376a | 202 | float MEMS_Mag_Conv_Xout = 0; |
BlueShadow | 6:7946b5c2376a | 203 | float MEMS_Mag_Conv_Yout = 0; |
BlueShadow | 6:7946b5c2376a | 204 | float MEMS_Mag_Conv_Zout = 0; |
BlueShadow | 6:7946b5c2376a | 205 | |
BlueShadow | 6:7946b5c2376a | 206 | double MEMS_Accel[3]; |
BlueShadow | 6:7946b5c2376a | 207 | float MEMS_Mag[3]; |
BlueShadow | 6:7946b5c2376a | 208 | #endif |
BlueShadow | 6:7946b5c2376a | 209 | |
BlueShadow | 6:7946b5c2376a | 210 | #ifdef COLOR |
BlueShadow | 6:7946b5c2376a | 211 | int BH1745_addr_w = 0x72; //write |
BlueShadow | 6:7946b5c2376a | 212 | int BH1745_addr_r = 0x73; //read |
BlueShadow | 6:7946b5c2376a | 213 | char BH1745_persistence[2] = {0x61, 0x03}; |
BlueShadow | 6:7946b5c2376a | 214 | char BH1745_mode1[2] = {0x41, 0x00}; |
BlueShadow | 6:7946b5c2376a | 215 | char BH1745_mode2[2] = {0x42, 0x92}; |
BlueShadow | 6:7946b5c2376a | 216 | char BH1745_mode3[2] = {0x43, 0x02}; |
BlueShadow | 6:7946b5c2376a | 217 | char BH1745_Content_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 218 | char BH1745_Addr_color_ReadData = 0x50; |
BlueShadow | 6:7946b5c2376a | 219 | int BH1745_Red; |
BlueShadow | 6:7946b5c2376a | 220 | int BH1745_Blue; |
BlueShadow | 6:7946b5c2376a | 221 | int BH1745_Green; |
BlueShadow | 6:7946b5c2376a | 222 | int32_t BH1745[3]; //Red, Blue Green matrix |
BlueShadow | 6:7946b5c2376a | 223 | #endif |
BlueShadow | 6:7946b5c2376a | 224 | |
BlueShadow | 6:7946b5c2376a | 225 | #ifdef KX022 |
BlueShadow | 6:7946b5c2376a | 226 | int KX022_addr_w = 0x3C; //write |
BlueShadow | 6:7946b5c2376a | 227 | int KX022_addr_r = 0x3D; //read |
BlueShadow | 6:7946b5c2376a | 228 | char KX022_Accel_CNTL1[2] = {0x18, 0x41}; |
BlueShadow | 6:7946b5c2376a | 229 | char KX022_Accel_ODCNTL[2] = {0x1B, 0x02}; |
BlueShadow | 6:7946b5c2376a | 230 | char KX022_Accel_CNTL3[2] = {0x1A, 0xD8}; |
BlueShadow | 6:7946b5c2376a | 231 | char KX022_Accel_TILT_TIMER[2] = {0x22, 0x01}; |
BlueShadow | 6:7946b5c2376a | 232 | char KX022_Accel_CNTL2[2] = {0x18, 0xC1}; |
BlueShadow | 6:7946b5c2376a | 233 | char KX022_Content_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 234 | char KX022_Addr_Accel_ReadData = 0x06; |
BlueShadow | 6:7946b5c2376a | 235 | float KX022_Accel_X; |
BlueShadow | 6:7946b5c2376a | 236 | float KX022_Accel_Y; |
BlueShadow | 6:7946b5c2376a | 237 | float KX022_Accel_Z; |
BlueShadow | 6:7946b5c2376a | 238 | short int KX022_Accel_X_RawOUT = 0; |
BlueShadow | 6:7946b5c2376a | 239 | short int KX022_Accel_Y_RawOUT = 0; |
BlueShadow | 6:7946b5c2376a | 240 | short int KX022_Accel_Z_RawOUT = 0; |
BlueShadow | 6:7946b5c2376a | 241 | int KX022_Accel_X_LB = 0; |
BlueShadow | 6:7946b5c2376a | 242 | int KX022_Accel_X_HB = 0; |
BlueShadow | 6:7946b5c2376a | 243 | int KX022_Accel_Y_LB = 0; |
BlueShadow | 6:7946b5c2376a | 244 | int KX022_Accel_Y_HB = 0; |
BlueShadow | 6:7946b5c2376a | 245 | int KX022_Accel_Z_LB = 0; |
BlueShadow | 6:7946b5c2376a | 246 | int KX022_Accel_Z_HB = 0; |
BlueShadow | 6:7946b5c2376a | 247 | float KX022_Accel[3]; |
BlueShadow | 6:7946b5c2376a | 248 | #endif |
BlueShadow | 6:7946b5c2376a | 249 | |
BlueShadow | 6:7946b5c2376a | 250 | #ifdef Pressure |
BlueShadow | 6:7946b5c2376a | 251 | int Press_addr_w = 0xBA; //write |
BlueShadow | 6:7946b5c2376a | 252 | int Press_addr_r = 0xBB; //read |
BlueShadow | 6:7946b5c2376a | 253 | char PWR_DOWN[2] = {0x12, 0x01}; |
BlueShadow | 6:7946b5c2376a | 254 | char SLEEP[2] = {0x13, 0x01}; |
BlueShadow | 6:7946b5c2376a | 255 | char Mode_Control[2] = {0x14, 0xC4}; |
BlueShadow | 6:7946b5c2376a | 256 | char Press_Content_ReadData[6]; |
BlueShadow | 6:7946b5c2376a | 257 | char Press_Addr_ReadData =0x1A; |
BlueShadow | 6:7946b5c2376a | 258 | int BM1383_Temp_highByte; |
BlueShadow | 6:7946b5c2376a | 259 | int BM1383_Temp_lowByte; |
BlueShadow | 6:7946b5c2376a | 260 | int BM1383_Pres_highByte; |
BlueShadow | 6:7946b5c2376a | 261 | int BM1383_Pres_lowByte; |
BlueShadow | 6:7946b5c2376a | 262 | int BM1383_Pres_leastByte; |
BlueShadow | 6:7946b5c2376a | 263 | short int BM1383_Temp_Out; |
BlueShadow | 6:7946b5c2376a | 264 | float BM1383_Temp_Conv_Out; |
BlueShadow | 6:7946b5c2376a | 265 | float BM1383_Pres_Conv_Out; |
BlueShadow | 6:7946b5c2376a | 266 | float_t BM1383[2]; // Temp is 0 and Pressure is 1 |
BlueShadow | 6:7946b5c2376a | 267 | float BM1383_Var; |
BlueShadow | 6:7946b5c2376a | 268 | float BM1383_Deci; |
BlueShadow | 6:7946b5c2376a | 269 | #endif |
BlueShadow | 6:7946b5c2376a | 270 | |
BlueShadow | 6:7946b5c2376a | 271 | /**************************************************************************************************** |
mfiore | 0:a44e71488e1f | 272 | // function prototypes |
BlueShadow | 6:7946b5c2376a | 273 | ****************************************************************************************************/ |
mfiore | 0:a44e71488e1f | 274 | bool init_mtsas(); |
BlueShadow | 6:7946b5c2376a | 275 | void ReadAnalogTemp(); |
BlueShadow | 6:7946b5c2376a | 276 | void ReadAnalogUV (); |
BlueShadow | 6:7946b5c2376a | 277 | void ReadHallSensor (); |
BlueShadow | 6:7946b5c2376a | 278 | void ReadCOLOR (); |
BlueShadow | 6:7946b5c2376a | 279 | void ReadRPR0521_ALS (); |
BlueShadow | 6:7946b5c2376a | 280 | void ReadKMX62_Accel (); |
BlueShadow | 6:7946b5c2376a | 281 | void ReadKMX62_Mag (); |
BlueShadow | 6:7946b5c2376a | 282 | void ReadPressure (); |
BlueShadow | 6:7946b5c2376a | 283 | void ReadKX022(); |
mfiore | 0:a44e71488e1f | 284 | |
BlueShadow | 6:7946b5c2376a | 285 | /**************************************************************************************************** |
mfiore | 0:a44e71488e1f | 286 | // main |
BlueShadow | 6:7946b5c2376a | 287 | ****************************************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 288 | int main() |
BlueShadow | 6:7946b5c2376a | 289 | { |
mfiore | 0:a44e71488e1f | 290 | mts::MTSLog::setLogLevel(mts::MTSLog::TRACE_LEVEL); |
mfiore | 0:a44e71488e1f | 291 | debug.baud(debug_baud); |
mfiore | 0:a44e71488e1f | 292 | logInfo("starting..."); |
BlueShadow | 6:7946b5c2376a | 293 | |
BlueShadow | 6:7946b5c2376a | 294 | |
BlueShadow | 6:7946b5c2376a | 295 | /**************************************************************************************************** |
BlueShadow | 6:7946b5c2376a | 296 | Initialize I2C Devices ************ |
BlueShadow | 6:7946b5c2376a | 297 | ****************************************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 298 | |
BlueShadow | 6:7946b5c2376a | 299 | #ifdef RPR0521 |
BlueShadow | 6:7946b5c2376a | 300 | i2c.write(RPR0521_addr_w, &RPR0521_ModeControl[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 301 | i2c.write(RPR0521_addr_w, &RPR0521_ALSPSControl[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 302 | i2c.write(RPR0521_addr_w, &RPR0521_Persist[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 303 | #endif |
BlueShadow | 6:7946b5c2376a | 304 | |
BlueShadow | 6:7946b5c2376a | 305 | #ifdef KMX62 |
BlueShadow | 6:7946b5c2376a | 306 | i2c.write(KMX62_addr_w, &KMX62_CNTL2[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 307 | #endif |
BlueShadow | 6:7946b5c2376a | 308 | |
BlueShadow | 6:7946b5c2376a | 309 | #ifdef COLOR |
BlueShadow | 6:7946b5c2376a | 310 | i2c.write(BH1745_addr_w, &BH1745_persistence[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 311 | i2c.write(BH1745_addr_w, &BH1745_mode1[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 312 | i2c.write(BH1745_addr_w, &BH1745_mode2[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 313 | i2c.write(BH1745_addr_w, &BH1745_mode3[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 314 | #endif |
BlueShadow | 6:7946b5c2376a | 315 | |
BlueShadow | 6:7946b5c2376a | 316 | #ifdef KX022 |
BlueShadow | 6:7946b5c2376a | 317 | i2c.write(KX022_addr_w, &KX022_Accel_CNTL1[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 318 | i2c.write(KX022_addr_w, &KX022_Accel_ODCNTL[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 319 | i2c.write(KX022_addr_w, &KX022_Accel_CNTL3[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 320 | i2c.write(KX022_addr_w, &KX022_Accel_TILT_TIMER[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 321 | i2c.write(KX022_addr_w, &KX022_Accel_CNTL2[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 322 | #endif |
BlueShadow | 6:7946b5c2376a | 323 | |
BlueShadow | 6:7946b5c2376a | 324 | #ifdef Pressure |
BlueShadow | 6:7946b5c2376a | 325 | i2c.write(Press_addr_w, &PWR_DOWN[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 326 | i2c.write(Press_addr_w, &SLEEP[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 327 | i2c.write(Press_addr_w, &Mode_Control[0], 2, false); |
BlueShadow | 6:7946b5c2376a | 328 | #endif |
BlueShadow | 6:7946b5c2376a | 329 | //End I2C Initialization Section ********************************************************** |
BlueShadow | 6:7946b5c2376a | 330 | |
BlueShadow | 6:7946b5c2376a | 331 | |
BlueShadow | 6:7946b5c2376a | 332 | // Initialization Radio Section ********************************************************** |
BlueShadow | 6:7946b5c2376a | 333 | |
mfiore | 0:a44e71488e1f | 334 | radio_ok = init_mtsas(); |
mfiore | 0:a44e71488e1f | 335 | if (! radio_ok) |
mfiore | 0:a44e71488e1f | 336 | logError("MTSAS init failed"); |
mfiore | 0:a44e71488e1f | 337 | else |
mfiore | 0:a44e71488e1f | 338 | logInfo("MTSAS is ok"); |
BlueShadow | 6:7946b5c2376a | 339 | |
BlueShadow | 6:7946b5c2376a | 340 | //End Radio Initialization Section ********************************************************** |
BlueShadow | 6:7946b5c2376a | 341 | |
BlueShadow | 6:7946b5c2376a | 342 | // button.fall(&button_irq); |
BlueShadow | 6:7946b5c2376a | 343 | |
BlueShadow | 6:7946b5c2376a | 344 | |
mfiore | 3:f6bceb9e5e1a | 345 | Timer thpm_timer; |
BlueShadow | 6:7946b5c2376a | 346 | thpm_timer.start(); // Timer data is set in the Variable seciton see misc variables Timer motion_timer; |
mfiore | 1:a049d113e250 | 347 | Timer print_timer; |
BlueShadow | 6:7946b5c2376a | 348 | print_timer.start(); |
BlueShadow | 6:7946b5c2376a | 349 | Timer motion_timer; |
BlueShadow | 6:7946b5c2376a | 350 | motion_timer.start(); |
BlueShadow | 6:7946b5c2376a | 351 | |
BlueShadow | 6:7946b5c2376a | 352 | #ifdef SMS |
BlueShadow | 6:7946b5c2376a | 353 | Timer sms_timer; |
BlueShadow | 6:7946b5c2376a | 354 | sms_timer.start(); |
BlueShadow | 6:7946b5c2376a | 355 | #endif |
BlueShadow | 6:7946b5c2376a | 356 | #ifdef Web |
mfiore | 4:730b61258422 | 357 | Timer post_timer; |
mfiore | 4:730b61258422 | 358 | post_timer.start(); |
BlueShadow | 6:7946b5c2376a | 359 | #endif |
mfiore | 1:a049d113e250 | 360 | |
mfiore | 0:a44e71488e1f | 361 | while (true) { |
BlueShadow | 6:7946b5c2376a | 362 | if (thpm_timer.read_ms() > thpm_interval_ms) { |
BlueShadow | 6:7946b5c2376a | 363 | #ifdef AnalogTemp |
BlueShadow | 6:7946b5c2376a | 364 | ReadAnalogTemp (); |
BlueShadow | 6:7946b5c2376a | 365 | #endif |
BlueShadow | 6:7946b5c2376a | 366 | |
BlueShadow | 6:7946b5c2376a | 367 | #ifdef AnalogUV |
BlueShadow | 6:7946b5c2376a | 368 | ReadAnalogUV (); |
BlueShadow | 6:7946b5c2376a | 369 | #endif |
BlueShadow | 6:7946b5c2376a | 370 | |
BlueShadow | 6:7946b5c2376a | 371 | #ifdef HallSensor |
BlueShadow | 6:7946b5c2376a | 372 | ReadHallSensor (); |
BlueShadow | 6:7946b5c2376a | 373 | #endif |
BlueShadow | 6:7946b5c2376a | 374 | |
BlueShadow | 6:7946b5c2376a | 375 | #ifdef COLOR |
BlueShadow | 6:7946b5c2376a | 376 | ReadCOLOR (); |
BlueShadow | 6:7946b5c2376a | 377 | #endif |
BlueShadow | 6:7946b5c2376a | 378 | |
BlueShadow | 6:7946b5c2376a | 379 | #ifdef RPR0521 //als digital |
BlueShadow | 6:7946b5c2376a | 380 | ReadRPR0521_ALS (); |
BlueShadow | 6:7946b5c2376a | 381 | #endif |
BlueShadow | 6:7946b5c2376a | 382 | |
BlueShadow | 6:7946b5c2376a | 383 | #ifdef Pressure |
BlueShadow | 6:7946b5c2376a | 384 | ReadPressure(); |
BlueShadow | 6:7946b5c2376a | 385 | #endif |
BlueShadow | 6:7946b5c2376a | 386 | thpm_timer.reset(); |
BlueShadow | 6:7946b5c2376a | 387 | } |
BlueShadow | 6:7946b5c2376a | 388 | |
mfiore | 0:a44e71488e1f | 389 | if (motion_timer.read_ms() > motion_interval_ms) { |
BlueShadow | 6:7946b5c2376a | 390 | #ifdef KMX62 |
BlueShadow | 6:7946b5c2376a | 391 | ReadKMX62_Accel (); |
BlueShadow | 6:7946b5c2376a | 392 | ReadKMX62_Mag (); |
BlueShadow | 6:7946b5c2376a | 393 | #endif |
BlueShadow | 6:7946b5c2376a | 394 | |
BlueShadow | 6:7946b5c2376a | 395 | #ifdef KX022 |
BlueShadow | 6:7946b5c2376a | 396 | ReadKX022 (); |
BlueShadow | 6:7946b5c2376a | 397 | #endif |
mfiore | 0:a44e71488e1f | 398 | motion_timer.reset(); |
mfiore | 0:a44e71488e1f | 399 | } |
BlueShadow | 6:7946b5c2376a | 400 | |
mfiore | 0:a44e71488e1f | 401 | if (print_timer.read_ms() > print_interval_ms) { |
mfiore | 0:a44e71488e1f | 402 | logDebug("%s", wall_of_dash); |
mfiore | 0:a44e71488e1f | 403 | logDebug("SENSOR DATA"); |
BlueShadow | 6:7946b5c2376a | 404 | logDebug("temperature: %0.2f C", BM1383[0]); |
BlueShadow | 6:7946b5c2376a | 405 | logDebug("analog uv: %.1f mW/cm2", ML8511_output); |
BlueShadow | 6:7946b5c2376a | 406 | logDebug("ambient Light %0.3f", RPR0521_ALS[0]); |
BlueShadow | 6:7946b5c2376a | 407 | logDebug("proximity count %0.3f", RPR0521_ALS[1]); |
BlueShadow | 6:7946b5c2376a | 408 | logDebug("hall effect: South %d\t North %d", Hall_Return[0],Hall_Return[1]); |
BlueShadow | 6:7946b5c2376a | 409 | logDebug("pressure: %0.2f hPa", BM1383[1]); |
BlueShadow | 6:7946b5c2376a | 410 | logDebug("magnetometer:\r\n\tx: %0.3f\ty: %0.3f\tz: %0.3f\tuT", MEMS_Mag[0], MEMS_Mag[1], MEMS_Mag[2]); |
BlueShadow | 6:7946b5c2376a | 411 | logDebug("accelerometer:\r\n\tx: %0.3f\ty: %0.3f\tz: %0.3f\tg", MEMS_Accel[0], MEMS_Accel[1], MEMS_Accel[2]); |
BlueShadow | 6:7946b5c2376a | 412 | logDebug("color:\r\n\tred: %ld\tgrn: %ld\tblu: %ld\t", BH1745[0], BH1745[1], BH1745[2]); |
mfiore | 0:a44e71488e1f | 413 | logDebug("%s", wall_of_dash); |
mfiore | 0:a44e71488e1f | 414 | print_timer.reset(); |
mfiore | 0:a44e71488e1f | 415 | } |
BlueShadow | 6:7946b5c2376a | 416 | |
BlueShadow | 6:7946b5c2376a | 417 | |
BlueShadow | 6:7946b5c2376a | 418 | |
BlueShadow | 6:7946b5c2376a | 419 | #ifdef SMS |
BlueShadow | 6:7946b5c2376a | 420 | if (sms_timer.read_ms() > sms_interval_ms) { |
BlueShadow | 6:7946b5c2376a | 421 | sms_timer.reset(); |
BlueShadow | 6:7946b5c2376a | 422 | logInfo("SMS Send Routine"); |
BlueShadow | 6:7946b5c2376a | 423 | printf(" In sms routine \r\n"); |
mfiore | 0:a44e71488e1f | 424 | if (radio_ok) { |
mfiore | 0:a44e71488e1f | 425 | MbedJSONValue sms_json; |
mfiore | 0:a44e71488e1f | 426 | string sms_str; |
BlueShadow | 6:7946b5c2376a | 427 | |
BlueShadow | 6:7946b5c2376a | 428 | // sms_json["temp_C"] = BDE0600_output; |
BlueShadow | 6:7946b5c2376a | 429 | // sms_json["UV"] = ML8511_output; |
BlueShadow | 6:7946b5c2376a | 430 | sms_json["Ambient Light"] = RPR0521_ALS[0]; |
BlueShadow | 6:7946b5c2376a | 431 | sms_json["Prox"] = RPR0521_ALS[1]; |
BlueShadow | 6:7946b5c2376a | 432 | // sms_json["pressure_hPa"] = BM1383[1]; |
BlueShadow | 6:7946b5c2376a | 433 | // sms_json["mag_mgauss"]["x"] = MEMS_Mag[0]; |
BlueShadow | 6:7946b5c2376a | 434 | // sms_json["mag_mgauss"]["y"] = MEMS_Mag[1]; |
BlueShadow | 6:7946b5c2376a | 435 | // sms_json["mag_mgauss"]["z"] = MEMS_Mag[2]; |
BlueShadow | 6:7946b5c2376a | 436 | // sms_json["acc_mg"]["x"] = MEMS_Accel[0]; |
BlueShadow | 6:7946b5c2376a | 437 | // sms_json["acc_mg"]["y"] = MEMS_Accel[1]; |
BlueShadow | 6:7946b5c2376a | 438 | // sms_json["acc_mg"]["z"] = MEMS_Accel[2]; |
BlueShadow | 6:7946b5c2376a | 439 | // sms_json["Red"] = BH1745[0]; |
BlueShadow | 6:7946b5c2376a | 440 | // sms_json["Green"] = BH1745[1]; |
BlueShadow | 6:7946b5c2376a | 441 | // sms_json["Blue"] = BH1745[2]; |
BlueShadow | 6:7946b5c2376a | 442 | |
mfiore | 2:955a63247721 | 443 | sms_str = "SENSOR DATA:\n"; |
mfiore | 0:a44e71488e1f | 444 | sms_str += sms_json.serialize(); |
BlueShadow | 6:7946b5c2376a | 445 | |
mfiore | 0:a44e71488e1f | 446 | logDebug("sending SMS to %s:\r\n%s", phone_number.c_str(), sms_str.c_str()); |
mfiore | 0:a44e71488e1f | 447 | Code ret = radio->sendSMS(phone_number, sms_str); |
mfiore | 0:a44e71488e1f | 448 | if (ret != MTS_SUCCESS) |
mfiore | 0:a44e71488e1f | 449 | logError("sending SMS failed"); |
mfiore | 0:a44e71488e1f | 450 | } |
mfiore | 0:a44e71488e1f | 451 | } |
BlueShadow | 6:7946b5c2376a | 452 | #endif |
BlueShadow | 6:7946b5c2376a | 453 | #ifdef Web |
mfiore | 4:730b61258422 | 454 | if (post_timer.read_ms() > post_interval_ms && do_cloud_post) { |
BlueShadow | 6:7946b5c2376a | 455 | printf("in web\n\r"); |
mfiore | 4:730b61258422 | 456 | if (radio->connect()) { |
mfiore | 4:730b61258422 | 457 | logDebug("posting sensor data"); |
mfiore | 5:a946ef74a8c4 | 458 | |
mfiore | 5:a946ef74a8c4 | 459 | HTTPClient http; |
mfiore | 5:a946ef74a8c4 | 460 | MbedJSONValue http_json_data; |
mfiore | 5:a946ef74a8c4 | 461 | std::string http_json_str; |
mfiore | 5:a946ef74a8c4 | 462 | std::string m2x_header = "X-M2X-KEY: " + m2x_api_key + "\r\n"; |
mfiore | 5:a946ef74a8c4 | 463 | int ret; |
mfiore | 5:a946ef74a8c4 | 464 | char http_response_buf[256]; |
mfiore | 5:a946ef74a8c4 | 465 | HTTPText http_response(http_response_buf, sizeof(http_response_buf)); |
BlueShadow | 6:7946b5c2376a | 466 | |
mfiore | 5:a946ef74a8c4 | 467 | // temp_c, temp_f, humidity, pressure, and moisture are all stream IDs for my device in M2X |
mfiore | 5:a946ef74a8c4 | 468 | // modify these to match your streams or give your streams the same name |
BlueShadow | 6:7946b5c2376a | 469 | http_json_data["values"]["temp_c"] = BDE0600_output; |
BlueShadow | 6:7946b5c2376a | 470 | http_json_data["values"]["UV"] = ML8511_output; |
BlueShadow | 6:7946b5c2376a | 471 | http_json_data["values"]["Ambient Light"] = RPR0521_ALS[0]; |
BlueShadow | 6:7946b5c2376a | 472 | http_json_data["values"]["Prox"] = RPR0521_ALS[1]; |
mfiore | 5:a946ef74a8c4 | 473 | http_json_str = http_json_data.serialize(); |
BlueShadow | 6:7946b5c2376a | 474 | |
mfiore | 5:a946ef74a8c4 | 475 | // add extra header with M2X API key |
mfiore | 5:a946ef74a8c4 | 476 | http.setHeader(m2x_header.c_str()); |
BlueShadow | 6:7946b5c2376a | 477 | |
mfiore | 5:a946ef74a8c4 | 478 | HTTPJson http_json((char*) http_json_str.c_str()); |
mfiore | 5:a946ef74a8c4 | 479 | ret = http.post(url.c_str(), http_json, &http_response); |
mfiore | 5:a946ef74a8c4 | 480 | if (ret != HTTP_OK) |
mfiore | 5:a946ef74a8c4 | 481 | logError("posting data to cloud failed: [%d][%s]", ret, http_response_buf); |
mfiore | 5:a946ef74a8c4 | 482 | else |
mfiore | 5:a946ef74a8c4 | 483 | logDebug("post result [%d][%s]", http.getHTTPResponseCode(), http_response_buf); |
BlueShadow | 6:7946b5c2376a | 484 | |
mfiore | 4:730b61258422 | 485 | radio->disconnect(); |
mfiore | 4:730b61258422 | 486 | } else { |
mfiore | 4:730b61258422 | 487 | logError("establishing PPP link failed"); |
mfiore | 4:730b61258422 | 488 | } |
BlueShadow | 6:7946b5c2376a | 489 | |
mfiore | 4:730b61258422 | 490 | post_timer.reset(); |
mfiore | 4:730b61258422 | 491 | } |
BlueShadow | 6:7946b5c2376a | 492 | #endif |
mfiore | 1:a049d113e250 | 493 | wait_ms(10); |
mfiore | 0:a44e71488e1f | 494 | } |
mfiore | 0:a44e71488e1f | 495 | } |
mfiore | 0:a44e71488e1f | 496 | |
mfiore | 1:a049d113e250 | 497 | // init functions |
BlueShadow | 6:7946b5c2376a | 498 | bool init_mtsas() |
BlueShadow | 6:7946b5c2376a | 499 | { |
mfiore | 1:a049d113e250 | 500 | io = new MTSSerialFlowControl(RADIO_TX, RADIO_RX, RADIO_RTS, RADIO_CTS); |
mfiore | 1:a049d113e250 | 501 | if (! io) |
mfiore | 1:a049d113e250 | 502 | return false; |
BlueShadow | 6:7946b5c2376a | 503 | |
mfiore | 1:a049d113e250 | 504 | io->baud(115200); |
mfiore | 1:a049d113e250 | 505 | radio = CellularFactory::create(io); |
mfiore | 1:a049d113e250 | 506 | if (! radio) |
mfiore | 1:a049d113e250 | 507 | return false; |
BlueShadow | 6:7946b5c2376a | 508 | |
mfiore | 1:a049d113e250 | 509 | Code ret = radio->setApn(apn); |
mfiore | 1:a049d113e250 | 510 | if (ret != MTS_SUCCESS) |
mfiore | 1:a049d113e250 | 511 | return false; |
BlueShadow | 6:7946b5c2376a | 512 | |
mfiore | 5:a946ef74a8c4 | 513 | Transport::setTransport(radio); |
BlueShadow | 6:7946b5c2376a | 514 | |
mfiore | 1:a049d113e250 | 515 | return true; |
mfiore | 1:a049d113e250 | 516 | } |
mfiore | 1:a049d113e250 | 517 | |
BlueShadow | 6:7946b5c2376a | 518 | |
mfiore | 0:a44e71488e1f | 519 | // Sensor data acquisition functions |
BlueShadow | 6:7946b5c2376a | 520 | /************************************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 521 | #ifdef AnalogTemp |
BlueShadow | 6:7946b5c2376a | 522 | void ReadAnalogTemp () |
BlueShadow | 6:7946b5c2376a | 523 | { |
BlueShadow | 6:7946b5c2376a | 524 | BDE0600_Temp_value = BDE0600_Temp.read_u16(); |
BlueShadow | 6:7946b5c2376a | 525 | |
BlueShadow | 6:7946b5c2376a | 526 | BDE0600_output = (float)BDE0600_Temp_value * (float)0.000050354; //(value * (3.3V/65535)) |
BlueShadow | 6:7946b5c2376a | 527 | BDE0600_output = (BDE0600_output-(float)1.753)/((float)-0.01068) + (float)30; |
BlueShadow | 6:7946b5c2376a | 528 | |
BlueShadow | 6:7946b5c2376a | 529 | // printf("BDE0600 Analog Temp Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 530 | // printf(" Temp = %.2f C\r\n", BDE0600_output); |
BlueShadow | 6:7946b5c2376a | 531 | } |
BlueShadow | 6:7946b5c2376a | 532 | #endif |
BlueShadow | 6:7946b5c2376a | 533 | |
BlueShadow | 6:7946b5c2376a | 534 | #ifdef AnalogUV |
BlueShadow | 6:7946b5c2376a | 535 | void ReadAnalogUV () |
BlueShadow | 6:7946b5c2376a | 536 | { |
BlueShadow | 6:7946b5c2376a | 537 | ML8511_UV_value = ML8511_UV.read_u16(); |
BlueShadow | 6:7946b5c2376a | 538 | ML8511_output = (float)ML8511_UV_value * (float)0.000050354; //(value * (3.3V/65535)) //Note to self: when playing with this, a negative value is seen... Honestly, I think this has to do with my ADC converstion... |
BlueShadow | 6:7946b5c2376a | 539 | ML8511_output = (ML8511_output-(float)2.2)/((float)0.129) + 10; // Added +5 to the offset so when inside (aka, no UV, readings show 0)... this is the wrong approach... and the readings don't make sense... Fix this. |
BlueShadow | 6:7946b5c2376a | 540 | |
BlueShadow | 6:7946b5c2376a | 541 | // printf("ML8511 Analog UV Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 542 | // printf(" UV = %.1f mW/cm2\r\n", ML8511_output); |
BlueShadow | 6:7946b5c2376a | 543 | |
BlueShadow | 6:7946b5c2376a | 544 | } |
BlueShadow | 6:7946b5c2376a | 545 | #endif |
BlueShadow | 6:7946b5c2376a | 546 | |
BlueShadow | 6:7946b5c2376a | 547 | |
BlueShadow | 6:7946b5c2376a | 548 | #ifdef HallSensor |
BlueShadow | 6:7946b5c2376a | 549 | void ReadHallSensor () |
BlueShadow | 6:7946b5c2376a | 550 | { |
BlueShadow | 6:7946b5c2376a | 551 | |
BlueShadow | 6:7946b5c2376a | 552 | Hall_Return[0] = Hall_GPIO0; |
BlueShadow | 6:7946b5c2376a | 553 | Hall_Return[1] = Hall_GPIO1; |
BlueShadow | 6:7946b5c2376a | 554 | |
BlueShadow | 6:7946b5c2376a | 555 | // printf("BU52011 Hall Switch Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 556 | // printf(" South Detect = %d\r\n", Hall_Return[0]); |
BlueShadow | 6:7946b5c2376a | 557 | // printf(" North Detect = %d\r\n", Hall_Return[1]); |
BlueShadow | 6:7946b5c2376a | 558 | |
mfiore | 0:a44e71488e1f | 559 | |
mfiore | 0:a44e71488e1f | 560 | } |
BlueShadow | 6:7946b5c2376a | 561 | #endif |
BlueShadow | 6:7946b5c2376a | 562 | |
BlueShadow | 6:7946b5c2376a | 563 | #ifdef COLOR |
BlueShadow | 6:7946b5c2376a | 564 | void ReadCOLOR () |
BlueShadow | 6:7946b5c2376a | 565 | { |
BlueShadow | 6:7946b5c2376a | 566 | |
BlueShadow | 6:7946b5c2376a | 567 | //Read color data from the IC |
BlueShadow | 6:7946b5c2376a | 568 | i2c.write(BH1745_addr_w, &BH1745_Addr_color_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 569 | i2c.read(BH1745_addr_r, &BH1745_Content_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 570 | |
BlueShadow | 6:7946b5c2376a | 571 | //separate all data read into colors |
BlueShadow | 6:7946b5c2376a | 572 | BH1745[0] = (BH1745_Content_ReadData[1]<<8) | (BH1745_Content_ReadData[0]); |
BlueShadow | 6:7946b5c2376a | 573 | BH1745[1] = (BH1745_Content_ReadData[3]<<8) | (BH1745_Content_ReadData[2]); |
BlueShadow | 6:7946b5c2376a | 574 | BH1745[2] = (BH1745_Content_ReadData[5]<<8) | (BH1745_Content_ReadData[4]); |
mfiore | 0:a44e71488e1f | 575 | |
BlueShadow | 6:7946b5c2376a | 576 | //Output Data into UART |
BlueShadow | 6:7946b5c2376a | 577 | // printf("BH1745 COLOR Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 578 | // printf(" Red = %d ADC Counts\r\n",BH1745[0]); |
BlueShadow | 6:7946b5c2376a | 579 | // printf(" Green = %d ADC Counts\r\n",BH1745[1]); |
BlueShadow | 6:7946b5c2376a | 580 | // printf(" Blue = %d ADC Counts\r\n",BH1745[2]); |
BlueShadow | 6:7946b5c2376a | 581 | |
mfiore | 0:a44e71488e1f | 582 | } |
BlueShadow | 6:7946b5c2376a | 583 | #endif |
mfiore | 0:a44e71488e1f | 584 | |
BlueShadow | 6:7946b5c2376a | 585 | #ifdef RPR0521 //als digital |
BlueShadow | 6:7946b5c2376a | 586 | void ReadRPR0521_ALS () |
BlueShadow | 6:7946b5c2376a | 587 | { |
BlueShadow | 6:7946b5c2376a | 588 | i2c.write(RPR0521_addr_w, &RPR0521_Addr_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 589 | i2c.read(RPR0521_addr_r, &RPR0521_Content_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 590 | |
BlueShadow | 6:7946b5c2376a | 591 | RPR0521_ALS[1] = (RPR0521_Content_ReadData[1]<<8) | (RPR0521_Content_ReadData[0]); |
BlueShadow | 6:7946b5c2376a | 592 | RPR0521_ALS_D0_RAWOUT = (RPR0521_Content_ReadData[3]<<8) | (RPR0521_Content_ReadData[2]); |
BlueShadow | 6:7946b5c2376a | 593 | RPR0521_ALS_D1_RAWOUT = (RPR0521_Content_ReadData[5]<<8) | (RPR0521_Content_ReadData[4]); |
BlueShadow | 6:7946b5c2376a | 594 | RPR0521_ALS_DataRatio = (float)RPR0521_ALS_D1_RAWOUT / (float)RPR0521_ALS_D0_RAWOUT; |
BlueShadow | 6:7946b5c2376a | 595 | |
BlueShadow | 6:7946b5c2376a | 596 | if(RPR0521_ALS_DataRatio < (float)0.595) { |
BlueShadow | 6:7946b5c2376a | 597 | RPR0521_ALS[0] = ((float)1.682*(float)RPR0521_ALS_D0_RAWOUT - (float)1.877*(float)RPR0521_ALS_D1_RAWOUT); |
BlueShadow | 6:7946b5c2376a | 598 | } else if(RPR0521_ALS_DataRatio < (float)1.015) { |
BlueShadow | 6:7946b5c2376a | 599 | RPR0521_ALS[0] = ((float)0.644*(float)RPR0521_ALS_D0_RAWOUT - (float)0.132*(float)RPR0521_ALS_D1_RAWOUT); |
BlueShadow | 6:7946b5c2376a | 600 | } else if(RPR0521_ALS_DataRatio < (float)1.352) { |
BlueShadow | 6:7946b5c2376a | 601 | RPR0521_ALS[0] = ((float)0.756*(float)RPR0521_ALS_D0_RAWOUT - (float)0.243*(float)RPR0521_ALS_D1_RAWOUT); |
BlueShadow | 6:7946b5c2376a | 602 | } else if(RPR0521_ALS_DataRatio < (float)3.053) { |
BlueShadow | 6:7946b5c2376a | 603 | RPR0521_ALS[0] = ((float)0.766*(float)RPR0521_ALS_D0_RAWOUT - (float)0.25*(float)RPR0521_ALS_D1_RAWOUT); |
BlueShadow | 6:7946b5c2376a | 604 | } else { |
BlueShadow | 6:7946b5c2376a | 605 | RPR0521_ALS[0] = 0; |
BlueShadow | 6:7946b5c2376a | 606 | } |
BlueShadow | 6:7946b5c2376a | 607 | // printf("RPR-0521 ALS/PROX Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 608 | // printf(" ALS = %0.2f lx\r\n", RPR0521_ALS[0]); |
BlueShadow | 6:7946b5c2376a | 609 | // printf(" PROX= %0.2f ADC Counts\r\n", RPR0521_ALS[1]); //defined as a float but is an unsigned. |
BlueShadow | 6:7946b5c2376a | 610 | |
BlueShadow | 6:7946b5c2376a | 611 | } |
BlueShadow | 6:7946b5c2376a | 612 | #endif |
BlueShadow | 6:7946b5c2376a | 613 | |
BlueShadow | 6:7946b5c2376a | 614 | #ifdef KMX62 |
BlueShadow | 6:7946b5c2376a | 615 | void ReadKMX62_Accel () |
BlueShadow | 6:7946b5c2376a | 616 | { |
BlueShadow | 6:7946b5c2376a | 617 | //Read Accel Portion from the IC |
BlueShadow | 6:7946b5c2376a | 618 | i2c.write(KMX62_addr_w, &KMX62_Addr_Accel_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 619 | i2c.read(KMX62_addr_r, &KMX62_Content_Accel_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 620 | |
BlueShadow | 6:7946b5c2376a | 621 | //Note: The highbyte and low byte return a 14bit value, dropping the two LSB in the Low byte. |
BlueShadow | 6:7946b5c2376a | 622 | // However, because we need the signed value, we will adjust the value when converting to "g" |
BlueShadow | 6:7946b5c2376a | 623 | MEMS_Accel_Xout = (KMX62_Content_Accel_ReadData[1]<<8) | (KMX62_Content_Accel_ReadData[0]); |
BlueShadow | 6:7946b5c2376a | 624 | MEMS_Accel_Yout = (KMX62_Content_Accel_ReadData[3]<<8) | (KMX62_Content_Accel_ReadData[2]); |
BlueShadow | 6:7946b5c2376a | 625 | MEMS_Accel_Zout = (KMX62_Content_Accel_ReadData[5]<<8) | (KMX62_Content_Accel_ReadData[4]); |
BlueShadow | 6:7946b5c2376a | 626 | |
BlueShadow | 6:7946b5c2376a | 627 | //Note: Conversion to G is as follows: |
BlueShadow | 6:7946b5c2376a | 628 | // Axis_ValueInG = MEMS_Accel_axis / 1024 |
BlueShadow | 6:7946b5c2376a | 629 | // However, since we did not remove the LSB previously, we need to divide by 4 again |
BlueShadow | 6:7946b5c2376a | 630 | // Thus, we will divide the output by 4096 (1024*4) to convert and cancel out the LSB |
BlueShadow | 6:7946b5c2376a | 631 | MEMS_Accel[0] = ((float)MEMS_Accel_Xout/4096/2); |
BlueShadow | 6:7946b5c2376a | 632 | MEMS_Accel[1] = ((float)MEMS_Accel_Yout/4096/2); |
BlueShadow | 6:7946b5c2376a | 633 | MEMS_Accel[2] = ((float)MEMS_Accel_Zout/4096/2); |
BlueShadow | 6:7946b5c2376a | 634 | |
BlueShadow | 6:7946b5c2376a | 635 | // Return Data to UART |
BlueShadow | 6:7946b5c2376a | 636 | // printf("KMX62 Accel+Mag Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 637 | // printf(" AccX= %0.2f g\r\n", MEMS_Accel[0]); |
BlueShadow | 6:7946b5c2376a | 638 | // printf(" AccY= %0.2f g\r\n", MEMS_Accel[1]); |
BlueShadow | 6:7946b5c2376a | 639 | // printf(" AccZ= %0.2f g\r\n", MEMS_Accel[2]); |
BlueShadow | 6:7946b5c2376a | 640 | |
mfiore | 0:a44e71488e1f | 641 | } |
mfiore | 0:a44e71488e1f | 642 | |
BlueShadow | 6:7946b5c2376a | 643 | void ReadKMX62_Mag () |
BlueShadow | 6:7946b5c2376a | 644 | { |
BlueShadow | 6:7946b5c2376a | 645 | |
BlueShadow | 6:7946b5c2376a | 646 | //Read Mag portion from the IC |
BlueShadow | 6:7946b5c2376a | 647 | i2c.write(KMX62_addr_w, &KMX62_Addr_Mag_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 648 | i2c.read(KMX62_addr_r, &KMX62_Content_Mag_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 649 | |
BlueShadow | 6:7946b5c2376a | 650 | //Note: The highbyte and low byte return a 14bit value, dropping the two LSB in the Low byte. |
BlueShadow | 6:7946b5c2376a | 651 | // However, because we need the signed value, we will adjust the value when converting to "g" |
BlueShadow | 6:7946b5c2376a | 652 | MEMS_Mag_Xout = (KMX62_Content_Mag_ReadData[1]<<8) | (KMX62_Content_Mag_ReadData[0]); |
BlueShadow | 6:7946b5c2376a | 653 | MEMS_Mag_Yout = (KMX62_Content_Mag_ReadData[3]<<8) | (KMX62_Content_Mag_ReadData[2]); |
BlueShadow | 6:7946b5c2376a | 654 | MEMS_Mag_Zout = (KMX62_Content_Mag_ReadData[5]<<8) | (KMX62_Content_Mag_ReadData[4]); |
mfiore | 0:a44e71488e1f | 655 | |
BlueShadow | 6:7946b5c2376a | 656 | //Note: Conversion to G is as follows: |
BlueShadow | 6:7946b5c2376a | 657 | // Axis_ValueInG = MEMS_Accel_axis / 1024 |
BlueShadow | 6:7946b5c2376a | 658 | // However, since we did not remove the LSB previously, we need to divide by 4 again |
BlueShadow | 6:7946b5c2376a | 659 | // Thus, we will divide the output by 4095 (1024*4) to convert and cancel out the LSB |
BlueShadow | 6:7946b5c2376a | 660 | MEMS_Mag[0] = (float)MEMS_Mag_Xout/4096*(float)0.146; |
BlueShadow | 6:7946b5c2376a | 661 | MEMS_Mag[1] = (float)MEMS_Mag_Yout/4096*(float)0.146; |
BlueShadow | 6:7946b5c2376a | 662 | MEMS_Mag[2] = (float)MEMS_Mag_Zout/4096*(float)0.146; |
BlueShadow | 6:7946b5c2376a | 663 | |
BlueShadow | 6:7946b5c2376a | 664 | // Return Data to UART |
BlueShadow | 6:7946b5c2376a | 665 | // printf(" MagX= %0.2f uT\r\n", MEMS_Mag[0]); |
BlueShadow | 6:7946b5c2376a | 666 | // printf(" MagY= %0.2f uT\r\n", MEMS_Mag[1]); |
BlueShadow | 6:7946b5c2376a | 667 | // printf(" MagZ= %0.2f uT\r\n", MEMS_Mag[2]); |
BlueShadow | 6:7946b5c2376a | 668 | |
mfiore | 0:a44e71488e1f | 669 | } |
BlueShadow | 6:7946b5c2376a | 670 | #endif |
mfiore | 0:a44e71488e1f | 671 | |
BlueShadow | 6:7946b5c2376a | 672 | #ifdef KX022 |
BlueShadow | 6:7946b5c2376a | 673 | void ReadKX022 () |
BlueShadow | 6:7946b5c2376a | 674 | { |
mfiore | 0:a44e71488e1f | 675 | |
BlueShadow | 6:7946b5c2376a | 676 | //Read KX022 Portion from the IC |
BlueShadow | 6:7946b5c2376a | 677 | i2c.write(KX022_addr_w, &KX022_Addr_Accel_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 678 | i2c.read(KX022_addr_r, &KX022_Content_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 679 | |
BlueShadow | 6:7946b5c2376a | 680 | //Format Data |
BlueShadow | 6:7946b5c2376a | 681 | KX022_Accel_X_RawOUT = (KX022_Content_ReadData[1]<<8) | (KX022_Content_ReadData[0]); |
BlueShadow | 6:7946b5c2376a | 682 | KX022_Accel_Y_RawOUT = (KX022_Content_ReadData[3]<<8) | (KX022_Content_ReadData[2]); |
BlueShadow | 6:7946b5c2376a | 683 | KX022_Accel_Z_RawOUT = (KX022_Content_ReadData[5]<<8) | (KX022_Content_ReadData[4]); |
BlueShadow | 6:7946b5c2376a | 684 | |
BlueShadow | 6:7946b5c2376a | 685 | //Scale Data |
BlueShadow | 6:7946b5c2376a | 686 | KX022_Accel[0] = (float)KX022_Accel_X_RawOUT / 16384; |
BlueShadow | 6:7946b5c2376a | 687 | KX022_Accel[1] = (float)KX022_Accel_Y_RawOUT / 16384; |
BlueShadow | 6:7946b5c2376a | 688 | KX022_Accel[2] = (float)KX022_Accel_Z_RawOUT / 16384; |
BlueShadow | 6:7946b5c2376a | 689 | |
BlueShadow | 6:7946b5c2376a | 690 | //Return Data through UART |
BlueShadow | 6:7946b5c2376a | 691 | // printf("KX022 Accelerometer Sensor Data: \r\n"); |
BlueShadow | 6:7946b5c2376a | 692 | // printf(" AccX= %0.2f g\r\n", KX022_Accel[0]); |
BlueShadow | 6:7946b5c2376a | 693 | // printf(" AccY= %0.2f g\r\n", KX022_Accel[1]); |
BlueShadow | 6:7946b5c2376a | 694 | // printf(" AccZ= %0.2f g\r\n", KX022_Accel[2]); |
BlueShadow | 6:7946b5c2376a | 695 | |
mfiore | 0:a44e71488e1f | 696 | } |
BlueShadow | 6:7946b5c2376a | 697 | #endif |
BlueShadow | 6:7946b5c2376a | 698 | |
BlueShadow | 6:7946b5c2376a | 699 | |
BlueShadow | 6:7946b5c2376a | 700 | #ifdef Pressure |
BlueShadow | 6:7946b5c2376a | 701 | void ReadPressure () |
BlueShadow | 6:7946b5c2376a | 702 | { |
BlueShadow | 6:7946b5c2376a | 703 | |
BlueShadow | 6:7946b5c2376a | 704 | i2c.write(Press_addr_w, &Press_Addr_ReadData, 1, RepStart); |
BlueShadow | 6:7946b5c2376a | 705 | i2c.read(Press_addr_r, &Press_Content_ReadData[0], 6, NoRepStart); |
BlueShadow | 6:7946b5c2376a | 706 | |
BlueShadow | 6:7946b5c2376a | 707 | BM1383_Temp_Out = (Press_Content_ReadData[0]<<8) | (Press_Content_ReadData[1]); |
BlueShadow | 6:7946b5c2376a | 708 | BM1383[0] = (float)BM1383_Temp_Out/32; |
BlueShadow | 6:7946b5c2376a | 709 | |
BlueShadow | 6:7946b5c2376a | 710 | BM1383_Var = (Press_Content_ReadData[2]<<3) | (Press_Content_ReadData[3] >> 5); |
BlueShadow | 6:7946b5c2376a | 711 | BM1383_Deci = ((Press_Content_ReadData[3] & 0x1f) << 6 | ((Press_Content_ReadData[4] >> 2))); |
BlueShadow | 6:7946b5c2376a | 712 | BM1383_Deci = (float)BM1383_Deci* (float)0.00048828125; //0.00048828125 = 2^-11 |
BlueShadow | 6:7946b5c2376a | 713 | BM1383[1] = (BM1383_Var + BM1383_Deci); //question pending here... |
BlueShadow | 6:7946b5c2376a | 714 | |
BlueShadow | 6:7946b5c2376a | 715 | // printf("BM1383 Pressure Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 716 | // printf(" Temperature= %0.2f C\r\n", BM1383[0]); |
BlueShadow | 6:7946b5c2376a | 717 | // printf(" Pressure = %0.2f hPa\r\n", BM1383[1]); |
mfiore | 0:a44e71488e1f | 718 | |
mfiore | 0:a44e71488e1f | 719 | } |
BlueShadow | 6:7946b5c2376a | 720 | #endif |
mfiore | 1:a049d113e250 | 721 | |
BlueShadow | 6:7946b5c2376a | 722 | |
BlueShadow | 6:7946b5c2376a | 723 | /************************************************************************************ |
BlueShadow | 6:7946b5c2376a | 724 | // reference only to remember what the names and fuctions are without finding them above. |
BlueShadow | 6:7946b5c2376a | 725 | ************************************************************************************ |
BlueShadow | 6:7946b5c2376a | 726 | (" Temp = %.2f C\r\n", BDE0600_output); |
BlueShadow | 6:7946b5c2376a | 727 | printf(" UV = %.1f mW/cm2\r\n", ML8511_output); |
BlueShadow | 6:7946b5c2376a | 728 | |
BlueShadow | 6:7946b5c2376a | 729 | printf("BH1745 COLOR Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 730 | printf(" Red = %d ADC Counts\r\n",BH1745[0]); |
BlueShadow | 6:7946b5c2376a | 731 | printf(" Green = %d ADC Counts\r\n",BH1745[1]); |
BlueShadow | 6:7946b5c2376a | 732 | printf(" Blue = %d ADC Counts\r\n",BH1745[2]); |
BlueShadow | 6:7946b5c2376a | 733 | |
BlueShadow | 6:7946b5c2376a | 734 | printf(" ALS = %0.2f lx\r\n", RPR0521_ALS[0]); |
BlueShadow | 7:dd550a829ece | 735 | printf(" PROX= %u ADC Counts\r\n", RPR0521_ALS[1]); //defined as a float but is an unsigned, bad coding on my part. |
BlueShadow | 6:7946b5c2376a | 736 | |
BlueShadow | 6:7946b5c2376a | 737 | printf("KMX62 Accel+Mag Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 738 | printf(" AccX= %0.2f g\r\n", MEMS_Accel[0]); |
BlueShadow | 6:7946b5c2376a | 739 | printf(" AccY= %0.2f g\r\n", MEMS_Accel[1]); |
BlueShadow | 6:7946b5c2376a | 740 | printf(" AccZ= %0.2f g\r\n", MEMS_Accel[2]); |
BlueShadow | 6:7946b5c2376a | 741 | |
BlueShadow | 6:7946b5c2376a | 742 | printf(" MagX= %0.2f uT\r\n", MEMS_Mag[0]); |
BlueShadow | 6:7946b5c2376a | 743 | printf(" MagY= %0.2f uT\r\n", MEMS_Mag[1]); |
BlueShadow | 6:7946b5c2376a | 744 | printf(" MagZ= %0.2f uT\r\n", MEMS_Mag[2]); |
BlueShadow | 6:7946b5c2376a | 745 | |
BlueShadow | 6:7946b5c2376a | 746 | printf("KX022 Accelerometer Sensor Data: \r\n"); |
BlueShadow | 6:7946b5c2376a | 747 | printf(" AccX= %0.2f g\r\n", KX022_Accel[0]); |
BlueShadow | 6:7946b5c2376a | 748 | printf(" AccY= %0.2f g\r\n", KX022_Accel[1]); |
BlueShadow | 6:7946b5c2376a | 749 | printf(" AccZ= %0.2f g\r\n", KX022_Accel[2]); |
BlueShadow | 6:7946b5c2376a | 750 | |
BlueShadow | 6:7946b5c2376a | 751 | printf("BM1383 Pressure Sensor Data:\r\n"); |
BlueShadow | 6:7946b5c2376a | 752 | printf(" Temperature= %0.2f C\r\n", BM1383[0]); |
BlueShadow | 6:7946b5c2376a | 753 | printf(" Pressure = %0.2f hPa\r\n", BM1383[1]); |
BlueShadow | 6:7946b5c2376a | 754 | |
BlueShadow | 6:7946b5c2376a | 755 | **********************************************************************************/ |
BlueShadow | 6:7946b5c2376a | 756 | |
BlueShadow | 6:7946b5c2376a | 757 | |
BlueShadow | 6:7946b5c2376a | 758 | |
BlueShadow | 6:7946b5c2376a | 759 | |
BlueShadow | 6:7946b5c2376a | 760 | |
BlueShadow | 6:7946b5c2376a | 761 | |
BlueShadow | 6:7946b5c2376a | 762 |