Posts

Showing posts with the label Raspberry Pi

Work with IoT devices on a standard computer using CircuitPython and the Adafruit MCP2221 breakout board

Image
The MCP2221 and FTD2302 are breakout boards that have a USB on one side and a series of structured and unstructured I/O pins on the other. The breakout boards have various GPIO, I2C other pins on them that you attach sensors, LEDs, or other components.  This lets you indirectly attach GPIO inputs and outputs to a regular computer.   Adafrut's CircuitPython Blinka library emulates the CircuitPython IOT  board interface that is the root of many of the Circuitpython distributions.  That interface sits between standard Python and computer-attached I/O devices.  It was originally designed to support the I/O pins of the Linux-based Raspberry Pi. In our case, it sits between standard Python and the I/O devices that exist on the other sides of the MCP2221 and FTD2302 breakout boards. The Stack Python Program Python 3.x Runtime CircuitPython Framework Circuit Python Blinka board adapter Breakout Board Definition Individual Drivers...

Raspberry Pi could not connect to Internet on FIOS but could reach all local nodes and DNS

Image
I have a Raspberry Pi network monitor that lost access to the Internet. DNS worked but everything else was blocked. Local network connectivity worked fine in both directions. It took me a couple of hours to identify the FIOS firewall issue. What Didn't Work Raspberry Pi could not curl or ping Internet services. Raspberry Pi could not get updates O/S re-installation What Worked Other machines on the local network could retrieve resources from the Internet via browser and command line. Other machines on the local network could ssh into the Raspberry Pi. Other machines on the local network could ping the Raspberry Pi. Raspberry Pi could ping the local machine. Raspberry Pi initiated DNS lookup worked Raspberry Pi traceroute to 8.8.8.8 or www.google.com would timeout Raspberry Pi /etc/dhcpcd.conf was unchanged. Raspberry Pi /etc/resolv.conf had the two needed rows in it Other Info This ran for two years without issue. Raspberry Pi IP issued via DHCP.  Other DHCP devices had no issues. ...

Free up a lot of memory on the Raspberry Pi Zero by disabling the desktop

Image
Did you install the full version of Raspian on your Raspberry Pi only to realize that you are going to run it as a headless appliance with no HDMI attached to it?  It turns out you can disable that desktop which will free up enough memory to leave almost 5x available to programs.    Disable the Desktop using raspi-config 1. Verify the free memory available after a restart with ` free -m` 2. Launch the shell-based configuration tool to disable  the desktop with ` sudo raspi-config` 3. Move through the screens shown below. 3. Reboot 4. Verify the free memory after a restart with ` free -m` Raspi-config Enabling and disabling the desktop involves changing the System Options We're going to change the boot/Auto Login  Select one of the console options.  You can always restore desktop access later by picking one of the Desktop  options The desktop should be disabled upon the end of the next restart. Before and After disabling th...

Installing the RNDIS driver on Windows 11 to use USB Raspberry Pi as network attached

Image
I do a lot of my development and configuration via ssh into my Raspberry Pi Zero over the RNDIS connection. Some models of the Raspberry PIs can be configured with  gadget drivers  that let the Raspberry pi emulate different devices when plugged into computers via USB. My favorite gadget  is the network profile that makes a Raspberry Pi look like an RNDIS-attached network device.  All types of network services travel over an RNDIS device without knowing it is a USB hardware connection. A Raspberry Pi shows up as a Remote NDIS (RNDIS) device when you plug the Pi into a PC or Mac via a USB cable. The gadget  in the Windows Device Manager picture shows this RNDIS Gadget connectivity between a Windows machine and a Raspberry Pi. The Problem Windows 11 and Windows 10 no longer auto-installs the RNDIS driver that makes magic happen. Windows recognizes that the Raspberry Pi is some type of generic USB COM device. Manually running W indows Update  or  Upd...

Monitor Internet Broadband service with a Raspberry Pi 4 and some Python

Image
You can easily automate capturing broadband connection statistics with some Python code  running on a Raspberry Pi, a Mac or, a PC.  I used a Raspberry Pi 4 as my test appliance because it is cheap and can support 1GB/s ethernet connections. That means it is fast enough to service most residential or low-end commercial connections. I'm lazy and wanted the data to end up in a secure public cloud that could be populated and viewed from anywhere.  We can send our broadband statistics from 1 or more locations and graph the different locations against each other. Any tool could be used. Monitoring One or Compare Two  We wanted to compare two different internet provider's service levels.  One provider is a FIOS 1GB down / 1GB up.  The other is a cable service with 1GB down / 50MB up. The providers and the technology were different.  We wanted to know if the complaints about one of the providers were valid. Relies on Speedtest.net infrastructure We're going t...

