Pages: [1]   Go Down
Author Topic: Transfer and parse variables via serial with PHP  (Read 483 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

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....

Thanks!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you looked at the Messenger library?
Logged

0
Offline Offline
Tesla Member
***
Karma: 141
Posts: 9470
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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?
Logged

Consider the daffodil. And while you're doing that, I'll be over here, looking through your stuff.   smiley-cool

0
Offline Offline
Newbie
*
Karma: 0
Posts: 7
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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!
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 601
Posts: 48543
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
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.
Logged

Pages: [1]   Go Up
Jump to: