Changes

Beaglebone black

3,665 bytes added, 07:56, 7 December 2019
/* Networking */
wpa-ssid hentschel
wpa-psk bb78bbaa6a8425255774e5d49b51b4038d55c0c3e493334abbecec31c27096b6
 
* disable and remove connman, use standard resolv.conf
sudo systemctl disable connman
sudo systemctl stop connman
sudo apt remove connman
 
resolv.conf
<pre>
nameserver 192.168.1.2
search home.hentschel.net
</pre>
=== reset switch ===
also enable i2c in /boot/config.txt
dtparam=i2c_arm=on
 
==== BBB ====
sudo apt-get install build-essential python-dev python-setuptools python-pip python-smbus -y
sudo pip install Adafruit_GPIO
sudo pip install Adafruit_SSD1306
sudo apt-get install python-pil
sudo pip install gpiozero
sudo apt-get install psutil
=== enable systemd service ===
=== lcd + button script ===
==== standard Raspi ====<pre>#!/usr/bin/python import timeimport Adafruit_GPIO.SPI as SPIimport Adafruit_GPIO.GPIO as GPIOimport Adafruit_SSD1306from PIL import Imagefrom PIL import ImageDrawfrom PIL import ImageFontimport subprocessimport socketimport psutilimport os from gpiozero import CPUTemperaturefrom datetime import datetime button_off = 4gpio = GPIO.get_platform_gpio() while True: try: gpio.setup(button_off, GPIO.IN, GPIO.PUD_UP) button_oldstate = gpio.input(button_off) # RST = 0 # disp = Adafruit_SSD1306.SSD1306_128_32(rst=RST) disp.begin() disp.clear() disp.display() # width = disp.width height = disp.height # image1 = Image.new('1', (width, height)) draw = ImageDraw.Draw(image1) draw.rectangle((0,0,width,height), outline=0, fill=0) # padding = -2 top = padding # bottom = height-padding x = 0 font = ImageFont.load_default() # s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.connect(("192.168.1.1", 80)) hostname = socket.gethostname() ip = s.getsockname()[0] firstline = ip + " " + hostname # while True: time.sleep(1) # image1 = Image.new('1', (width, height)) draw = ImageDraw.Draw(image1) draw.rectangle((0,0,width,height), outline=0, fill=0) cputemp = CPUTemperature() memstr = '{0: >5}'.format(str(int(psutil.virtual_memory().percent))) + "%|" statvfs = os.statvfs('/') disktotal = statvfs.f_frsize * statvfs.f_blocks # Size of filesystem in bytes diskfree = statvfs.f_frsize * statvfs.f_bavail # Number of free bytes that ordinary users diskpercent = round((disktotal - diskfree) * 100.0 / float(disktotal),0) diskstr = 'SD:' + '{0: >3}'.format(str(int(diskpercent))) + "%" now = datetime.now() tempstr ='{0: >5}'.format(str(round(cputemp.temperature,))) + u"\u00b0" + "C|" cpustr = '{0: >6}'.format(str(round(psutil.cpu_percent(),1))) + "%" secondline = "CPU:" + tempstr + cpustr thirdline = "MEM: " + memstr + diskstr fourthline = now.strftime("%d/%m/%Y %H:%M:%S") disp.clear() draw.text((x, top), firstline, font=font, fill=255) draw.text((x, top+8), secondline, font=font, fill=255) draw.text((x, top+16), thirdline, font=font, fill=255) draw.text((x, top+25), fourthline, font=font, fill=255) disp.image(image1) disp.display() # # button_state = gpio.input(button_off) if( button_state != button_oldstate ): if( button_state ): print("Button OFF") else: print("Button ON -> reboot") disp.clear() image1 = Image.new('1', (width, height)) draw = ImageDraw.Draw(image1) draw.rectangle((0,0,width,height), outline=0, fill=0) draw.text((x, top + 8), "Rebooting...", font=font, fill=255) disp.image(image1) disp.display() os.system("reboot now") # exit() button_oldstate = button_state # # except Exception as e: print("LCD Error: %s" % str(e) ) </pre> ==== BBB ====
<pre>
#!/usr/bin/python
Bureaucrat, administrator
963
edits