RaspberryPi

Processador     
  Broadcom BCM2837B0, Cortex-A53 (ARMv8) 64-bit SoC @ 1.4GHz
Memória RAM     
  1GB LPDDR2 SDRAM
Armazenamento   
  Cartão MicroSD 32GB com NOOBS
Wi-Fi e Bluetooth       
  2.4GHz e 5GHz IEEE 802.11.b/g/n/ac wireless LAN, Bluetooth 4.2, BLE
LAN     
  Gigabit Ethernet em USB 2.0 (saída máxima 300 Mbps)
Expansão        
  Extended 40-pin GPIO header
  CSI camera port
  DSI display port
  4-pole stereo output e composite video port
Portas  
  HDMI 
  USB 2.0 (4) 
  Micro-SD
Alimentação     
  Entrada 5V/2.5A DC
Prazo de Garantia       
  2 Anos

BCM2835

Install and configure screensaver and lock screen

Info

   1 lsb_release -a
   2 # No LSB modules are available.
   3 # Distributor ID:       Raspbian
   4 # Description:  Raspbian GNU/Linux 9.4 (stretch)
   5 # Release:      9.4
   6 # Codename:     stretch
   7 
   8 uname -a
   9 # Linux raspberrypi 4.14.71-v7+ #1145 SMP Fri Sep 21 15:38:35 BST 2018 armv7l GNU/Linux
  10 

Install eclipse

   1 apt-get install eclipse-platform

   1 python drive_gpio26.py

   1 # drive_gpio26.py
   2 from gpiozero import LED
   3 from time import sleep
   4 
   5 led = LED(26)
   6 
   7 while True:
   8     led.on()
   9     sleep(1)
  10     led.off()
  11     sleep(1)

Install python 3.8.5 in raspberry py

   1 tar xvzf Python-3.8.5.tgz 
   2 cd Python-3.8.5/
   3 ./configure 
   4 make clean
   5 make
   6 make install
   7 sudo make install
   8 /usr/local/bin/python3.8 -v
   9 /usr/local/bin/pip3.8 install cherrypy
  10 pip3.8 install jinja2

Enable X11 forwarding

   1 # Raspberry pi side
   2 sudo nano /etc/ssh/sshd_config
   3 # add line X11Forwarding yes
   4 service ssh restart
   5 # client side
   6 ssh -X -Y userx@192.168.2.3
   7 echo $DISPLAY
   8 leafpad & # text editor
   9 pcmanfm & # file explorer
  10 

Starts automatically after boot.

/home/pi/Documents/drive_gpio26.py

   1 from gpiozero import LED
   2 from time import sleep
   3 import os
   4 
   5 f = open('/tmp/drive_gpio26.pid','wb')
   6 f.write(str(os.getpid()))
   7 f.close()
   8 
   9 led = LED(26)
  10 
  11 while True:
  12     led.on()
  13     sleep(1)
  14     led.off()
  15     sleep(1)

/etc/init.d/drive_gpio26

   1 #! /bin/sh
   2 ### BEGIN INIT INFO
   3 # Provides:          drive_gpio26
   4 # Default-Start:     2 3 4 5
   5 # Default-Stop:
   6 # Short-Description: Blinks a led
   7 # Description:       Blinks a led
   8 ### END INIT INFO
   9 touch /var/lock/drive_gpio26
  10 # Carry out specific functions when asked to by the system
  11 case "$1" in
  12   start)
  13     echo "Starting script drive_gpio26 "
  14     su pi -c "nohup /usr/bin/python /home/pi/Documents/drive_gpio26.py >> /tmp/drive_gpio26.log 2>&1  &"
  15     ;;
  16   stop)
  17     echo "Stopping script drive_gpio26"
  18     kill $(cat  /tmp/drive_gpio26.pid)
  19     ;;
  20   *)
  21     echo "Usage: /etc/init.d/drive_gpio26 {start|stop}"
  22     exit 1
  23     ;;
  24 esac
  25 
  26 exit 0

   1 update-rc.d drive_gpio26 defaults # insert links in /etc/rc*d
   2 update-rc.d drive_gpio26 defaults 20 80
   3 update-rc.d drive_gpio26 enable
   4 service drive_gpio26 status 
   5 reboot 

