i am working on a Project for the University.
I am trying to controll a heater with PID while communicating with a web service using Node.JS.
My first approach was a PID Sketch which is working fine on the Arduino.
Now i want to be able to set the target temperature via a web service and this is where i started to struggle.
I was able to get Node.JS and Firmata working but my Node.JS - PID Sketch is not working at all.
Now i am wondering if it´s possible to use my already working Arduino PID - Sketch together with the Firmata - Sketch to controll my heater while using Node.JS running on the OpenWRT to communicate with the web-service.
It seems like you may have misunderstood what Firmata is for.
Basically - firmata is a both a sketch - but also a communication protocol.
Essentially, it's a sketch that runs on an Arduino (although other implementations may be available) that implements this communications protocol - which other libraries which implement the protocol can communicate with (in your case, there is a library for Node.js that implements the firmata protocol).
So - you end up having a process like this:
PC (Yun in your case, running Node.js) -> firmata lib (Node.js) -> (comm channel) -> Arduino -> firmata sketch -> (control of pins)
If I am understanding correctly (and if I have anything wrong, let me know), you have a Yun running Node.js, with the firmata library package installed. This you are using to connect to the Arduino, which is running the firmata sketch.
Now - basically - what you need to do is convert the PID portion over to Node.js to run it on the Yun (that, or set something up on the Yun that runs and communicates thru Node.js - but that seems a bit roundabout to me; while it could be done, it just adds complexity for little gain).
What firmata does is allow you to specify pins to read/write to, and send commands down a communications channel (serial port, ethernet, wifi, bluetooth, etc) - which on the other end, an Arduino (or something else) is running the Firmata sketch (etc) - which then interprets the commands and sets or reads the pins on the Arduino as specified.
You don't need to combine any sketches - Firmata should be the -only- thing running on the Arduino (Uno? Mega? I'm not sure what you are using) - and on the Arduino Yun, you should only be running Node.js with the Firmata library/package installed.
You might also better understand this process if you read some of the stuff here:
This basically uses Firmata, Node.js, and the Johnny-Five module (the Node.js firmata lib) to allow you control a robot. Well - in your case, it's a heater - but it is basically the same idea.
Good luck - and I hope this helps in some manner.