Go to advanced search

by ghp
Thu Jul 18, 2019 9:18 pm
Forum: Python
Topic: Sending a number to raspberry pi from arduino card via USB
Replies: 7
Views: 195

Re: Sending a number to raspberry pi from arduino card via USB

print (myData) if float(myData) == 4: The number sent by the arduino is a 'int number', so try using "if int(myData) == 4". If you convert a value to a float, you loose precision and comparing gets a nightmare. What does the printout say in these cases when there are errors? If you add something li...
by ghp
Thu Jul 18, 2019 5:15 am
Forum: Python
Topic: Sending a number to raspberry pi from arduino card via USB
Replies: 7
Views: 195

Re: Sending a number to raspberry pi from arduino card via USB

Hello, look into https://pyserial.readthedocs.io/en/latest/shortintro.html, where some samples are given. Using ser.readline will not work, - ser.readline() should be used - you call this twice print(ser.readline) #missing () if ser.readline==4: #missing () better is res = ser.readline() print(res) ...
by ghp
Wed Jul 17, 2019 8:19 pm
Forum: Python
Topic: How to run this code
Replies: 3
Views: 137

Re: How to run this code

In the github readme file, there is a chapter "Installation", which covers basic installation. In 'API Reference', there is a list of dependencies. picamera, RPI.GPIO should be available on a Pi. For PIL, Pillow, there is a remark "The Pillow fork of the Python Image Library. One issue is with PIL I...
by ghp
Wed Jul 17, 2019 6:29 pm
Forum: Python
Topic: My program stuck after sometime
Replies: 10
Views: 236

Re: My program stuck after sometime

I simulated inputs from serial in a random way. class S: def __init__(self, name, speed, timeout=0): pass def read(self): return random.choice( [b'\x01', b'\x02', b'\x03', b'\x04', b'\x05', ]) def write(self, data): print("data", data) ser=S('/dev/ttyAMA0',921600,timeout=1) This produces byte inputs...
by ghp
Mon Jul 15, 2019 7:51 pm
Forum: Python
Topic: write python output to a excel field
Replies: 3
Views: 154

Re: write python output to a excel field

by ghp
Sat Jul 13, 2019 4:59 pm
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 316

Re: LMX2594 programming using Python and Raspberry PI

