Skip to content

Instantly share code, notes, and snippets.

View gbaman's full-sized avatar

Andrew Mulholland gbaman

View GitHub Profile
@gbaman
gbaman / HowToOTG.md
Last active April 16, 2024 22:39
Simple guide for setting up OTG modes on the Raspberry Pi Zero

Raspberry Pi Zero OTG Mode

Simple guide for setting up OTG modes on the Raspberry Pi Zero - By Andrew Mulholland (gbaman).

The Raspberry Pi Zero (and model A and A+) support USB On The Go, given the processor is connected directly to the USB port, unlike on the B, B+ or Pi 2 B, which goes via a USB hub.
Because of this, if setup to, the Pi can act as a USB slave instead, providing virtual serial (a terminal), virtual ethernet, virtual mass storage device (pendrive) or even other virtual devices like HID, MIDI, or act as a virtual webcam!
It is important to note that, although the model A and A+ can support being a USB slave, they are missing the ID pin (is tied to ground internally) so are unable to dynamically switch between USB master/slave mode. As such, they default to USB master mode. There is no easy way to change this right now.
It is also important to note, that a USB to UART serial adapter is not needed for any of these guides, as may be documented elsewhere across the int

@gbaman
gbaman / HowToOTGFast.md
Last active April 16, 2024 06:29
Simple guide for setting up OTG modes on the Raspberry Pi Zero, the fast way!

Setting up Pi Zero OTG - The quick way (No USB keyboard, mouse, HDMI monitor needed)

More details - http://blog.gbaman.info/?p=791

For this method, alongside your Pi Zero, MicroUSB cable and MicroSD card, only an additional computer is required, which can be running Windows (with Bonjour, iTunes or Quicktime installed), Mac OS or Linux (with Avahi Daemon installed, for example Ubuntu has it built in).
1. Flash Raspbian Jessie full or Raspbian Jessie Lite onto the SD card.
2. Once Raspbian is flashed, open up the boot partition (in Windows Explorer, Finder etc) and add to the bottom of the config.txt file dtoverlay=dwc2 on a new line, then save the file.
3. If using a recent release of Jessie (Dec 2016 onwards), then create a new file simply called ssh in the SD card as well. By default SSH i

@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
@gbaman
gbaman / sd-cards.md
Last active May 8, 2022 01:31
How to clone an SD card for use in a classroom

##Creating SD card clones for classrooms

The basic idea for creating SD cards in a classroom is you create a master SD card, make all the required changes (install software, edit configuration files etc), then read it back onto the computer and flash it onto the rest of your SD cards like a normal Raspbian SD card image.

##Shameless plug If you have a networked classroom or are able to set one up, my free and open-source Raspi-LTSP project will save you a lot of time and hastle!

###A few key tips

  1. Be careful what size of SD card you use! As you will be cloning the entire SD card (even blank areas) it is important you create the master image with your smallest SD card. For example, if you are using 8gb cards that are all exactly the same make and model, it shouldn't be much of a problem. The issue is different manufacturers when they create an 8gb sd card, it may be a few kilobytes bigger than that other brands 8gb SD card. So if you use the bigger one to cr
@gbaman
gbaman / README.md
Last active November 21, 2019 09:58
Repl.it publish all activities
@gbaman
gbaman / checkInternet.py
Created May 18, 2016 11:05
PiNet web access tester
# Part of PiNet https://github.com/PiNet/PiNet-Support
#
# See LICENSE file for copyright and license details
# Tool for checking if all the domains used by PiNet are accessable.
# Run with python3 check-web.py
version="0.0.1"
def testSiteConnection(siteURL, timeoutLimit = 5):
@gbaman
gbaman / Farset-3D-printer.ini
Created April 25, 2016 12:53
Farset labs 3D printer config file
[profile]
layer_height = 0.1
wall_thickness = 0.8
retraction_enable = True
solid_layer_thickness = 0.6
fill_density = 20
nozzle_size = 0.4
print_speed = 50
print_temperature = 210
print_temperature2 = 0