Shop OBEX P1 Docs P2 Docs Learn Events
2011 Spinneret Web Server design contest entry; JHA — Parallax Forums

2011 Spinneret Web Server design contest entry; JHA

JeffaJeffa Posts: 80
edited 2011-07-18 22:46 in Accessories
Note: I changed the name of this project to nerdDoro see this thread for final spin source code as well as examples of accessing nerdDoro from a Wordpress widget and MS Windows phone 7 as well as a .net console application for database persistence and an asp.net MVC w/jQuery display of the data over time. http://forums.parallax.com/showthread.php?133459-nerdDoro-Spinneret-design-contest-entry-submission -jeffa @jhalbrecht www.rodaw.com

JHA [just|jiffy|?] Home Automation. A play on initials/words of my name Jeffrey H. Albrecht

JHA will be an implementation of ePhidgetY replacing a Phidget controller and Linux box with a Spinneret web server and environmental sensors such as the Parallax Sensirion Temperature/Humidity Sensor #28018and/or LM34 temperature sensors. Possibly others.

ePhidgetY is a Windows Phone 7 application that I wrote during xapfest. It reads an XML file to display current and summary environmental data. ePhidgetY allows configuration of the URL for reading the XML such that any application writing to it’s XML format can display environmental data from that url.

ePhidgetY is a Phidget controller, temperature and lightsensor and LCD that displays the current inside and outside temperature, time and date. It runs on a Linux box running Fedora core 13 (hence it’s host name Saturn) and records this data every sixty seconds. It’s been quite a learning experience starting with the Phidget, (BEFORE I WAS AWARE OF PARALLAX), controller. Learning to manipulate the LCD and read the sensor using c++. Then enhancing the program to write to MySQL. To make SQL queries with PHP and send that data via JSON to a web page using the jQuery flot plugin to display temperature over time. The latest was to write an XML file with summary data for the windows phone application ePhidgetY.

A feature of JHA may be the ability to continue logging to the MySQL db and use the SD card as a backup in the event of a loss of connectivity.

Marketplace_Desktop_200x200.png
The phidget controller and display in a Glad refrigrator storage container.
Capture.PNG
Windows Phone 7 ePhidgetY screen

References:
www.xapfest.com
http://www.xapfest.com/apps/details/ephidgety
http://www.jeffa.org/~jeffa/ePhidgetY/(takes a moment to load…) Might view better in Chrome or Firefox. I am in theprocess of moving this to http://appdevpro.com/ePhidgetY.aspx
http://code.google.com/p/flot/
480 x 800 - 25K

