Showing posts with label raspberry pi. Show all posts
Showing posts with label raspberry pi. Show all posts

Sunday, March 23, 2025

Raspberry Pi running BASIC

Earlier on this blog, I posted something about the BASIC language on Linux. 

It turns out that all the tools mentioned in this posting are available on Raspberry Pi computers too. In fact, BWBASIC, FreeBasic and Geany work in the exact same way.


Raspberry Pi zram swap

Raspberry Pi computers may not always have the best amount of RAM available. For small embedded applications, this is just perfect, no precious ram wasted by remaining empty.
However, depending on the application, more memory might be required. The fallback would be virtual memory. In big server installations, swap is not even a topic. However, if an SD-card is were the files live on, SWAP is somewhat out of the picture.

If CPU power is not an issue, ZRAM might be a solution of the RAM-shortage of an RPi-application. 
While my RPi500 has plenty of RAM, I installed ZRAM anyways.
This is what my present memory situation looks like:

               total        used        free      shared  buff/cache   available
Mem:         8131616      835544     6173708      103560     1315828     7296072
Swap:        4270584           0     4270584

NAME       ALGORITHM DISKSIZE DATA COMPR TOTAL STREAMS MOUNTPOINT
/dev/zram0 lzo-rle       3.9G   4K   80B   12K       4 [SWAP]

NAME       TYPE      SIZE USED PRIO
/dev/zram0 partition 3.9G   0B  100
/var/swap  file      200M   0B   -2

And yes, the RPi500 is equipped with 8GB of RAM and 4 CPU cores. 
Presently I would not know how to fill up all the memory available to me.

Sunday, April 4, 2021

Raspberry Pi 400 Document Scanning with Canon LiDE 30

My RPi400 evolves more and more into my daily driver for my office activities. Here and there I got paper documents to share, so I needed to scan those, for sending them as PDFs around the world.

Many year ago, I purchased a Canon LiDE 30 USB scanner. This scanner is powered by the USB connection only. Until today, I used this particular scanner on a powered USB hub, thinking the power draw would be to great for the RPi400.
Well, I was wrong. Today, I hooked the scanner up to one of the USB3 ports of the RPi400 directly and the scanner worked perfectly.

If you wonder, the Canon LiDE 30 is supported up to Windows Vista 32bit or Mac OS X 10.5 (Leopard) and won't work on anything more modern than that in Microsoft or Apple environments.
However, we are in good luck with linux and the "sane" environment. 
On Raspberry Pi linux systems, XSane is available. To my surprise, the RPi400 delivers sufficient current on the USB3 connectors to power my Canon LiDE 30 scanner. 


Monday, February 22, 2021

Raspberry Pi and Arduino revisted

In my earlier post, locating a valid Arduino connection, I used exception handling by catching the error message created by attempting to open a non-existing device.
Of course there is an easier way of doing this in a POSIX compliant system, by looking at the existence of the respective device files. If you are confused about the ttyUSB0 device, this is how an inexpensive Arduino clone appears in my system.

Here is my new approach, which is bit more elegant and less brutish. This approach uses the "glob" module and the "set" data-type.


import glob

def listFiles(prefix):
    _=set()
    for file in glob.glob(prefix):
        _.add(file)
    return _

def findArduino():
    ser_dev={'/dev/ttyACM0','/dev/ttyACM1','/dev/ttyUSB0'}
    dev_list=listFiles('/dev/tty*')
    for _ in ser_dev:
        if _ in dev_list:
            return _

if __name__=='__main__':
    arduino=findArduino()
    if arduino:
        print('Arduino found at',arduino)
    else:
        print('Arduino not found')


Saturday, February 13, 2021

Raspberry Pi with Arduino

Over the last few months I was developing hard- and software for a project. While I won't disclose any details of the project here, I think it would be fun for the readers to see me learning Raspberry Pi, Arduino and Python.
And yes, the previous Raspberry Pi blog posts were all somewhat triggered by the project mentioned above. In fact, the main idea of the project was not only using Raspberry Pi hardware for the project itself, bu also as main hardware for the company running said project, including all staff. (I am diverting...)

On particular problem with Arduino boards hooked up to Raspberry Pi boards is that the device might change from /dev/ttyACM0 to /dev/ttyACM1 from one use to the other. When using cheap clones, the device might be /dev/ttyUSB0.
So, in a project using Arduino (clone) boards with a Raspberry Pi board, one needs to test which device is in use.

