Unable to HTTP POST multiple data to a server

I created an HTTP POST node and linked the imp node to the POST soft node in the planner. I am unable to send to our server anything other than one integer number from the imp and in any case never a float number. The imp server seems to receive the data correctly even if on the planner, the "server.show" numbers stays on the planner only for an instant.

The code I am running is below and my server (RoR log) gets:

Started POST "/api/impUpload" for at 2012-08-09 22:07:37 +0000
 Processing by Api::DevicesController#impUpload as HTML
 Parameters: {"value"=>"778", "target"=>"30731e5e118cbee7", "channel"=>"1"}
Rendered text template (0.0ms)
Completed 200 OK in 1ms (Views: 0.7ms | ActiveRecord: 0.0ms)

My server receives the proper HTTP request with the method POST as expected. However, i receive only the constant 778 in the "value" in the payload, and only if the output variable contains an integer. If I try to send for instance only the temperature as in the code below, my server doesn't receive the POST at all.

Please advise.


-Marco G.

// Code sample
server.log("test started");

local i2c = hardware.i2c1;

local out_number = OutputPort("Number", "number");    // send a constant
local out_temp = OutputPort("Temperature", "number");
local out_humid = OutputPort("Humidity", "number");

// Register with the server
imp.configure("NebulaTemp", [], [out_number,out_temp, out_humid]);

local function change() {
   local number = 778;
   local temperature = 0.01;
   local humidity = 0.02;

   // Start conversion
   i2c.write(0x4e, "");

   // Wait at least 36ms

   // Read out temperature and humidity, zero length subaddress means the write
   // subaddr phase will be totally skipped and we'll just do the read
   local th = i2c.read(0x4e, "", 4);

   // note data will be marked as stale because each read kicks off another
   // cycle as we always do a write-before-read on i2c
   // hence, we need to mask top bits of humidity byte

   // Form temp and humidity
   local temperature = ((((th[2]         <> 2)) * 165) / 16383.0) - 40;
   local humidity    = ((((th[0] & 0x3F) << 8 ) | (th[1]     ))        / 163.83 );

    // Log and show
   server.log(format("number %d temperature %.2fC humidity %.2f%%", number, temperature, humidity));
   server.show(format("%d %.2fC %.2f%%", number, temperature, humidity));

   // Send data to server

server.sleepfor((1 * 30));

Hi Marco,
Each of the output ports you’ve configured (number, temperature, humidity) have separate connections. If you only connect the number port to your HTTP POST node, then setting out_temp isn’t going to trigger any request. You’ll need to make three separate connections to get all of those ports to generate POST requests.

If you’d like to send all of them at once and have them be a single HTTP request to your service, send an array of values to your output port. Something like

local out_all = OutputPort(“N,T,H”, “array”);
out_all.set([number, temperature, humidity]);

That will post to your server as a form-encoded array (value=1&value=2&value=3), which Rails should parse just fine.

Yes, that would do the trick. Thank you.

One suggestion is to update the documentation to include the “array” type for OutputPort. It is kind of implicit that if there is “color” represented as a 3-element array, probably there must be an “array” as well.

Another improvement is to have the array index in the LHS of the serialization string in the soft node HTTP POST payload. Just to help parsing even if I will probably end up sending a JSON string from the imp.


-Marco G.

Documentation updated.



Fen Consultants, UK

This seems to contradict the final post here -


which indicated that currently you could only send a single value.  If I read this post carefully you can send an array and it will be sent to the HTTP post correctly formatted... yes?

The “array” type for OutputPort either didn’t exist or hadn’t been mentioned when I wrote the earlier post. Neither had it been mentioned that the HTTP POST vimp could parse an array other than as a single combined field. However this still isn’t what the poster asked for on the other thread - it’s one field, with one name, but parsed as an array.


Solved serializing data in a JSON string. Working very well and didn’t miss a message in 2 days.

-Marco G.