0

Time Tracking Cube Code Question
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Time Tracking Cube Code Question

by hepaestus on Tue Sep 28, 2021 11:43 am

Hello!,
On the code page for the https://learn.adafruit.com/time-tracking-cube/code there is reference to this code:
Code: Select all | TOGGLE FULL SIZE

  // Send to Adafruit IO based off of the orientation of the cube
  switch (cubeState)
  {
  case 1:
    Serial.println("Switching to Task 1");
    // update the neopixel strip
    updatePixels(50, 0, 0);
    // play a sound
    tone(PIEZO_PIN, 650, 300);
    Serial.print("Sending to Adafruit IO -> ");
    Serial.println(taskTwo);

    cubetask->save(taskTwo, minutes); // THIS IS MY QUESTION MY Minutes are not being saved.
    // There is no mention of this method signature in the docs
    // https://adafruit.github.io/Adafruit_IO_Arduino/html/class_adafruit_i_o___feed.html#a783174b3bb1fc40a2e89c78cc6e6e5c1
    // I do not think this minutes data is being sent to AIO.

    // reset the timer
    minutes = 0;
    break;


cubetask->save(taskTwo, minutes);
THIS IS MY ISSUE.
Minutes are not being saved.
There is no mention of this method signature in the docs
https://adafruit.github.io/Adafruit_IO_ ... 8cc6e6e5c1
I do not think this minutes data is being sent to AIO.

What am I missing?
Thank You,
Pete

hepaestus
 
Posts: 44
Joined: Sat May 07, 2016 6:54 am

Re: Time Tracking Cube Code Question

by brubell on Wed Sep 29, 2021 11:44 am

`save()` publishes data to Adafruit IO, see: https://github.com/adafruit/Adafruit_IO ... ub.ino#L85

When you open http://io.adafruit.com/monitor, do you see any data coming into the minutes feed?

brubell
 
Posts: 1524
Joined: Fri Jul 17, 2015 10:33 pm

Re: Time Tracking Cube Code Question

by hepaestus on Wed Sep 29, 2021 11:59 am

Yes I get the STRING data. See the attached image of the AD.io page.

I am not getting the second piece of the data, the minutes passed.

Thanks,
Pete.
Attachments
tc-screenshot-1.png
tc-screenshot-1.png (40.76 KiB) Viewed 929 times

hepaestus
 
Posts: 44
Joined: Sat May 07, 2016 6:54 am

Re: Time Tracking Cube Code Question

by brubell on Mon Oct 04, 2021 10:13 am

Code: Select all | TOGGLE FULL SIZE
cubetask->save(taskTwo, minutes);


What does your taskTwo feed look like?

brubell
 
Posts: 1524
Joined: Fri Jul 17, 2015 10:33 pm

Re: Time Tracking Cube Code Question

by hepaestus on Mon Oct 04, 2021 10:20 am

I only have one feed for this.

hepaestus
 
Posts: 44
Joined: Sat May 07, 2016 6:54 am

Re: Time Tracking Cube Code Question

by hepaestus on Mon Oct 04, 2021 2:39 pm

I am trying to measure the tilt angle of the project but the sensor values change wildly:

I am not even moving the sensor and you can see below it has values all over the place.

Code: Select all | TOGGLE FULL SIZE
// Basic demo for accelerometer readings from Adafruit LIS3DH
#include <Wire.h>
#include <SPI.h>
#include <Adafruit_LIS3DH.h>
#include <Adafruit_Sensor.h>

// Used for software SPI
#define LIS3DH_CLK 13
#define LIS3DH_MISO 12
#define LIS3DH_MOSI 11
// Used for hardware & software SPI
#define LIS3DH_CS 10

// software SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS, LIS3DH_MOSI, LIS3DH_MISO, LIS3DH_CLK);
// hardware SPI
//Adafruit_LIS3DH lis = Adafruit_LIS3DH(LIS3DH_CS);
// I2C
Adafruit_LIS3DH lis = Adafruit_LIS3DH();

void setup(void) {
  Serial.begin(115200);
  while (!Serial) delay(10);     // will pause Zero, Leonardo, etc until serial console opens

  Serial.println("LIS3DH test!");

  if (! lis.begin(0x18)) {   // change this to 0x19 for alternative i2c address
    Serial.println("Couldnt start");
    while (1) yield();
  }
  Serial.println("LIS3DH found!");

  lis.setRange(LIS3DH_RANGE_2_G);   // 2, 4, 8 or 16 G!

  Serial.print("Range = "); Serial.print(2 << lis.getRange());
  Serial.println("G");

  lis.setDataRate(LIS3DH_DATARATE_10_HZ);
  Serial.print("Data rate set to: ");
  switch (lis.getDataRate()) {
    case LIS3DH_DATARATE_1_HZ: Serial.println("1 Hz"); break;
    case LIS3DH_DATARATE_10_HZ: Serial.println("10 Hz"); break;
    case LIS3DH_DATARATE_25_HZ: Serial.println("25 Hz"); break;
    case LIS3DH_DATARATE_50_HZ: Serial.println("50 Hz"); break;
    case LIS3DH_DATARATE_100_HZ: Serial.println("100 Hz"); break;
    case LIS3DH_DATARATE_200_HZ: Serial.println("200 Hz"); break;
    case LIS3DH_DATARATE_400_HZ: Serial.println("400 Hz"); break;

    case LIS3DH_DATARATE_POWERDOWN: Serial.println("Powered Down"); break;
    case LIS3DH_DATARATE_LOWPOWER_5KHZ: Serial.println("5 Khz Low Power"); break;
    case LIS3DH_DATARATE_LOWPOWER_1K6HZ: Serial.println("16 Khz Low Power"); break;
  }
}

int x, y, z;                        //three axis acceleration data
double roll = 0.00, pitch = 0.00;       //Roll & Pitch are the angles which rotate by the axis X and y

void RP_calculate(){
  double x_Buff = float(x);
  double y_Buff = float(y);
  double z_Buff = float(z);
  //roll = atan2(y_Buff , z_Buff) * 57.3;
  roll =  atan2( y_Buff , x_Buff ) * 57.3;
  pitch = atan2((- x_Buff) , sqrt(y_Buff * y_Buff + z_Buff * z_Buff)) * 57.3;
}


void loop() {
  sensors_event_t event;
  lis.getEvent(&event);

  /* Display the results (acceleration is measured in m/s^2) */
  Serial.print("2X: "); Serial.print(event.acceleration.x);
  Serial.print(" \t2Y: "); Serial.print(event.acceleration.y);
  Serial.print(" \t2Z: "); Serial.print(event.acceleration.z); 
  x = event.acceleration.x;
  y = event.acceleration.y;
  z = event.acceleration.z;
  RP_calculate();
  Serial.print("\tRoll 2: "); Serial.print(roll);
  Serial.print("\tPitch 2: "); Serial.print(pitch);
  Serial.println();
  delay(200);
}




Here is the OUTPUT:
Code: Select all | TOGGLE FULL SIZE
14:36:20.148 -> 2X: 182.62    2Y: 90.39    2Z: 60.28   Roll 2: 26.31   Pitch 2: -59.28
14:36:20.352 -> 2X: 212.75    2Y: 90.39    2Z: 30.16   Roll 2: 23.00   Pitch 2: -65.90
14:36:20.558 -> 2X: -239.14    2Y: 180.76    2Z: 30.16   Roll 2: 143.03   Pitch 2: 52.64
14:36:20.758 -> 2X: 212.75    2Y: 150.64    2Z: 60.28   Roll 2: 35.28   Pitch 2: -52.69
14:36:20.964 -> 2X: 182.62    2Y: 120.51    2Z: 120.53   Roll 2: 33.40   Pitch 2: -47.01
14:36:21.170 -> 2X: 152.50    2Y: 90.39    2Z: 90.41   Roll 2: 30.63   Pitch 2: -50.06
14:36:21.376 -> 2X: 212.75    2Y: 150.64    2Z: 90.41   Roll 2: 35.28   Pitch 2: -50.48
14:36:21.580 -> 2X: -239.14    2Y: 120.51    2Z: 90.41   Roll 2: 153.35   Pitch 2: 57.89
14:36:21.783 -> 2X: -239.14    2Y: 30.13    2Z: 90.41   Roll 2: 172.86   Pitch 2: 68.35
14:36:21.990 -> 2X: 212.75    2Y: 60.26    2Z: 120.53   Roll 2: 15.80   Pitch 2: -57.68
14:36:22.162 -> 2X: -239.14    2Y: 150.64    2Z: 60.28   Roll 2: 147.90   Pitch 2: 55.95

hepaestus
 
Posts: 44
Joined: Sat May 07, 2016 6:54 am

Please be positive and constructive with your questions and comments.