Demonstrating Docker on Raspberry Pi is more than a party trick.

Image
Big pieces of the 2018 Microsoft Build conference were about applied machine models and secure IOT. One of the keynote demos was called "Scott or Not" where a Raspberry PI used a machine learning vision model to determine if the person in front of a camera "looked like Scott". Some of the most interesting parts of the demo were not obvious without a both demo later in the day. Hobbyist are often ok with a hand crafted build using manual script instructions. That approach doesn't work in a commercial environment with 100s or 1000s of units. Microsoft took a more enterprise approach by creating a modular demo that supported easier automation. The demonstration code is organized in a modular fashion using Docker images. Individual functions of the pipeline are isolated to their own containers. This makes it possible to update tools, languages and code without any updates to the core system. Demonstration Flow The diagram on the right shows the flow for the vi...

Protecting the Pi: Restricting SSH to the USB gadget

Image
Why? ssh is a remote login that is pretty much the only way to work on a headless Raspberry Pi without an attached keyboard/monitor or serial console cable. Remote login capability is a security risk even with something like SSH.  There are some good articles that describe how to lock down SSH via password change or other security measures. I decided to limit SSH to specific network interfaces. Raspberry PIs can have several network interfaces. The only hardwire network interfaces Raspberry Pi Zero when it is in Network Gadget mode. I only truly trust the USB private LAN ( usb0)  since it requires a direct connection and cannot be directly seen by any other device. Interfaces Our Raspberry PI can have several different Network Interfaces.  All of them are candidates for allowing or denying SSH or other inbound access. Linux lets us manage ssh by letting us configure port related ALLOW / DENY on all network interfaces. We can create inbound iptables firewal...

Create unique Raspberry Pi host names

Image
Why bother? IOT can generate a lot of things, with each new function implemented by a new device.  Raspberry Pi devices are unix systems where each one has a name. It works best if the names on the network are unique. Manually naming IOT devices can get pretty tedious.  The following script generates a "unique" host-name based on existing device specific identifiers. The script can generate host-names based on identifiers or retrieve host names from a config file. Better living through scripting Run the script as a non privileged user to see the calculated name. Run the script with escalated privilege to change the host-name. Past the following into a file on your Raspberry Pi. This file is available on GitHub #!/bin/bash # Created 2018-03-20 http://joe.blog.freemansoft.com # derived from 2017-08-18 https://raspberrypi.stackexchange.com/questions/42145/raspberry-pi-hardware-id # script to set Pi hostname based on MAC (or Serial number) # This script should be ...

Setting up the Raspberry Pi Zero without HDMI or OTG

Image
The Raspberry Pi Zero W is a full featured Raspberry Pi that includes USB, GPIO connector and built-in wireless connectivity. The main limitations of the Pi Zero is its' lack of USB ports, the use of USB OTG and weaker single core CPU, similar to the first generation Raspberry Pi. A raspberry Pi Zero is an ideal device for embedded applications where higher level programming capabilities and a Linux footprint are desired. Pi Zero Programming Options The Pi Zero is a full featured Raspberry Pi with built in video, HDMI, USB, and a full Linux operating system.  You have exactly the same development platform options as the Pi2/Pi3.  The Pi Zero's USB OTG feature means that the Raspberry Pi Zero can act as a peripheral instead of acting as a controller.  Raspberry Pi developers have written drivers/gadgets that emulate USB disk drives, USB Ethernet adapters and others.  The Ethernet gadget makes the Pi Zero appear to a USB connected computer as if the Pi was an Ether...

Rasberry Pi, Z-Wave and Domoticz: Setup Part 2

Image
This article is about using Z-Wave with a Raspberry Pi.  Z-Wave and ZigBee are the two big wireless players in the Home Automation automation market.  A single z-wave wireless controller can communicate with a large number of devices.  These devices include outlet switches, power meters, alarm sensors, remote controlled light bulbs and other accessories. The USB stick on the left is a Z-Wave Z-Stick S2 that acts as an interface between a computer and a network of wireless devices. It can be controlled via COTS software open source libraries like openzwave .  The outlet on the right is a Z-Wave wireless controlled outlet that reports back power consumption and state. I received this controller / switch pair at the Microsoft Build conference a couple years back.  They were one of the "prizes" you could buy when you earned conference credits for running through the labs.  I really had no idea what they were for a couple years until I took the time to do ...