Browsed by
Category: Raspberry Pi

[PIGET] Save and share your projects

[PIGET] Save and share your projects

We are going to see how tu use git module to create your own modules.

Modules are a great way to works on your project on a Raspberry Pi.
You can save your project and make it available at the beginning of it and share all your scripts to automate tasks.

You can also use all availables modules on Piget , and works with anyone on it.

In this tutorial we are going to :

  • Install git module
  • Create an example module
  • Save this module

Install git module

You can easily create and save module using git module.

To install git module type :

/pi/install git

Git must know your username and email to identify you.
This information is not mandatory, but it is adviced to fill it.
To setup git type :

/do/git/setup

  • Enter your username on github
  • Enter your email on github
When you save a module, your password will be cached for 15 minutes before you need to enter it againr

Create a module

You can do all theses directly on Windows with samba module

We are going to create an example module.

  • Create /do/example folder

mkdir /do/example

Module name must be in lowercase
  • Create install script

nano /do/example/install

  • Make it executable (This also check compatibility)

/system/convertScript /do/example/install

A module always starts with a install script
The install script have all the commands needed to make the module works, When the module is installed, this command will be launch .

A good way to start a module is to copy all the commands from a tutorial inside this script, so you won’t need to go back back to it, and you can make and keep modifications.
Don’t forget to put a link to the tutorial, and his author name inside your script. This will help people to know where to find more information.

Try to avoid as much as possible user interactions in your install script. If you need to ask something to the user, put it inside a setup script

Since we have an install script, we can already upload it, so be can easily save it and get some help to make it.

Save your module

On github

  • Create a new repository

repo

  • Put inside Repository name, the name of your module

name

  • Click on Create repository

In your terminal

  • Inside the module folder /do/example

cd /do/example

  • Type

/do/git/create username/example
/do/git/create benzaie/example

  • Enter your email (github)
  • Enter your password (github)

Your module is now available on github !

Some advice

  • No settings and password inside your module ! Use the folder /user/config/module_name instead !
  • Only put scripts in the main folder, put code / settings / documentations in subfolders.
  • Check out modules inside github.com/pigetnet (especially those who have a documentation)
  • We see how to document your scripts in another tutorial.
  • We see how to use system commands in another tutorial.

Others commands

Coming Soon!

[PIGET] Modify a module

[PIGET] Modify a module

We will see how to modify a module on Piget

Modules can be easily update, so anyone can contribute easily !

Thans to Github, You can work on your own version of piget modules without asking it, and share it with the rest of the world.
If your changes are interesting, I can add it easily.

In this tutorial we are going to :

  • Copy led module
  • Modify it on Github
  • Install your own led module

Copy a module

All Piget modules are on Github, you can copy any module on your own account.

For example, Benzaie want to improve led module, he need to clone (fork) it :

Benzaie now have his own led module at github.com/benzaie/led

Modify a module on Github

You can modify files directly on Github website.
Let’s say Benzaie want to add comments on script on

  • Click on

on

  • Click on the pencil (left)

crayon

  • Modify the code
  • Add a title and a description
  • Click on commit changes

Et voilà , you can see the modification here : https://github.com/pigetnet/led/commit/7433163094076de271f1ae6748c49124c994914d

Install your module

Benzaie want to see his modules or even share them with his friends.

We need to

  • Delete the led module

rm -rf /do/led

/pi/install benzaie/led

Update a module

To update all modules, type

/pi/update

To update led module, type

cd /do/led
/do/git/update

We’ll see in another tutorial, how to create your own modules.

Create a portable synth with a Raspberry Pi (samplerbox)

Create a portable synth with a Raspberry Pi (samplerbox)

samplerbox

Samplerbox (samplerbox.org) is an open hardware / open source synth on a Raspberry Pi.
I’m actually working an a new version with a LCD screen and instrument banks. I also add some modifications from the samplerbox community.

Here are other versions of samplerbox:

This version was made to make it as easy as possible to create instruments / develop new functionalities and to be used outdoors.

This is an unfinished prototype

We are going to :

  • see the needed components
  • Download and copy my samplerbox image
  • Learn how to use it
  • See how to create instrument

 

  • Needed components

    Keep in mind you can reuse any components, no soldering is required
    • LCD Display Shield is a copy of Adafruit LCD shield : Adafruit LCD
    • Most USB-MIDI instruments should works.
    Minimal version
    Portable version
    Speakers version

Installation

  • Download the test version here : samplerBoxLCD (mega)
  • Copy the image (samplerBox.img) on an sdcard (tutorial)

