Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: libmDot mbed-rtos mbed
Fork of Adafruit_I2C_9dof_mDot_TTN by
Diff: main.cpp
- Revision:
- 10:798cac7d3dcb
- Parent:
- 9:e3756ad55310
- Child:
- 11:a2a6b1214ae4
diff -r e3756ad55310 -r 798cac7d3dcb main.cpp
--- a/main.cpp Sun Aug 21 23:28:04 2016 +0000
+++ b/main.cpp Mon Sep 12 00:23:43 2016 +0000
@@ -68,6 +68,9 @@
std::vector<uint8_t> data; // mDot data->send variable
char data_str[64]; // Intermediate conversion variable
uint32_t update_interval = 15000; // TTN transmission interval (loop interval)
+ int16_t analog_input;
+ //initialize pins for analog input
+ AnalogIn ain(A0);
// get a mDot handle
dot = mDot::getInstance();
@@ -119,39 +122,15 @@
while (true) {
- // Enable the Magnetometer
- cmd[0] = 0x02;
- //cmd[1] = 0x00;
- i2c.write(addr8bit, cmd, 1);
- logInfo("Wake magnetometer");
-
- // Read magnetic field
- cmd[0] = 0x03; // see for a list of addresses and commands https://github.com/adafruit/Adafruit_LSM303/blob/master/Adafruit_LSM303.h
- i2c.write(addr8bit, cmd, 1);
- i2c.read( addr8bit, my_data, 6);
-
- // This section is converted from Arduino version: https://github.com/adafruit/Adafruit_MCP9808_Library/blob/master/Adafruit_MCP9808.cpp
- mag_x = my_data[0];
- mag_x <<= 8;
- mag_x |= my_data[1];
-
- mag_y = my_data[2];
- mag_y <<= 8;
- mag_y |= my_data[3];
-
- mag_z = my_data[4];
- mag_z <<= 8;
- mag_z |= my_data[5];
-
-
- logInfo("X_MAG = %d Y_MAG = %d; Z_MAG = %d", mag_x, mag_y, mag_z);
+ analog_input = ain;
+ logInfo("analog input = %d", analog_input);
// Empty data vector
data.clear();
// Push temperature value into data array
- sprintf(data_str, "%d", mag_x);
+ sprintf(data_str, "%d", analog_input);
for (int i = 0; i<strlen(data_str); i++)
{
data.push_back(((char*)data_str)[i]);