Comments

  • JeffaJeffa Posts: 80
    edited 2011-06-28 17:38
    Got my Project ID. Thanks Lauren! I also ordered up some parts earlier today. Don't know that I'll use the Backpack in this project but I've been wanting to take a look at it.

    3.3V Regulator
    Prop Plug
    Propeller Backpack
    Prototyping Daughterboard
    Sensirion Temperature/Humidity Sensor
    Spinneret Web Server

    c ya... - jeffa
  • JeffaJeffa Posts: 80
    edited 2011-07-01 20:27
    Parts!

    And look, there's a giant bug in the hardware already! :-)
    1024 x 768 - 83K
  • JeffaJeffa Posts: 80
    edited 2011-07-01 22:45
    uh ohh....

    "The final factor is professionalism, which accounts for 25% of the final score. We will be reading through all of the project reports and forums posts, as well as viewing all of the pictures, videos, and files associated with the entries. It is important for us that everything is presented in a professional, easy to follow format, so it plays a significant role in the final score."

    Have I already blown the: "professionalism" by my diary like entries as I entered the contest, ordered parts and made offhand fun remarks such as refering to the spider on the spinneret "... there's a giant bug in the hardware ..." when I received the parts and saw the Spinneret for the first time?

    Or will it be be obvious or noted in the text when I have specific contributions, and that my final submission project report is the criteria in this regard?

    c ya... - jeffa
  • David CarrierDavid Carrier Posts: 294
    edited 2011-07-05 08:42
    Jeffa,
    If we thought comments like yours about the "giant bug in the hardware" were unprofessional, we wouldn't have printed a giant spider on the bottom of the Spinneret Web Server.

    — David Carrier
    Parallax Inc.
  • JeffaJeffa Posts: 80
    edited 2011-07-06 11:10
    HelloWorld and Power over other Pairs

    I designed, assembled and blogged on a way to power up my Spinneret using what I call: "Power over other Pairs" Here is a details view.
    PooPOpenedUpReSizedAgain.jpg
    and here it is buttoned up.
    PooPbuttonedUpReSizedAgain.jpg
    I have approximatley fifty feet of cat5 between the two ends that are shown here in one picture.
    A wall wart feeds one end, and a small circuit in a low profile box regulates and filters to 5VDC.

    Using the: "W5100_Web_Page_Demo_indirect.spin" I got a jHelloWorld loaded from the Spinneret.
    jHelloWorldwm.jpg

    What next? I think I'll try the NTP thread.
    1024 x 937 - 100K
    1024 x 1102 - 129K
    645 x 564 - 37K
  • JeffaJeffa Posts: 80
    edited 2011-07-08 09:58
    Yup. SNTP it was. I got the Spinneret RTC set from an NTP server. Then worked up some routines to display the time from the RTC. kinda of a check and balance to be sure I actually did what I thought I did.

    Then I added a 4 line serial LCD display and have that functioning too. I switched the way I power the Spinneret so I could use J6 to drive the LCD with a servo cable. I'm now powering through J1 pin 2 and 12.

    The wall wart I was using claimed it was 9v but was more like 12v. The regulator I was using to produce 5v was overheating and once I added the LCD it dropped out several times. I found another wall wart that claimed 6.5v it's working well enough to continue development until I get to a store to pick up a more optimum 7.5vdc unit. Currently I'm supplying 4.5vdc to the Spinneret and the LCD.

    I also added a few more entries to my Spinneret Resources blog.

    The Sensirion and web server are calling.

    c ya... - jeffa
  • JeffaJeffa Posts: 80
    edited 2011-07-09 14:32
    Added Sensirion

    Today I soldered up the Proto-DB to support Vin, and the Sensirion temperature / humidity sensor for my Spinneret project.
    IMG_0968.jpg

    Note in this picture the Spinneret with Proto-DB board and sensor perched ontop of a clock thermometer. You can also see a PST displaying data read from the Sensirion using the SensirionDemo_full.spin object. I’m using A24/A25 onthe Spinneret. The thermometer indicates 79.2 while the sensor data displayedis 84 degrees. Seems reasonable.
        if count//4                                       'toggle every 4 cycles
          sht.config(33,sht#off,sht#no,sht#lores)         '3 fast, loRes measurements
        else
          sht.config(33,sht#off,sht#yes,sht#hires)        '1 slow, hiRes measurement
        count++
    
    It appears that only the '1 slow, hiRes measurement' is returning valid results.
    DATA, 6884, 1199, 29.1, 84.5, 40.1%,  14.2,       57.6,    84, 39,   00000000,
    DATA, 1721,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 40,   00000011,
    DATA, 1720,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    DATA, 1720,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 40,   00000011,
    DATA, 6883, 1198, 29.1, 84.4, 40.1%,  14.2,       57.5,    84, 39,   00000000,
    DATA, 1721,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 40,   00000011,
    DATA, 1721,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    DATA, 1721,   75,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    DATA, 6883, 1198, 29.1, 84.4, 40.1%,  14.2,       57.5,    84, 39,   00000000,
    DATA, 1721,   74,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    DATA, 1721,   74,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    DATA, 1721,   74,-22.5, -8.5, -0.1%,   0.0,        0.0,    84, 39,   00000011,
    
    1024 x 768 - 120K
  • JeffaJeffa Posts: 80
    edited 2011-07-15 17:14
    I am calling the project nerdDoro now.

    Added XML output for dateTime and temperature to use in my wp7 application. The XML looks like this:

    [HTML]
    <nerdDoroData xmlns:xsd="http://www.w3.org/2001/XMLSchema&quot; xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt;
    <currentTemperature0>86.9</currentTemperature0>
    <currentMeasuredTime>2011-07-15T16:50:45</currentMeasuredTime>
    </nerdDoroData>[/HTML]

    I extend the s-35390A_GBSbuild_02_09_2011.spin to additionaly return a shorter string for use on the LCD.
    PUB ShortFmtDateTime      ' jeffa 7/12/2011 Returns similar to: "Tue Jul 12 08:51 AM"
          FmtDateTime
          bytemove (@DataBuffer[10], @DataBuffer[16], 12)
          bytemove (@DataBuffer[16], @DataBuffer[19], 3)
          bytemove (@DataBuffer[19], 0, 1)
          return @DataBuffer
    

    I created this code to get a datetime for the xml (see above output) I'm reading in a .net wp7 application.
    PUB doXmlDateTime
     
        ' 2011-01-03T03:41:02   want it in this format for .net xml reader
        ' 01234567890123456789  column numbers
     
        rtc.Update
        bytemove(@xmldatetime[0], string("20"), 2)
        bytemove(@xmldatetime[2], str.trimCharacters(str.numberToDecimal(rtc.GetYear, 2)), 2)
        bytemove(@xmldatetime[4], string("-"), 1)
        bytemove(@xmldatetime[5], str.trimCharacters(str.numberToDecimal(rtc.GetMonth, 2)), 2)
        bytemove(@xmldatetime[7], string("-"), 1)
        bytemove(@xmldatetime[8], str.trimCharacters(str.numberToDecimal(rtc.GetDay, 2)), 2)
        bytemove(@xmldatetime[10], string("T"), 1)
        if rtc.IsPM
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour + 12, 2)), 2)
        else
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour, 2)), 2)
        bytemove(@xmldatetime[13], string(":"), 1)
        bytemove(@xmldatetime[14], str.trimCharacters(str.numberToDecimal(rtc.GetMinutes, 2)), 2)
        bytemove(@xmldatetime[16], string(":"), 1)      
        bytemove(@xmldatetime[17], str.trimCharacters(str.numberToDecimal(rtc.GetSeconds, 2)), 2)
        xmldatetime[19] := 0
        return @xmldatetime
    





    Some to do items
    • check sensirion code. Appears inaccurate relative to actual temperature swings in it's measured environment
    • Enclosure
    • Start the project documentation
    • It's only working on one socket
    • Clean up the HTML from the 'working' to something more organized and self documenting
    Lovin' the Spinneret! Can't believe how fun it still is to click the LED button and watch the usr led toggle on and off! :-)

    nerdDoro is available at https://github.com/jhalbrecht/nerdDoro
  • JeffaJeffa Posts: 80
    edited 2011-07-15 18:01
    Meant to include that when it's up it can be reached as http://jeffa.org:90 you can click on the button xml or access http://jeffa.org:90/xml for the xml.
  • JeffaJeffa Posts: 80
    edited 2011-07-16 13:10
    Noticed a little problem today while looking at the XML during the noon hour. It displayed as 24:53:10 rather than 12:53:10

    I changed the code from
    if rtc.IsPM
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour + 12, 2)), 2)
        else
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour, 2)), 2)
    
    to
    if rtc.IsPM  & (rtc.GetHour <> 12)
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour + 12, 2)), 2)
        else
          bytemove(@xmldatetime[11], str.trimCharacters(str.numberToDecimal(rtc.GetHour, 2)), 2)
    

    the XML is all better now.

    Regarding the temperature readings, I put an extension cable on the Spinneret to move the Proto-DB away from the Spinneret. I also tweaked the temperature conversion coefficients. And in reviewing the SHT11 Sensirion data sheet I'm now satisified the results are acceptable.
  • JeffaJeffa Posts: 80
    edited 2011-07-17 10:25
    I was fiddling around with my XML code last night with fiddler (pun intended). Fixed up some issues with CR LF. Server appears more robust now.

    If you haven’t used fiddler check it out at: http://www.fiddler2.com/fiddler2/ It’s a very handy freeware tool for debugging web applications. I’ve been making use of the HEX dump to fix my server response.
  • Mike GMike G Posts: 2,702
    edited 2011-07-17 10:52
    Hi Jeffa, nice work by the way.

    I tried hitting your site a few times the last couple of days but I keep getting an "Unable to connect" message; Win XP, Firefox. Is the site up or are you working on it?
  • JeffaJeffa Posts: 80
    edited 2011-07-17 22:13
    I've been working on it a quite a bit. I'm trying to leave it up as much as possible when not working on it. It hasn't seemed to be as reliable as I would hope. Not sure what's happening. I hit it as 10.9.8.150 pretty hard from two different ip addresses on my intranet and one external as http://jeffa.org:90 it seems to stay up and running. I turn my back and work on some other things and hours later I notice it unresponsive. I'm going to check the power supply a bit more tomorrow.

    What's your experience with stability / relability?
  • Mike GMike G Posts: 2,702
    edited 2011-07-18 03:34
    What's your experience with stability / reliability?
    I spent a few months of my life building a stable Spinneret. You have to look at the state of the status registers and handle the changing state accordingly.
  • JeffaJeffa Posts: 80
    edited 2011-07-18 09:48
    Hmmm......

    This morning my code is running. The LCD is being updated with current time and temperature. I haven't accessed nerdDoro for many hours yet it is unresponsive to http requests. I can ping it.
    Netstat shows
    C:\Users\jeffa>netstat
    Active Connections
      Proto  Local Address          Foreign Address        State
      TCP    10.9.8.108:49566       10.9.8.150:http        ESTABLISHED
    ...
      TCP    10.9.8.108:56003       10.9.8.150:http        ESTABLISHED
      TCP    10.9.8.108:56033       10.9.8.150:http        ESTABLISHED
      TCP    10.9.8.108:56072       10.9.8.150:http        ESTABLISHED
    ...
      TCP    10.9.8.108:61851       10.9.8.150:http        SYN_SENT
    
    Scratching my head right now. I've really hammered on it from multiple clients and hosts with it responding. Then I let it idle for hours and this.

    I'm thinking about creating a debug object in a COG to print to the PST whenever a wiznet status register changes. Anyone have a code snippet like that?

    I'm thinking I should look at why the TCP connections to .108, my main win 7 64bit notebook, are established and not droping.

    Any ides / suggestions?

    Source code to nerdDoro: https://github.com/jhalbrecht/nerdDoro
  • Mike GMike G Posts: 2,702
    edited 2011-07-18 12:17
    Yeah, take a look at my Multi-Socket Project it does exactly that and with all 4 sockets.
    http://www.agaverobotics.com/spinneret/source/

    You can find the bare bones project in my Spinneret Project entry. The pages are being rendered from the Spinneret.
    http://spinneret.servebeer.com:5000/source/httpserv.zip
  • JeffaJeffa Posts: 80
    edited 2011-07-18 22:46
    Wee fun! I pretty much have the functionality I was looking for implemented. And a first pass at cleaning up the rough. Time to enhance my wp7 app for the nerdDoro data. I have a php example created. Still need to do the prototype enclosure.

    Striped out a bunch of test code. Lot's of unused HTML and js.

    Added utility function button to set the RTC from SNTP. Eventualy I should set the RTC from NTP once a day or week. For now I want to watch the drift.

    Added the timer object rather than the rtc alarm as it has display capabilities built in as well as some other handy features.

    Added a check on the usr push button to restart the timer object.I had planed to use a Memsic 2125 dual-axis accelerometer but couldn't find one in my sensor bin. Don't think I'll have time to implement that before the deadline. I would have just shaken the clock to set the timer rather than the push button.

    Added code to check when the minutes were equal to 25 for a Pomodoro. Actually I've been testing it with 1 minute. I might use the HTML utility page to set the timer length. I had planed to have it do a 10 minute timer for one type of shake, and a 25 minute pomodoro for another shake. Useful in the kitchen for a cookie timer. Once I hit the programed interval I flash the LCD backlight on and off. After codding the LCD pizzo I noticed that my LCD is an 'E' revision apparently without the speaker. I wonder if I can add the pizzo to an 'E' model ?? I let the timer continue to count up after the 25 minute Pomodoro.

    nerdDoro seems stable tonight. I've left it runing after hitting it hard from several ips and browsers. It's available as jeffa.org:90 the xml is at http://jeffa.org:90/xml Hope it's still answering requests when I wake up. 'night.

    Source updated https://github.com/jhalbrecht/nerdDoro
Sign In or Register to comment.