Need help in understanding Firmata applications

Hi guys. I've got some idea what Firmata is, eg. controlling an Arduino from a Processing language sketch on a host computer. (by loading the Firmata library into the Arduino)

My Question:

Can I have a running Arduino sketch downloaded into the Arduino AND modify variables in that running sketch via a Processing sketch running on a host computer?

For example, let's suppose I'd like to build and program my Arduino sketch to measure temperature and display temperature on an LCD... a fairly reasonable small project.

Let's suppose I don't have the physical temperature sensor (yet).

Can I have my Arduino sketch loaded in the microprocessor AND simulate the temperature sensor using Firmata from my host computer?

I just can't quite get if this is possible and if so, how to achieve it.

Any help will be greatly appreciated.

It would be possible, but an extremely convoluted solution which involved very substantial changes to your sketch to include Firmata handling.

By far the easiest approach would be to just replace the temperature reading code with a stub that just returns hard-coded temperature values. For example it would be simple to make the returned temperature vary over time following a sine wave or saw tooth shape.

A slightly more sophisticated approach would change the stub to return a value saved in global data and add some code to update that saved 'current value' based on input from the serial port. Then you can write new values via the serial monitor or write a Processing application to send them for you.

Thanks for your reply. Much appreciated :slight_smile: