Green Building Forum - RaspberryPi Tue, 19 Dec 2023 05:11:14 +0000 http://www.greenbuildingforum.co.uk/newforum/ Lussumo Vanilla 1.0.3 RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217525#Comment_217525 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217525#Comment_217525 Mon, 19 Jan 2015 09:00:05 +0000 SteamyTea Thanks.
I think it was me that asked about one or many scripts to do things.
Going to start working on it in earnest today, I have a pencil with a rubber at the other end, let's see which end wears out quickest.]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217532#Comment_217532 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217532#Comment_217532 Mon, 19 Jan 2015 10:21:33 +0000 snyggapa
an example of what I get out (you can also get the raw data) is here

https://grovestreams.com/singleDash.html?org=b1343ea7-bff5-303b-9d31-89469cd583ab&itemUid=7e8f1935-2742-3d22-87fe-0f4f1fa9c8ba&api_key=2c615462-fe55-38c3-b8b9-cb31f141bc84&title=FlottageBoard&titleColor=000000

grovestreams just gets raw data, it then derives the rest like daily usages, day/night split etc from the raw data. And it's free for less than 10,000 transactions/month and very little money for above that. I post a set of data every 5 minutes which comes to less that 10,000 per month, so free to me :)

-Steve]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217579#Comment_217579 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217579#Comment_217579 Mon, 19 Jan 2015 16:18:06 +0000 Ed Davies Posted By: borpinBetter if the clients simply send the data regularly or by exception to a 'static' server. There have been a couple of comments on this theme. I'd agree in general but practically it might turn out in this case easier to open a port on the sensor machine's net than the central site's, particularly for Steamy's initial demo (because the sensor is on his home network whereas the central machine is in an office with separate IT people) . All a matter of circumstances. The key is not to have the overall design too dependent on the communications details.]]> RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217750#Comment_217750 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217750#Comment_217750 Tue, 20 Jan 2015 22:27:08 +0000 cjard
Nothing like making a job easy from the start eh?

"Hmm.. I need to get into something regularly. I know. I'll use one of the cells at the prison where I work"



When amazon and azure will give free micro virtual machines away with totally configurable security, choosing to site a server at a network where the security is under the control of people who have bigger problems and deeper concerns is perhaps not ideal]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217754#Comment_217754 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217754#Comment_217754 Tue, 20 Jan 2015 23:34:04 +0000 SteamyTea I need to check if I can reach the RPi that is doing the logging at home from the big scary world (I know a cafe with a good view and free wireless). Hopefully I have set up my port forwarding right, guess I will find out if I wake up to no files and plenty of Trojans. Shall pull the lead on the NAS!
I can grab data of the logging RPi from a remote RPi using ssh in a Python script. I have set up passwordless login with RSA, so hopefully I am secure. All passwords have been changed to 'quite tricky ones'. So tricky I keep getting them wrong.

So my Python script on the Office RPi can send a request for data to my Logging RPi and that gets sent back. It prints out to the screen no problem.
Unfortunate when I try and save that data as a .csv file I just get a stream of zeros. There was some message about not being an int value (integer). Need to look at that. Not sure if it is the way the data is transported, or read 'back at the Office'. Just surprised I have got this far without serious upset (writing things down does help).

I lost a day re-writing my CC reading script, was pretty easy once I had finished (dumb mistake not defining it). But now it just logs what I want rather than everything spewing out the CC.
Out of interest, and to save me having a go on something working, can I use 'or' in an if statement. Something like:

If == 100 or 200 or 300

Where would I put the :
After every condition or just at the end?

Off to bed now, not a real programmer, can't live off Red Bull and Pizza.

Thanks for all your help and suggestion.]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217757#Comment_217757 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217757#Comment_217757 Wed, 21 Jan 2015 05:36:46 +0000 cjard
I'm no python expert but typically programming languages don't work like that. It's a very human thing to remember the left hand operand ( i ) and then look at everything to the right of the operator as the other operand. The computer just sees it as a bunch of operators ( = + * > or and so on) and on either side the two operators. As a result the computer sees if i == 1 or 2 or 3 as

If ( i == 1 ) or ( 2 or 3)

Whether it can resolve (2or3) to true depends on the language. In some it fails. In some it may become either a 2 or a 0, which may then be true or false depending on how it sees numbers and booleans. In some it may work, though the coding community would generally avoid those languages

