Go Down

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

sts

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!

PaulS


zoomkat

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?
Google forum search: Use Google Advanced Search and use Http://forum.arduino.cc/index in the "site or domain:" box.

sts

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!

PaulS

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.

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy