Go to advanced search

by ghp
Tue Jul 17, 2018 6:11 am
Forum: Scratch
Topic: How do I create a multiplayer system
Replies: 2
Views: 363

Re: How do I create a multiplayer system

Hello, in a school course, the kids created games with hand made controllers. They have used two controllers at one Pi with each using its own set of GPIO. So each controller was moving its own character in the game. This is another variant to the sharing of a keyboard as proposed by ejolson. Regard...
by ghp
Sat Jun 16, 2018 4:58 pm
Forum: Python
Topic: websocket error
Replies: 1
Views: 250

Re: websocket error

Hello, there are some problems in your code. See the annotations in the attached sample class WSHandler(tornado.websocket.WebSocketHandler): # # there is no server for the http-page # so you need to have this feature # def check_origin(self, origin): return True def open(self): self.connected = True...
by ghp
Fri May 18, 2018 4:37 pm
Forum: Python
Topic: Tornado web sockets and coroutines
Replies: 2
Views: 170

Re: Tornado web sockets and coroutines

Hello, I propose a structure where the web-application build with tornado and the other control is decoupled with a queue. In tornado websockethandler, when receiving a command as e.g. 'on', 'off', then write this into a queue. So you do not need threads inside tornado. A thread set up before the we...
by ghp
Mon May 14, 2018 6:06 pm
Forum: Scratch
Topic: coding GPIO high/low input pins on Scratch
Replies: 7
Views: 1559

Re: coding GPIO high/low input pins on Scratch

Hello, There are two flavors for this card, I2C and SPI. In scratchClient, there is support for 23S17 chips using SPI. Eight chips are possible. scratchClient supports scratch1.4 and scratch2. Eight chips are possible. ScratchClient allows to name each pin individually. But keep in mind that scratch...
by ghp
Fri May 11, 2018 6:19 am
Forum: Python
Topic: Python lux + wiringpi
Replies: 5
Views: 218

Re: Python lux + wiringpi

Hello, most possibly the term Relay[s] does not return an integer. You could check the content of Relay with an additional line of code s = int(s) pin = Relay[s] if not isinstance( pin, int): print("ERROR, Relay[s] is not an int", Relay[s]) if wiringpi.digitalRead(pin) == 0 and RelayCtrl[s] == "True...
by ghp
Mon Apr 30, 2018 6:14 pm
Forum: Python
Topic: Python error since 2 days
Replies: 4
Views: 234

Re: Python error since 2 days

Hello, the adafruit samples contain a section: # Note that sometimes you won't get a reading and # the results will be null (because Linux can't # guarantee the timing of calls to read the sensor). # If this happens try again! if humidity is not None and temperature is not None: print('Temp={0:0.1f}...
by ghp
Mon Apr 30, 2018 6:08 pm
Forum: Python
Topic: Servo motors freeze after exactly 250 initializations
Replies: 2
Views: 184

Re: Servo motors freeze after exactly 250 initializations

Hello, there are some things I would propose to change: - use the " GPIO.setmode(GPIO.BCM) " only once, either in the __init__() or perhaps after the #GPIO.setwarnings(False). - in your code, the PWM object is created many times. " self.pos = GPIO.PWM(self.pinNo,50) ". IHHO this is needed only once ...
by ghp
Mon Apr 30, 2018 5:55 pm
Forum: Python
Topic: Threading with SQLite and python3
Replies: 3
Views: 203

Re: Threading with SQLite and python3

Hello, you write data to db, wait a second and then commit. Meaning you keep the transaction open for a long time.
Try to make the commit immediately after insert.
Regards,
Gerhard
by ghp
Sun Mar 11, 2018 8:00 pm
Forum: Scratch
Topic: coding GPIO high/low input pins on Scratch
Replies: 7
Views: 1559

Re: coding GPIO high/low input pins on Scratch

Hello, there are two things to solve, get a button press and then play a sound. The example cited from pcmanbob is for scratch1.4 with gpioserver. When using scratch2, then see https://www.raspberrypi.org/blog/scratch-2-raspberry-pi/. For playing sounds, there is an option using scratchclient and so...
by ghp
Sat Feb 17, 2018 4:55 pm
Forum: Scratch
Topic: Sensing Block in Scratch 2.0
Replies: 1
Views: 1464

Re: Sensing Block in Scratch 2.0

Hello,
scratch2 is using extensions, which are written in javascript and provide additional blocks controlling the hardware.

With scratchClient it is possible to connect hardware to scratch1.4 or scratch2. See http://heppg.de/ikg/wordpress/?page_id=6 for download.

Hope this helps,
Gerhard
by ghp
Sat Feb 17, 2018 4:48 pm
Forum: Scratch
Topic: 2018: CamJam Edukit3 & Scratch2 EdukitMotorBoard
Replies: 2
Views: 1288

Re: 2018: CamJam Edukit3 & Scratch2 EdukitMotorBoard

Hello, I do not own a copy of this kit, but based on the descriptions I have setup a config file for scratchClient config_camjam_edukit.xml ScratchClient works both with scratch1.4 and scratch2 Steps to do: - download scratchClient code distribution from http://heppg.de/ikg/wordpress/?page_id=6 - in...
by ghp
Sun Jan 07, 2018 10:36 am
Forum: Scratch
Topic: Scratch2 Motor Control
Replies: 4
Views: 2133

Re: Scratch2 Motor Control

Hello, scratchClient is supporting scratch2 and allows to use prebuild python adapters for GPIO, PWM, Servo, ADC chips and a lot more. See http://heppg.de/ikg/wordpress/?p=984 for some details. Regards, Gerhard There is an adapter "adapter.gpio.GpioMotorPWM"; sample config is config/config_hbridge_m...
by ghp
Tue Jan 02, 2018 8:06 pm
Forum: Scratch
Topic: Ultrasonic Scratch2
Replies: 2
Views: 1668

