navitron
 
Renewable Energy and Sustainability Forum
UK's most popular Renewable Energy Forum May 25, 2012, 04:07:31 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: Anyone wishing to register as a new member on the forum is strongly recommended to use a "proper" email address - following recent spam/hack attempts on the forum, all security is set to "high", and "disposable" email addresses like Gmail, Yahoo and Hotmail tend to be viewed with suspicion, and the application rejected if there is any doubt whatsoever
 
Recent Articles: UPDATE ON DECC APPLICATION FOR LEAVE TO APPEAL TO THE SUPREME COURT | Yingli Green Energy's PV Module Ranks No.2 in TUV Rheinland Energy Yield Test | Navitron Solar Showers at Glastonbury for Year 5!
   Home   Help Search Login Register  
Pages: 1 [2]   Go Down
  Print  
Author Topic: Digitemp! And then what?  (Read 4667 times)
djh
Hero Member
*****
Online Online

Posts: 1230


« Reply #15 on: November 09, 2009, 03:46:18 PM »

http://www.sqlite.org/lang_datefunc.html
Logged

Cheers, Dave
sleepybubble
Hero Member
*****
Offline Offline

Posts: 988


expect the unexpected, then its expected


« Reply #16 on: November 09, 2009, 05:59:22 PM »


AFAIU SleepyB runs a very similar setup already.



he certainly does  Wink. There is a semi helpful Howto on the Unslung website. I wish there was more info on that website, so much of it is incomplete or out of date. I've got my Slug reading Voltages from my inverter now too. Just have to script that so it posts into my database too.

I'm sure I have said it before but, I run Unslung on my NLSU2. Apache with the PHP modules installed, MySql, and I use PHPMyAdmin for interacting with the MySql database. All of those are ipkg's which can be installed from the command line.

Wookey uses OWFS for data harvesting, I use a variation of the perl scripts which package with Digitemp.

I have found the slug to be a little slow on webpage loads but I think that is more to do with the fact that I am using Drupal as a content management system. I'm only using that because I have used it on other website projects and I kinda like it. There are probably 'lighter' CMS systems out there, or you could just write your own html and use an offline management system such as Dreamweaver or NetObjects to keep everything trim and up to date. I used to do a lot of coding through dreamweaver with heavy use of SSI and style sheets, but I can't be bothered to do it all myself nowadays. I have been toying with the idea of shunting the webserving onto another machine and just use the slug for the data hosting. However that is all irrelevent.

My question as a slug user is; do you use it for anything else right now? i.e. Itunes, twonkyvision etc as you might start streching its capabilities a bit. Plus I am sure I have asked you before but is yours running at full speed? I know mine isn't and I keep meaning to chomp the resistor inside the case to get some more grunt out of it.
Logged

;-)
KLD
Hero Member
*****
Offline Offline

Posts: 1340


« Reply #17 on: November 09, 2009, 06:15:13 PM »

"My question as a slug user is; do you use it for anything else right now? i.e. Itunes, twonkyvision etc as you might start streching its capabilities a bit. Plus I am sure I have asked you before but is yours running at full speed? I know mine isn't and I keep meaning to chomp the resistor inside the case to get some more grunt out of it."

Sleepy, just quickly (dinner is being served as I type Cheesy )
My Slug is leads an idle life, the 1-wire stuff will be the only thing running.
It has survide the snip, and is ticking twice as fast now.
Have you done anything about automatic reboot after power failure?

Klaus
Logged
sleepybubble
Hero Member
*****
Offline Offline

Posts: 988


expect the unexpected, then its expected


« Reply #18 on: November 10, 2009, 09:59:49 AM »

"My question as a slug user is; do you use it for anything else right now? i.e. Itunes, twonkyvision etc as you might start streching its capabilities a bit. Plus I am sure I have asked you before but is yours running at full speed? I know mine isn't and I keep meaning to chomp the resistor inside the case to get some more grunt out of it."

Sleepy, just quickly (dinner is being served as I type Cheesy )
My Slug is leads an idle life, the 1-wire stuff will be the only thing running.
It has survide the snip, and is ticking twice as fast now.
Have you done anything about automatic reboot after power failure?

Klaus

No I haven't, I jumped straight in with both boots on trying to get it to do the 1-wire stuff and ignored all the other things that might have been more useful to do first. However it is powered off the UPS so rarely suffers power failure.
We store music and films on ours as well as the database stuff, it seems to cope fine with streaming them around the house. I have a webcam that I want to strap to it as well, I think that one might give it a bit of a hard time!
Logged

;-)
KLD
Hero Member
*****
Offline Offline

Posts: 1340


« Reply #19 on: November 10, 2009, 12:18:45 PM »

