How to visualise sensor data from arduino in processing?

edited November 2017 in Arduino

Hi there.

I'm currently working on a thermal imaging camera for my project in university. The system is as follows: there is an mlx90614 temperature sensor mounted on two servo motors and connected to an arduino leonardo. One to control y-axis rotation and one to control x-axis rotation. The arduino currently collects data by rotating the x-axis servo motor (right to left) to take 90 measurements( one measurement per degree of rotation). Once this is done the y-axis motor rotates one degree up and repeats the previous step). This continues until the x-axis motor has completed 90 increments. The data is being sent to the serial monitor as it is measurement.

I'm new to using processing and I'm not sure how to create a processing script to visually represent the data. My idea was to assign a coloured square to each temperature measurement (For example between 10 and 40 degrees, the colour would change from blue at 10 degrees to red at 40 degrees as you go from 10 to 40) and position them one by one in the position they were measured from.

I would appreciate any ideas people can give me. Sorry this question is so long winded and maybe confusing. If there is any more information needed i will provide it.


  • use mouse to zoom and rotate

    click a small sphere to select it

    import peasy.*;
    PeasyCam cam;
    Node[] nodes;
    Node curr=null; 
    // -----------------------------------------------------
    void setup() {
      size(1200, 800, P3D);
      int NUM_PARTICLES = 350;
      nodes = new Node[NUM_PARTICLES];
      cam = new PeasyCam(this, width);
      for (int i=0; i<NUM_PARTICLES; i++) {
        // Node n = new Node( PI, .3 );  // belt        
        Node n = new Node(i, map(i, 0, NUM_PARTICLES, -1, 1));   // full sphere 
        nodes[i] = n;
    void draw() {
      translate(0, 0, 0);
      fill(0, 244, 255);
      box(10, 10, 10);
      stroke(0, 0, 0, 20);
      for (int i=0; i<nodes.length; i++) {
        Node n = nodes[i];
      text("click a node to select (it appears red), then space key "
        +"to change Z; use peasycam outside sphere; use mousewheel to zoom etc.", 
        19, 19); 
    void keyPressed() {
      if (curr!=null)
    void mousePressed() {
      //for (int i=0; i<nodes.length; i++) {
      //  Node n = nodes[i];
      //  n.selected=false;
      boolean done=false; 
      Node  old=curr; 
      for (int i=0; i<nodes.length; i++) {
        Node n = nodes[i];
        if (dist(n.scrX, n.scrY, mouseX, mouseY)<6) {
          done = true; 
          break; // leave
      if (done&&old!=null&&(curr!=old)) {
    // =====================================================================
    class Node extends PVector {
      float radius = 150;
      float theta, u;
      float scrX, scrY; 
      boolean selected= false; 
      color c = color(random(100, 255), 
        random(100, 255), 
        random(100, 255));
      // constructor
      Node(float Theta, float U) {
        theta = Theta;
        u = U;
        x = radius*cos(theta)*sqrt(1-(u*u));
        y = radius*sin(theta)*sqrt(1-(u*u));
        z = u*radius;
      }  // constructor
      void render() {
        translate(x, y, z);
        if (selected) 
          fill(255, 0, 0);
        else {
          // fill(0, 244, 0);
        sphere(10) ;
        scrX=screenX(0, 0, 0); 
        scrY=screenY(0, 0, 0); 
Sign In or Register to comment.