CAI Webcontrol Enviroment Controller Project, Need Help

ricosuave

New Member
Hello, I'm working on a project at the moment to design a webcontrol board to monitor and control the temp, and in the future, co2, humidity, and other plant growing related factors. I have purchased and assembled the webcontrol, along with the correct temp and humidity sensor. I also bought a dual relay board, that I'm planning on using to control a vent fan and heater to keep a temperature equilibrium. Its a Electronics-salon RLY-1 off ebay from a Chinese seller. I have the board showing correct values for temp/humidity, and will be finishing my relay box soon. I will be needing to program the webcontrol to turn on/off the relays relative to the temperature of the room. I have very little programming knowledge, but from what i can deduce about the webcontrol, is that its not a lot of work and just a few lines of logic. Is there anyone who would be willing to give me some advice and or help with the coding? It would be much appreciated as there seems to be a lack of info about the webcontrol, and would love to get started on the next step of my project. In addition to my first problem, i would also appreciate any help configuring email alerts and how to log the temperature remotely through the internet. I understand the DDNS stuff and how to get that configured, but am clueless to the basics of how the webcontrol communicates with other computers through non web-interface methods. I know all of this is possible on the webcontrol, and would appreciate any recommendations for easy to learn books, articles, anything related to programming the webcontrol so i may learn how to add additional sensors and program them to control outputs in the future.
 