SleepyB

One for the slug / 1-wire owner: can you use the slug's power supply unit's spare capacity (it's spec'ed at 5V / 2A) to inject power into the 1-wire network? It would be easy to just T off the +5V. But what about the ground? I've got the DS9490R USB-to-1-wire adaptor. It sounds likely that the ground connection on the USB side and on the 1-wire side are connected, and therefore the 1-wire ground should be the same as the PSU ground. Right / wrong / haven't-you-got-anything-else-to-worry-about?

Klaus
« Last Edit: November 10, 2009, 04:22:13 PM by KLD » Logged
KLD
Hero Member
*****
Offline Offline

Posts: 1340


« Reply #20 on: November 10, 2009, 12:24:41 PM »

Wyleu,

I heard you mentioning somewhere else that it's not a good idea to install branches on the 1-wire network. I seem to remember, though, a diagram of a star topology on the Dallas web site. Does this mean only branches further down the tree are bad?

Also, on a small network (current plan is for below 20 sensors, hardly worth it  Wink ) do I need to worry about Schottky diodes / pull-up (?) resistors? Maybe you've got a pointer handy to the relevant Maxim docu.

Thanks
Klaus
Logged
wyleu
Guest
« Reply #21 on: November 10, 2009, 09:52:53 PM »

Your enemy is the reflection. A signal 'bounces' back from the end of the branch inverted and interferes with other signals, which is why branches are generally considered a bad thing. It's called transmission line theory.