Here comes the learn Python with me. This might not be the most elegant way to do this, however, here is a solution that works for me:

def initialize():
    global SERIAL_PORT
    global ser
    # find a valid serial port
    try:
        TSER='/dev/ttyACM0'
        print('trying '+TSER)
        tser = serial.Serial(
            port=TSER,
            baudrate = 115200,
            parity=serial.PARITY_NONE,
            stopbits=serial.STOPBITS_ONE,
            bytesize=serial.EIGHTBITS,
            timeout=1
        )
        print(TSER + ' found')
        SERIAL_PORT=TSER
        tser.close()
    except serial.serialutil.SerialException:
        try:
            TSER='/dev/ttyACM1'
            print('trying '+TSER)
            tser = serial.Serial(
                port=TSER,
                baudrate = 115200,
                parity=serial.PARITY_NONE,
                stopbits=serial.STOPBITS_ONE,
                bytesize=serial.EIGHTBITS,
                timeout=1
            )
            print(TSER+' found')
            SERIAL_PORT=TSER
            tser.close()
        except:
            print('no Arduino found, using clone')
            SERIAL_PORT='/dev/ttyUSB0'
            
    finally:
        print('using '+SERIAL_PORT)

    ser = serial.Serial(
        port=SERIAL_PORT,
        baudrate = 115200,
        parity=serial.PARITY_NONE,
        stopbits=serial.STOPBITS_ONE,
        bytesize=serial.EIGHTBITS,
        timeout=1
    )


Sunday, January 31, 2021

Raspberry Pi 400 - the Most Significant Computer in 2020

Is that a click-bait title?!
I don't think so. While Raspberry Pis were doing well over the years. There never was an attempt to creating a breakthrough by the RPi-foundation. At least that's my thought on things. 
Personally, I was never really attracted to their devices, until the RPi3B+ was released. Now we are talking. Not perfect yet, however, the device was boot-able over USB and with 1GB of RAM, this has beaten many of my previous Linux machines.

With the RPi 4 coming in, the game changed. Now we are talking about a tiny computer that boots from USB3, adding the speed needed for real computing.
In fact, I used a RPi4-8GB in a 64bit computing environment successfully.

The before mentioned setup required some pain and suffering to set up, in particular choosing the 64bit OS that supports the 8GB. So, is that what I would recommend to others? No it is not, only if you know your ways around Linux and stuff. Many of the amenities you get with a 32bit Raspberry Pi OS wont be there. Lets wait and see how the 64bit Raspberry Pi OS will perform, once it left the beta stage.

So, what the fuzz about the RPi 400 then? Well, it is not much of an improvement over the RPi4 to be honest. However, having the only choice of a 4GB version eliminates the need for a 64bit OS. Consequently, the Raspberry Pi OS is all you might want to use.
And that is what I am running on my machine, which I actually use for business, believe it or not. I wished the keyboard was a little bit better, but for the rest, the RPi 400 does a fine job.

To add something technical here, I did overclock my RPi 400 to 2.1GHz by adding the following lines to the file /boot/config.txt (I left the original comment line for reference): 

#uncomment to overclock the arm. 700 MHz is the default.
over_voltage=6
arm_freq=2100
gpu_freq=750

And here we go, this change makes the RPi 400 just a little bit snappier.

Here is another suggestion I got for you: install zram-tools. This will setup virtual swap space using compression in RAM rather than real disk/SSD-space. With 4 cores and 4GB of RAM, zram-tools will provide 1GB of virtual swap. This may not sound like much, however, once you hit the memory ceiling, you will see that this is a really good tool, in particular with higher clock speeds.

Should you consider using the RPi 400 as a daily driver, I highly recommend using an SSD on one of the USB3 ports. Further, a (powered) USB(3) hub will help to add devices you would regularly use for daily work, such as a scanner.
Writing about scanners, I am using an old Canon LIDE 30 with great success on an even older powered USB hub. To be honest, before using those things with the RPi 400, I considered discarding those devices, due to a lack of drivers on OS other than Linux.

And the best thing about the RPi 400, it is passively cooled. As long as you are not using a mechanical HDD with the device, you got a totally silent working environment, which to me means a lot.
 


Saturday, November 14, 2020

Raspberry Pi 400 audio issues update

Bluetooth remains still unsolved beyond what I was writing earlier.

