Go to advanced search

by PingoBags
Mon Sep 03, 2018 3:33 pm
Forum: Beginners
Topic: start app via ssh
Replies: 11
Views: 599

Re: start app via ssh

Heres the vb source. I'll also upload the entire app. Tested and works for me. Send Command.zip Imports Renci.SshNet Imports Renci.SshNet.Sftp Imports System.IO Public Class GPIO Dim ssh As New SshClient("Ip here", "Username here", "Password here") Private Sub GPIO_Load(ByVal sender As System.Object...
by PingoBags
Sun Sep 02, 2018 10:45 am
Forum: Beginners
Topic: start app via ssh
Replies: 11
Views: 599

Re: start app via ssh

SftpClient for creating files, SshClient for running commands. I'm not a vb coder but you should beable to work it out. /home/pi/Desktop/Scripts/test.py is the path to a script on my pi, so i'll use it as an example. Dim ssh As New SshClient("IP", "user", "password") ssh.Connect() Dim cmd = ssh.Crea...
by PingoBags
Wed Aug 15, 2018 1:21 am
Forum: General programming discussion
Topic: "get" http code example - roadblock
Replies: 8
Views: 3101

Re: "get" http code example - roadblock

I've only played with the relay through a webpage once. All I did was read the current value of the pin and set the opposite value every time I clicked the button. In my test code, I used gpio pin 18, 23 and 24. Click the button, relay turns on, click it again, it turns off. My full sample code. My ...
by PingoBags
Mon Jun 04, 2018 1:38 pm
Forum: Python
Topic: Line counter
Replies: 14
Views: 983

Re: Line counter

A simple way would be to store the pin state. The just increase the counter by one when the state changes. Using GPIO 13 import RPi.GPIO as GPIO import time GPIN = 13 Pinstate = False counting = 0 GPIO.setmode(GPIO.BCM) GPIO.setup(GPIN, GPIO.IN) try: while True: if GPIO.input(GPIN) and not Pinstate:...
by PingoBags
Thu Apr 12, 2018 10:37 am
Forum: Python
Topic: 100 % processing power
Replies: 15
Views: 843

Re: 100 % processing power

Yes good point about the GPIO clean, it was a quick cut and paste to get it happening. Script did not turn off the light this evening, which is disappointing. Will go back through now and see if I can find where I have gone wrong. When you first ran the script and turned the lights on, it cleaned t...
by PingoBags
Wed Apr 11, 2018 2:35 pm
Forum: Python
Topic: 100 % processing power
Replies: 15
Views: 843

Re: 100 % processing power

You don't need gpio clean every time you turn the lights on or off, all that is doing it resetting the pins back to input. I don't even think your new script would run correctly in it current state. If you reset those pins, it'l probably stop working. I don't completely understand the on off functio...
by PingoBags
Wed Apr 11, 2018 11:10 am
Forum: Python
Topic: 100 % processing power
Replies: 15
Views: 843

Re: 100 % processing power

Is this what your script does? Figures out where in time it is, what should be happening, and then sets a timer to the next event to occur and every event from then on? That's precisely what it does. I also like having two different scripts, essentially dedicated to two different functions - one wh...
by PingoBags
Tue Apr 10, 2018 1:05 pm
Forum: Python
Topic: 100 % processing power
Replies: 15
Views: 843

Re: 100 % processing power

I use a timer for my light script instead of a while loop. Instead of constantly checking in a while loop, I calculate the intervals for the timer so the code only runs twice daily. This script could actually work for you. Just fill in the blanks where I've commented. I've been using something simil...
by PingoBags
Mon Apr 02, 2018 6:52 pm
Forum: General programming discussion
Topic: Source control and development "ecosystem"
Replies: 13
Views: 1654

Re: Source control and development "ecosystem"

I personally use Renci ssh.net. I made a simple windows app to upload and run my scripts.
by PingoBags
Sun Mar 25, 2018 12:06 pm
Forum: Python
Topic: getting values from variable and storing it to array
Replies: 14
Views: 1271

Re: getting values from variable and storing it to array

You won't need a key press for that, you don't even need to store the voltages in an array to get the mean. Just calculate it on the fly. Example, have 3 variables for storing outside of the while loop, not within it. TheMean,TenCount,TotalVolt = 0,0,0 And in your current while loop, just after you ...
by PingoBags
Fri Mar 23, 2018 4:27 pm
Forum: General discussion
Topic: How to monitor a /var/log file
Replies: 9
Views: 683

Re: How to monitor a /var/log file

Glad to help
by PingoBags
Thu Mar 22, 2018 5:40 pm
Forum: General discussion
Topic: How to monitor a /var/log file
Replies: 9
Views: 683

Re: How to monitor a /var/log file

I can't see a problem off hand but I am wondering why you used $res as your variable when calling ReturnError. You should be using $output. Also I though the code returned from your output was -0, with the minus. It should have still output something but I changed it anyway to reflect the true error...
by PingoBags
Wed Mar 21, 2018 5:12 pm
Forum: General discussion
Topic: How to monitor a /var/log file
Replies: 9
Views: 683

Re: How to monitor a /var/log file

What exactly does $output print out, not from the code I posted, but the original code you have. I assumed it printed 2018-03-21 15:21:13,NM_Test.h264,-0 or whatever the code is at the end. Add an extra line to ReturnError function so it looks like this. See if it prints out anything. It might give ...
by PingoBags
Wed Mar 21, 2018 1:45 pm
Forum: General discussion
Topic: How to monitor a /var/log file
Replies: 9
Views: 683