Your options for doing thus are varied. I'd choose the simplest:

If k == 1 or k==2 or k==3 :

The colon goes at the end of the line]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217775#Comment_217775 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217775#Comment_217775 Wed, 21 Jan 2015 11:02:00 +0000 Ed Davies
if i in (100, 200, 300):

or

if i in {100, 200, 300}:

I.e., using membership testing on a tuple or set. Could use a list, [100, 200, 300], or a dictionary as well if wanted.]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217777#Comment_217777 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217777#Comment_217777 Wed, 21 Jan 2015 11:30:33 +0000 SteamyTea
The good news is that I can log in remotely using Firessh from a cafe overlooking the sea. So that bit seems to be OK.
Just got to sort this strange thing with the zeros when I try and save the data to a file.

I have a line something like

fandata = (ssh pi@192.168.1.100 cat "/home/pi/CurrentCost/oneline.csv")

This prints to the screen fine and updates every few seconds, but when I try and append it to a file with

tfile = open("/home/pi/RemoteData/oneline.csv", "a")
tfile.write("%s"%fandata + "\n")
tfile.close()

I just get this error message about int not being defined.

I may have made an error in the fandata = line as I am doing that from memory.

Edit

Changed the code above as it was total nonsense.
But thinking about it, as I am using cat, I should be able to just write to an existing file as it concatenates. Is that right?]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217878#Comment_217878 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217878#Comment_217878 Thu, 22 Jan 2015 15:05:40 +0000 Ed Davies Posted By: SteamyTeaChanged the code above as it was total nonsense.Good, it was. :smile: You need to use subprocess.Popen or something to execute a command, you can't just write it in a string.

In general something like "%s" % fandata is pretty meaningless; you might as well just write fandata I'm not quite sure what you had in mind but perhaps it could be done a little more compactly with "%s\n" % fandata
But thinking about it, as I am using cat, I should be able to just write to an existing file as it concatenates. Is that right?
cat concatenates its input files to produce a single output file. (About the only time I use it like that is to concatenate public keys from multiple ssh clients to form the authorized_keys file in the .ssh directory on the host, as I described in email.) To concatenate the output of cat onto an existing file you need to use something else. If it's all on one machine:

cat input1 input2 >> outputadds the contents of the two input files in turn to the output file. Doing redirection like this over ssh or within a Python subprocess.Popen call is more tricky as redirections are handled by the shell (often bash or dash). What I think you want might be done in a shell script on the central data-collection machine using:

ssh pi@192.168.1.100 cat "/home/pi/CurrentCost/oneline.csv" >> /home/pi/RemoteData/oneline.csvYou could get a similar effect in a Python script fairly easily but it would be a few lines of code.

If you were running a script on the sensor machine (the one with the CurrentCost connected) then something like:

cat "/home/pi/CurrentCost/oneline.csv" | ssh steamy@server.charity.org tee --append /home/pi/RemoteData/oneline.csvmight append on the server appropriately - with a few tweaks to the file names.]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217880#Comment_217880 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=217880#Comment_217880 Thu, 22 Jan 2015 15:14:45 +0000 SteamyTea If the tender is won, then I can try it out in the real world and worry about putting all the little things right, things like my router IP address changing.

Working for the next few days so it will all come to a stop now till next week. Quite chuffed that the concept is sound.

Thanks for your help.]]>
RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218371#Comment_218371 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218371#Comment_218371 Mon, 02 Feb 2015 08:22:44 +0000 Chris P Bacon http://www.theregister.co.uk/2015/02/02/raspberry_pi_model_2/]]> RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218372#Comment_218372 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218372#Comment_218372 Mon, 02 Feb 2015 08:40:51 +0000 SteamyTea RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218416#Comment_218416 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218416#Comment_218416 Mon, 02 Feb 2015 21:40:52 +0000 cjard https://www.modmypi.com/rasclock-raspberry-pi-real-time-clock-module among others?]]> RaspberryPi http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218422#Comment_218422 http://www.greenbuildingforum.co.uk/newforum/comments.php?DiscussionID=9179&Focus=218422#Comment_218422 Mon, 02 Feb 2015 22:52:38 +0000 SteamyTea I would rather and RTC was there than an ADC, though both would be best.]]>