Pixy2 connection to photon


#21

First, your data string does not look like valid JSON to be ready for publishing. You are missing a closing curly brace.
Also, why would you want the serial monitor to show a different format than what you are actually publishing. For debugging it’s always better to actually see what you send out.

And - as always - I’d not use String but something like this

  char   data[128];
  Block *curBlock = &pixy.ccc.blocks[i];
  snprintf(data, sizeof(data)
          , "{ \"block\":\"%d\""
            ", \"sig\":\"%d\""
            ", \"x\":\"%d\""
            ", \"y\":\"%d\""
            ", \"width\":\"%d\""
            ", \"height\":\"%d\""
            ", \"angle\":\"%d\""
            ", \"index\":\"%d\""
            ", \"age\":\"%d\""
            "}" 
          , i
          , curBlock->m_signature
          , curBlock->m_x
          , curBlock->m_y
          , curBlock->m_width
          , curBlock->m_height
          , curBlock->m_angle
          , curBlock->m_index;
          , curBlock->m_age
          );
  Serial.println(data);
  Particle.publish("MachineVisionDemo", data, PRIVATE);

#22

Thank you @ScruffR! That worked perfectly. I did have to remove the ; from “after delay(1000);” :slight_smile: