Domotica using a NAS, a CA42, a Remeha heater and HTML5 part 4, the result.

It has been a little while ago but I made some progress and here is the result…

A web interface showing information obtained from the Remeha Avanta heating. This is how it works:

  1. My Synology DS210J runs an application named remeha2xml. This application is written in C.
  2. remeha2xml opens a serial connection to the Remeha Avanta using a modified CA42 datacable.
  3. remeha2xml sends commands to the Remeha Avanta and reads the responses.  The commands to and the responses from the Remeha Avanta have been obtained using a serial port sniffer.
  4. remeha2xml writes the response data to an xml file. This file is stored in a folder that is accessible by the webserver running on the Synology.
  5. The remeha2xml application is periodically started by cron so that the xml data is refreshed at given intervals.
  6. The xml file contains a process instruction to use a stylesheet. When requesting the XML file via a browser, the data is nicely formatted:Screenshot showing xml stylesheet result
  7. I also created an HTML5 page that uses the SteelSeries widgets and Rgraph. The result is displayed at the beginning of this post.

I ran into three minor issues during this project:

  1. The modem cable, see previous posts.
  2.  The warm water temperature was 623 degrees celcius 🙂 but Remeha clarified that for me. (Their customer support is very friendly).
  3. the data obtain from the XML files does not show my HTC Desire’s browser and I don’t know why yet but I will find out.

There are a number of things I want to do before closing this project:

  1. Porting the application over to a Raspberry PI. I would like to build a Diskless Remeha Monitor and the Raspberry PI would be a low cost platform to achieve this goal.
  2. Finding out how to utilize the remeha2xml application without waking up the harddisks from hibernate every time (xml file is stored on harddisk, storing it on the ramdrive would be an option).

Here are a code snippets that I would like to share with you:

  • Setting up the communication with a serial device is easy, this is what I did in C:

/* Declare and initialize termios */
struct termios tio;
memset(&tio,0,sizeof(tio));

int fd=0;
int result=0;
char requestbuffer[255] = {0};
char responsebuffer[255] = {0};

int main() {
/* open serial port */
fd = open(argv[1], O_RDWR | O_NDELAY | O_NOCTTY);
if (fd < 0) {
printf(“Oops…\n”);
} else {
cfmakeraw(&tio);
tio.c_cflag |= CLOCAL;
cfsetospeed(&tio,B9600);
cfsetispeed(&tio,B9600);
tcsetattr(fd, TCSANOW, &tio);
result = write(fd, requestbuffer, sizeof(requestbuffer));
if (result > 0) {
result = read(fd, responsebuffer, sizeof(responsebuffer));
if (result > 0) {
printf(“We have data…\n”);
} else {
printf(“Oops…\n”);
}
} else {
printf(“Oops…\n”);
}
close(fd);
}
}

  • libxml: I struggled to get it working and this is what I used in my code:

xmlDocPtr doc = xmlNewDoc(BAD_CAST(“1.0”));
xmlNodePtr root_node = xmlNewNode(NULL,BAD_CAST(“remeha”));
xmlDocSetRootElement(doc,root_node);
xmlNodePtr PINode=xmlNewDocPI(doc,(xmlChar *)”xml-stylesheet”,(xmlChar *)”type=\”text/xsl\” href=\”remeha2xml.xsl\””);
xmlAddPrevSibling(root_node,PINode);
xmlNodePtr pnode = xmlNewChild(root_node, NULL, “value”, formattedbuffer);
xmlSetProp(pnode, “type”, attr_value_string); // Add attribute to pnode

See ya.

Advertisements
This entry was posted in communication, domotica, Uncategorized, User Interfaces and tagged , , , , , , , , , , . Bookmark the permalink.

3 Responses to Domotica using a NAS, a CA42, a Remeha heater and HTML5 part 4, the result.

  1. Joey says:

    Hello Freddy,

    You did a great job here. i want to do something similar.
    Are you willing to share the “remeha2xml” program with me?

    Greetings,
    Joey

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s