Usage

  • Plug the LCD shield on the Raspberry Pi
  • Plug the USB audio card (pcm2704)
  • Plug your synth
  • Turn on your Raspberry Pi
You can plug and deplug your synth whenever you want, you can even plug multiples USB-midi devices.

You should see your Raspberry Pi started, and 00 Vibraphone should show up on screen.

Here is how to control the screen

  • Menu instrument menu (par défaut)
    • UP/DOWN : Change instrument
    • LEFT/RIGHT : Change menu
    • SELECT : Reload instrument
  • Volume menu
    • UP/DOWN : Change volume
    • LEFT/RIGHT : Change menu
  • Sustain menu
    • UP/DOWN : Enable/Disable sustain
    • LEFT/RIGHT : Change menu
  • Transpose menu
    • UP/DOWN : Transpose 1 octave
    • LEFT/RIGHT : Change menu
  • Quit menu
    • UP/DOWN : Shutdown
    • LEFT/RIGHT : Change menu
    • SELECT : Restart
You can change the volume with any control knob

Copy sounds

  • Plug your Raspberry Pi on Ethernet
  • Search on your network: synth
  • Enter a username : pi
  • Enter a password : a

You should see two folders : samples et software

software folder is where samplerbox and scripts are, inside python folder: you can find samplerbox.py
You can setup and modify samplerbox with samplerbox.py

samples folder is where the samples are.
The name of each instrument starts with a number ,(for example: 11 Pan Flute)

Inside instrument folder , samples are named by there note :for example a#2.wav
If you play an b2 and there is no b2.wav then it will play a#2.wav (for example) faster (with a higher pitch).

  • You don’t need to create all notes to create an functional instrument.
  • Try to create long note first and reduce the length of the note until it sounds right.

You can use Reason NN-XT as an example on how to make samples (especially for the note range)

nnxt

  • Export loop to generate a .wav file in \\synth\samples\number instrument_name\

If you create a new instrument, you need to restart your Raspberry Pi
If you have modify a instrument, press SELECT to reload the instrument
How to make instruments with velocity

Debug mode on terminal

  • Stop samplerbox
    /do/samplerbox/panic
  • Start samplerbox
    /do/samplerbox/check

Issues

  • SD card is not in read-only / optimized as the original version
  • Pop noises can be heard when volume is too high (stay at volume 0.5 for more safety and avoid using too many notes as the same time)
  • Slow down on long samples if played fast
  • Volume can be too low, if speakers are not correctly amplified.
  • When buttons are pressed , this can generate audio glitch
  • Volume button and sustain button are linked
  • Release (time before the note fadeout) can’t be set for each instruments (FADEOUTLENGTH)

Synthetizer usually have 4 parameters : ATTACK / DECAY / SUSTAIN / RELEASE (ADSR)

Notes

Here is what have been added on this version of samplerbox

  • A 16×2 LCD (To choose your instruments, show their name  / set the volume / stop it)
  • If no definition file is used , velocity will be managed by changing volume
  • You can set the volume on your midi controller
  • Some instruments to show how to make them
  • File sharing (samba) to copy / modify samples while testing them

 

Manual Install

(note : The installer is not finished)
(note : There are still issues with samba)

curl -L piget.madnerd.org | sudo bash

  • Setup your Raspberry Pi name

/pi/setup

  1. Name : synth
  2. Password : (choose your own)
  3. Color : (choose your own)
  • Install samplerbox

/pi/install samplerbox

This will install:

  • Python dependencies
  • Samplerbox
  • Create samba file sharing (\\synth\samples and \\synth\software)
  • Install adafruitLCD library

16×2 LCD Display

Add theses line at the end of these files
(note : this will be automate)

[PIGET] Watch your Raspberry Pi with 2b3l

[PIGET] Watch your Raspberry Pi with 2b3l

This project is unfinished !

Idea

We are going to use 2 buttons and 3 leds to:

  • See if someone have access to our terminal (red led)
  • See if file sharing is active (yellow led)
  • See if someone is currently using file sharing (green led)
  • Button 1 : Restart our Raspberry Pi
  • Button 2 : Enable / Disable file sharing

