28 de febrero de 2023

How to Compile and Upload .ino file to Arduino board in Rpi Linux Shell


I have a system composed by RpiB+ and Arduino Uno board working together, monitoring parameters, triggering reles, storing data into MariaDB and presenting with apache2 webserver.

When I have to change arduino program I have to open vnc session, execute arduino-ide, edit sketch, compile and upload to arduino board !!, ... painful due limited resources o my old RpiB+.

Thus, can I compile and upload and .ino file from rpi linux shell ??

Yes, and very ease.

 

Protocol:

Install arduino, if not installed already:

# aptitude install arduino

Compile and upload Shell command:

$ arduino --upload yourfile.ino --port yourArduinoport

 

Example:

$ arduino --upload example.ino --port /dev/ttyACM0

Picked up JAVA_TOOL_OPTIONS:
Cargando configuración...
Inicializando paquetes...
Preparando tarjetas...
Verficando...
...
El Sketch usa 16464 bytes (51%) del espacio de almacenamiento de programa. El máximo es 32256 bytes.
Las variables Globales usan 754 bytes (36%) de la memoria dinámica, dejando 1294 bytes para las variables locales. El máximo es 2048 bytes.
Subiendo...
...

I can also modify the .ino sketches with nano, compile and upload them to arduino from shell, without need any graphical environment.

Ref.:
https://arduino.stackexchange.com/questions/15893/how-to-compile-upload-and-monitor-via-the-linux-command-line

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 !?.