27 de febrero de 2023

Overlay Rpi Firmware: disable Wifi, Bluetooth and easy Shutdown Button

Rpi's Firmware has many posibilities to configure changing /boot/config.txt file


Usefull overlays:

Disable bluetooth:

Name: disable-bt
Info: Disable onboard Bluetooth on Pi 3B, 3B+, 3A+, 4B and Zero W, restoring
UART0/ttyAMA0 over GPIOs 14 & 15.
N.B. To disable the systemd service that initialises the modem so it
doesn't use the UART, use 'sudo systemctl disable hciuart'.
Load: dtoverlay=disable-bt
Params: <None>

Disable wifi:

Name: disable-wifi
Info: Disable onboard WLAN on Pi 3B, 3B+, 3A+, 4B and Zero W.
Load: dtoverlay=disable-wifi
Params: <None>


Safe shutdown button:

Clinton

Hey Shane,
No this won’t but if you wire the button to GPIO3 and add
dtoverlay=gpio-shutdown
to /boot/config.txt it will give you a safe shutdown and start up again.

You can find out more about it in the overlay readme search for shutdown and you will find it.
@Josh Told me about this just after I finished writing the tutorial.

-----------------------------------------------------------

Tested in my Rpi4: NOT WORK !!!

other recipe:

Tentsing this:

Include in /boot/config.txt and reboot

dtoverlay=gpio-shutdown,gpio_pin=3

NOT WORK !!

seems that nt work with GPIO_3 = SCL

Changing to GPI #17

===================================================

Include into /boot/config.txt and reboot

dtoverlay=gpio-shutdown,gpio_pin=17

YES, it's WORKS, can shutdown rpi4 with switch from GPIO#17 -- GND

===================================================


Ref:

https://github.com/raspberrypi/firmware/blob/master/boot/overlays/README

26 de febrero de 2023

Linux shell Upgrade from RpiOS-10 buster to RpiOS-11 bullseye, fast recipe.

Protocol:

 0 - Make rpi SD backup in other linux computer:
# dd if=/dev/mmcblk0 status=progress bs=5M | gzip -9 > rpi-sd-bck-$(date +%Y%m%d_%H%M%S).img.gz
 

1 - Check current version: 
$ lsb_release -a
 
No LSB modules are available.
Distributor ID: Raspbian
Description:    Raspbian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

 
2- Update, Upgrade current version
# aptitude update
# aptitude upgrade -y
# aptitude dist-upgrade -y
 
3 - Update Rpi firmware (?)
# rpi-update
 
4 - Change sourceslist.list file: "buster" to "bullseye"
# nano /etc/apt/sources.list
 
old: 
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
new:
deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

5 - Update & Upgrade new OS version
# aptitude update
# aptitude upgrade -y

6 - Clean installation files
# aptitude autoclean
 
7 - Reboot the system
# reboot
 
8 - Check OS
$ lsb_release -a
 or
$ neofetch
  `.::///+:/-.        --///+//-:``    pi@rpi4 
`+oooooooooooo:   `+oooooooooooo:    -------  
 /oooo++//ooooo:  ooooo+//+ooooo.    OS: Raspbian GNU/Linux 11 (bullseye) armv7l  
 `+ooooooo:-:oo-  +o+::/ooooooo:     Host: Raspberry Pi 4 Model B Rev 1.4  
  `:oooooooo+``    `.oooooooo+-      Kernel: 5.10.103-v7l+  
    `:++ooo/.        :+ooo+/.`       Uptime: 13787B year 
       ...`  `.----.` ``..           Packages: 2098 (dpkg)  
    .::::-``:::::::::.`-:::-`        Shell: bash 5.1.4  
   -:::-`   .:::::::-`  `-:::-       Resolution: 3840x2160  
  `::.  `.--.`  `` `.---.``.::`      Terminal: /dev/pts/0  
      .::::::::`  -::::::::` `       CPU: BCM2711 (4) @ 1.500GHz  
.::` .:::::::::- `::::::::::``::.    Memory: 367MiB / 7847MiB  
-:::` ::::::::::.  ::::::::::.`:::-
::::  -::::::::.   `-::::::::  ::::                            
-::-   .-:::-.``....``.-::-.   -::-
.. ``       .::::::::.     `..`..
  -:::-`   -::::::::::`  .:::::`
  :::::::` -::::::::::` :::::::.
  .:::::::  -::::::::. ::::::::
   `-:::::`   ..--.`   ::::::.
     `...`  `...--..`  `...`
           .::::::::::
            `.-::::-`


9 - Check all your Rpi system.

bye.

24 de febrero de 2023

Hacer funcionar arduino-IDE en Raspberry Pi B+ con OS 11 y Java 11

Me ha dejado de funcionar arduino-IDE en rpiB+ con Raspberry Pi OS 11.

Desde la consola aparece un error:

$ /usr/bin/arduino
Picked up JAVA_TOOL_OPTIONS:  
Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP

De modo que parece que hay un problema con java

$ java -version
Error occurred during initialization of VM
Server VM is only supported on ARMv7+ VFP

Pues is, confirmado no funciona java.

El procesador de mi máquina es ARMv6:

$ cat /proc/cpuinfo
processor       : 0
model name      : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS        : 697.95
Features        : half thumb fastmult vfp edsp java tls  
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xb76
CPU revision    : 7

Hardware        : BCM2835
Revision        : 0010
Serial          : 00000000ae3e152f
Model           : Raspberry Pi Model B Plus Rev 1.2


Solución:

from: https://stackoverflow.com/questions/61175441/error-occurred-during-initialization-of-vm-server-vm-is-only-supported-on-armv7

Si el procesador es ARMv6 hay que sustituir java:

$ cd /usr/lib/jvm

$ sudo wget https://cdn.azul.com/zulu-embedded/bin/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz

$ sudo tar -xzvf zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz

$ sudo rm zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf.tar.gz

Actualizar alternatives:


$ sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/java 1 $ sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/zulu11.41.75-ca-jdk11.0.8-linux_aarch32hf/bin/javac 1

Ahora seleccionar el nuevo java instalado:


$ sudo update-alternatives --config java
           [revisa y selecciona la nueva version instalada, en mi caso es el 2 ] 
$ sudo update-alternatives --config javac

Comprueba la nueva versión de java:

$ java -version
openjdk version "11.0.8" 2020-07-14 LTS
OpenJDK Runtime Environment Zulu11.41+75-CA (build 11.0.8+10-LTS) OpenJDK Client VM Zulu11.41+75-CA (build 11.0.8+10-LTS, mixed mode)

Ok!!! parece que funciona.

Pruebo si funciona arduino IDE:
Ok! funciona.



 

 

 

 

 

 





8 de febrero de 2023

Aviod undervoltage detected! warning in raspberry pi

Recipe:

- Insert the line: 'avoid_warnings=1' into /boot/config.txt 

$ sudo echo "avoid_warnings=1" >> /boot/config.txt
 
- Uninstall lxplug-ptbatt:

$ sudo apt remove lxplug-ptbatt

And reboot rpi:

$ sudo reboot

----------

P.S.: Changing usb wire solves the problem, very ofen!!,
more gauge, better !?.

28 de enero de 2022

Simple Web Scraper for Linux command line


 The Steps:

[1] download web text --->
[2] Select target text     --->
[3] Clean scraped text  --->
[4] Present result          --->
[5] Enjoy.


The System setup:

# aptitude install lynx

 

The Code:

    #!/bin/bash
    ##########################################
    # by www.misnotaslinux.blogspot.com 2022 #
    ##########################################

    url="https://PutWebUrlHere.html"

    from='Put here your starting text scrap from the web'

    to='Put here the End text of scraped text'

    web_scrap=`lynx -dump "$url" | sed -n /"$from"/,/"$to"/p | grep -v "$from" | grep -v "$to" | grep -v "*" | grep -v "_" | grep -v "^$"`

    echo "$web_scrap"

    exit 0


The Comments:

[1] El script descarga la web indicada en $url, en modo texto con lynx.

[2] Usando sed el script scrapea el texto de la web desde la cadena de texto $from hasta $to.

[3] Se limpia es texto scrapeado grep de las cadenas de texto $from y $to, así como de los caracteres no deseados: ("*", "_") y líneas en blanco ("^$"). 

Para identificar las cadenas de inicio y final del texto buscado hay que revisar previamente el texto generado por lynx de la web objetivo:

    $ lynx -dump "https://PutYourWebUrlHere.html"

Las cadenas de inicio y final deben ser lo más específicas posible, que no se repitan en el cuerpo del texto objetivo.

[4] Revisar el resultado y añadir | grep -v "cadena o carácter" con las cadenas o caracteres que queremos eliminar del texto resultante [5].


27 de enero de 2022

Enviar eMail con una cuenta gmail desde la linea de comandos linux con sendemail

 Instalar la aplicacion y dependencias necesarias:

$ sudo apt-get sendemail install libnet-ssleay-perl libio-socket-ssl-perl tcl-tls

 

El comando para la consola linux es:

$ sendemail -q -f "TuCuenta@gmail.com" -u "Asunto de email" -t "Destinatario@gmailUotra.com" -s "smtp.gmail.com" -o tls=yes -xu "TuCuenta@gmail.com" -xp "TuGmailPassword" -m "Texto del email"

N.B.: Tiene que estar activada la opci'on: Acceso de aplicaciones poco seguras, en la cuenta google de envio:

 

 

Update IMPORTANTE: 15/02/2023: para poder usar linux sendemail con una cuenta Google hay que configurar en la cuenta google:

1) Activar la verificación en dos pasos

2)  Crear una contraseña de aplicación.

3) Usar esta contraseña en el comando anterior.


19 de diciembre de 2021

SQLite basic commands

Start SQLite from cosole:
$ sqlite3
sqlite>

sqlite>.help
output all comands

sqlite>.open database_name.db
open or cretae database.

sqlite>.tables
show tables of active database.

sqlite>.schema table_name    show SQL create table fields command.


To show 20 rows of table_name with MySQL look:

    sqlite>.header on

    sqlite>.mode column

    sqlite>SELECT * FROM table_name LIMIT 20;


Describe table in MySQL look:

    sqlite> pragma table_info('table_name');

Tables like MySQL
    sqlite>.mode table

30 de octubre de 2021

How to measure Temperature and Humidity from two DHT22 sensors conected to Raspberry-Pi and Python3

For this project I used 2 DHT22 sensors modules that include the resistor.

Sensor has 3 wires to connect to GPio: Data, GND and VCC (+5V or 3.3V).

Can be use 5V or 3.3V to provide power to sensor.

With 3.3V sometimes DHT22 sensor did no respond or lost the connection (?), in my case using 5V solve the problem.

Script are coded in Python3, let's install previously the libraries. 

 

   1) The Python script:

#!/usr/bin/python3
####################################################
# (C)by MisNotasLinux 2021
# DHT22_01: data wire to gpio 23

# DHT22_02: data wire to gpio 24
# Conect VCC of
DHTs to 5V or 3.3V rpi gpio pin.
# Conect GND of DHTs to GND rpi gpio pin.
####################################################

import Adafruit_DHT
import time
import datetime

DHT_SENSOR = Adafruit_DHT.DHT22
DHT_01 = 23   # data rpi gpio pin for dht sensor 01
DHT_02 = 24   #
data rpi gpio pin for dht sensor 02

t = 10    # time for repeat measurement

while True:
    print(datetime.datetime.now())
    print("----------------------------------------------")

    h01, t01 = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_01)

    if h01 is not None and t01 is not None:
        print("Temp_01={0:0.1f}*C  Humidity_01={1:0.1f}%".format(t01, h01))
    else:
        print("Failed to retrieve data from humidity sensor 01")

    h02, t02 = Adafruit_DHT.read_retry(DHT_SENSOR, DHT_02)

    if h02 is not None and t02 is not None:
        print("Temp_02={0:0.1f}*C  Humidity_02={1:0.1f}%".format(t02, h02))
    else:
        print("Failed to retrieve data from humidity sensor 02")

    print("Sleeping " + str(t) + " sec ...")
    print("----------------------------------------------")

 

   2) References:

https://github.com/adafruit/Adafruit_Python_DHT