Re: How to monitor a /var/log file

What if you create a function to output the custom errors for you? <?php function ReturnError($res) { switch ($res) { case "0": return " no errors reported"; case "1": return " some error"; case "2": return " Missing file"; case "3": return " some error"; } } $command = "ssh -p 97 -i /var/www/html/t...
by PingoBags
Thu Mar 15, 2018 11:32 am
Forum: General discussion
Topic: UPS solutions?
Replies: 21
Views: 2344

Re: UPS solutions?

mosespi, That's a good point about the commercial UPSs switching quickly enough. I thought about changing the timing in my script for that reason. If I did leave the inverter on, it might be doable. But I'm not that comfortable doing it. The inverter and mains, power the same plug, only separated by...
by PingoBags
Wed Mar 14, 2018 12:20 am
Forum: General discussion
Topic: UPS solutions?
Replies: 21
Views: 2344

Re: UPS solutions?

@mosespi No, the system is to power some 120v low watt lights, a 120v 100 watt water heater, small water pump and a few other devices. I was just saying that the pi is also powered from the same system but I need to power it when the switch from mains to inverter happens. I don't need nor want the i...
by PingoBags
Mon Mar 12, 2018 1:07 pm
Forum: General discussion
Topic: UPS solutions?
Replies: 21
Views: 2344

Re: UPS solutions?

I'm in the process of making something close to a UPS but not. I didn't want the wear on an inverter running 24/7 just to have no interruption for devices that aren't that crucial. The only interruption I don't want, is to my pi. Its not fully finished but I have tested it and it works great. I used...
by PingoBags
Mon Mar 05, 2018 6:03 pm
Forum: Beginners
Topic: Remotely updating code on multiple devices easily
Replies: 4
Views: 1992

Re: Remotely updating code on multiple devices easily

You could always create an app to automatically handle it via ssh.
Store all the pi user/pass and ip's in a text file.
Loop through them all to upload and run the new scripts if needed.

I do something similar from my win pc.
by PingoBags
Sun Mar 04, 2018 1:06 pm
Forum: Beginners
Topic: Pi as heating/elec failure alarm
Replies: 27
Views: 1842

Re: Pi as heating/elec failure alarm

Another option.. If you had some way to power your router, my router has a 4hr built in battery backup so my internet keeps working on power failure. All I did to detect power failure with my pi, I took a 5v 550mah power supply. Made a voltage divider with resistors to drop the voltage to 3v. Limite...
by PingoBags
Tue Feb 27, 2018 1:06 am
Forum: Python
Topic: Problem comparing if two images are different ( imagechops)
Replies: 11
Views: 4830

Re: Problem comparing if two images are different ( imagechops)

The issue isn't what I posted, it's ImageChops.difference.
Images do not match error. Could it be the image extension?

Post up a little more of your code.
Are you looking to make motion detection?
by PingoBags
Mon Feb 26, 2018 2:01 pm
Forum: Beginners
Topic: if x < y then x = y
Replies: 27
Views: 1261

Re: if x < y then x = y

Something like this?

Code: Select all

wind_chill = 0

def MaxWindChill(current_chill):
  global wind_chill
  wind_chill = current_chill if wind_chill < current_chill else wind_chill

Code: Select all

MaxWindChill(2.2)#2.2 celcius chill as an example
print(wind_chill)
by PingoBags
Fri Feb 23, 2018 11:56 am
Forum: Python
Topic: Problem comparing if two images are different ( imagechops)
Replies: 11
Views: 4830

Re: Problem comparing if two images are different ( imagechops)

Your code returns None when the images are the same, just use that to set your flag. Only a slight change to your code. from PIL import Image from PIL import ImageChops im1 = Image.open("imagenupload.jpg") im2 = Image.open("imagereference.jpg") Flag = 1 if ImageChops.difference(im2, im1).getbbox() =...
by PingoBags
Fri Feb 09, 2018 11:36 am
Forum: Python
Topic: Interface raspbeery pi With Visual studio 2010
Replies: 10
Views: 890

Re: Interface raspbeery pi With Visual studio 2010

I'm not super familiar with the pi and all the programming features of python but I have an idea you can try. I communicate with my pi from my windows machine using visual studio to send and receive info. An easy solution would be to save the unique user ID's to a single text file on the pi. Downloa...
by PingoBags
Sat Feb 03, 2018 12:18 pm
Forum: Beginners
Topic: problem with gpio
Replies: 10
Views: 887

Re: problem with gpio

You could try using try except, that way it should work in python 2&3

Code: Select all

try:
  import Tkinter
  from Tkinter import*
except ImportError:
  import tkinter
  from tkinter import*
by PingoBags
Fri Feb 02, 2018 11:49 am
Forum: Python
Topic: Help with datetime.strftime
Replies: 8
Views: 1894

Re: Help with datetime.strftime

strptime converts string to a datetime object strftime converts datetime object to string from datetime import datetime DTNow = datetime.now().replace(microsecond=0) DTThen = datetime.strptime('2015-08-30 15:35:20', '%Y-%m-%d %H:%M:%S') print(DTNow - DTThen) or using your code from datetime import d...

Go to advanced search