Install MariaDB raspbian

   1 sudo bash
   2 apt install mariadb-server
   3 mysql_secure_installation
   4 # define root pass
   5 mysql
   6 GRANT ALL ON *.* TO 'admin'@'localhost' IDENTIFIED BY '????????' WITH GRANT OPTION;
   7 FLUSH PRIVILEGES;
   8 create database testdb;
   9 show databases;
  10 use testdb
  11 CREATE TABLE locations ( id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY, lat VARCHAR(30) NOT NULL, lon VARCHAR(30) NOT NULL);
  12 exit
  13 mysql -u admin -p
  14 sudo pip3.8 install mysql-connector-python
  15 #
  16 python 3.8
  17 import mysql.connector
  18 mysql.connector.connect(host='localhost',database='testdb',user='admin',password='xxxxxxxx')

test_mariadb.py

   1 import mysql.connector
   2 conn = mysql.connector.connect(
   3   host='localhost',
   4   database='testdb',
   5   user='admin',
   6   password='xxxxxxxx'
   7 )
   8 cursor=conn.cursor()
   9 cursor.execute("Insert into locations (lat,lon) values(%s,%s)" , ("aaa","bbb") )
  10 conn.commit()
  11 print(cursor.rowcount, "record inserted.")

Install Squid Web Proxy

   1 sudo bash 
   2 apt update 
   3 apt install squid
   4 cd /etc/squid/
   5 cp squid.conf squid.conf.ORIG
   6 cat squid.conf.ORIG | egrep -v -e '^[[:blank:]]*#|^$' > squid.conf
   7 nano squid.conf 
   8 acl localnet src 192.168.111.0/24
   9 http_access allow Localnet 
  10 # comment http_access deny all 
  11 service squid reload
  12 #firefox manual proxy 
  13 #IP rpi: 192.168.111.222   Port: 3128
  14 #also for ftp and https
  15 

Raspberry Pi Pico

Raspberry Pi Pico is a low-cost, high-performance microcontroller board with flexible digital interfaces.

Connect with micro-usb

   1 sudo dmesg
   2 # [ 3570.065996] usb 1-4.3: Product: RP2 Boot
   3 # [ 3570.066006] usb 1-4.3: Manufacturer: Raspberry Pi
   4 # [ 3570.066016] usb 1-4.3: SerialNumber: E0C9xxxxxxxx
   5 # [ 3570.163372] usb-storage 1-4.3:1.0: USB Mass Storage device detected
   6 # [ 3570.164049] scsi host2: usb-storage 1-4.3:1.0
   7 # [ 3570.164381] usbcore: registered new interface driver usb-storage
   8 # [ 3570.180142] usbcore: registered new interface driver uas
   9 # [ 3571.192940] scsi 2:0:0:0: Direct-Access     RPI      RP2              3    PQ: 0 ANSI: 2
  10 # [ 3571.194468] sd 2:0:0:0: Attached scsi generic sg1 type 0
  11 # [ 3571.195164] sd 2:0:0:0: [sdb] 262144 512-byte logical blocks: (134 MB/128 MiB)
  12 # [ 3571.195818] sd 2:0:0:0: [sdb] Write Protect is off
  13 # [ 3571.195830] sd 2:0:0:0: [sdb] Mode Sense: 03 00 00 00
  14 # [ 3571.196325] sd 2:0:0:0: [sdb] No Caching mode page found
  15 # [ 3571.196335] sd 2:0:0:0: [sdb] Assuming drive cache: write through
  16 # [ 3571.217448]  sdb: sdb1
  17 # [ 3571.237585] sd 2:0:0:0: [sdb] Attached SCSI removable disk
  18 

Update apt source

Set for /etc/apt/sources.list and /etc/apt/sources.list.d/raspi.list

deb http://legacy.raspbian.org/raspbian/ stretch main contrib non-free rpi

Swap 512 MB

   1 nano /etc/dphys-swapfile
   2 # CONF_SWAPSIZE=512
   3 dphys-swapfile swapoff
   4 dphys-swapfile setup 
   5 dphys-swapfile swapon

RaspberryPi (last edited 2024-07-27 13:41:45 by vitor)