Go Down

Topic: Transfer and parse variables via serial with PHP (Read 815 times) previous topic - next topic



I am trying to run an HVAC system from my Arduino MEGA. In order to be able to set temperatures and times, I need to be able to change the values of variables from the outside. This whole thing is pretty complex, so there's a lot of variables to exchange.

The basic software is running fine. It measures temperature and opens and closes flaps as needed. I can talk back and forth between PHP and Arduino, using serial. But handing over names, arrays etc. seems terribly complex.

The variables:

several byte,integer, one-dimensional, two-dimensional and three-dimensional arrays.

It can be done, writing about 783,000 "if / else if statements", but I am definitely not in the mood.

Is there anybody here who has an at least semi-elegant solution? I'm at my wit's end....



The art of getting good answers lies in asking good questions.


But handing over names, arrays etc. seems terribly complex.

Can you give a little more detail on what you expect to be doing in the above line?
Google forum search: Use Google Search box in upper right side of this page.
Why I like my 2005 Rio Yellow Honda S2000  https://www.youtube.com/watch?v=pWjMvrkUqX0


Looking at "messenger" right now. So far it looks like I can make this work!

Here are some of the variables:

byte        Mode;
byte        StartTime [8][4][2];
char*      RoomName [8];
float        Temp[8];

There's plenty more, but I think this highlights pretty much the worst of it.

I would like to be able to "run" this from PHP. So I can send a command from PHP, requesting values of certain variables. Maybe something like this:

"? RoomName"         // requests all the values of "RoomName" to be sent
"? Mode"                // requests the vaue of "Mode" to be sent

This part is relatively simple, just using Serial.print. parsing it in PHP is pretty straightforward.

Then I would like a user to change the values on a *.php page and the values to be returned to Arduino. That of course requires some parsing on the side of the Arduino.

Maybe the message I send would look something like this:

"! Mode 2"                                     (This should set "Mode" to value "2")
"! StartTime 1 2 3 4 5 6 7 8 .........." (Sets all 64 values of "StartTime")

Any  better ideas, please let me know!


Any  better ideas, please let me know!

I think you pretty much understand what you need to do. Implement and test one command at a time.
The art of getting good answers lies in asking good questions.

Go Up