(note : if you find other ideas on how to use 3 leds and 2 buttons, you can post them on http://github.com/pigetnet/ledsButtons/issues )

3D model

2b3l en filaments phosporescent
2b3l made with phosphorescent filament

Link to 3D model:
https://github.com/pigetnet/ledsButtons/tree/master/3d

(note : This model was not properly test, if you have another 3D model idea, feel free to share them)

(note : We will explain how to solder the components here)

Wiring

Cables must make a 3×2 rectangle on the Raspberry Pi at the end.

2b3l_bb

  • Red led : 21
  • Yellow led : 20
  • Green led: 16
  • Button 1 : 26
  • Button 2 :19

https://pinout.xyz/

You can also display the pinout by typing /do/ledsButtons/pinout

Installation

To install this module, type in your terminal :

/pi/install ledsButtons

(note : Beware of the uppercase, I will modify this module to be only in lowercase later)

This will install led , buttons and supervisor.

Usage

Two modes are available :

Test Mode : This mode will check if everything is correctly wired:

Type :

/do/ledsButtons/test

Bouton 1Turn on all leds
Bouton 2 : Turn off all leds

Security Mode : This mode will check if something is connected to your Raspberry Pi

/do/ledsButtons/security

Red led :  Terminal is currently use(ssh)
Yellow led : File sharing is currently use (samba)
Green led : File sharing is enabled (samba)
Button 1 : Blink all the led , and shutdown the Raspberry Pi
Button 2 : Enable / Disable file sharing (samba)

Create your own mode :

Check this script: https://github.com/pigetnet/ledsButtons/blob/master/scripts/ssh/check
If you want to create your own services, you need to learn how to clone a module here

Commandes

Security Mode
Buttons
All leds
Red led
Yellow led
Green led

Supervisor

(note : this module is undocumented and needed to be check properly: http://github.com/pigetnet/supervisor/issues)
(note : This part will be a tutorial on his own)

The supervisor module can be use to transform a software or a script as a service.
You only need to make your scripts/software run in an infinite loop.

To create a service, type:
/do/supervisor/create service_name script
/do/supervisor/create sambaCheck /do/ledsButtons/scripts/samba/check

To display a list of services:
/do/supervisor/list

To display log of a service:
/do/supervisor/log service_name
/do/supervisor/log service_name

To remove a service:
/do/supervisor/remove service_name
/do/supervisor/remove sambaCheck

To restart a service:
/do/supervisor/restart

To stop a service:
/do/supervisor/stop

To start a service:
/do/supervisor/start

[PIGET] Wi-Fi

[PIGET] Wi-Fi

In this tutorial, we will learn how to connect our Raspberry Pi to Wi-Fi.

wifi-dongle

Prerequisite: Piget

/pi/wifi

  • Choose your router

wifi-hotspot

  • Enter your passwordwifi-motdepasse
  • Wait until the connection is established

wifi-connected

An insufficient power supply can result in Wi-Fi instability or failure to work.
[PIGET] Buttons

[PIGET] Buttons

We will learn how to launch commands with buttons.

In this tutorial, we are going to :

  • Plug two buttons
  • Setup buttons to turn off or reboot our Raspberry Pi
  • Use other commands with the buttons module
  • Setup buttons from Windows
Prerequisite: Piget

Needed components

Composants Prix Liens
Buttons 2.43$ — 1.20$
Breadboard 2.8$ – 1.21$
Dupont cables 1.96$ – 1.25$
Total : 7.19$ – 3.66$

Plug a button

We will see how to plug two buttons on our Raspberry Pi:

Button 1

Bouton 2

GPIO 19

GPIO 26

  • Take the first pin of each button and wire it to the Raspberry Pi

 

gpio Boutons

  • Take the next pin and wire it together
  • Then wire it to the ground (GND) of the Raspberry Pi

Schéma bouton

Why the button is not wired to VCC?

Setup buttons

  • To install button module, Type in your terminal:

/pi/install buttons

This will install buttons service which will watch all buttons setup in /user/config/buttons/buttons.cfg

  • To setup buttons type:

/do/buttons/settings

nano buttons.cfg
All shortcuts are written on the bottom of the screen. For example,  to save (write) ^O or CTRL-O, to exit : CTRL-X

Each buttons are setup in a block of text which starts with a [B Pin], for example [B19] or [B26].
There are twos parameters :

  • action = command to launch
  • timer = times before the action is restarted
What is the line timer = ?

For example, if we want a button to :

  • Turn off our Raspberry Pi (poweroff)
  • Reboot our Raspberry Pi (reboot)
To exit nano press:

  • CTRL-O then ENTER
  • CTRL-X then ENTER

This will automatically restart button service and display the log in order to try the buttons.

Commands

Here are all the commands of button module :

  • Setup the button service: /do/buttons/settings
  • Setup 19/26 buttons pour shutdown and restart: /do/buttons/poweroffReboot
  • Simulate a button press on pin 26: /do/buttons/press 26
  • Display button state on pin 26: /do/buttons/state 26
  • Display settings: /do/buttons/commands
  • Display logs: /do/buttons/log
  • Display logs live: /do/buttons/tailLog
  • Restart le bouton service: /do/buttons/restart
  • Start button service: /do/buttons/start
  • Stop button service: /do/buttons/stop
  • Uninstall le service bouton: /do/buttons/remove
  • Start button service in debug mode: /do/buttons/check
How button service works ?

Setup without terminal

If you want to be able to setup buttons without the terminal.

  • Then using Windows explorer go to your Raspberry Pi (for example : \\madnerd)
  • Go to \user\config\buttons (for example : \\MADNERD\user\config\buttons )
  • Open file buttons.cfg with your favourite text editor
  • The first button will blink a led on pin 21
  • The second button will restart button service
We can now, modify what button 1 do without using the terminal.
Press button 2 to update the settings.

 

[PIGET] LED

[PIGET] LED

Let’s see how to control LED from the terminal.

In this tutoriel we are going to:

  • Control the ACT LED on the Raspberry Pi.
  • Plug a LED
  • Control a LED from the terminal
Prerequisite: Piget

Needed components

Composants Prix Liens
LED 5.93$ — 3.5$
Resistor 10.95$ – 3.64$
Breadboard 2.8$ – 1.21$
Dupont cables male/female 1.96$ – 1.25$
Total : 21.64$ – 9.6$

Control the ACT led

led Act

By default, the green led (ACT led) light up when data is read or write on the SD card.
Here is how to control it :

  • Turn on LED: /pi/ledOn
  • Turn off LED: /pi/ledOff
  • Blink LED: /pi/ledBlink
  • Return LED to normal state: /pi/ledReset
Plug a led

ledon

We are going to plug our first led on pin 21, This is the pin near the USB port.

  • Wire the LED + (the longest leg) on pin 21
  • Wire the LED  on a (at least 100 ohms) resistor
  • Wire the resistor to the ground, next to pin 21.

schema Led 21

If you want to plug a led on another pin here is a list on pinout.xyz
How to find the right resistor for a led?
Control a led on the terminal

To install led module type:

/pi/install led

Here are the commands to control a led on pin 21 :

  • Turn on LED: /do/led/on 21
  • Turn off LED: /do/led/off 21
  • Blink LED: /do/led/blink 21
  • Change led intensity: /do/led/pulse 21
  • Display state of led (0:off 1:on): /do/led/state 21
  • Display gpio: /show/gpio
You can use additional arguments on some commands.
/do/led/blink
/do/led/pulse
Others ressources
[PIGET] Access files (samba)

[PIGET] Access files (samba)

We will learn how to access files on our Raspberry Pi using Samba.

schéma_Samba

Prerequisite : Piget

Thanks to Samba, we can use Windows file sharing on Linux.

Windows network shares are compatible with all operating systems.

In this tutorial, We are going to

  • Install samba module
  • Share piget’s folder
  • Protect all shared folder with a password
  • Learn how to fix issues on Windows
  • See what’s inside piget’s folders
  • Create a report
  • Share all files on a Raspberry pi
  • See all the other commands
Installation

To install a module on Piget, we just need to type this on our terminal:

/pi/install nom_du_module

  • Install samba module

/pi/install samba

Samba is installed (if it wasn’t already), then a default password is created. No files are shared.

User : pi
Password : raspberry

 

Share Piget folders

To share piget’s folders, type

/do/samba/sharePiget

This will set up and restart samba

Protect your network shares with a password

Before we go to the files on our Raspberry Pi, we should change the default password.

Tape this to change password and type your password twice.

/do/samba/setupPassword

You can access shared folders in Network on Windows explorer

reseau

Fix issues on Windows

If you have previously entered a different password, this may have been cached by Windows, we can’t change it and an error message will be displayed.

error

There are 3 ways to fix this:

  • close and open your session
  • restart your computer
  • Type these commands on the command line as an Administrator (Shortcut : WINDOWS-X then A)

net stop workstation
net start workstation

We are going to see what we have shared.

schéma_Samba

Boot folder

Click on your Raspberry Pi in Network and enter pi as your username and password

password

In boot folder, we can store files that will be available on the boot partition on our Raspberry Pi.
This partition is the only one that can be access on Windows, when you plug your sd card on your computer.

This partition only have 37 megas, so you shouldn’t store anything except text files.

We are going to use this partition to create a text file which will explain what is installed on your Raspberry Pi.

Create a report

To generate a report, type :

/pi/logBook

This will create logBook.txt on your SD card.

This file contain a list of installed modules, the name of our Raspberry Pi, the IP address of our Raspberry Pi.

Here is an example of a log :

Logbook.txt
Piget folder

The folder Piget contains all piget’s scripts and softwares.
You can see and modify how Piget works here.

However if you update your Raspberry Pi by typing :

/pi/update

All modifications will be lost, except if you create a new module, will see how on another tutorial.

User folder

Finally, you can store all your personal files in the user folder.

  • You can save your own scripts in /user/scripts
  • No setting is saved inside piget folder , there are saved inside /user/config
Share all folders

We will see how to share all folders on the Raspberry Pi.

Your Raspberry Pi will be completely vulnerable, only do this on your own network and if you really need it.

Type :

/do/samba/shareAll

We have now access to all folders.

Stop sharing
If you want to stop sharing files , type:

/do/samba/shareNothing

Once you don’t need it anymore, stop sharing files to avoid unwanted access to your Raspberry Pi.

Other shares

There are more settings available on samba modules

To code a website, you can share /var/www , by typing :

/do/samba/shareWeb

You can share the user folder only, by typing :

/do/samba/shareUser

Other commands
Modify samba settings

Load a previously saved settings
Save current settings
Add samba share
Remove a samba share
Copy a settings file (/etc/samba/smb.conf)
Download a settings file on github
Check if a folder is shared (0:no 1:yes)
Display a list of users
Change password directly
Change password (user need to type password)
Don't start samba at boot
Start samba at boot

Restart samba

Stop samba

Start samba

Display samba status (open files, users)

Display if a user is connected (0:no 1:yes)

There is a automatically generated documentation available at http://github.com/pigetnet/samba

If a module doesn’t have any documentation on Github, you should consider it as unfinished.
[PIGET] Install Piget

[PIGET] Install Piget

We are going to see how to install Piget on your Raspberry Pi and how to use it to set it up.

Piget will allow us to automate software and components install on the Raspberry Pi
Instead of typing complex commands and modify configuration files, you can use short command instead.

In the tutorial, we are going to :

  • Install piget
  • Setup our Raspberry Pi
  • See useful commands on Piget
Piget is made to be used with Raspbian Lite
Installation

You just need to copy-paste this command in your terminal  to install Piget.

curl -L piget.madnerd.org | sudo bash

What happens during install?
Setup

We can setup our Raspberry Pi using a menu, by typing :

/pi/setup

/pi/setup

  1. Choose a name for your Raspberry Pi
  2. Choose a password for the terminal (user: pi)
  3. Choose a colour (This can be useful to differentiate Raspberry Pi)
The SD card will be resized, if needed
Useful Commands
  • Rename Raspberry Pi

/pi/name nom
/pi/name madnerd

  • Change password

passwd pi

  • Resize SD card

/pi/resizeSD

  • Update Raspberry Pi

/pi/update

  • Install a module

/pi/install module
/pi/install led

  • Display help for a command

/show/help command
/show/help /pi/name

Connect to the terminal

Connect to the terminal

We will see how to remotely connect to the Raspberry Pi’s terminal on Windows.
The terminal will allow us to setup our Raspberry Pi using commands.

In this tutorial, we are going to:

  • Download and install putty
  • Install bonjour service (if needed)
  • Learn how to use autocompletion
Connect to the terminal

We will use putty to connect to our Raspberry Pi SSH terminal.

Putty is a portable application, you can use it without installing it.
  • Plug your Raspberry Pi into your router with an ethernet cable

Raspberry Pi - Ethernet

  • Download putty here : putty.madnerd.org
  • Start putty.exe
  • Enter your hostname : raspberrypi.local
  • Click on Open

putty

Le service Bonjour (zeroConf)

If you see this error message :”Unable to open connection to raspberrypi.local
errorputty

This means that bonjour services is not installed on your computer or that your Raspberry Pi is not linked to your network.
You can download it here : bonjour.madnerd.org

Bonjour service is installed by default on Windows 10 or with Skype.
Autocompletion

If there are one thing to remember when you use the terminal is if you don’t know what to type :

Press [TAB] twice

This will enable autocompletion.
For example:
If you type : power puis and press [TAB]
This will complete the command with poweroff

If you type: re and press [TAB]
Nothing will happen, as there are multiple possibilities
Press [TAB] again, and you will see all the possible commands :

Here we can see the command reboot, we just need to type reb and press [TAB] again to complete the command.