Monday, November 24, 2014

Uno32 serving web pages

I'm rather pleased with myself, probably more than I should be - "pride cometh before a fall" and all. Especially when I really didn't write the original code (I'll give credit to the original code author(s) on the git page). I did make some effort to port it and now I'm going to make an additional effort to correct what doesn't already work. I used it mainly because I couldn't find running code (what can I say, I'm lazy and as a programmer, well, that's a good thing ;-) ). So far, I see that the static IP address is working fine. I haven't tried the DNS functionality, I see the DHCP requests with Wireshark and the DHCP info but the Uno32 never returns from the call. The server is working fine and as you can see below, the Uno32 responds to the HTTP request. I did try the Ethernet client also and it never connected. Still, some working code is a great morale booster.

njc@Mozart:~$ telnet 192.168.1.4 80
Trying 192.168.1.4...
Connected to 192.168.21.4.
Escape character is '^]'.

HTTP/1.1 200 OK
Content-Type: text/html
Connection: close
Refresh: 5

<!DOCTYPE HTML>
<html><body>
analog input 0 is 735<br/>
analog input 1 is 772<br/>
analog input 2 is 768<br/>
analog input 3 is 766<br/>
analog input 4 is 791<br/>
analog input 5 is 794<br/>
Humidity: 44.10 % Temperature: 25.50 *C 77.90 *F
Heat index: 78.88 *F</br></body></html>
Connection closed by foreign host.
njc@Mozart:~$

What I'll work on next is the DHCP part of the code. I think this will the next important step, then the DNS and then the Ethernet client. After that I hope to port over an Arduino MQTT client. I need both the publish and subscribe parts of MQTT. My thinking is that the publish part will publish device updates at regular intervals. The Humidity and temperature in the case of the DHT22. Then the Subscribe part will allow for configuration, such that I can rename a light switch, configure the update times and other details of a device's operations. I think this will go a long way toward making easy to install, HA ready, devices in the home. The end user can then know a lot less about the devices and only need to configure a minimum number of parameters to make device operational. More on that to come as it does require a great deal of thought. At the moment I'm not sure how the HA software will deal with these publish/subscription issues. As I said, more thought is needed.

Saturday, November 22, 2014

ChipKit Uno32 with the WIZnet WIZ550io and some other ramblings

Yea, I finally have basic network code working with the ChipKit Uno32 and the WIZnet WIZ550io board. Yes I can ping and connect to its port 80 just fine. I had various problems with porting the code from the Arduino to the MPIDE environment but I've finally done it. I'm not exactly sure how fast the WIZ550io board is being clock at, I'll need to figure that out. Later I'll make some effort to move it from the SPI to the DSPI library but for now it's working. I'll try some of the more complex examples later. I'd like to use this setup to monitor the temperature and humidity in various parts of the house. My wife has been asking for this to replace the failing display she has on the table next to her. In addition I'd like to add support for MQTT. That way multiple HA systems can subscribe to the information. And, yes, I do have more than 1 HA system running. The Uno32 should have plenty of flash and RAM to handle the job. I'll post the initial code and updates to my Linux HA git account later this week.

I received the initial WIZ550io board from a WIZnet Circuit Cellar contest where I was going to build some HA nodes. While I probably wouldn't have won I'm still going to build the nodes. I had everything planned out except for my employer's work load. I managed to get a last minute work to build automation framework for our testing. I'm actually quite proud of that code. I'm now spending some time to document my framework and I have a number of ideas for improvements and tools to help with the automation. Anyways, back to Circuit Cellar; I might try to write an article for Circuit Cellar once I get this working (and I finish my presenations for TCF and VCF). I'm happy to see that Steve Ciarcia has bought Circuit Cellar. I didn't like the way Elector went out of it's way to hide any article of interest behind an Elector pay wall.

Back on the subject of HA, I've been reading a lot of articles on HA and IoT. I really need to spend some time adding it to my site. There are lots of projects people are undertaking. One of them is OpenHAB and it seems the Java folks have taken some interest in it. I read an interesting article on Java (from Java Magazine) on IoT and HA. The one asumption I found difficult to understand was that the HA node/device had enough resources to deal with the java VM. I don't see that happening with things like the Arduino. But is my assumption or theirs unrealistic? With small devices such as the Arduino we have to put up with a lack of security. The Uno32 has more resources it may be inadequate also. Perhaps we shouldn't settle for small devices with such short comings. Security isn't something you can easily bolt on a later date but we seem to be pushing forward building on that very premise.