Re: Ultrasonic Scratch2

Hello, since a short time scratchClient is supporting scratch2 in addition to scratch1.4. There is an adapter supporting the ultrasonic sensor. See http://heppg.de/ikg/wordpress/?p=984 for a summary. When connecting the ultrasonic HC-SR04, be sure to use level shifters for the output signal. The sen...
by ghp
Sun Dec 17, 2017 5:29 pm
Forum: Python
Topic: Remotely shutting down a pi with another pi
Replies: 10
Views: 943

Re: Remotely shutting down a pi with another pi

Hello, There is another possibility: use linux command ssh [email protected].168.2.123 sudo halt which is easily executed from python command import os os.system('ssh <remote_user>@192.168.2.123 sudo halt') Replace <remote_user> with a valid user on remote machine. Although it looks simple at first glance, you...
by ghp
Mon Dec 04, 2017 6:26 pm
Forum: Scratch
Topic: Launch Scratch game from OS
Replies: 3
Views: 1947

Re: Launch Scratch game from OS

Hello, the script I proposed extends the idea from afmcdnl which looks as if there is already some python script to start scratch2. The added functionality is to have some sort of 'mouse action robot' which presses some buttons in a started scratch2. If you automatically start this combined python s...
by ghp
Sat Dec 02, 2017 8:11 am
Forum: Python
Topic: Assistance with Real time alteration of delay times between multiple lights turning on/off using button inputs
Replies: 4
Views: 448

Re: Assistance with Real time alteration of delay times between multiple lights turning on/off using button inputs

Hello, the proposed waiting-method uses a loop which will increase cpu usage a lot. With a small delay in the loop the cpu usage will be much lower. Timing will be a little bit less accurate, though. Global variables which are read only in a method do not need to be declared as global. def waiting()...
by ghp
Sat Dec 02, 2017 7:34 am
Forum: Python
Topic: Reading temp from 2 separate pi's and updating to central mysql db via python
Replies: 1
Views: 241

Re: Reading temp from 2 separate pi's and updating to central mysql db via python

Hello, you have some options, let each pi connect to the database and store the data. Databases can have multiple remote clients connected. send the data to a central pi. You could use MQTT to send/receive the data, using mosquitto as a MQTT broker. The second option using MQTT would also allow to u...
by ghp
Sun Nov 26, 2017 3:33 pm
Forum: Scratch
Topic: Some errors on using scratchClient with Wedo 2.0
Replies: 9
Views: 3011

Re: Some errors on using scratchClient with Wedo 2.0

Hello,
perhaps your command line is wrong ?
instead of

Code: Select all

(wrong)
sudo python scratchClient -c config_wedo2_complete.xml
try using

Code: Select all

cd ~/scratchClient
sudo python scratchClient.py -c config_wedo2_complete.xml
Hope this helps,
Gerhard
by ghp
Sun Nov 19, 2017 3:59 pm
Forum: Scratch
Topic: Launch Scratch game from OS
Replies: 3
Views: 1947

Re: Launch Scratch game from OS

Hello, did not find a simple way to automate scratch2. What could help is an automated way to move the mouse pointer and click on the screen. This script should have some sort of 'record' capability to get the coordinates from the screen, and a 'play' mode to execute the actions. To keep the complex...
by ghp
Sat Nov 11, 2017 4:44 pm
Forum: Python
Topic: Losing Temperature probe
Replies: 2
Views: 294

Re: Losing Temperature probe

Hello, put the code into a try-except statement: try: tfile = open("/sys/bus/w1/devices/28-0315a4e4e6ff/w1_slave")#yellow ... process data as usual except FileNotFoundError as e: print("ERROR", str(e) ) ... stop heater, send emails, sound a buzzer or whatever needed See also https://docs.python.org/...
by ghp
Fri Nov 10, 2017 6:39 am
Forum: Python
Topic: Finding a Line of GPS data
Replies: 11
Views: 957

Re: Finding a Line of GPS data

Hello,
you can check a line of code with string method startswith:

Code: Select all

import serial
ser=serial.Serial('dev/ttyUSB0',9600)
while 1:
    textln=ser.readline()
    if textln.startswith( '$GPGGA'):
        print (textln)
Good luck with your project !
by ghp
Thu Nov 09, 2017 9:09 pm
Forum: Scratch
Topic: puzzle
Replies: 0
Views: 1152

puzzle

scratch can produce nice scenes. Hope you enjoy:
Image
Implemented with scratch1.4.
by ghp
Wed Nov 08, 2017 9:49 pm
Forum: Scratch
Topic: create a block to execute a python script
Replies: 2
Views: 1475

Re: create a block to execute a python script

Hello, with scratchClient, it is possible to start shell scripts. See http://www.heppg.de/download/scratchClient/doc/html/scratchClient.html#scratch.client.adapters.os.command_line This specific adapter does not use parameters. scratchClient is written in python and there are quite a few adapters fo...
by ghp
Tue Oct 17, 2017 8:40 pm
Forum: Scratch
Topic: New Scratch things for Raspbian September 2016
Replies: 26
Views: 11294

Re: New Scratch things for Raspbian September 2016

Hello, I have since long time a DHT11, DHT22 connection to scratch using an atmel328 as a slave processor. http://heppg.de/ikg/wordpress/?p=430 And since short time there is an adapter using pigpiod software. scratchClient supports both scratch1.4 and scratchx, the extension enabled version of scrat...

Go to advanced search