Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This is a step by step manual for getting started with shiftr.io (desktop application), shiftr.io pocket and Processing. The goal is to collect data via shiftr.io Pocket and to store this in an .csv file.

...

Also you need to make sure that you're running the latest version of Processing. If you have an old version or haven’t Processing installed at all, get it from their website.

Afterwards, download the processing-mqtt library from the GitHub repository. When the download has finished, move the library to your sketch folders libraries directory. More information about installing a library can be found here.

...

Once you've managed to have the sensor sending data, you can use the following Processing script to store the received data in an .csv file.

Please note: Change the URI (here: "mqtt://67edd5ec:ca0473914fbded6b@broker.shiftr.io") to the one you are connected to. And don't forget to subscribe to the right Pocket device (here: p7) with the active activated sensor (here: dst).

Please note: The script overwrites the current .csv file, if you don't change the file name (to f.e. "new-2.csv") 

Code Block
languagejava
import mqtt.*;

MQTTClient client;

Table table;

void setup() {
  client = new MQTTClient(this);
  client.connect("mqtt://67edd5ec:ca0473914fbded6b@broker.shiftr.io", "processing");
  client.subscribe("p7/dst");

  table = new Table();
  table.addColumn("time");
  table.addColumn("dst");
}

void draw() {
}

void keyPressed() {
  client.publish("/hello", "world");
}

void messageReceived(String topic, byte[] payload) {
  println("new message: " + topic + " - " + new String(payload));

  String str = new String(payload);
  int dst = Integer.parseInt(str);

  TableRow newRow = table.addRow();
  newRow.setInt("time", millis());
  newRow.setInt("dst", dst);
  
  saveTable(table, "data/new.csv");
}

...