If you put the correct termination at the hub end I suspect ( and if Maxim have said it it must be true ) you could run multiple branches but it would be a patching nightmare and would probably require every branch to be terminated at one point ( I don't know ). I've not tried it, as much because it requires some fairly messy wiring than an desire to test it.  I know long runs do work so stick with them. (40 metres with 40 sensors  buried in a concrete screed ) If someone can say they've done it then fantastic!!

After much initial playing around I settled on using the hobbyboard power injector and the Blue USB dongle which just sort of does it all for you. If your building stuff yourself I'd follow the Maxim guidelines exactly cos they are as keen as anybody to get it working.

 In practice you will learn far more by just going for it and learning how to read the values with which ever tool you use. The gap from getting a reading to getting lot's an be quite a step and nothing like the realisation that you've read a temperature 5 metres above your head to with an accuracy that would confound Maxwell is something rather wonderful in itself.

Then you look around at the wires draped all over the family  computer and the messy collection of if's and whiles in whatever lash up you've used to get that magic first reading and start to wonder now it's working how does one keep it working and not tripping everyone up?
The major reason you measure is to learn things about the system and its' the result of what you learn that decides what you want to measure next, and what's the betting you have a wire there?

Sorry to not point to lot's of Datasheets but it's been a long day.... surrender


Logged
KLD
Hero Member
*****
Offline Offline

Posts: 1340


« Reply #22 on: November 15, 2009, 05:30:56 PM »

Look what you've done: your encouragements have let to me spending the evenings reading up on sqlite, perl, digitemp, et al. Hardly any time left to read the forum  Grin
What happened so far:
Hardware: Four sensors populated their respective pockets in the thermal store. They are now connected through a DS9490 1-wire-to-USB bridge to a slug, running Debian Lenny.
Digitemp: when querying temperatures with 'digitemp -a -q' the first output line reads something like 'Found DS2490 ...'. I had to re-compile the sources, after editing out a few lines in ./userial/ds2490/usbses.c Now the quiet flag really means quiet.
Perl: Digitemp comes with a few scripts. There is an example perl script that calls digitemp and inserts the output into a MySQL database. Was a bit of a faff to convert that to SQL as understood by SQLite3 (for somebody who two days ago had never (knowingly?) looked into a database).
Cron: The above perl script is now called every 5 minutes by root's crontab. Using the USB interface, digitemp apparently has to be called by root, otherwise it has no access to the USB port. (The 1-wire-to-serial port adaptors DS9097(U) will work after granting rights to all users).
SQLite3: I created a new database using this:
Code:
klaus@Slug1:~/sqlite$ cat make_sqlite.sql
CREATE table digitemp (
  dtKey INTEGER PRIMARY KEY,
  timeEnter DATE,
  SerialNumber varchar(17) NOT NULL,
  Celsius decimal(6,2) NOT NULL
);
CREATE TRIGGER insert_digitemp_timeEnter AFTER INSERT ON digitemp
BEGIN
UPDATE digitemp SET timeEnter = DATETIME('NOW','localtime')
WHERE rowid = new.rowid;
END;

So, every 5min I get four new lines inserted, like these:
Code:
890|2009-11-15 16:50:08|2820341D020000D9|36.94
891|2009-11-15 16:50:08|28204A1D02000016|42.06
892|2009-11-15 16:50:08|2883361D0200005F|44.19
893|2009-11-15 16:50:08|283F551D0200007A|37.56

That's the end of my current wisdom. How do I get the data out again? I've managed to extract the time and temperatures for one sensor at a time, and dump that to an ASCII file. The next stage in my data handling would be a few mathematical transformations (eg. calculated solar heat gain per day / month / nnn, subsequently use these figures to compute distribution tables (how often did I gain between 4 and 5kWh per day in September?), and the like. Until now I have done most of these analyses in OpenOfficeCalc.

Klaus
Logged
wyleu
Guest
« Reply #23 on: November 15, 2009, 06:41:52 PM »

Well that's a smite for Perl straight off...  Shocked

The next tool to look at is sqlite manager on firefox. That will allow you to start to learn how to extract information at the SQL level. https://addons.mozilla.org/en-US/firefox/addon/5817
That will demonstrate you how these questions are phrased.
http://docs.python.org/library/sqlite3.html#module-sqlite3 is one way of getting at the data from python, hopefully someone perlish well sling up the equvalent, and Java anyone?

That shows how you might interconnect the data with any other form of craziness you might have.
For instance think about how you would now construct the pump control code. ( don't worry about how you might operate a pump, just print Pump ON and probably more  important PUMP OFF.)
You might discover you want one or several tables to define some parameters. The sort of thing that is essential would be the difference in temperatures at which you would pump ad how long to wait between readings.

settings = read_settings_from_database()
while 1:
    sensor = read_sensors_and_database()
    if sensor.roof > (sensor.coil + settings.temperature_diff ):
        print 'pump On'
    else:
        print 'pump Off'
    sleep (settings.wait_between_reads )

The good thing here is that rather than me having to go into the programme code and change these values I can change them in the database with some other chunk of code, running a nice flashy front end on a webpage for instance and the pump programme never need worry itself about that bit of data. It only needs to complain when read_settings_from_database() can't find anything and that's not the pump programmes concern anyway.


The calculation of how much Energy type questions is really one of display.
Quite how do you want to present the data?
Graphs ? Pie charts,? 3D surfaces, Flashing LED's, scrolling messages on all the music system displays around the house?, broadcast to the Internet? World War Three claxon ?!? all require default ranges values and some parameters, What colour is that graph? , how loud is that claxon? to be stored to describe your particular requirements. The important thing is whilst your designing your display requirements, the database is chugging away making readings.

http://documentation.openoffice.org/HOW_TO/data_source/SQLite.pdf  Is one way of hooking openOffice  into the sqlite3 database, which should let you do a bit of data using Open Office calc. once you have it as a datasource.

I have to say it's a bit crashy as I've tried it here, but that might just be my lack of experience with Officey type programmes.
I've certainly got the database end of OpenDoc hooked up.

But the question is one for yourself. How do you intend to present the data, and to whom?













« Last Edit: November 15, 2009, 07:04:31 PM by wyleu » Logged
sleepybubble
Hero Member
*****
Offline Offline

Posts: 988


expect the unexpected, then its expected


« Reply #24 on: November 15, 2009, 11:01:33 PM »

Klaus,

Well done its a bold step but one well taken. As Chris says what do you actually want to do with the data? Graphs widgets etc etc...

For us (read my missus) I just wanted some simple html to insert into a webpage running on the slug that could be checked at the end of the day to see if we needed to add heat to the cylinder.... something like the below with a bit of hacking to suit youre own settings on a php enabled webserver (say the slug maybe?) is possible the next step.

Code:
<?php

$dbhost 
'localhost';
$dbuser 'root';
$dbpass 'not flippin likely';
$dbname 'tempdata';

$conn mysql_connect($dbhost$dbuser$dbpass) or die                      ('Error connecting to mysql');
mysql_select_db($dbname);
$query  "SELECT time, SerialNumber, Fahrenheit FROM digitemp LIMIT 1 WHERE SerialNumber='280B428F01000064'";
$result mysql_query($query);

while(
$row mysql_fetch_assoc($result))
{
    echo 
"Stove Flow".
  "time :{$row['time']} <br>" .
         
"Sensor : {$row['SerialNumber']} <br>" 
         
"Temperature : {$row['Fahrenheit']} <br><br>";


mysql_close($conn);

?>

When you've sussed simple data extraction you need to think about a metadata table in your DB so you can assign real world names to the unintelligible sensor address's. You soon learn to recognise the last four digets of a sensor address, but it will only make sense to you.

Well done for starting to log though....
Logged

;-)
Pages: 1 [2]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!