You made a comment in another thread about the topic. The posted lines from you were: actually i added these lines to your code and i read back something that i did not figure out yet, i wrote Changed code and output: transferWrite( "MUXOUT", 0, 0b00000000, 0b00000100 ) transferWrite( "MUXOUT", 0, 0...
by ghp
Sat Jul 13, 2019 4:44 pm
Forum: Python
Topic: Some random error
Replies: 4
Views: 169

Re: Some random error

Yes, think MrYsLab is correct with the 'many issues'. - you did not strip down the code to the pure minimum. Not may people in this world do have exactly the same LCD, ADC, lux sensor and can run your code for validation just as provided. I used here adc_value = [math.sin(time.time()/66.666), 22.3, ...
by ghp
Fri Jul 12, 2019 5:35 pm
Forum: Python
Topic: Approach? Multiprocessing and variables
Replies: 4
Views: 210

Re: Approach? Multiprocessing and variables

What I understood: long running processes. One place where a button is checked and when pressed, then the processes run an extra second and terminate. The clue is to use Event from multiprocessing and signal the terminate! to the processes. from multiprocessing import Process, Event import time def ...
by ghp
Fri Jul 12, 2019 4:29 am
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 316

Re: LMX2594 programming using Python and Raspberry PI

perhaps needed to move this max_speed-statement after the spiLMX.open(0,0).
by ghp
Thu Jul 11, 2019 5:11 pm
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 316

Re: LMX2594 programming using Python and Raspberry PI

Read/ writes for the chip are according to the sheet always 24 bits, address and 16 bits of data. I do not have this chip here, so following the datasheet the process is - reset chip, remove reset. - write the 'MUXOUT bit in register 0 - read back register 0, just for tests. import spidev # for GPIO...
by ghp
Wed Jul 10, 2019 5:15 pm
Forum: Python
Topic: getting horizontal question question mark symbol instead of code in .py file
Replies: 4
Views: 158

Re: getting horizontal question question mark symbol instead of code in .py file

Sometimes I get long rows of characters when I place some stuff on my keyboard........................................................
by ghp
Wed Jul 10, 2019 5:11 pm
Forum: Python
Topic: Transfer image over xbee s2c pro using raspberry pi3
Replies: 3
Views: 161

Re: Transfer image over xbee s2c pro using raspberry pi3

There are a number of python libs for xbee around, one example is https://xbplib.readthedocs.io/en/latest/. Using API is a good thing. Split the binary file into junks. Add a packet number and total number of packets, from this the receiver knows when data are complete. If you own DIGI devices: ther...
by ghp
Wed Jul 10, 2019 5:18 am
Forum: Python
Topic: DHT22 script error handling
Replies: 2
Views: 103

Re: DHT22 script error handling

I looked into your print statement and do not understand the syntax. print("Temp={0:0.0f}".format(temperature, humidity)+deg_sym+"C Humidity={1:0.0f}%".$ gives a syntax error in my system. in python3, i'd propose to write # -*- coding: utf-8 -*- temperature = 33.1415 humidity = 50.11 ## print("Temp=...
by ghp
Wed Jul 10, 2019 5:02 am
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 316

Re: LMX2594 programming using Python and Raspberry PI

Although there are reports saying that xfer and xfer2 do the same, i'd recommend using xfer2 when CS is needed active during the whole transaction. https://embeddedmicro.weebly.com/spi.html When I look into the datasheet if the "LMX2594 15-GHz Wideband RF Synthesizer", there is no serial data out or...
by ghp
Tue Jul 09, 2019 5:01 pm
Forum: Python
Topic: Transfer image over xbee s2c pro using raspberry pi3
Replies: 3
Views: 161

Re: Transfer image over xbee s2c pro using raspberry pi3

sending binary data through a serial line needs some work - use python3. Strict in using binary arrays in the right places. - do not use readline().strip() with binary data. There might be all sort of bytes in there, so make no assumptions on content. - build a frame around the binary data. Some sta...
by ghp
Tue Jul 09, 2019 4:51 pm
Forum: Python
Topic: ValueError: chr() arg not in range(0x110000)
Replies: 8
Views: 266

Re: ValueError: chr() arg not in range(0x110000)

I would propose to stay with python3. Change places like if rbuff == chr(0x02) and flag==0: # and zero_detect==1: into if rbuff[0] == 0x02 and flag==0: # and zero_detect==1: and then of course if temp == chr(ord(rbuff)+1) or temp == chr(ord(rbuff)-1) or temp == chr(ord(rbuff)+2) or temp == chr(ord(r...
by ghp
Tue Jul 09, 2019 4:42 pm
Forum: Python
Topic: LMX2594 programming using Python and Raspberry PI
Replies: 11
Views: 316

Re: LMX2594 programming using Python and Raspberry PI

spidev is explained in many places, see this as a starter: https://pypi.org/project/spidev/
xfer2 is usually a good choice if chip select is needed.
Please post your current code, makes it easier to understand your problems.
by ghp
Mon Jul 08, 2019 6:21 pm
Forum: Python
Topic: ValueError: chr() arg not in range(0x110000)
Replies: 8
Views: 266

Re: ValueError: chr() arg not in range(0x110000)

The python serial got an upgrade between python2 and python3: the return in python3 is a bytes like object (was character in python2). So if you want to send characters or string over serial in p3, then you need to encode. But if you want to handle bytes, then things get more simple. So rbuff=ser.re...
by ghp
Sun Jul 07, 2019 3:22 pm
Forum: Python
Topic: tkinter and GPIO, how to set up a physical input button
Replies: 7
Views: 311

Re: tkinter and GPIO, how to set up a physical input button

If you already own a LDR, you could use a comparator like LM293 to do a faster conversion. LDR react in 2 to 50ms to light changes (these are times found in data sheets). Use a 20k resistor in line with LDR to form a voltage divider, and a trim-poti with 10k to build an adjustable reference voltage....
by ghp
Sun Jul 07, 2019 1:28 pm
Forum: Python
Topic: not finding inkyphat on buster
Replies: 2
Views: 79

Re: not finding inkyphat on buster

The error message does not say something like 'module not found'.
Did you enable SPI on the new distribution, use "sudo raspi-config" for this.
by ghp
Sun Jul 07, 2019 10:02 am
Forum: Python
Topic: gfx hat screen and working by area
Replies: 1
Views: 76

Re: gfx hat screen and working by area

According to your description, there are at least two processes writing to the display - "Can we update by area, to let present informations already in place" so there is some process writing information - the ifup-process, triggered by ifup in network configurations. Providing an icon The gfx-hat/s...
by ghp
Sat Jul 06, 2019 8:20 pm
Forum: Python
Topic: Official 7" touchscreen backlight control
Replies: 2
Views: 110

Re: Official 7" touchscreen backlight control

there are multiple places like
os.system("sudo shutdown -c")
echo 0 > /sys/class/backlight/rpi_backlight/bl_power
think you should wrap the echo command into a os.system("echo ...")-command.
by ghp
Sat Jul 06, 2019 4:01 pm
Forum: Python
Topic: Could I use python to shut down the Pi when pushing the button on the Fan Shim on Rpi4?
Replies: 2
Views: 120

Re: Could I use python to shut down the Pi when pushing the button on the Fan Shim on Rpi4?

Short answer: yes. There is a discussion @pimoroni about pin assignment: https://forums.pimoroni.com/t/fan-shim-button-always-held/10784 and also some GPIO library updates needed to switch the pullup/down correctly on pi4. In github, there are some examples, also for the button. https://github.com/p...
by ghp
Fri Jul 05, 2019 6:42 pm
Forum: Python
Topic: cursor_position problem
Replies: 1
Views: 89

Re: cursor_position problem

Hello, the adafruit sources are on github. There is an embedded sample in https://github.com/adafruit/Adafruit_CircuitPython_CharLCD/blob/master/adafruit_character_lcd/character_lcd.py, line 228. The truth lies in the code... hopefully. import time import board import busio import adafruit_character...
by ghp
Fri Jul 05, 2019 4:54 pm
Forum: Python
Topic: label with textvariable doesn't refresh (tkinter)
Replies: 4
Views: 136

Re: label with textvariable doesn't refresh (tkinter)

Hello as always there are alternate solutions. Let me propose some code using a thread to read values from arduino serial line. In the thread, the StringVar is set and the window is updating. A slight advantage over the root.after(1000, Main)-solution is that the thread is independent from the updat...

Go to advanced search