Hello, I'm working on a project at the moment to design a webcontrol board to monitor and control the temp, and in the future, co2, humidity, and other plant growing related factors. I have purchased and assembled the webcontrol, along with the correct temp and humidity sensor. I also bought a dual relay board,
...
Well my understanding is that there is no non web-interface methods (unless you mean "non web-interface" == browser). Its interface is http and its output is html (if someone know otherwise please correct me and you'll save me a lot of trouble :D).

Some simple things you can do, first disable the web login on the network admin page. Now what language and OS do you want to work with? I found something that explains the http string to send to turn on a device. I'll look for that later and post it here.

Edit: changed general admin to network admin.
 
Well my understanding is that there is no non web-interface methods (unless you mean "non web-interface" == browser). Its interface is http and its output is html (if someone know otherwise please correct me and you'll save me a lot of trouble :D).

Some simple things you can do, first disable the web login on the general admin page. Now what language and OS do you want to work with? I found something that explains the http string to send to turn on a device. I'll look for that later and post it here.

Here are the documents in one file (.tar.gz - gzip'd and tar'd). The file contains:
  • CasaRemote-Webcontrol.pdf
  • HowtoWriteGUICodeforWebControl.pdf
  • WebControlPLCUserGuide3-00-00.pdf
  • WebControlUserGuide2-03-00.pdf
  • WebControlUserGuide2-03-03.pdf
  • WebControlUserGuide.pdf
I'm not sure which files are which. One interesting thing to note. The main web page uses ajax to update the status of each interface. That can become a standard interface to the and would look something like this:

http : //webcontrol.uucp/api/status.xml?rand=0.8621719880887507

The random number is to get around caching issues in browsers. Each time you call the URL you need to have a different random numeric value.
 
Thanks for the link, i'll take a look and see what i can come up with. I would ideally like to use my Win7 machine to communicate with the box, to log temp and check status. What i meant by non web interface was non-browser, such as an app or something within windows. If windows is an issue i have no issues dual booting my win7 machine with something else until i can get a dedicated box up. I downloaded an app xapmcs, but did not get very far into it, and gave up because i had no idea what i was doing. Is xapmcs a viable solution or is it incompatible? Thanks for the help-
 
Thanks for the link, i'll take a look and see what i can come up with. I would ideally like to use my Win7 machine to communicate with the box, to log temp and check status. What i meant by non web interface was non-browser, such as an app or something within windows. If windows is an issue i have no issues dual booting my win7 machine with something else until i can get a dedicated box up. I downloaded an app xapmcs, but did not get very far into it, and gave up because i had no idea what i was doing. Is xapmcs a viable solution or is it incompatible? Thanks for the help-

With today's modern language OS shouldn't matter. I just need it as a reference point. I'm used to Unix and have a tendency to think from that perspective. Just don't ask me about VB as I have no access to use it.

One thing to note, the power supply should be between 6 and 9vdc, 800mA minimum. I just took a look at the 03.03 user guide.
 
ok cool, i made sure to get a suitable power supply when researching before i purchased. I think it would be best if i just got the remote temp monitoring in place before messing with the ttl output and relays. From what i can understand from the user guide, you send commands (cgi) to the webcontrol and it returns the values. How would you do this, from a web browser? or through a terminal/command prompt? Possibly a program or app? Ideally i want to install the device in a shed, it will be wirelessly networked to a modem inside with directional antennas, and then have a gui that i can monitor and or graph the temp for 24hrs to analyze the currents temps. I have all the parts i need and the components for the wireless link configured (ddwrt), i just need to figure out how to connect to and "talk" with the webcontrol in a way that allows me to see the highs and lows for various times, this will be done in my lan first, them installed on site.
 
I downloaded an app xapmcs, but did not get very far into it, and gave up because i had no idea what i was doing. Is xapmcs a viable solution or is it incompatible?

xapmcsWebControl can be used to "program" the WebControl for closed loop control using a model of a thermostat/humidistat with a setpoint. It can also be run in parallel with the WebControl to dynamically change the setpoint (or other control parameters) based upon some other higer level logic typically in a home automation system.

xapmcsWebControl was only developed for the BRE version of the WebControl and not the PLC one. Integration with other home automation elements is via LAN xAP message protocol. Use of xapmcsWebControl to "program" the WebControl is via a browser interface.

It is likely that for your dedicated application it will be easier to directly "program" the WebControl using either their browser UI for the BRE or upload script-like control logic via their browser UI for the PLC.
 
Here's an example of some C# (running mono in Linux, but the compiled exe works on Win,Lin,Mac) code I threw together a while back that will allow command line control of a webcontrol board. This code isn't optimized at all so there's a a lot of improvements that could be made (ie, its ugly). It does work quite well though and should be decently easy to follow. There should be enough comments to help you along, but post back if you have questions.

Usage
Webcontrol.exe <-- reports status of all inputs/outputs
Webcontrol.exe 4 1 <-- sets output 4 on
Webcontrol.exe 4 0 <-- sets output 4 off

Code:
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Net;
using System.Web;
using System.IO;

namespace WebControlBoard
{
	public class MainClass
	{
		public static void Main (string[] args)
		{			
			if (args.Length != 0)
			{
				SetOutput(args[0], args[1]);
			}
			
			string html = GetWebsiteHtml("http://10.10.220.170/index.cgi");
			// Build Regex to extract Temp, HUmidity, Digital and Analog inputs
			Regex rx1 = new Regex("(\\<p align=\"left\">)(.*?)(\\<\\/(.*?)\\>)",RegexOptions.IgnoreCase);
			MatchCollection matches = rx1.Matches(html);
			
                       //Pull Temps out of Collection
			GroupCollection TempGroup = matches[0].Groups;
			string[] temps = TempGroup[2].ToString().Split(' ');	
			for (int TempCount = 3; TempCount < 11; TempCount++)
			{
				Console.WriteLine("Temp Sensor " + (TempCount-2) + ": " + temps[TempCount]);
			}
		
			//Pull Humidity out of collection
			GroupCollection HumidityGroup = matches[1].Groups;
			string[] Humidity = HumidityGroup[2].ToString().Split(' ');	
			Console.WriteLine("Humidity Sensor: " + Humidity[2]);
         
			//Pull Digital Inputs out of Collection
			GroupCollection DigitalInGroup = matches[2].Groups;
			string[] DigitalIn = Regex.Split(DigitalInGroup[2].ToString(), ("&nbsp;"));	
			Console.WriteLine(("Digital Input 1: " + DigitalIn[0]).Replace("Digital Input 1-8 = ", ""));
			for (int DigitalInCount = 1; DigitalInCount < 8; DigitalInCount++)
			{
				Console.WriteLine(("Digital Input " + (DigitalInCount+1) + ": " + (DigitalIn[DigitalInCount]).Replace(" ", "")));
			}
         
			//Pull Analog Inputs out of Collection
			GroupCollection AnalogInGroup = matches[3].Groups;
			string[] AnalogIn = Regex.Split(AnalogInGroup[2].ToString(), ("&nbsp;"));	
			Console.WriteLine(("Analog Input 1: " + AnalogIn[0]).Replace("Analog Input 1-3 = ", ""));
			for (int AnalogInCount = 1; AnalogInCount < 3; AnalogInCount++)
			{
				Console.WriteLine(("Analog Input " + (AnalogInCount+1) + ": " + (AnalogIn[AnalogInCount]).Replace(" ", "")));
			}

			//Build New Regex to Extract Digital Output status
		        Regex rx2 = new Regex("(\\<td>TTL[0-7]</td>\\r\\n    <td>)(.*?)(\\</td>\\r\\n  </tr>)",RegexOptions.IgnoreCase);
			MatchCollection matches2 = rx2.Matches(html);
			int DigitalOutCount = 1;
			foreach (Match match in matches2)
                        {
                        GroupCollection groups = match.Groups;
			Console.WriteLine("Digital Output " + DigitalOutCount + ": " +   groups[2]);
			DigitalOutCount++;
			}	
			
		        }
		        //If command line arguments are supplied, use them to set outputs
		        public static void SetOutput(string Output, string State)
			{
		 	   string SetOut = "http://10.10.220.170/setoutps.cgi?0000W" + Output + State;
			   WebRequest request = WebRequest.Create(SetOut);
			   WebResponse response = request.GetResponse();	
			}
		
        static string GetWebsiteHtml(string url)
        {
            WebRequest request = WebRequest.Create(url);
            WebResponse response = request.GetResponse();
            Stream stream = response.GetResponseStream();
            StreamReader reader = new StreamReader(stream);
            string result = reader.ReadToEnd();
            stream.Dispose();
            reader.Dispose();
            return result;
        }

    }

Terry
 
Here's an example of some C# (running mono in Linux, but the compiled exe works on Win,Lin,Mac) code I threw together a while back that will allow command line control of a webcontrol board.
...

Thanks for the code Terry, are you missing the final '}' to close the namespace? While I won't touch mono, code is code and I can translate it into another language I can use.
 
Thanks for the code Terry, are you missing the final '}' to close the namespace? While I won't touch mono, code is code and I can translate it into another language I can use.

Yeah, probably. It was a quick cat/copy/paste from a ssh session. Most of the magic lies in the proper regex so any language that can scrape html will work fine - which is pretty much anything these days.

Won't touch Mono but you snuggle up to Perl??? I think you need medication Neil. ;) I guess you won't help me to fork a MonoMisterHouse then huh? :)

Terry
 
Yeah, probably. It was a quick cat/copy/paste from a ssh session. Most of the magic lies in the proper regex so any language that can scrape html will work fine - which is pretty much anything these days.

Won't touch Mono but you snuggle up to Perl??? I think you need medication Neil. ;) I guess you won't help me to fork a MonoMisterHouse then huh? :)

Terry
Mono is the kissing disease and if my wife catches me kissing anything other than her ... well there will be hell to pay :rolleyes:.

My DollHouse stuff will be an OOPL, for now I've selected Java/Groovy but that's not written in stone just yet. There are still many miles down that road yet.

My issues with Mono have to do with my distrust of Microsoft. Nearly 3 1/2 decades have taught me to keep a weary eye on them.
 
Roussel, thanks man that's a good first step. I'm a little confused though, don't have much experience with code, its mostly greek to me. Do i have to compile it into a program? I'm not sure how to do that, but can figure it out if that's what i need to do.
 
Roussel, thanks man that's a good first step. I'm a little confused though, don't have much experience with code, its mostly greek to me. Do i have to compile it into a program? I'm not sure how to do that, but can figure it out if that's what i need to do.

Attached is a zip of the project. If you're using Windows you can download either the Mono framework (opensource .NET) and MonoDevelop (the IDE) or you can use the free version of MS Visual Studio to compile it. There is a already compiled .exe in the debug folder, but unless your WCB's IP address is 10.10.220.170 it won't work for you as I hardcoded that IP in there... If anyone is interested, I'll make a generic version that allows you to put the IP in as a command line argument. I don't use this app, it was just an experiment right after I got the WCB.

EDIT: Also attached is an example of a vbscript that I use with HouseBot to control/monitor the WCB. Note that there are several HouseBot-specific lines in there that would need to be removed before it could function as a standalone vbscript.


Terry
View attachment WebControlBoard.zip
View attachment WebControlBoard2.vbs.txt
 
Hi Roussell,

My understanding is the current PLC firmware have a /getall.cgi call, which enable getting all the I/O status in one call. Do you have update to parse that getall.cgi output?

Thanks for posting your code.
 
Hi Roussell,

My understanding is the current PLC firmware have a /getall.cgi call, which enable getting all the I/O status in one call. Do you have update to parse that getall.cgi output?

Thanks for posting your code.

All of my boards have the old firmware so I haven't had the opportunity to play with the new PLC versions. The code shown in the above post (for the old firmware) will get all of the I/O status in one call. Setting the I/O status requires multiple calls though, does the PLC firmware allow that?

Terry
 
Back
Top