In order to get some sort of audio output, I changed back to the only HDMI monitor having speakers in my possession. After the removal of pulseaudio (apt remove pulseaudio), the monitor is perfectly fine to use for sound playback, however, the audio from those tiny speakers is pretty poor. I guess, it is what it is.

Hopefully the Raspberry Pi Foundation will solve the Bluetooth issues with the RPi400 as soon as possible.

Friday, November 13, 2020

Raspberry Pi 400 audio problems - USB not the solution

In my earlier post, I as speculating if the use of a USB sound card would be a possible solution to the audio problems of the Raspberry Pi 400.
Well, it is not!
The audio was playing, however, at a terrible quality, not worth further talking about.

While the RPi400 was never meant to be used in my amateur radio setting, it now shows clearly to not be suitable for such use at all. The only thing still untested would be SDR devices such as the SDR-Play RSP1A.
Seen that a simple audio dongle does not work well, I have serious doubts about any of the SDRs being better supported,

If the Raspberry Pi Foundation is reading, please consider adding an AV jack to a future version of the RPi400. The form-factor of the device is excellent, having it performing similar to a RPi3B+ in respect to audio would make this device usable for not just the ham radio community but also so many more folks looking for some audio abilities of a device.

Raspberry Pi 400 (audio issues)

So, the RPi400 came in. First of all, is it worth the money? Yes it is. The device itself has a good, i.e. reasonable, weight to it, thanks to the internal heat-sink. The keys feel very good and typing is on those is a pleasure. The mouse, meeeeh, well, feels a bit cheap, works well though. In my view, the cheap feel of the mouse comes from its lack of weight. Reducing the mouse acceleration to 3 already helped a lot. I might be temped to open the mouse up and add some weight to it, e.g. by gluing steel nuts to the inside of the case.
I love the size of the device, just perfect. Have a look at my before (Raspberry Pi 3B+) and after setup.

The old and the new

The photographs show my old RPi3B+ setup with a 3.5" external mechanical 320GB USB2 HDD and the RPi400 with a 128GB Kingston SSD in a USB3 enclosure.

The RPi400, having USB3 ports, can benefit from the SSD in a USB3 enclosure. Further, the RPi400 can boot from USB devices. Therefore, the speed of the combination is really close to a decent desktop PC. 

Now, I am appear to be full of praise for the new device. However, beyond the disappointment with the mouse, there is something else which is close to being a deal breaker, at least when running Raspberry Pi OS. That deal breaker being the difficulties of connecting audio output devices, aka speakers.
The RPi400 does not have an analog AV output, which all the other Raspberry Pis have. Hence, there is not way of connecting a wired audio connection, e.g. active speakers, to the RPi400. Lets forget about HDMI for a minute... Well, no problem, you may think, the RPi400 got Bluetooth... RIGHT! Yes, it got Bluetooth, however, the implementation in Raspberry Pi OS does not connect to BT audio sinks as easily.
It took me the better part of the evening, despite the posts about the issue I found on divers fora, to get a BT speaker connected. And even then, the result is less than perfect. My way is sufficiently satisfying to me, however, this might not be the case for someone expecting an OOB experience.

Here is what I had to do to get to the point of semi-happiness:
  1. in a terminal type: sudo apt install pulseaudio-bluetooth-module
  2. add "Volume Control" to the TaskBar, next to "Volume Control (ALSA/BT)" 
Item 1 will add all the necessary programs and drivers to the system.
Item 2 will give you control over the volume of the audio played out. Somehow, the ALSA/BT panel item does no longer function with BT devices, however, it is necessary to select a BT device as an audio sink. Controlling the volume itself is now done with the 'other' volume control icon, but not in a way that is desirable... Right click on the icon and " Launch Mixer". This will open a terminal with alsamixer. While this works, perfect it is not.

A possible solution could be using a different OS. However, this comes with some drawbacks itself. Raspberry Pi OS is optimized for the hardware and comes with some very interesting software packages, e.g. Mathematica or the RPi Bookshelf.

Another solution would be to add a USB sound card to the mix. However, the RPi400 only having 3 available USB ports, of which one might be used for the mouse and another one for the USB-boot-device, there isn't a lot of wiggle room, unless adding a USB-hub. 

In the near future, I will have a look at other operation systems on the RPi400. One of my present favorites might be Ubuntu Mate 20.10.


Wednesday, November 11, 2020

Raspberry Pi 3B+ USB Boot

Earlier, I describe the use of BerryBoot with an external USB HDD with a RPi (1) B+. To be honest, this was a terrible user experience. While everything worked, this setup was tantalisingly slow. I mean really really slow. 
My assumption is that the USB2 implementation of the RPi1B+ does not reach USB2 speeds, not even close. Presumably the USB ports a run by the CPU, which in itself is relatively low power already. Consequently, I abandoned the idea of running the RPi1B+ from a USB drive.

As an experiment, I used the exact same external USB-HDD and microSD-card with my RPi3B+. What a difference! This setup really resembles a usable desktop computer. 
In my experience, the Raspberry Pi 3 B+ appears to be able to run the USB2 ports at USB2 speeds.
While booting and running of the microSD-card appears to be a little bit more snappy, the combo of BerryBoot and the externally powered 3.5" HDD on USB2 delivers an acceptable user experience.

The obvious advantage of this particular install is the amount of storage available, in my case more than 300GB.  The amount is only dependent on the HDD in the enclosure.


Monday, November 9, 2020

Raspberry Pi OS on USB

Lately, for various reasons, I got into using Raspberry Pis, in particular in combination with the GPIO.
What puts me off by a bit is the fact that the regular RPis used (micro) SD cards. While reading from an SD card might not be that bad, but writing to it, over and over again, will destroy over a short period of time. Thereby destroying the data you stored on it.

For my projects, therefore, another solution had to be found.

In this series of posts, I will document my experiences using various methods and devices to avoid the wear and tear of an SD card.

This first episode reflects on using BerryBoot to boot from and load the OS from USB connected devices.

Using and installing BerryBoot is very simple. Download the archive provided in the above mention link. Make sure you picked the file that fits your Raspberry Pi. 
During writing this article, it appears that the BerryBoot image now changed to a single archive for all variants of the RPi. I have not tested this, since I just a few hours prior to the writing of this post, downloaded the archive for Pi0 to Pi3+ boards.
Anyway, I stick with what I have and what worked for me earlier.

In my present test, I am using a Raspberry Pi 1 B+ with a 2GB micro-SD card as a boot device and a USB-2 HDD enclosure with a 320GB 3.5" hard-disk. The enclosure came with a 2TB disk, which is used in something else by now.
Further, the enclosure is powered externally by a 12V wall-ward. This, of course, is important, since a Raspberry Pi would never be able to provide the power for any HDD.

Following the procedure as set out on the BerryBoot page, an OS will be written to the USB attached device. I opted for a full install of Raspberry Pi OS, as it is presently called.
After having booted "into" the HDD, the experience is certainly less snappy, compared to running the OS from the SD card. However, the mere difference is storage space should put up some questions: 8GB SD card vs. 320GB HDD.
Initially, no swap space was created. So, I decided for creating a swap-file on the root directory of the hard-drive. That did not work. It appears that under BerryBoot, using a swap file is impossible.

A solution to the missing swap-file is to install zram-tools, which will enable a virtual swap into compressed memory.

In following posts, I will discuss various other options for booting a Raspberry Pi from USB devices.





Saturday, May 18, 2019

Down Sizing My Computing

Most likely, I am not the only one who noticed that it is rarely a necessity to maintain high power computing equipment at home. For me, the last resort for this sort of demand would be video editing.
Most of my photo editing is done in the cloud by now, either by moving a finger across the screen of my phone of with the aid of Chromebooks.
While my Chromebooks do a great job, for some applications, I wished to have some other tools available.
So, after a longer struggle, I finally decided to "invest" in a Raspberry Pi. That decision came when I learned that there a at least 2 ways to boot the Pi from USB HDDs. Why is that important, I hear you thinking. Well, first of all I still got a bunch of spinning HDD in my scrap-box, and secondly, SD cards are certainly not the fastest medium in the world what read and write speeds are concerned, but they are the fastest storage medium in the world to wear out. Seen the RAM limitation of a Raspberry Pi, my regular use will heavily rely on swap, resulting in the foreseeable death of many SD cards in the near future.
While my Chromebooks wont be replaced any time soon, the FX-6100 and i7 4770k workstations will see a lot less work soon.
Presently there is a Pi 1 B+ and Pi 3 B+ in my possession.
My junk box further comprises a lot of old USB stuff, e.g. powered hubs, WiFi dongles, sound dongles, etc. So, there are a lot of options to build system around Raspberry Pi boards by recycling obsolete stuff. How exciting!