Rasp
Rasp
For a step-by-step guide to getting your Pi up and running, check out our online
Getting started guide.
===================================================================================
The Raspberry Pi 3 Model B+ is the latest product in the Raspberry Pi 3 range.
===================================================================================
===================================================================================
=========
AZARTICOLO:ROBOT DOMESTICI INDUSTRIES
===================================================================================
=========
DI ARMANDO PALIANI
Via Montauro 33 - 00118 ROMA (RM)
P.I. 12960231004 - C.F. PLNRND74R03G763Q
REA di Roma n. RM1413309
Telefono 06 45548263 - Fax 06 45595204
dal Lunedì al Venerdì
dalle 10:00 alle 18:00
orario continuato
================================================================================
AZARTICOLO:Versione di rasbian
================================================================================
cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 9 (stretch)"
NAME="Raspbian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="http://www.raspbian.org/RaspbianForums"
BUG_REPORT_URL="http://www.raspbian.org/RaspbianBugs"
===================================================================================
========
AZARTICOLO:Raspbian: handling temperature sensor and leds on the Raspberry Pi
===================================================================================
========
http://www.xappsoftware.com/wordpress/?s=raspbian
In this short tutorial I m going to show to you how to build a temperature alarm
with the
Raspberry Pi.
Raspbian is a free operating system based on Debian optimized for the Raspberry Pi
hardware.
An operating system is the set of basic programs and utilities that make your
Raspberry Pi run.
However, Raspbian provides more than a pure OS: it comes with over 35,000
packages,
pre-compiled software bundled in a nice format for easy installation on your
Raspberry Pi.
The Raspberry Pi provides a lot of hardware, two items of this HW are very
interesting to
control the status of the system.
The first one is the temperature sensor into the CPU and the other one is the
presence of
two leds.
We can think to use the leds to signal (with a fade in fade out effect) when the
temperature overcomes a threshold.
Raspbian provides the access to these two devices using the sys filesystem.
So they are very simple to control also using the bash.
Temperature sensor
------------------
the output will be refreshed every two seconds (see man watch), stop the watch
command hitting CTRL-C
You can connect many leds to the gpio output of your Raspberry Pi, but you already
have
four leds wired onto the board.
So the first 3 leds cannot be used, while we are going to use the last one.
The green leds is available through the sysfs at
/sys/class/leds/led0
The default trigger for this led is 'mmc0' , so before using this led you have to
deactivate
this trigger. Simply issue the following command (you must be root or you need to
be sudo):
# echo 1 >/sys/class/leds/led0/brightness
# echo 0 >/sys/class/leds/led0/brightness
Now we are going to write a simple shell script which will flash the led when the
teperature
overcomes 40 degrees.
in pseudo code
while (1)
{
temp = currentTemperature
if temp > 40
start flashing led 0
else
stop flashing led 0
sleep 5 seconds
}
#!/bin/bash
fault=0
while [ 1 ] ; do
temp=cat /sys/class/thermal/thermal_zone0/temp
if [ $temp -gt 40000 ]
then
fault=1
echo "Starting flash"
else
if [ $fault -eq 1 ]
then
fault=0
echo "Stopping flash"
fi
fi
sleep 5
done
In the above code I have added the fault variable to avoid the stop of the led
blinking at each
loop (I m going to stop the flashing only if it is yet blinking).
At this point we have only to drive the led. A kernel module, can help us to do
this job,
it is the ledtrig_heartbeat module. we can attach this module to the trigger of the
led.
with the following commands:
# modprobe ledtrig_heartbeat
# echo heartbeat >/sys/class/leds/led0/trigger
and we will stop the blinking with this command:
#!/bin/bash
modprobe ledtrig_heartbeat
fault=0
echo none >/sys/class/leds/led0/trigger
while [ 1 ] ; do
temp=cat /sys/class/thermal/thermal_zone0/temp
echo $temp
if [ $temp -gt 40000 ]
then
if [ $fault -eq 0 ]
then
fault=1
echo "Starting flash"
echo heartbeat >/sys/class/leds/led0/trigger
fi
else
if [ $fault -eq 1 ]
then
fault=0
echo "Stopping flash"
echo none >/sys/class/leds/led0/trigger
fi
fi
sleep 5
done
root@raspberrypi:/home/pi# ./my.sh
40084
Starting flash
39546
Stopping flash
39546
39007
39546
39007
40084
Starting flash
40084
After you read "Starting flash" you should see the led blinking.
Try to change the temperature, using a lighter or something similar,
Note I m not responsible for any damages you can cause. So be careful.
===================================================================================
=========
AZARTICOLO: Wiring the Cobbler to the LCD by Michael Sklar
===================================================================================
========
https://learn.adafruit.com/drive-a-16x2-lcd-directly-with-a-raspberry-pi/overview
The LCD
raspberry_pi_IMG_5592.jpg
Whenever you come across a LCD that looks like it has 16 connectors it is most
likely using a
HD44780 controller. These devices provide the same pinouts making them relatively
easy to work with.
The LCD uses a parallel interface meaning that we will need many pins from our
raspberry pi to control it.
In this tutorial we will use 4 data pins (4-bit mode) and two control pins.
The read/write pin will be pulled low (write only) as we only want to write to the
LCD based on
this setup.
Before wiring, check that your LCD has an LED backlight, not an EL backlight.
LED backlights use 10-40mA of power, EL backlights use 200+ma!
EL backlights are often cheap to get but are not usable, make sure you don't use
one or you will
overload the Pi. Some cheap LCDs that have LED backlights do not include a resistor
on the LCD
module for the backlight, if you're not sure, connect a 1Kohm resistor between pin
15 and 5V
instead of connecting directly. All Adafruit LCDs have LED backlights with built in
resistors so
you do not need an extra resistor!
Wiring Diagram
-------------
raspberry_pi_pi-char-lcd.gif
First, connect the Cobbler power pins to the breadboard power rail. +5.0V from the
Cobbler
goes to the red striped rail (red wire) and GND from the cobbler goes to the blue
striped
rail (black wire)
Then connect up the potentiometer, the left pin connects to ground (black wire) and
the right pin
connects to +5V (red wire)
Schematic
raspberry_pi_Untitled.png
5v LCD vs 3.3v Pi
---------------
The raspberry Pi GPIOs are designed for 3.3v, but our LCD is a 5v device.
It's fine to use a 5v display, but only if we are sending data out of the Pi.
We are not going to use the 3.3v power rail on the Cobbler, and we will tie the RW
(read/write)
pin of the display to GND as we do not want the display sending a 5v signal into
the Pi.
Before you start, make sure you have a strip of 0.1" male header and a 10K
potentiometer.
All Adafruit Character LCDs come with these parts so you should be good to go.
raspberry_pi_parts.jpg
Most LCDs have a strip of 16 pins on the top, if the header is a little longer,
just break it off
until its the right length
raspberry_pi_headersize.jpg
raspberry_pi_lcdbb.jpg
Start by connecting the 5V and GND wires from the cobbler to the breadboard.
Then connect pins #1, #2 and #15, #16 to the breadboard power rails as shown.
The backlight should come on. If it doesn't, check the wiring!
raspberry_pi_lcdpower.jpg
raspberry_pi_charbacklite.jpg
Next, wire up the contrast potentiometer as shown above, with the middle pin
connecting
to LCD pin #3 and the other two pins going to 5V and ground.
Twist the potentiometer until you see the first line of the LCD fill with boxes.
If you don't see the boxes, check your wiring!
raspberry_pi_charboxes.jpg
Finish the wiring for the RS, RW, EN, D4, D5, D6, and D7 pins as shown in the
diagram up top
raspberry_pi_lcdwire.jpg
That's it! Now you're ready to run the Python script to draw text on the screen!
raspberry_pi_cosm-python-dev.gif
Upgrade distribute (required for RPi.GPIO 0.3.1a) - [No image for this one]
NOTE: This page describes an older version of the Raspberry Pi character LCD Python
code.
You can find a newer library that works on more platforms like the Raspberry Pi and
by checking out the new character LCD Python library guide.
For new projects it's recommended to use the new library!
The Code
--------
The Python code for Adafruit's Character LCDs on the Pi is available on Github at
https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code
The first file, Adafruit_CharLCD.py is a mashup from two different sources of LCD
code.
Github user lrvick put together a nice python class.
His work is the baseline that is slowly being changed as we are bringing in more
elements from
the Arduino LiquidCrystal library.
The easiest way to get the code onto your Pi is to hook up an Ethernet cable, and
clone it directly
using 'git', which is installed by default on most distros.
Simply run the following commands from an appropriate location (ex. /home/pi):
Copy Code
apt-get install git
git clone git://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git
cd Adafruit-Raspberry-Pi-Python-Code
cd Adafruit_CharLCD
Testing
You can test the wiring from the previous step by simply running the
Adafruit_CharLCD.py
Python code, as it has a little code it in that will simply display a test message
when wired correctly
You can use vi Adafruit_CharLCD.py to edit.
Copy Code
chmod +x Adafruit_CharLCD.py
./Adafruit_CharLCD.py
IP Clock Example
This script assumes you ll want to display the Ethernet (eth0) IP address.
You may want to replace eth0 with wlan0 or wlan1 (etc) for Wireless IP address!
Copy Code
#!/usr/bin/python
lcd = Adafruit_CharLCD()
cmd = "ip addr show eth0 | grep inet | awk '{print $2}' | cut -d/ -f1"
lcd.begin(16,1)
def run_cmd(cmd):
p = Popen(cmd, shell=True, stdout=PIPE)
output = p.communicate()[0]
return output
while 1:
lcd.clear()
ipaddr = run_cmd(cmd)
lcd.message(datetime.now().strftime('%b %d %H:%M:%S\n'))
lcd.message('IP %s' % ( ipaddr ) )
sleep(2)
Running the Code
Start the IP + Clock example
Copy Code
$ ./Adafruit_CharLCD_IPclock_example.py
What You Should See
raspberry_pi_timeip.jpg
===================================================================================
==
AZARTICOLO: Wiring Pi: GPIO Interface library for the Raspberry Pi
===================================================================================
==
http://wiringpi.com/
About
WiringPi is a GPIO access library written in C for the BCM2835 used in the
Raspberry Pi.
It’s released under the GNU LGPLv3 license and is usable from C and C++ and many
other languages
with suitable wrappers (See below)
It’s designed to be familiar to people who have used the Arduino “wiring” system1
Arduino is really two things; one is a hardware platform, the other software, and
part of the
software is a package called Wiring.
Wiring is the core of the input and output for the Arduino, so I thought it would
be good to
replicate that functionality (or a good usable subset with Raspberry Pi extensions)
on the Raspberry Pi.
The original Raspberry Pi Model A and B version B1 was a $35 single board computer
with a 26-pin
General Purpose Input/Output (GPIO) connector and this carries a set of signals and
buses.
There are 8 general purpose digital I/O pins – these can be programmed as either
digital outputs
or inputs. One of these pins can be designated for hardware PWM output too.
The model B, Revision 1.1 Raspberry Pi has an additional 4 GPIO lines on a separate
connector
which you have to solder onto the board.
The model A+ and B+ Raspberry Pi’s represents 2 years of research, development and
testing and
now features a single 40-pin GPIO connector with 28 usable GPIO pins and 4 USB
sockets.
The model 2 features a quad-core Arm A7 processor with 1GB of RAM. Same GPIO.
The model 3 features a quad-core Arm A8 processor (64-bits) with the same RAM and
GPIO as
the model 2, however it also features on-board Wi-Fi and Bluetooth. Still the same
$35 price tag.
The I2C, SPI and UART interfaces can also be used as general purpose I/O pins when
not being
used in their bus modes, giving a grand total of 8 + 2 + 5 + 2 = 17 I/O pins on the
P1 connector
(plus 4 more on the P5 connector on a Revision 2 Pi) and 28 I/O pins on the B+ and
version 2 and 3
boards (Although 2 are reserved for the HAT I2C interface, but can be used as
normal GPIOs
if not using a HAT board)
WiringPi includes a command-line utility gpio which can be used to program and
setup the GPIO pins.
You can use this to read and write the pins and even use it to control them from
shell scripts.
WiringPi is extendable and modules are provided to extend wiringPi to use analog
interface devices
on the Gertboard, and to use the popular MCP23x17/MCP23x08 (I2C 7 SPI) GPIO
expansion chips,
as well as module that will allow blocks of up to 4 74×595 shift registers to be
daisy-chained
together for an additional 32-bits worth of output as a single unit.
(You can have several blocks of 4 74x595s if needed)
One of the extension modules allows you to use an ATmega (e.g. Arduino, or the
Gertboard) as
more GPIO expansion too – via the Pi’s serial port.
Additionally, you can easily write your own expansion modules to integrate your own
peripheral
devices with wiringPi as required.
WiringPi supports analog reading and writing, and while there is no native analog
hardware on a
Pi by default, modules are provided to support the Gertboards analog chips and
other A/D and
D/A devices can be implemented relatively easily.
NOTE:
The devLib is a set of library routines implemented using wiringPi to give you easy
access to some
popular peripherals. Devices supported include
character LCD displays (based on the Hitachi HD44780U chips),
and graphical ones – e.g. the common 128×64 pixel displays with the generic 12864H
driver chip.
The DS1302 RTC clock chip, sensors based on the Maxdetect chips (e.g. RHT003) the
Gertboard
and PiFace interface boards and so on.
WiringPi Resources
---------------
WiringPi fully supports the PiFace board too. See this page for more details.
Gertboard
WiringPi fully supports the Gertboard. See this page for more details.
Thanks to Gadgetoid there are now wrappers for Ruby, Python and Perl and these can
all be found here.
Thanks to Jeroen Kransen there are wrappers for Java which can be found here.
Thanks to Dave Boulton for creating a TCL wrapper which can be found here.
Pi4J is another Java project that uses WiringPi. It has a Github repository here.
Additional information can be found on the Raspberry Pi Wiki pages.
WiringPi is maintained under GIT for ease of change tracking, however there is a
Plan B if you’re
unable to use GIT for whatever reasons (usually your firewall will be blocking you,
so do check that first!)
If you do not have GIT installed, then under any of the Debian releases (e.g.
Raspbian), you can install
it with:
If you get any errors here, make sure your Pi is up to date with the latest
versions of Raspbian:
apt-get update
apt-get upgrade
If you have already used the clone operation for the first time, then
cd wiringPi
git pull origin
Will fetch an updated version then you can re-run the build script below.
cd wiringPi
./build
The new build script will compile and install it all for you – it does use the
command at one
point, so you may wish to inspect the script before running it.
Plan B
------
https://git.drogon.net/?p=wiringPi;a=summary
Then look for the link marked snapshot at the right-hand side.
You want to click on the top one.
This will download a tar.gz file with a name like wiringPi-98bcb20.tar.gz.
Note that the numbers and letters after wiringPi (98bcb20 in this case) will
probably be different –
they’re a unique identifier for each release.
Note that the actual filename will be different – you will have to check the name
and adjust
accordingly.
gpio -v
gpio readall
That should give you some confidence that it’s working OK.
===================================================================================
=========
AZARTICOLO:Wiring Pi GPIO Interface library for the Raspberry Pi Examples/How-To
===================================================================================
=========
Examples/How-To
wiringPi comes with many example programs to perform different tasks.
You’ll find these in the examples directory of the distribution if you downloaded
it from the
git.drogon.net website. Additionally in the examples directory, there are 2 others
– Gertboard,
q2w and Piface with examples for the Gertboard, quick2Wire and Piface interface
boards.
Esempio di Blink
-------------
#include <wiringPi.h>
int main (void)
{
wiringPiSetup () ;
pinMode (0, OUTPUT) ;
for (;;)
{
digitalWrite (0, HIGH) ; delay (500) ;
digitalWrite (0, LOW) ; delay (500) ;
}
return 0 ;
}
To see the output of this, you would need to connect a single LED to the GPIO
connector of the
Raspberry Pi as follows:
blink1and if all goes well, you should see the LED flashing once a second.
The LED is any generic LED you may have – typically 5mm diameter and the resistor
is 330Ω.
You can find blink.c and others – blink8.c and blink12.c in the examples directory
of the wiringPi
distribution. To use the makefile to compile them:
make blink
make blink8
make blink12
The wiringPi LCD devLib allows you to drive most of the popular 1, 2 and 4-line LCD
displays that
are based on the Hitachi HD44780U or compatible controllers.
The following Fritzing diagrams describe how to connect the displays directly to
the on-board
GPIO of a Raspberry Pi in both 8 and 4-bit modes:
The library is simple to use in your own programs, however wiring the displays up
may be challenging,
so do take care.
The LCD display can be either a 5V display or a 3,3v display, however if we are
using a 5V display
then we must make absolutely sure the display can never write data back to the
Raspberry Pi,
otherwise it will present 5V on the Pi’s GPIO pins which will not be good.
At best you’ll destroy the pin drivers, at worst you’ll destroy your Pi.
When using a 5v display, make sure you always connect the R/W pin on the display to
ground to
force the display to be read-only to the host. If not, the display can potentially
present 5v back
to the Pi which is potentially damaging.
To use the LCD library, you’ll need this at the start of your program:
#include <wiringPi.h>
#include <lcd.h>
First, you need to initialise wiringPi in the way you want to.
The LCD library will call pinMode functions as required.
int lcdInit (int rows, int cols, int bits, int rs, int strb,
int d0, int d1, int d2, int d3, int d4, int d5, int d6, int
d7) ;
This is the main initialisation function and must be called before you use any
other LCD functions.
Rows and cols are the rows and columns on the display (e.g. 2, 16 or 4,20).
Bits is the number of bits wide on the interface (4 or 8).
The rs and strb represent the pin numbers of the displays RS pin and Strobe (E)
pin.
The parameters d0 through d7 are the pin numbers of the 8 data pins connected from
the Pi to
the display. Only the first 4 are used if you are running the display in 4-bit
mode.
The return value is the ‘handle’ to be used for all subsequent calls to the lcd
library when dealing
with that LCD, or -1 to indicate a fault. (Usually incorrect parameters)
In the above Fritzing diagrams, the 4-bit one would be initialised by:
Functions
--------
These turn the display on or off, turn the cursor on or off and the cursor blink
on or off.
The state parameter is True or False.
The initial settings are display on, cursor off and cursor blink off.
At the moment, there is no clever scrolling of the screen, but long lines will wrap
to the next line,
if necessary.
Do see the example program lcd.c in the examples directory inside the wiringPi
software distribution.
When using a 5v display, make sure you always connect the R/W pin on the display to
ground to
force the display to be read-only to the host.
If not, the display can potentially present 5v back to the Pi which is potentially
damaging.
You refer to the diagram of the edge connector on the LCD and use that to hook up
the pins
on the GPIO connector. Use the diagram here to help you keep track of the GPIO pins
you are using.
For a 2nd (or 3rd, etc.) display, you wire the displays in parallel, connecting up
all the same pins
with the exception of the E pin. Each display needs its own unique E pin connected
back to a
different GPIO pin.
------------------------
PROGETTO PIR
------------------------
GPIO.output (led,GPIO.HIGH)
print "Ti Vedo!"
time.sleep (5)
else:
GPIO.output (led,GPIO.LOW)
print "Non ti vedo"
time.sleep (1)
--------------------------------------------------------------------------------
The GPIO utility
--------------------------------------------------------------------------------
WiringPi comes with a separate program to help manage the on-board GPIO interface
as well as
additional modules such as the PiFace and other devices like the Gertboard as well
as generic
GPIO expander type devices.
This program, called gpio, can also be used in scripts to manipulate the GPIO pins
–
set outputs and read inputs. It’s even possible to write entire programs just using
the gpio command
in a shell-script, although it’s not terribly efficient doing it that way… Another
way to call it is
using the system() function in C/C++ or it’s equivalent in other programming
languages.
In addition to using the gpio utility to control, read and write the GPIO pins, you
can:
Export/Unexport pins via the /sys/class/gpio interface, where they will then be
available to user
programs (that then do not need to be run as root or with)
Export pins to enable edge-triggered interrupts via the /sys/class/gpio interface.
Load SPI and I2C modules and set /dev/ permissions to enable read/write by the user
running
the gpio program.
Run the i2cdetect program with appropriate flags for your Raspberry Pi board
revision.
Set the SPI buffer size and I2C baud rate (when loading the modules)
Determine your Raspberry Pi board hardware revision.
See the man page for the gpio program to see what all the features are by typing
man gpio
at the command prompt.
Usage
gpio -v
------
gpio -g …
-----
The optional -g flag causes pin numbers to be interpreted as BCM_GPIO pin numbers
rather
than standard wiringPi pin numbers.
gpio -1 …
------
The optional -1 flag causes pin numbers to be interpreted as hardware pin numbers –
this works for the P1 connector only.
gpio -p …
------
The optional -p flag causes the gpio program to assume there is a PiFace board
fitted to the
Rasberry Pi and subsequent commands are interpreted as pins on the PiFace.
Note: Pins on the PiFace are 200 through 207 for both reading and writing,
with pins 208 through 215 reading the state of the output latch register
(ie. you can read the state of the output pins)
gpio -x …
--------
The optional -x flag causes the gpio program to initialise an additional expansion
module.
Expansion modules are defined with their name (e.g. mcp23s17), and a set of
parameters
separated by colons. The first parameter is always the base pin number for this
expansion module.
See the documentation for each module type to determine the additional parameter
values and
functions.
gpio readall
----------
This reads all the normally accessible pins and prints a table of their numbers
(wiringPi, BCM_GPIO and physical pin numbers), so makes for a handy cross-reference
chart),
along with their modes and current values.
This command will detect the version/model of your Pi and printout the pin diagram
appropriate
to your Pi.
gpio allreadall
-----------
This reads all the pins on your Raspberry Pi.
It’s essentially the same format as used on the Compute Module.
The /dev/spi* entries are set to be owned by the person using the gpio program, so
there is no
need to run subsequent programs as root (unless they use other wiringPi functions)
The /dev/I2c* entries are set to be owned by the person using the gpio program, so
there is no
need to run subsequent programs as root (unless they use other wiringPi functions)
I2C Detection
------------
gpio i2cdetect
------------
This runs the i2cdetect command, but passes in the correct parameters for the I2C
bus for the
Pi’s hardware revision. ie. it runs i2cdetect -y 0 on a Rev. 1 Pi, and i2cdetect -y
1 on a Rev. 2 Pi.
(You can shorten i2cdetect to i2cd)
gpio unexportall
--------------
Removes all /sys/class/gpio exports.
gpio exports
----------
This prints a list of all gpio pins which have been exported via the
/sys/class/gpio interface and
their modes.
Note: The pin numbers in the sys mode are always BCM-GPIO pin numbers.
Examples
--------
The above uses the wiringPi pin numbers to set pin 0 as an output and then sets the
pin to a logic 1.
The GPIO lines have internal pull up or pull-down resistors which can be controlled
via software
when a pin is in input mode. There is no-way to read the status of these resistors.
gpio mode 0 up
gpio mode 0 down
gpio mode 0 tri
These set the resistors to pull-up, pull-down and none respectively on wiringPi pin
0.
================================================================================
AZARTICOLO: INTERFACING A 16 X 2 LCD WITH THE RASPBERRY PI
================================================================================
http://ozzmaker.com/interface-16x2-lcd-with-the-raspberry-pi/?utm_source=feedly
In this post I’ll show how to connect and use a 16 x 2 LCD on a Raspberry Pi.
This display has ultra-high contrast and any-angle readability. It has the best
display I have seen on any LCD.
This LCD uses the HD44780 controller which is present in almost all LCDs.
LCDs that use this controller usually have 14 or 16 pins. This LCD has 16, numbered
from 0 to 16 as shown below.
OLED.front 823back_LRG
Sometimes these pins are present, but not used. Eg, pins 15 & 16 are for back-light
and they are not used on this LCD. It depends on the manufacture.
Pin 1 Ground.
Pin 2 Supply Voltage for OLED and logic
Pin 3 Is usually connected to a potentiometer to control the contrast of the
display.
Pin 4 The register select signal (RS) determines whether the Data Bit values are
interpreted as a command (E.g. clear screen) or data (aka: a character to display).
Pin 5 Is the Read/Write pin. In read mode, this pin is used to get feedback from
the LCD to work out if the LCD can accept commands or to indicate it is too busy.
We don’t need this function as we can wait the maximum time for a command to be
written (200us) before sending the next command.
If read is enabled and Pin4 on the LCD is connected to a pin on your Raspberry Pi,
there is a chance that you can destroy your Pi. We only ever want to write to the
LCD, we never want to read from it. So this should always be connected to ground.
Pin 6 The enable pin (E)functions as the command/data latching signal for the LCD.
The LCD will latch in whatever is on the Data Bits and process it on the falling
edge of the E signal
Meaning, when this pin goes low, the LCD will take the input from the data pins at
this time.
Pins 7 to 14 Are the data pins. In 4 pin mode, only pins 11 to 14 are used.
Pins 15 & 16 Are used for the backlight if present.
Below shows how to wire up the LCD to the Raspberry Pi. We will be using 4 pin
mode, so there is no need to connect pins 7 to 10. This LCD doesn’t use the
backlight pins, pins 15 and 16. It also doesn’t use the contrast pin, pin 3.
OLED2
Code
In the past, you would have had to know the registers used by the controller to
setup the display, position the cursor or even write a single character. There was
also timing issues to take into consideration. This is no more, with thanks to
WiringPi.
Installing WiringPi;
int main()
{
int lcd; //Handle for LCD
wiringPiSetup(); //Initialise WiringPi
//Initialise LCD(int rows, int cols, int bits, int rs, int enable, int d0, int
d1, int d2, int d3, int d4, int d5, int d6, int d7)
if (lcd = lcdInit (2, 16,4, LCD_RS, LCD_E ,LCD_D4 , LCD_D5,
LCD_D6,LCD_D7,0,0,0,0)){
printf ("lcdInit failed! \n");
return -1 ;
}
The code below is what was used in the video at the top of this post
Compile with;
#include <signal.h>
#include <stdlib.h>
#include <stdio.h>
#include <wiringPi.h>
#include <lcd.h>
#include <string.h>
#include <time.h>
#define COLUMNS 16
#define LCD_RS 3
#define LCD_E 0
#define LCD_D4 6
#define LCD_D5 1
#define LCD_D6 5
#define LCD_D7 4
void uptime(void);
void memory(void);
void volume(void);
void scrollText(void);
void INThandler(int sig);
int mymillis(void);
int main()
{
signal(SIGINT, INThandler);
wiringPiSetup () ;
int uptimeTimer;
while(1){
lcdClear (lcd);
volume();
sleep(1);
memory();
sleep(4);
lcdClear (lcd);
uptimeTimer = mymillis();
while ((mymillis() - uptimeTimer) < 5000)
uptime();
sleep(1);
lcdClear (lcd);
scrollText();
}
void uptime(void)
{
unsigned int uptime_unsorted = 0;
unsigned char c;
unsigned int DD;
unsigned int HH;
unsigned int MM;
unsigned int SS;
uptime_file=fopen("/proc/uptime","r");
if(NULL != uptime_file)
{
while((c=fgetc(uptime_file))!= '.')
{
unsigned int i;
i = atoi(&c);
uptime_unsorted = (uptime_unsorted * 10) + i;
}
SS = uptime_unsorted % 60;
MM = uptime_unsorted / 60 % 60;
HH = uptime_unsorted / 60 / 60 % 24;
DD = uptime_unsorted / 60 / 60 / 24;
printf("\x1B[2J");
printf("Uptime:D%i,%02i:%02i:%02i\n",DD,HH,MM,SS);
lcdPosition(lcd,0,0);
lcdPrintf(lcd,"Uptime: Days %i", DD);
lcdPosition(lcd,4,1);
lcdPrintf(lcd,"%02i:%02i:%02i",HH,MM,SS);
}
else
{
printf("Open file \"proc/uptime\" failed!\n");
}
}
void memory(void)
{
char MemTotal[35];
char MemFree[35];
char total[35];
char free[35];
lcdClear (lcd);
mem_file=fopen("/proc/meminfo","r");
if(NULL != mem_file)
{
fscanf(mem_file,"%*s%s%*s", MemTotal);
fscanf(mem_file,"%*s%s%*s", MemFree);
printf("\x1B[2J");
lcdPosition(lcd,0,0);
lcdPrintf(lcd,"MemTotal-%sk",MemTotal);
lcdPosition(lcd,0,1);
lcdPrintf(lcd,"MemFree -%sk",MemFree);
fclose(mem_file);
}
else
{
printf("Open file \"/proc/meminfo\" failed!\n");
}
}
void volume(void)
{
//Defined custom characters for volume display
lcdCharDef (lcd, 0, level0);
lcdCharDef (lcd, 1, level1);
lcdCharDef (lcd, 2, level2);
lcdCharDef (lcd, 3, level3);
lcdCharDef (lcd, 4, level4);
lcdCharDef (lcd, 5, level5);
lcdCharDef (lcd, 6, level6);
lcdCharDef (lcd, 7, level7);
lcdClear (lcd);
int i;
lcdPosition (lcd, 9,1);
lcdPuts (lcd, ":Volume");
for (i = 0; i < 7; i++){
lcdPosition (lcd, i, 1);
lcdPutchar (lcd, i);
usleep(400000);
}
}
void scrollText(void)
{
int i,n;
int h ;
int tempSpace = 0;
char scrollPadding[] = " ";
int mymillis(void)
{
struct timeval tv;
gettimeofday(&tv, NULL);
return (tv.tv_sec) * 1000 + (tv.tv_usec)/1000;
}
The LCD->Pi wiring diagram has an error, the sire from the LCD RS line (4) is going
to the Pi
connector pin 17 (3.3 v power), it should be going to ping 15 (GPIO3).
REPLY
REPLY
================================================================================
MOUSE
================================================================================
dmesg -C cancella device messagge
dmesg
================================================================================
Settato Controllo: [./?action=command&dest=0&plugin=0&id=9963776&group=1&value=51]
================================================================================
-------------------------------------
Logging in via SSH without a password
-------------------------------------
The target root file system included in the STLinux distribution is setup in such a
way that the user root can log on to a target system without a password.
We achieve this by leaving the password field on the target´s etc/passwd file is
empty:
root::0:0:root:/root:/bin/bash
The configuration file for the Open SSH server running on the target has also been
modified to allow users to login without a pasword.
PermitEmptyPasswords yes
Securing the Target
From what has been said above, a target system can be made more secure by either
Create a public key by typing the following on the host at the shell prompt
(note that there are no spaces in ssh-keygen):
Enter the root password of the target machine and press Return.
SSH is now configured on both sides and will work without a password. To check
this, type the following at the shell prompt on the host:
--------------------------------------------------------------------------------
sshpass: Login To SSH Server / Provide SSH Password Using A Shell Script
--------------------------------------------------------------------------------
by Vivek Gite on September 12, 2008 · 12 comments
How do I login over ssh without using password less RSA / DSA public keys?
How do I use ssh in a shell script?
How do I login non-interactivly performing password authentication
with SSH and shell scripts?
You can use sshpass command to provide password for ssh based login.
sshpass is a utility designed for running ssh using the mode referred to as
"keyboard-interactive" password authentication, but in non-interactive mode.
ssh uses direct TTY access to make sure that the password is indeed issued by an
interactive keyboard user. Sshpass runs ssh in a dedicated tty, fooling it into
thinking it is getting the password from an interactive user.
Run rsync over SSH using password authentication, passing the password on the
command line:
Further readings:
mkdir ${HOME}/.ssh
% chmod 700 ~/.ssh
occorre dare al solo utente che deve accedere i permessi su tale directory !!
È possibile creare una chiave RSA per poter accedere al sito remoto dal tuo
account, senza avere
bisogno di inserire la password.
Notare che una volta che tutto ciò è configurato, se un estraneo si inserisce nel
vostro account
avrà accesso anche ai sistemi remoti ai quali avete accesso!
Per questo motivo è meglio che questa procedura non sia mai fatta da root.
Eseguire ssh-keygen sulla tua macchina e premere Invio quando viene chiesta la
password.
~/.ssh/identity e
~/.ssh/identity.pub;
~/.ssh/id_rsa e
~/.ssh/id_rsa.pub.
Importante: Notare che chiunque abbia accesso in lettura al file con la chiave
privata può usarla
per avere lo stesso accesso senza password al sito remoto. Fra queste persone sono
incluse coloro
che hanno accesso come root alla vostra macchina locale, di conseguenza se non
siete l'unico
amministratore della macchina locale è fortemente raccomandato proteggere la
vostra chiave
privata con una passphrase.
Il pacchetto ssh-askpass deve essere installato per poter eseguire ssh-add senza un
terminale.
===================================================================================
=========
AZARTICOLO:Abilitare ssh server login con password
===================================================================================
=========
#PubkeyAuthentication yes
#AuthorizedKeysFile .ssh/authorized_keys
/etc/ssh/sshd_config
-------------------------------
# AZPATCH
#PermitRootLogin without-password
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
PasswordAuthentication yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
UsePAM yes
-----------------------------------------------------------------------------------
-------------------------------------------------------------
Setting up an SSH Server
-----------------------------------------------------------------------------------
-------------------------------------------------------------
You can access the command line of a Raspberry Pi remotely from another computer or
device
on the same network using the Secure Shell (SSH) protocol.
You will only have access to the command line, not the full desktop environment.
For a full remote desktop, see VNC.
NOTE
You will need to note down the IP address of your Raspberry Pi in order to connect
to it later.
Using the ifconfig command will display information about the current network
status, including
the IP address, or you can use hostname -I to display the IP addresses associated
with the device.
Raspberry Pi OS has the SSH server disabled by default. It can be enabled manually
from the
desktop:
Click OK
Alternatively you can enable it from the terminal using the raspi-config
application,
Choose Yes
Select Ok
Choose Finish
NOTE
For headless setup, SSH can be enabled by placing a file named ssh, without any
extension,
onto the boot partition of the SD Card. When the Raspberry Pi boots, it looks for
the ssh file.
If it is found, SSH is enabled and the file is deleted.
The content of the file does not matter; it could contain text, or nothing at all.
NOTE
For headless setup in addition to the ssh file you need a userconf.txt file, which
contains a string
username:encryptedpassword.
Please refer to the section on configuring a user in the discussions around
headless setup of a
Raspberry Pi.
WARNING
When enabling SSH on a Raspberry Pi that may be connected to the internet, you
should ensure
that your password is not easily brute forced.
Secure Shell from Linux or Mac OS
Edit this on GitHub
You can use SSH to connect to your Raspberry Pi from a Linux desktop, another
Raspberry Pi,
or from an Apple Mac without installing additional software.
Open a terminal window on your computer replacing <IP> with the IP address of the
Raspberry
Pi you’re trying to connect to,
ssh pi@<IP>
NOTE
If you receive a connection timed out error it is likely that you have entered the
wrong IP address
for the Raspberry Pi.
WARNING
In the event your Raspberry Pi has taken the IP address of a device to which your
computer has
connected before (even if this was on another network), you may be given a warning
and asked
to clear the record from your list of known devices.
Following this instruction and trying the ssh command again should be successful.
Next you will be prompted for the password for the pi login: the default password
on Raspberry
Pi OS is raspberry.
For security reasons it is highly recommended to change the default password on the
Raspberry Pi (also, you can not login through ssh if the password is blank).
You should now be able to see the Raspberry Pi prompt, which will be identical to
the one found
on the Raspberry Pi itself.
If you have set up another user on the Raspberry Pi, you can connect to it in the
same way,
replacing the username with your own, e.g. [email protected]
pi@raspberrypi ~ $
You are now connected to the Raspberry Pi remotely, and can execute commands.
Forwarding X11
You can also forward your X session over SSH, to allow the use of graphical
applications, by using the -Y flag:
ssh -Y [email protected]
NOTE
X11 is no longer installed by default on macOS, so you will have to download and
install it.
Now you are on the command line as before, but you have the ability to open up
graphical windows.
For example, typing:
geany &
will open up the Geany editor in a window on your local desktop.
You can use SSH to connect to your Raspberry Pi from a Windows 10 computer that is
using
October 2018 Update or later without having to use third-party clients.
Open a terminal window on your computer replacing <IP> with the IP address of the
Raspberry Pi you’re trying to connect to,
ssh pi@<IP>
When the connection works you will see a security/authenticity warning.
Type yes to continue. You will only see this warning the first time you connect.
NOTE
If you receive a connection timed out error it is likely that you have entered the
wrong
IP address for the Raspberry Pi.
WARNING
In the event your Raspberry Pi has taken the IP address of a device to which your
computer has
connected before (even if this was on another network), you may be given a warning
and asked to
clear the record from your list of known devices.
Following this instruction and trying the ssh command again should be successful.
Next you will be prompted for the password for the pi login: the default password
on Raspberry
Pi OS is raspberry.
For security reasons it is highly recommended to change the default password on the
Raspberry Pi
(also, you can not login through ssh if the password is blank).
You should now be able to see the Raspberry Pi prompt, which will be identical to
the one found
on the Raspberry Pi itself.
If you have set up another user on the Raspberry Pi, you can connect to it in the
same way, replacing the username with your own, e.g. [email protected]
pi@raspberrypi ~ $
You are now connected to the Raspberry Pi remotely, and can execute commands.
First, check whether there are already keys on the computer you are using to
connect to the Raspberry Pi:
ls ~/.ssh
If you see files named id_rsa.pub or id_dsa.pub then you have keys set up already,
so you can
skip the 'Generate new SSH keys' step below.
ssh-keygen
Upon entering this command, you will be asked where to save the key.
We suggest saving it in the default location (~/.ssh/id_rsa) by pressing Enter.
ls ~/.ssh
and you should see the files id_rsa and id_rsa.pub:
cat ~/.ssh/id_rsa.pub
It should be in the form:
Using the computer which you will be connecting from, append the public key to your
authorized_keys
file on the Raspberry Pi by sending it over SSH:
ssh-copy-id <USERNAME>@<IP-ADDRESS>
NOTE
During this step you will need to authenticate with your password.
-----------------------------------------------------------------------------------
------------------------------------------------------------
ssh-copy-id [email protected]
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed:
"/root/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out
any that are already installed
/usr/bin/ssh-copy-id: WARNING: All keys were skipped because they already exist on
the remote system.
(if you think this is a mistake, you may want to use -f option)
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
-----------------------------------------------------------------------------------
-------------------------------------------------------------
Alternatively, if ssh-copy-id is not available on your system, you can copy the
file manually over SSH:
If you see the message ssh: connect to host <IP-ADDRESS> port 22: Connection
refused and
you know the IP-ADDRESS is correct, then you may not have enabled SSH on your
Raspberry Pi.
Run sudo raspi-config in the Raspberry Pi’s terminal window, enable SSH, then try
to copy the files
again.
Now try ssh <USER>@<IP-ADDRESS> and you should connect without a password prompt.
If you see a message "Agent admitted failure to sign using the key" then add your
RSA or DSA
identities to the authentication agent ssh-agent then execute the following
command:
ssh-add
NOTE
You can also send files over SSH using the scp (secure copy) command.
Adjust Directory Permissions
If you can’t establish a connection after following the steps above there might be
a problem with
your directory permissions. First, you want to check the logs for any errors:
tail -f /var/log/secure
# might return:
Nov 23 12:31:26 raspberrypi sshd[9146]: Authentication refused: bad ownership or
modes for directory /home/pi
If the log says Authentication refused: bad ownership or modes for directory
/home/pi there is a
permission problem regarding your home directory.
SSH needs your home and ~/.ssh directory to not have group write access.
You can adjust the permissions using chmod:
Now only the user itself has access to .ssh and .ssh/authorized_keys in which the
public keys
of your remote machines are stored.
If you are using macOS, and after verifying that your new key allows you to
connect, you have
the option of storing the passphrase for your key in the macOS keychain.
This allows you to connect to your Raspberry Pi without entering the passphrase.
ssh-add -K ~/.ssh/id_rsa
NOTE
From macOS Monterey onwards the -K flag has been deprecated and been replaced by
the --apple-use-keychain flag.
Secure Copy (scp) is a command for sending files over SSH. This means you can copy
files
between computers, say from your Raspberry Pi to your desktop or laptop, or vice-
versa.
Copy the file myfile.txt from your computer to the pi user’s home folder of your
Raspberry Pi at
the IP address 192.168.1.3 with the following command:
Copy the file myfile.txt from your Raspberry Pi to the current directory on your
other computer:
scp [email protected]:myfile.txt .
scp m* [email protected]:
(all files starting with m)
NOTE
Some of the examples above will not work for file names containing spaces.
Names like this need to be enclosed in quotes:
Copy the directory project/ from your computer to the pi user’s home folder of your
Raspberry
Pi at the IP address 192.168.1.3 with the following command:
Using rsync
-------------------
You can use the tool rsync to synchronise folders between computers. You might want
to transfer
some files from your desktop computer or laptop to your Raspberry Pi, for example,
and for them
to be kept up to date, or you might want the pictures taken by your Raspberry Pi
transferred to
your computer automatically.
Using rsync over SSH allows you to transfer files to your computer automatically.
mkdir camera
Look up the Raspberry Pi’s IP address by logging in to it and running hostname -I.
In this example, the Raspberry Pi is creating a timelapse by capturing a photo
every minute, and
saving the picture with a timestamp in the local folder camera on its SD card.
Now run the following command (substituting your own Raspberry Pi’s IP address):
================================================================================
AZARTICOLO:Force a full fsck on reboot, ignoring the dirty flag
================================================================================
Raspberry Pi Forums
https://www.raspberrypi.org/forums/
Thanks
Andrew.
Re: Force a full fsck on reboot, ignoring the dirty flag
This might require shutting down daemons (e.g. /etc/init.d/apache2 stop) that hold
write-locks
on files in your root filesystem.
The utility 'lsof' (apt-get install lsof) is useful to identify owning processes of
currently open files,
should you keep getting the '/ is busy' messages when trying to remount read-only.
I tried that and did indeed get the '/ is busy' message.
lsof did not prove useful though as I could not see any way to identify which open
files had write
locks set on them.
What I really need is a way to just force a filesystem check on each boot,
before the root filesystem gets remounted rw.
Thanks
I have done some more digging. It seems that forcing an fsck in reboot adds '-f' to
the command line
for fsck, so that should work.
For some reason in this script the 'rootcheck' variable is being set to 'no', which
is disabling the
root filesystem check. I am still investigating this but it looks like it is
actually a bug in raspbian.
I will post more once I have idenitifed why rootcheck is being set to 'no'.
Cheers
Andrew.
Re: Force a full fsck on reboot, ignoring the dirty flag
andrum99 wrote: I tried that and did indeed get the '/ is busy' message. lsof did
not prove useful though as I could not see any way to identify which open files had
write locks set on them. What I really need is a way to just force a filesystem
check on each boot, before the root filesystem gets remounted rw.
First of all, lsof's output, the FD column entries which are a number followed by
'w' or 'u' will have write or read/write locks (e.g. '2w' or '7u' - the number is
the file-descriptor).
Sorry for not reading your original question properly - I'd incorrectly read that
you wanted to do a one-time fsck.
I also had problems last night getting a boot-time fsck to work. Using 'touch
/forcefsck' or shutdown with a -F flag didn't work.
Looking deeper, I found that my fstab file didn't have the DUMP and PASS fields
defined for the root entry, and these default to zero if not specified. Adding '0
1' to the end of my root entry fixed this (a PASS of zero causes the init script to
skip the filesystem - see /lib/init/mount-functions.sh)
Re: Force a full fsck on reboot, ignoring the dirty flag
I have set up my fstab as you suggested and my system now responds to the presence
of the /forcefsck file.
I will ask the raspbian developer mailing list why they disabled fsck on boot as on
the face of it this seems like an odd thing to do.
Andrew.
Re: Force a full fsck on reboot, ignoring the dirty flag
Cheers
Andrew.
Re: Force a full fsck on reboot, ignoring the dirty flag
Cheers
Andrew.
Re: Force a full fsck on reboot, ignoring the dirty flag
I'm having problems forcing the "fsck" to run. I'm sure I've followed the
suggestions in the the posts but I still no sign that "fsck" is running at start up
and getting the boot message to run "fsck".
Could someone list the files that need to be changed / created
then the commands that can be used
Just so I'm clear that I am doing things right, I'm not as clued up on files and
structure as the rest of you seem to be.
Many Thanks
Jon
Re: Force a full fsck on reboot, ignoring the dirty flag
I m having problems forcing the "fsck" to run. I'm sure I've followed the
suggestions in the the posts but I still no sign that "fsck" is running at start up
and getting the boot message to run "fsck".
Could someone list the files that need to be changed / created
then the commands that can be used
Just so I'm clear that I am doing things right, I'm not as clued up on files and
structure as the rest of you seem to be.
Many Thanks
Jon
Looks like this is still an issue in Raspbian Jessie. To recap what the gentlemen
did above (and how I got it to work on my system):
Code: Select all
vi /cat/default/rcS
Change the FSCKFIX option to yes
Code: Select all
FSCKFIX=Yes
ctrl-x and y to save
Next use the "touch" executable to create a "forcefsck" file in the root /
Code: Select all
touch /forcefsck
Reboot the Pi
Code: Select all
shutdown -h -r
You should see fsck lines during boot, checking all attached drives. You can
validate whether it ran by checking the syslog:
Code: Select all
But the whole premise of this thread is flawed. fsck can repair routine
inconsistencies, not corruption.
If a filesystem is marked clean, but is actually corrupt, then some device-level
problem
has occurred. Perhaps the SD card is faulty, or power has been removed before the
card
finished reallocating data.
For fsck to run at all, the filesystem must be good enough to mount and boot, and
to find and load the fsck binary and all its libraries correctly. Then it can
repair any inconsistencies, and gloss over any corruption. If there are device-
level problems, sooner or later the system will stop booting, regardless of how
often or how hard you run fsck.
Re: Force a full fsck on reboot, ignoring the dirty flag
shutdown -r -F now
works for me @wheezy
Re: Force a full fsck on reboot, ignoring the dirty flag
Old thread but without any clear good solution. The only good solution I found is
to create a new kernel image with initramfs embedded that include e2fsck and that
handles mounting rootfs afterwards.
If anyone interested, I will push on github the buildroot .config and init script.
However, I think that the best way for users to have easily access to the above
solution would be a package in raspbian repos.
Thanks
Alex
Re: Force a full fsck on reboot, ignoring the dirty flag
Alex
Re: Force a full fsck on reboot, ignoring the dirty flag
vi /cat/default/rcS
Change the FSCKFIX option to yes
Code: Select all
FSCKFIX=Yes
ctrl-x and y to save
I just found this page and its really useful, anyone following the steps above the
rcS is file path should be
Code: Select all
vi /etc/default/rcS
All times are UTC
Page 1 of 1
Powered by phpBB® Forum Software © phpBB Limited
https://www.phpbb.com/
=================================================================================
AZARTICOLO: Repairing Corrupted SD Cards for the Raspberry Pi on Mac
=================================================================================
http://www.switchdoc.com/2016/01/tutorial-repairing-corrupted-sd-cards-for-
the-raspberry-pi-on-mac/
This posting will walk through how to fix a corrupted SD Card for your Raspberry Pi
using a Mac and
VirtualBox.
This is a fairly complicated procedure, but most of it only has to be done once and
then you can
fix corrupted cards quickly and efficiently.
Why do SD Cards get Corrupted?
Marginal power supplies. Watch the Red LED on newer Raspberry Pi’s.
If it is blinking, there are issues.
Poor power quality from the mains can also screw up your Raspberry Pi
Overclocking your Pi. If you push it too far, things start not quite working
correctly.
The first thing you can do is BEFORE you get corrupted, back up your SD Card on a
regular basis.
If you spend hours configuring an SD Card, then back it up. Changing your
software? Back it up.
It will save you a lot of time if you end up corrupting or destroying the SD Card.
Here is how to do it on a Mac.
Overall, this is the procedure for fixing a corrupted SD Card using a Mac.
The process is similar for a PC, but requires different instructions to install and
get VirtualBox working.
Step 1: Download the VirtualBox .dmg file for the Mac OS X from this page:
Step 5: Now download the installation file (.iso) for Ubuntu from this link:
Note: Make sure you use this link – ubuntu-1510-desktop-i386.iso.
If this link isn’t available, go to http://mirror.pnl.gov/releases/ and find the
latest release.
The default download link on Ubuntu server will download an amd64 image,
which WILL NOT WORK on your Mac OS X.
Step 8: Enter “Ubuntu” as the name. Linux and 64 bit will be automatically
selected. Click Continue.
Step 9: Click on continue until you are done, using all the defaults.
Step 10: Click on settings and then on Storage and then on Controller: SATA
Step 11: Enter 2 in port count! This is an important step not to miss! Click
“OK” to close
Step 12: Ready to install Ubuntu now! Click the Start Button
Step 13: When you are promoted to select an image, select the ubuntu .iso image
downloaded in Step 5.
Step 14: Select “Install Ubuntu” from the screen, then “Continue” from the next
screen and then keeping the defaults, finally “Install Now”.
Step 15: Click “Continue” when asked to erase the virtual disk. Don’t worry, this
is not your Mac OS X disk.
Step 17: Put in your name and choose a password. Make sure you can remember it!
Now hit “Continue” and you are installing Ubuntu.
Step 18: Now click “Restart Now” when the installation is finished.
If Ubuntu does not start (which happens often the first time), then hit the “x” in
the corner
and select “Power Off the Machine”.
Step 19: Now you have your Ubuntu Virtual Machine running.
Click the “X’ on the window and select “Send the shutdown signal”. Then click
“Shutdown”
Step 1: Insert your SD Card into the reader on your Mac OS X machine.
Below is on the Mac Mini. On a Mac Book, it will be on the side.
diskutil list
Step 3: You will see a list similar to this. Look for your SD card and note the
/dev path (/dev/disk4 in this case)
Step 4: In the terminal window type (replacing /dev/diskX with what you found in
Step 3):
Step 5: change directory in the terminal window to the “VirtualBox VMs” on our
development machine this command is:
cd "/Users/development/VirtualBox VMs"
Note the quotes around the directory name. Adding spaces in directory names and
filenames
causes all sorts of issues. The user on our machine is “development”.
The user name on your machine will be different.
Step 6: Now we come to the magic. Type the following (replacing diskX with what
you found in Step 3):
Step 7: Now we have an .vmdk file pointing to your raw SD Card device.
We next have to set the permissions on this file so your Ubuntu VirtualBox machine
can read the file.
Step 8: Next we have to add the SD Card (a SATA device) in the Ubuntu virtual
machine storage
configuration built in the previous section.
Step 10: Click on the icon on the right of the Controller: SATA disk and select
“Choose existing disk”.
Select the .vmdk file built in Step 6 above. If it reports that it is busy
(Mac OS X likes to remount things for some reason), repeat Step 4 and quickly do
Step 10 again.
Step 12: Start your Ubuntu Virtual machine with the start button.
Now finally, we can repair the SD Card.
Step 1: Select the top most icon on the Ubuntu Desktop. Type “Terminal” in the
search line.
Step 2: Select the Terminal Icon on the top line. You will get a terminal window.
Step 3: type
lsblk -l
into the terminal window (you may have to enter your password from Step 17 in the
section above)
Step 4: Note the name “/dev/sdb”. That is your SD Card on the Ubuntu system.
Note it may be different, but if you followed these directions, it should be the
same.
Step 5: Now the magic. Finally. We will fix the sdb2 partition on sdb.
That is the linux system.
Type the following in the terminal window:
rasberry-pi-b_-with-sd-cardConclusion
The next time you need to repair an SD Card, you should only have to plug it into
your Mac OS X
and then start Ubuntu from VirtualBox. Note that the image you built for the SD
Card repair
probably won’t boot without an SD Card plugged in. If you want to use Ubuntu
without the SD Card,
build another image in VirtualBox. You don’t have to delete the SD Card Ubuntu
image.
================================================================================
AZARTICOLO: LA MIA RASPBERRY
================================================================================
raspy
description: Computer
product: Raspberry Pi 3 Model B Rev 1.2
width: 32 bits
*-core
description: Motherboard
physical id: 0
capabilities: brcm_bcm2710 brcm_bcm2709
*-cpu:0
description: CPU
product: cpu
physical id: 0
bus info: cpu@0
size: 1200MHz
capacity: 1200MHz
capabilities: cpufreq
*-cpu:1 DISABLED
description: CPU
product: cpu
physical id: 1
bus info: cpu@1
size: 1200MHz
capacity: 1200MHz
capabilities: cpufreq
*-cpu:2 DISABLED
description: CPU
product: cpu
physical id: 2
bus info: cpu@2
size: 1200MHz
capacity: 1200MHz
capabilities: cpufreq
*-cpu:3 DISABLED
description: CPU
product: cpu
physical id: 3
bus info: cpu@3
size: 1200MHz
capacity: 1200MHz
capabilities: cpufreq
*-memory
*-usbhost
*-usb
*-usb
*-network:0
*-network:1
=================================================================================
AZARTICOLO:RASPBERRY PI 3 GPIO HEADER PINOUTS
=================================================================================
https://pinout.xyz/
================================================================================
RASPBERRY PI 2 COMPATIBLE TESTA SD CARD
SLOT
================================================================================
MARRONE | | 3.3V || 01 || 02 || 5V
| |
ROSSO | wpi:08 | GPIO02/SDA1 || 03 || 04 || 5V
| | S) I2C
ARANCIONE | wpi:09 | GPIO03/SCL1 || 05 || 06 || GND |
| S) I2C
GIALLO | wpi:07 | GPIO04/GCLK || 07 || 08 || GPIO14/TXD | wpi:15 |
D) UART
VERDE | | GND || 09 || 10 ||
GPIO15/RXD | wpi:16 | D) UART
BLUE | wpi 00 | GPIO17/GEN0 || 11 || 12 || GPIO18/GEN1 | wpi:01
|
VIOLA | wpi 02 | GPIO27/GEN2 || 13 || 14 || GND
| |
GRIGIO | wpi 03 | GPIO22/GEN3 || 15 || 16 || GPIO23/GEN4 | wpi:04 |
BIANCO | | 3.3V || 17 || 18 ||
GPIO24/GEN5 | wpi:05 |
NERO |wpi 12 | GPIO10/MOSI || 19 || 20 || GND
| | S) SPI
MARRONE |wpi 13 | GPIO09/MISO || 21 || 22 || GPIO25/GEN6 | wpi:06 | S)
SPI
ROSSO |wpi 14 | GPIO11/SCLK || 23 || 24 || GPIO08 /CE0 | wpi:10 |
S) SPI D) SPI
ARANCIONE | | GND || 25 || 26 || GPIO07 /CE1 |
wpi:11 | D) SPI
--------------------------------------------------------------------------------
RASPBERRY PI 3 SPECIFICO (NON COPERTO DA WIRINGPI)
--------------------------------------------------------------------------------
GIALLO | wpi 30 | GPIO00/ID_SD || 27 || 28 || GPIO01/ID_SC | wpi:31 | S)
EPROM D) EPROM
VERDE | wpi 21 | GPIO05 || 29 || 30 || GND |
|
BLUE | wpi 22 | GPIO06 || 31 || 32 || GPIO12 |
wpi:26 |
VIOLA | wpi 23 | GPIO13 || 33 || 34 || GND |
|
GRIGIO | wpi 24 | GPIO19/MISO || 35 || 36 || GPIO16/CE2 | wpi:27 |
BIANCO | wpi 25 | GPIO26 || 37 || 38 || GPIO20/MOSI | wpi:28 |
NERO | | GND || 39 || 40 || GPIO21/SCLK
| wpi:29 |
================================================================================
CONNETTORE P5 sotto MB
================================================================================
01 5V
02 3.3V
03 GPIO 28 wpi:17
04 GPIO 29 wpi:18
05 GPIO 30 wpi:19
06 GPIO 31 wpi:20
07 GND
08 GND
================================================================================
AZARTICOLO:SHIELD PIATTINA A 40 PIN 40° PIN
================================================================================
1022 1027 1017 GND 1004 SCL SLA 3V 5V 5V GND TxD RxD PCL GND
1023
| | | | | | | | | | | |
| | | |
| | | | | | | | | | | |
| | | |
| | | | | | | | | | | |
| | | |
| | | | | | | | | \--\ \ | |
| | |
| | | | | | \ 3V °01 °02 5V | | | |
| | |
| | | | | | SDA1 °03 °04 5V -/ | | |
| | |
| | | | | \-- SCL1 °05 °06 GND -/ | |
| | |
| | | | \------ GCLK °07 °08 TxD ----/ | |
| |
| | | \----------- GND °09 °10 RxD ---------/ |
| |
| | \-------------- GPIO17 °11 °12 GPIO18 ----------/ |
|
| \-------------------- GPIO27 °13 °14 GND -----------------/
|
\-------------------------- GPIO22 °15 °16 GPIO23 -------------------/
3V °---------------------------- 3V °17 °18 GPIO24 -------------- ° 1024
MOSI °-------------------------- MOSI °19 °20 GND ----------------- ° GND
MISO °-------------------------- MISO °21 °22 GPIO25 --------------- ° 1025
SCLK °-------------------------- SCLK °23 °24 CE0 ------------------ ° CE0
GND °--------------------------- GND °25 °26 CE1 ------------------ ° CE1
EED °-------------------------- ID_SD °27 °28 ID_SC ---------------- ° EEC
1005 °------------------------- GPIO05 °29 °30 GND ------------------ ° GND
1006 °------------------------- GPIO06 °31 °32 GPIO12 --------------- ° 1012
1013 °------------------------- GPIO13 °33 °34 GND ------------------ ° GND
1019 °------------------------- GPIO19 °35 °36 CE2 ------------------ ° 1016
1026 °------------------------- GPIO26 °37 °38 MOSI ---------------- ° 1020
GND °--------------------------- GND °39 °40 SCLK ----------------- ° 1021
http://www.raspberry-projects.com/pi/programming-in-c/io-pins/bcm2835-by-mike-
mccauley
root@raspy:~/.netbeans/remote/raspyc/portatile2009-Linux-x86_64/prog/wiringPi/gpio#
lshw
=================================================================================
AZARTICOLO: Raspberry Pi GPIO Pin numbering
=================================================================================
Pins
---
Pin numbering of the BCM2835 GPIO port(s) on the Raspberry Pi has been a source of
great
confusion since the designs for the Pi were first published.
In the early days (even before hardware was available) the default usable GPIO pins
were simply
referred to by number as GPIO0 through GPIO7. Additionally there were pins for
other purposes,
SPI, I2C and serial. This was highlighted on the original image on the Raspberry Pi
Wiki site too.
So when initially writing wiringPi, I chose to have the same default pin numbering
scheme and
numbered them from 0 upwards. This is no different to how the Arduino operates –
“Pin 13” on the Arduino is Port B, bit 5 for example.
The underlying hardware definitions are hidden by a simplified numbering scheme.
However this has subsequently been viewed as “wrong” and several people have
expressed concern
about my numbering scheme, however I’ve stuck with it (as by then people were using
wiringPi).
and it’s proven its worth over the hardware board revisions where some pins changed
their hardware
definitions, however wiringPi was able to hide this from the user.
As a result (for example) a program that uses wiringPi pin 2 on a Rev. 1 Pi will
work unchanged on
a Rev 2. Pi, however someone using BCM_GPIO pin 21 on a Rev 1 Pi will need to
change their program
to use BCM_GPIO pin 27 on a Rev 2.
So wiringPi supports its own pin numbering scheme as well as the BCM_GPIO pin
numbering scheme,
and as of Version 2, it also supports the physical hardware pin numbers (for the P1
connector only),
but I would like to suggest you stick to the simplified wiringPi pin numbers.
That way your programs will be portable over different hardware revisions without
needing any changes.
The following tables give the mapping of the Raspberry Pi GPIO Pins to the (P1)
GPIO connector
in relation to the pin numbers and the physical location on the connector.
This is a representation of the GPIO connector as viewed looking at the board from
above.
The GPIO connector is to the top-right of the board with the Ethernet and USB
sockets to the
bottom.
gpio1Board Revisions: Please note the differences between board revisions 1 and 2
(Rv1 and Rv2 above) The Revision 2 is readily identifiable by the presence of the 2
mounting holes.
gpio2
The P5 connector is designed to have the header soldered on the underside of the
board.
Pin 1 is identified by the square solder pad.
So if you solder the header on the top of the board be aware that the pin locations
will be the
other way round!
WiringPi defines 17 pins, (21 on a Rev. 2 board) but some of them and the functions
we can
use may potentially cause problems with other parts of the Raspberry Pi Linux
system.
-----------------------------------------------------------------------------------
---------------------------------------------
WiringPi | 0 1 2 3 4 5 6 | 7 | 8 9 | 10 11 12 13 14 | 15 16
| 17 18 19 20
BCM_GPIO | 17 18 27 22 23 24 25 | 04 | 02 03 | 8 7 10 9 11 | 14 15 | 28
29 30 31
Raspberry PINs| 11 12 13 15 16 18 22 | 07 | 03 05 | 24 26 19 21 23 | 08 10 |
-----------------------------------------------------------------------------------
---------------------------------------------
| AU | CLK | I2C | SPI | TX
RX | CONN P5
-----------------------------------------------------------------------------------
---------------------------------------------
Pin 0 1 2 3 4 5 6
---------------------------
These are safe to use at any time and can be set to input or output with or without
the internal
pull-up or pull-down resistors enabled.
Pin 7 (BCM_GPIO 4)
----------------------------
This is normally OK to use, however it is used by the 1-Wire kernel driver
and it can
optionally be connected to a GPIO clock source.
PWM: You can change the function of pin 1 (BCM_GPIPO 18) to be PWM output,
however if you are currently playing music or using the audio system via
the 3.5mm
jack socket, then you’ll find one channel of audio PWM coming through the
pin!
If you are not using the audio at all, (or the audio is going via the HDMI
cable),
then this pin is free to be used in PWM mode.
You may use them for digital IO if you are not using any I2C drivers which
use these
pins, however note that they have on-board 1.8KΩ resistors pulling the
signals to
the 3v3 supply. This feature does make them handy for switch inputs where
the
switch simply shorts the pin to ground without having to enable the
internal pull-up resistors
Like the I2C interface, if you are not using it, then you can freely use
them for
your own purposes. Unlike I2C, these pins do not have any external pull up
(or pull down) resistors.
If you want to use these pins as general purpose I/O pins then you need to
make sure
that you reboot your Pi with the serial console disabled.
See the file /boot/cmdline.txt and edit it appropriately.
=================================================================================
AZARTICOLO:How to install Microsoft fonts in Linux office suites
=================================================================================
Times New Roman, Calibri, and many other popular fonts are created by Microsoft and
can’t
be included with Linux. If you open a Word document or another Microsoft Office
document in
LibreOffice or OpenOffice, you’ll need Microsoft’s fonts installed on your Linux
system to see
the documents as they were intended to look.
You can also use Microsoft’s fonts to create documents of your own, so you can
compose
a document in Calibri or Times New Roman and save it as a DOCX or DOC file for
maximum
compatibility with Office.
Microsoft released a package of “TrueType core fonts for the web” back in 1996.
These fonts were given a very permissive license agreement, so anyone could install
them.
Microsoft wanted their fonts to be the standard fonts everyone with a web browser
had,
so they gave them away. Microsoft terminated this project in 2002, but the fonts
can still be
installed thanks to MIcrosoft’s old license agreement.
This font pack contains Andale Mono, Arial, Arial Black, Comic Sans MS, Courier
New, Georgia,
Impact, Times New Roman, Trebuchet, Verdana, and Webdings.
Times New Roman was the default font for Office documents until Calibri debuted in
Office 2007.
First, open a terminal. Click the Ubuntu icon on the dock, search for “Terminal,”
and click the
terminal shortcut.
Type or copy-and-paste the following command into the terminal and press Enter.
This command asks for administrator access (sudo) before launching the package
manager
(apt-get) and telling it to download and install (install) the ttf-mscorefonts-
installer package:
Other Linux distributions also offer similarly named “corefonts” packages you can
easily install.
Search your Linux distribution’s package manager for such a package.
Microsoft added a group of new “ClearType Fonts” to Windows with Windows Vista and
Office 2007.
These fonts are named Constantia, Corbel, Calibri, Cambria, Candara, and Consolas.
Calibri became
the default font on Microsoft Word 2007, and it’s still the default font on Word
2013 today.
Microsoft never released these fonts to everyone like they did with the older core
fonts.
However, Microsoft does make these fonts available to download as part of their
free
PowerPoint Viewer 2007 application. If you don’t have a Windows system around, you
can use a
script that downloads the PowerPoint Viewer 2007 application from Microsoft,
extracts the six
ClearType fonts, and installs them on your Linux system.
This script will install the ClearType fonts for just your user account, while the
above script installs
the TrueType core fonts for every user account on your system.
If you haven’t yet installed the TrueType core fonts, you’ll need to run the apt-
get install
cabextract command to install the cabextract utility on your system. If you
installed the Microsoft
core fonts using the command above, this should already be installed.
Next, type mkdir .fonts and press Enter to create the fonts directory the script
requires.
The script will complain that you don’t have a .fonts directory if you don’t do
this first.
Next, copy-and-paste or type the following command into the terminal and press
Enter.
This command downloads the VistaFonts-Installer script and runs it.
The script downloads the fonts from Microsoft and installs them on your system:
The above two font packages are probably all you’ll need.
They’ll give you the standard Microsoft Office fonts, from the older TrueType core
fonts like
Times New Roman to the newer ClearType Fonts like calibri.
These are the standard fonts used in Microsoft Office documents by default.
If you have a Windows system lying around, these fonts are fairly easy to install.
For example, let’s say you’re dual-booting Ubuntu Linux and Windows.
You’ll find your Windows partition in Ubuntu’s file manager.
Click the Windows drive in the sidebar to access it. Navigate to the Windows\Fonts
directory
and you’ll see all the fonts installed on your Windows PC, including the fonts that
came with it.
Double-click a font and click the Install button to install it for your user
account.
You can use this trick to quickly install any other Windows fonts you want,
including Tahoma and Segoe UI. In fact, you can even use this trick to install
fonts like
Times New Roman and Calibri if you have a Windows system.
If you have another Windows computer, you can navigate to the Fonts pane in the
Control Panel
or open the Fonts folder at C:\Windows\Fonts. Select the fonts you want to use,
then
drag-and-drop them to a removable drive. You’ll get copies of the fonts in .ttf
form.
Take the removable drive to your Ubuntu system, double-click each .ttf file you
want to install,
and click the Install button to install it.
Open a Microsoft Office document created using these fonts and LibreOffice or
OpenOffice will
automatically use the appropriate fonts.
They’ll display the document as it was intended to look, Microsoft fonts and all.
If you’d like to change your default fonts for new documents, click
Tools > Options > LibreOffice Writer or OpenOffice Writer > Basic Fonts (Western).
Your office suite of choice will use Microsoft’s fonts as the default fonts in
future documents
if you choose them here.
Ubuntu and other Linux distributions actually include Red Hat’s “Liberation Fonts”
and use them
by default in their office suites. These fonts were designed to substitute for
Arial, Arial Narrow, Times New Roman, and Courier New.
They have the same widths as Microsoft’s popular fonts.
If you open a document written with Times New Roman, the appropriate Liberation
font will be
used instead so the flow of the document won’t be interrupted.
However, these fonts don’t look identical to Microsoft’s fonts.
The Liberation project also doesn’t provide fonts designed to match the width of
Calibri and
Microsoft’s other newer ClearType fonts.
If you’re a Linux user that wants the best Microsoft Office compatibility possible,
you should install Microsoft’s fonts.
================================================================================
AZARTICOLO:Raspbian
================================================================================
Raspbian is the recommended operating system for normal use on a Raspberry Pi.
Raspbian is a free operating system based on Debian, optimised for the Raspberry Pi
hardware.
Raspbian comes with over 35,000 packages;
precompiled software bundled in a nice format for easy installation on your
Raspberry Pi.
## Contents
- Configuring Raspbian
- [raspi-config] (../configuration/raspi-config.md)
- [config.txt] (../configuration/config-txt.md)
- [Applications] (applications/README.md)
- [Camera] (applications/camera.md)
==============================================================
AZARTICOLO:NOOBS INSTALLATION INSTRUCTIONS
==============================================================
a. Windows
i. Download the SD Association's Formatting Tool from
https://www.sdcard.org/downloads/formatter_4/eula_windows/
ii. Install and run the Formatting Tool on your machine
iii. Set "FORMAT SIZE ADJUSTMENT" option to "ON" in the "Options" menu
iv. Check that the SD card you inserted matches the one selected by the Tool
v. Click the "Format" button
b. Mac
i. Download the SD Association's Formatting Tool from
ii. Install and run the Formatting Tool on your machine
iii. Select "Overwrite Format"
iv. Check that the SD card you inserted matches the one selected by the Tool
v. Click the "Format" button
c. Linux
i. We recommend using gparted (or the command line version parted)
ii. Format the entire disk as FAT
4. Copy the extracted files onto the SD card that you just formatted so that this
file is at the
root directory of the SD card. Please note that in some cases it may extract the
files into a folder,
if this is the case then please copy across the files from inside the folder rather
than the folder itself.
5. Insert the SD card into your Pi and connect the power supply.
Your Pi will now boot into NOOBS and should display a list of operating systems
that you can choose to install.
If your display remains blank, you should select the correct output mode for your
display by pressing
one of the following number keys on your keyboard:
1. HDMI mode - this is the default display mode.
2. HDMI safe mode - select this mode if you are using the HDMI connector and cannot
see anything on screen when the Pi has booted.
3. Composite PAL mode - select either this mode or composite NTSC mode if you are
using the composite RCA video connector.
4. Composite NTSC mode
If you are still having difficulties after following these instructions, then
please visit the
Raspberry Pi Forums ( http://www.raspberrypi.org/forums/ ) for support.
===================================================================================
========
AZARTICOLO:Setting up a RAM drive on Raspberry Pi
===================================================================================
========
http://www.domoticz.com/ domotica open source
Introduction
It is strongly believed that excessive writing to the Raspberry Pi's SD card will
finally cause
it to fail. But the only way to exchange data between Lua and shell scripts is
through
temporarily files.
To avoid SD card wearing these files could be written to a virtual drive in RAM.
This guide shows how to set up a 1 MB RAM drive on your Raspberry Pi.
Setup
mkdir /var/tmp
then edit the fstab file by
vi /etc/fstab
and add the line
mount -a
To check if your operation succeeded issue
df
which should report (among the other disks) a tmpfs with 1024 1K blocks (=1MB)
as /var/tmp
pi@raspberrypi ~ $ df
Filesystem 1K-blocks Used Available Use% Mounted on
rootfs 3807952 1814024 1820896 50% /
/dev/root 3807952 1814024 1820896 50% /
devtmpfs 183596 0 183596 0% /dev
tmpfs 38372 268 38104 1% /run
tmpfs 5120 0 5120 0% /run/lock
tmpfs 76740 0 76740 0% /run/shm
/dev/mmcblk0p1 57288 18544 38744 33% /boot
tmpfs 1024 4 1020 1% /var/tmp
=================================================================================
AZARTICOLO:Raspberry Pi firmware updates
=================================================================================
Installing rpi-update
----------------------------
Install dependencies
-----------------------------
Install rpi-update
# rpi-update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
*** Performing self-update
*** Relaunching after update
*** Raspberry Pi firmware updater by Hexxeh, enhanced by AndrewS and Dom
#############################################################
This update bumps to rpi-4.1.y linux tree
Be aware there could be compatibility issues with some drivers
Discussion here:
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=113753
##############################################################
*** Downloading specific firmware revision (this will take a few minutes)
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 168 0 168 0 0 221 0 --:--:-- --:--:-- --:--:-- 221
100 49.2M 100 49.2M 0 0 1111k 0 0:00:45 0:00:45 --:--:-- 974k
*** Updating firmware
*** Updating kernel modules
*** depmod 4.1.18-v7+
*** depmod 4.1.18+
*** Updating VideoCore libraries
*** Using HardFP libraries
*** Updating SDK
*** Running ldconfig
*** Storing current firmware revision
*** Deleting downloaded files
*** Syncing changes to disk
*** If no errors appeared, your firmware was successfully updated to
0d25b1c25d135090269ff74dc94dac0d31dcbcf9
*** A reboot is needed to activate the new firmware
===================================================================================
=========
AZARTICOLO:Introducing the Raspberry Pi 3
===================================================================================
=========
The Raspberry Pi 3 Model B features a quad-core 64-bit ARM Cortex A53 clocked at
1.2 GHz.
This puts the Pi 3 roughly 50% faster than the Pi 2.
Compared to the Pi 2, the RAM remains the same – 1GB of LPDDR2-900 SDRAM,
and the graphics capabilities, provided by the VideoCore IV GPU, are the same as
they ever were.
As the leaked FCC docs will tell you, the Pi 3 now includes on-board 802.11n WiFi
and
Bluetooth 4.0. WiFi, wireless keyboards, and wireless mice now work out of the box.
The Raspberry Pi 2 (left) and the Raspberry Pi 3 (right). Physically, there are
very few differences.
Specs
In the next few steps we’ll be doing as much prep work while our SD card is still
mounted so when we boot up for the first time there’s nothing to do post-install.
cat <<EOF>/mnt/sdcard/boot/config.txt
disable_overscan=1
hdmi_force_hotplug=1
hdmi_group=1
hdmi_mode=16
EOF
rpi-update is a useful utility that will sync the latest kernel and firmware/boot
files to your Raspberry Pi. Let’s get this in place
wget -O /mnt/sdcard/usr/bin/rpi-update
https://raw.githubusercontent.com/Hexxeh/rpi-update/master/rpi-update
chmod +x /mnt/sdcard/usr/bin/rpi-update
Currently the wifi does not work out of the box without some newer firmware,
particularly the non-free firmware. Fix it by plopping these files into
/lib/firmware.
In future rpi updates this should be resolved.
This will set your root password, you can skip this step if your first boot will be
hooked up to a
monitor (as it will boot to run level 5 with the “first” boot screen allowing you
to set things like
account passwords, timezone, etc.). If you’re running headless or with a non-
graphical image
you’ll want to perform this.
modprobe snd_bcm2835
Fix: Firewall
Despite generally not caring for firewalld and the over-engineered approach to
“zones” I’ve found it does not work reliably on ARMv7 in either CentOS or Fedora.
Let’s remove it and move back to trusty old iptables.
Now edit your firewall rules like a sane human in /etc/sysconfig/iptables and when
you’re done
you can save them.
================================================================================
AZARTICOLO:Installare Node.js su Raspberry Pi
================================================================================
Vediamo in questa guida come installare e configurare Node.js sul nostro Rapsberry
Pi.
nodejs
Passo dopo passo mostriamo quanto facile sia installare questo potente strumento
sul RPi.
1. Configurare il Raspberry Pi
-------------------------
Un passo che diamo per scontato, è l’aver una versione di Raspbian o NOOBS pronta e
funzionante.
La guida ufficiale spiega in modo esaustivo come fare.
2. Installare Node.js
------------------
wget http://node-arm.herokuapp.com/node_latest_armhf.deb
dpkg -i node_latest_armhf.deb
A questo punto per verificare che l’installazione sia avvenuta con successo,
lanciate il comando
node -v
npm -v
che restituisce la versione corrente del node package manager, necessario per
l’installazione rapida
di librerie.
NB. E’ necessario che l’archivio di node scaricato sia espressamente per Linux-ARM.
Lanciamo dunque lo script con il comando node app.js, sulla console ci apparirà
Come fare per eseguire il server appena creato con Node.js ad ogni avvio del
Raspberry?
Semplice! E’ sufficiente inserire nel file /etc/rc.local il comando che segue
(prima dell’istruzione exit 0):
How to Install the Latest Version of NodeJS, NPM and Express on the Raspberry Pi
----------------------------------------------------------------------
Please note that this blog post assumes that you have properly set up your
Raspberry Pi with the
Raspbian “wheezy” image and have SSH enabled. If you do not, please take a moment
to read
my earlier blog post, Super Easy Install of Raspbian “wheezy” on the Raspberry Pi
Using a Mac.
With that, let’s jump right in.
This next part is where Matt and I deviate. I’m a fan of making things easy.
Had we been installing NodeJS on a desktop or laptop, we would be able to use node
from the
command line simply by typing “node [COMMAND]”. This was how I set that up.
We’re going to create a symbolic link to both node and npm and put those links
in /usr/local/bin:
ln -s /opt/node/bin/node /usr/local/bin/node
ln -s /opt/node/bin/npm /usr/local/bin/npm
source ~/.bashrc
Now that .bashrc has been restarted, let’s verify that not only did our symbolic
link work, but
we have node and npm properly installed. First type node -v to see the installed
version of node
and then type npm -v to see the installed version of npm. You should see something
like the following:
pi@raspberrypi ~ $ node -v
v0.11.3
pi@raspberrypi ~ $ npm -v
1.2.25
INSTALLING EXPRESS
-------------------
Please note that this next section is completely optional and as of the latest RPi
OS,
seem to not work as listed here. Please use with caution.
With Express properly installed, it’s now time to create our working directory.
However, we’re going to let Express do that for us.
The working directory that we’re going to create will be /var/www though depending
upon your setup,
the directory www may or may not exist yet.
For the purposes of this tutorial, we are assuming it does not yet exist.
Simply type the following into the command line:
cd /var
express -e www
There are several flags you can set and depending upon what you prefer, many
combinations.
To see all of them, type express –help in the command line.
You should see something like the following:
Options:
Once Express successfully creates the necessary directory structure, the last step
before we turn
the sucker on is to jump into the www directory and let npm add the finishing
touches.
We do this as so (please note that I’ve chosen to add to the command which deviates
from
what Express shows. Without permissions, npm will not be able to install all the
dependencies
properly:
cd www && npm install
Again, you should see some warnings which you are welcome to go back and correct
but they will
not impact this process.
Once npm is done, it’s finally time to flip the switch and see if we made
Frankenstein or a flub:
node app.js
Go out to your Raspberry Pi’s ip address at port 3000 and if you created
Frankenstein,
you should see something like this:
pi@raspberrypi ~ $ node -v
v0.11.3
pi@raspberrypi ~ $ npm -v
1.2.25
Congratulations!
You have successfully installed NodeJS, NPM and Express on the Raspberry Pi!
================================================================================
AZARTICOLO:Generate Self-signed SSL Certificate
================================================================================
Using HTTPS for your web application is a no-brainer, but sometimes it is not
intuitively clear on
how to get started on using SSL for your website. I'm going to be going over step-
by-step on
generating a self-signed certficate and testing it out on a Node.js web server.
The output:
Note that if you do not want to use a passphrase for your key, you can remove it
from the private key.
Next we need to issue a Certificate Signing Request (CSR), which is responsible for
sending a
message to a Certificate Authority (CA) in order to apply for a digital certificate
which certifies
the ownership of the public key.
It will ask you for information for the certificate regarding your company and
location.
See the output after the command as an example.
The output:
Generating Certificate
-------------------
Now we use the Certficate Signing Request file to self-sign a new X.509
Certificate, valid for 365 days.
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
The output:
Signature ok
subject=/C=US/ST=CA/L=Los Angeles/O=My Company/OU=Information
Technology/CN=localhost/[email protected]
Getting Private key
----------------
const options =
{
// Private Key
key: fs.readFileSync('./ssl/server.key'),
// SSL Certficate
cert: fs.readFileSync('./ssl/server.crt'),
// Make sure an error is not emitted on connection when the server certificate
verification against the list of supplied CAs fails.
rejectUnauthorized: false
};
server.listen(9000);
You should get a browser warning like this one saying that the certificate could
not be validated.
This is normal since we're using this for development purposes. Go ahead and hit
Proceed to localhost.
You probably noticed the ugly red x over the https lock icon since the certificate
could not be
validated by a CA.
In order to get the nice green lock we can tell our operating system to always
trust this certificate.
If you're on Mac OSX; Open up the Keychain Acess app and on the left sidebar click
on System
under Keychains and click on Certificates under Category.
Now double-click on the certificate you just added and under Trust options, next to
When using
this certficate select the Always Trust option.
Conclusion
It is standard practice to use a SSL certificate for web applications even if not
planning on
sharing confidential data with visitors. Having encrypted communication ensures
trust with the
user accessing your site. Hope this guide helped you get started on using SSL while
developing.
================================================================================
AZARTICOLO:How to install the Microsoft Core Fonts on Debian or Sparkylinux
================================================================================
To install the Microsoft Fonts in Linux, you have to install the Microsoft TrueType
core fonts package.
After you press <OK> and <Yes> to accept the Terms and Conditions in the TUI (text
user interface)
window that appears your installation will finish and you will be able to use both
the Microsoft and the
Ubuntu fonts in OpenOffice, LibreOffice or any other text editor.
The Microsoft most famous fonts are now available in your Linux:
Arial
Comic Sans
Times New Roman
Verdana
Webdings
After the next login you should notice a big difference in the font rendering.
================================================================================
AZARTICOLO: VLC is not supposed to be run as root. Sorry. – Solution
================================================================================
vlc
This error says straight forward vlc can not be run as root privileged user.
What to do now? Don’t be panic. Here is the hacked solution 😀
vi /usr/bin/vlc
================================================================================
AZARTICOLO: Raspberry Pi - Raspbian Locale Settings
================================================================================
Example message:
LANGUAGE = (unset),
LC_ALL = (unset),
LC_CTYPE = "UTF-8",
LANG = "en_GB.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
To fix this warning, we can run the following command to generate the settings:
export LANGUAGE='en_GB'
and export LC_All
export LC_ALL="en_GB.UTF-8"
Once we have done this, we can update our locale config and we should no longer get
this warning
C) dpkg-reconfigure locales
Here we can use the up down keys to scroll for your language settings, and the
space bar to select it.
Once done hit tab to tab to OK or Cancel.
LANG=en_GB.UTF-8
LANGUAGE=en_GB
LC_CTYPE="en_GB.UTF-8"
LC_NUMERIC="en_GB.UTF-8"
LC_TIME="en_GB.UTF-8"
LC_COLLATE="en_GB.UTF-8"
LC_MONETARY="en_GB.UTF-8"
LC_MESSAGES="en_GB.UTF-8"
LC_PAPER="en_GB.UTF-8"
LC_NAME="en_GB.UTF-8"
LC_ADDRESS="en_GB.UTF-8"
LC_TELEPHONE="en_GB.UTF-8"
LC_MEASUREMENT="en_GB.UTF-8"
LC_IDENTIFICATION="en_GB.UTF-8"
LC_ALL=en_GB.UTF-8
================================================================================
AZARTICOLO: Control LED Using GPIO Output Pin
================================================================================
By Matt on June 10, 2012 Hardware, Python, Tutorials & Help
The circuit below shows to turn an LED on and off using a Raspberry Pi GPIO pin
configured as
an output. It uses the output pin to turn on a transistor which allows the LED to
draw current
from the supply.
Header Pin 2 : 5V
Header Pin 6 : Ground
Header Pin 11 : GPIO
The LED is a standard 5mm red type with a forward voltage of 2V.
The transistor could be a BC547, BC548 or equivalent.
R1 could be increased you just need to make sure you allow enough current to power
your LED.
R2 could be increased and this would reduce the current drawn from the GPIO pin but
it would
reduce the maximum current allowed to flow through the transistor.
Note : As with all connections you make to the Pi’s PCB you must double check
everything.
Making a mistake in your wiring could damage the CPU as some of the GPIO pins are
connected
straight to the Broadcom chip.
I’ve modified some of the details on this page thanks to feedback from Gert (see
comments below).
Python Code
----------
In order to control GPIO pins in Python you must install the RPi.GPIO library.
Installing the library is easy if you follow my RPi.GPIO Installation Guide.
Once installed you can use the following Python script to toggle the GPIO output on
header pin 11 (GPIO17) :
Python scripts must be run as the super user when they are using the GPIO library.
So if your script is called “ledtest.py” you would run it by typing :
python ledtest.py
The script should print text messages to the command line while toggling the state
of pin 11.
If your circuit is correct then the LED should turn on and off every one second.
================================================================================
AZJSON
================================================================================
Un JSONObject non e' altro che una LinkedHashMap ovvero dei vettori (accessibili
via indice) di
hash ovvero di coppie nome valore, ovvero del tipo <String nome,Object valore>
Infatti viene al suo interna definita come:
In Realtà in un oggetto JSON gli elementi in esso contenuti possono essere solo 3
categorie:
- JSONOBject
- JSONArray
- tipi primitivi: String,Integer,Boolean,Double,Long,NULL
(nel nostro caso si utilizzano solo Stringhe)
Le JSONArray poi non sono altro che delle ArrayList, ovvero dei vettori accessibili
via indice,
ma al contrario delle LinkedHashMap, le entry delle ArrayList sono anonime,
possiedono il solo valore,
il nome e' in sostanza dato dall'indice dell'array. Sono definite come:
L' ArrayList contiene oggetti che nel nostro caso possono essere solo oggetti
JSONObject
Ora il nostro oggetto JSON, e' LinkedHashMap denominata all suo interno
nameValuePairs,
i cui elementi sono solo due hash, di nome "controls" e "formats", ed il cui valore
e' rappresentato
per ambedue da una JSONArray.
L' JSONArray "controls" che al suo interno ha 34 oggetti
e "formats che a sua volta e' formato da 12 oggetti
"id":
"type"
"min"
"max"
"step"
"default"
"value"
"dest"
"flags"
"group"
esiste solo un eccezione: l'hash denominata "menu" ha come valore un oggetto JSON!
Tale oggetto e' composto da una serie di Hash di tipo semplice:
il nome e' una stringa corrispondente alla posizione della stringa nel vettore che
memorizza il menu,
il valore della coppia hash e' una stringa.
Il menu viene utilizzato allorche' nella hash "valore" andrebbe indicata una
stringa, ma avendo
deciso di trasformarla in numerico, allora tale valore coincide col indice del menu
in cui e'
memorizzata la stringa desiderata.
"0": "Disabled",
"1": "50 Hz",
"2": "60 Hz",
"3": "Auto"
"formats" invece e' una JSONArray contenente 14 elementi a loro volta oggetti JSON
Questi sono 7 coppie hash (nome,valore) il cui valore e' sempre di tipo <String>
"id": "1",
"name": "YUYV 4:2:2",
"compressed": "false",
"emulated": "false",
"current": "true",
"resolutions":
{
"0": "32x2592"
},
"currentResolution": "255"
Anche qui vi e' l'eccezione data da "esolutions" che in e' un JSONObject composto
da una sola
hash contenente la stringa che rappresenta le dimensioni
Ora ad ogni passo estraggo dall oggetto JSON la componente che mi interessa e la
memorizzo
in ItemsApp items composto dalle seguenti array_list <String>
--------------------------------------------------------------------------------
nome = key_name key_name key_name
"menu"
tipo = "ARRAY" "OBJECT" "STRING" MENU
"MITEM"
--------------------------------------------------------------------------------
LO STACK
--------------------------------------------------------------------------------
Per percorrere all'indietro l'oggetto JSON mi servo di uno stack di stringhe dove
memorizzo
l'oggetto contenitore come stringa_json del contenitore stesso.
In realta' siccome l'elemento di posto 0 e' l'intero oggetto sarebbe sufficente che
lo stack
memorizzasse i nomi degli oggetti attraversati, ovvero il percorso fino
all'elemento attuale e
non tutto l'oggetto che non occorre affatto!
Stack<String> json_stack
menu_editor(pos): Prelevo oggetto padre con json_stack_back () perche' e' qui che
e' contenuto
valore da modificare
if (json.has("value"))
json.putOpt("value",
Integer.toString(position_to_edit));
A) J0 : intero JSON_object
Quando viene caricato il file nello stack al posto 0 ci finisce l'intero oggetto
json
json_parser_object itera poi tutti i nomi dei suboggetti (JSONARRAY "controls" e
"formats")
ed infila i nomi in items (items.add()).
Nota
----
[
{
"name": "User Controls",
"id": "9961473",
"type": "6",
"min": "0",
"max": "0",
"step": "0",
"default": "0",
"value": "1",
"dest": "0",
"flags": "68",
"group": "1"
},
{
"name": "Brightness",
"id": "9963776",
"type": "1",
"min": "0",
"max": "100",
"step": "1",
"default": "50",
"value": "50",
"dest": "0",
"flags": "32",
"group": "1"
}
]
Scelgo di modificare "value", dopo aver accettato dall utente il nuovo valore
prelevo dallo stack
L'intera entry "User Controls" gli modifico il valore e poi la rimando di nuovo
nello stack
Avendo memorizzato gli interi oggetti ora l'oggetto modificato "User Controls"
andrebbe
modificato anche in tutti gli oggetti che si trovano nello stack almeno in quello
iniziale
ma avendo perso le scelte di come sono arrivato non posso farlo!
================================================================================
AZARTICOLO:How to Install the No-IP DUC on Raspberry Pi
================================================================================
You will be able to install No-IP’s Dynamic Update Client on Raspberry Pi in just a
few minutes
using Terminal. Installing the service is simple to do, and requires little
knowledge of Linux.
You will need to create a directory for the client software to be installed.
Open Terminal and type the following. After each entry press “Enter“.
mkdir /home/pi/noip
cd /home/pi/noip
After creating the folders for the DUC it is time to download the software.
Within the Terminal window type the following. After each entry you will press
“Enter”.
wget http://www.no-ip.com/client/linux/noip-duc-linux.tar.gz
tar vzxf noip-duc-linux.tar.gz
Next navigate to the directory you created to locate the downloaded files.
cd noip-2.1.9-1
After typing “make install” you will be prompted to login with your No-IP account
username and password.
After logging into the DUC answer the questions to proceed. When asked how often
you want the
update to happen you must choose 5 or more.
The interval is listed in minutes, if you choose 5 the update interval will be 5
minutes.
If you choose 30 the interval will be 30 minutes.
/usr/local/bin/noip2
To confirm that the service is working properly you can run the following command.
noip2 -S (Capital “S”)
================================================================================
AZARTICOLO:Configurare NO-IP Su Raspbian Per Raggiungere Il Raspberry Da Remoto
================================================================================
Requisiti:
Raspbian
Indirizzo IP statico assegnato al raspi (leggete nota a fine articolo per una
indicazione generica)
Procedimento – Creazione account:
Aprite il terminale
Digitate: mkdir /home/pi/noip
Ora spostatevi nella cartella con: cd /home/pi/noip
Quindi scaricate NO-IP tramite: wget http://www.no-ip.com/client/linux/noip-duc-
linux.tar.gz
Estraete quindi l’ archivio: tar vzxf noip-duc-linux.tar.gz
Ora entrate nella cartella estratta con: cd noip-2.1.9-1
Ora date: make
E per iniziare l’ installazione e la configurazione: make install
Inserite la vostra mail di registrazione e la password quando richiesto
Ora avviate il servizio con: /usr/local/bin/noip2
Fine
Bonus – Avviare NO-IP all’ avvio del Raspi:
Il gioco è fatto.
===================================================================================
=========
AZARTICOLO:NOOBS (New Out of Box Software)
===================================================================================
=========
https://github.com/raspberrypi/noobs
NOOBS (New Out Of Box Software) - An easy Operating System install manager for the
Raspberry Pi
http://www.raspberrypi.org/downloads
OS Boot Selector
--------------
After multiple OSes have been installed, you can select which OS to boot through
this selection
window that is automatically displayed. NOOBS will remember your choice and boot
this OS by
default unless a different option has been selected within 10 seconds.
Note that if only one OS is installed then the boot selector will not be displayed
and the OS will
be automatically booted.
Troubleshooting
-------------
Try pressing shift only when the grey splashscreen is displayed rather than holding
it from boot up.
To boot into a basic busybox shell rather than launching the NOOBS GUI, you can
either:
Append rescueshell to the argument list in the recovery.cmdline file which is found
in the root
NOOBS directory.
Reboot
To force Recovery Mode being entered on boot, connect GPIO pin 3 on header P1 to
GND (pin 25).
If GPIO pin 3 remains unconnected then it will boot through to the installed OS as
normal.
How to force Recovery Mode being entered on boot (overrides GPIO or keyboard input)
-------------------------------------------------------------------------
Alternatively, if you are unable to use either the GPIO or keyboard to trigger
entering
Recovery Mode, you can:
Reboot
Note that with this option enabled, the Recovery Mode will be displayed every time
you boot from
your NOOBS card (until you edit recovery.cmdline again).
In some rare cases, you may find that NOOBS incorrectly detects a SHIFT keypress
from your
keyboard regardless of the presence of user input.
In such cases it may be helpful to disable using the keyboard to trigger Recovery
Mode being entered.
If you don't have a keyboard, you can still change the display mode used by NOOBS
through
editing the recovery.cmdline file in the root NOOBS directory prior to first boot
and appending
the following argument:
================================================================================
AZARTICOLO:NOOBS partitioning explained
================================================================================
https://github.com/raspberrypi/noobs.wiki.git
NOOBS partitioning (and booting) explained
-----------------------------------------------------------------
Note that this was written for NOOBS v1.3.x / v1.4.x and the partition numbering
has changed
slightly in NOOBS v1.5.x
The multiple partitions that NOOBS divides your SD card into (at least 5) can be
quite overwhelming
and confusing. This page will try and explain how it all works, and illustrate how
NOOBS differs from
the 'traditional' standalone images.
Non-NOOBS partitioning
------------------------------------
Before you can understand how NOOBS partitioning works, you need to understand how
standalone
partitioning works on the Raspberry Pi, so go and read that page if you haven't
already.
For historical reasons (only 4 'slots' in the partition table), hard-drives and SD
cards can only
have a maximum of 4 primary partitions. To work around that limitation, one of
those primary
partitions can optionally be an extended partition.
An extended partition can contain an unlimited number of logical partitions inside
it.
Under Linux, the primary partitions are always numbered 1-4 (i.e. seen as
/dev/mmcblk0p1 -
/dev/mmcblk0p4 on the Pi), and any logical partitions are always numbered 5 and
above
(i.e. seen as /dev/mmcblk0p5 and above on the Pi).
NOOBS partitioning
------------------------------
When NOOBS is first copied to a FAT-format SD card, there's just a single partition
taking up
all the space on the card, and this is where the files from the NOOBS zipfile get
written to.
In tabular form it looks like:
1 FAT New Volume NOOBS boot files & initramfs, OS recovery images
The only difference between NOOBS and NOOBS lite is that NOOBS lite doesn't include
any
OS recovery images.
If runinstaller is present in the kernel command-line, then this must be the first
time NOOBS
has been booted, so it enters 'setup mode'. It then:
- Creates a new large empty extended partition /dev/mmcblk0p2, using up the vast
majority of
the remaining card space.
- Creates a new small (32MB) ext4-format partition /dev/mmcblk0p3 at the end of the
card,
and labels it as 'SETTINGS'. This is used to store files telling NOOBS which OSes
are installed
(and what partitions they're installed on), which OS should be loaded by default,
which language/keyboard NOOBS should use, etc.
- The settings are stored on a small auxiliary partition rather than the same
/dev/mmcblk0p1
partition as everything else. This is because of the NOOBS 'prime directive' -
"NOOBS never
writes to the first FAT partition.
FAT partition the first, NOOBS no writee...".
By never writing anything to the first partition (after the 'setup mode' has
finished),
this ensures that the first partition can never become corrupted;
and so NOOBS 'recovery mode' will always be accessible (to allow OSes to be re-
installed),
no matter what happens to the rest of the SD card.
--------------------------------------------------------------------------------
Primary partition Logical partition Type Label Contents
--------------------------------------------------------------------------------
1 FAT RECOVERY NOOBS boot files & initramfs, OS recovery images
2 extended Any logical partitions
3 ext4 SETTINGS NOOBS settings
--------------------------------------------------------------------------------
If NOOBS detects that no Operating Systems have been installed yet, or if the user
is pressing
the Shift key (or any of the other trigger actions are in effect), NOOBS enters
'recovery mode'.
This displays the OS-installation menu, allowing the user to choose which OS(es) to
install.
Refer to the normal documentation for more details a about this menu.
Install menu
----------
As you may have guessed, the "Available space" displayed here is the size of the
extended
/dev/mmcblk0p2 partition, which is where all the OSes get installed to.
NOOBS datafiles
---------------
NOOBS OS installation
---------------------------------
For the first example, let's assume that the user is installing just Raspbian.
The partitions.json (which can be viewed online here) then specifies which
partitions should be created,
how big they should be, and which filesystems they should use.
In this example it would create a 60MB FAT partition (/dev/mmcblk0p5), format it,
and extract
the contents of boot.tar.xz to it.
As the root partition has want_maximised: true it would then create an ext4
partition
(/dev/mmcblk0p6) filling up the entirety of the rest of the extended partition,
format it, and
extract the contents of root.tar.xz to it.
This gives us the full partition layout shown in the table earlier.
It then runs the partition_setup.sh script which mounts these new partitions, and
edits files
(typically just cmdline.txt on the boot partition and /etc/fstab on the root
partition) to tell
Raspbian which partitions it got installed to.
And finally it updates the settings partition with details of the OS we just
installed.
--------------------------------------------------------------------------------
Primary partition Logical partition Type Label Contents
--------------------------------------------------------------------------------
1 FAT RECOVERY NOOBS boot files & initramfs, OS recovery images
2 extended Any logical partitions
5 FAT boot Raspbian boot files
6 ext4 root Raspbian root filesystem
3 ext4 SETTINGS NOOBS settings
---------------------------------------------------------------------------------
If instead we were installing Raspbian and ArchLinux then we might end up with
ArchLinux's boot
partition as /dev/mmcblk0p5, ArchLinux's root partition as /dev/mmcblk0p6,
Raspbian's boot
partition as /dev/mmcblk0p7 and Raspbian's root partition as /dev/mmcblk0p8.
As both Raspbian's and ArchLinux's partitions.json file specify one of their
partitions as want_maximised: true then we'd end up with two small boot partitions
and two
large-as-possible root partitions.
---------------------------------------------------------------------------------
Primary partition Logical partition Type Label Contents
---------------------------------------------------------------------------------
1 FAT RECOVERY NOOBS boot files & initramfs, OS recovery images
2 extended Any logical partitions
5 FAT boot ArchLinux boot files
6 ext4 root ArchLinux root filesystem
7 FAT boot1 Raspbian boot files
8 ext4 root1 Raspbian root filesystem
3 ext4 SETTINGS NOOBS settings
---------------------------------------------------------------------------------
To accommodate Win10IoT, the partition layout has changed from v1.5 onwards.
Instead of the SETTINGS partition being fixed on the 3rd primary partition, it is
now located in
the first logical partition within the extended partition. This would change the
above layout as follows:
---------------------------------------------------------------------------------
Primary partition Logical partition Type Label Contents
---------------------------------------------------------------------------------
1 FAT RECOVERY NOOBS boot files & initramfs, OS recovery images
2 extended Any logical partitions
5 ext4 SETTINGS NOOBS settings
6 FAT boot ArchLinux boot files
7 ext4 root ArchLinux root filesystem
8 FAT boot1 Raspbian boot files
9 ext4 root1 Raspbian root filesystem
---------------------------------------------------------------------------------
If the user isn't pressing the Shift key, and (using the information stored on the
settings partition)
NOOBS detects that only one bootable Operating System has been installed, it
automatically boots
that Operating System.
It does this by reading the settings partition to determine the boot partition for
that OS, and
then instructs the firmware to "soft-reboot" using the OS's boot partition. This
then 'reboots'
the firmware and loads start.elf from the specified partition
(typically /dev/mmcblk0p5 if only one OS is installed) and then proceeds the same
as the standalone
boot described at the very top of this page - start.elf loads kernel.img and reads
cmdline.txt,
and then kernel.img uses the command-line that was passed to it to determine which
partition
the root filesystem is stored on (typically /dev/mmcblk0p6 if only one OS is
installed), and loads
the rest of the system from there.
If instead multiple Operating Systems have been installed, NOOBS then displays the
OS-boot menu,
allowing the user to choose which OS(es) to boot. Boot menu Once the user has
selected an option
(or if the menu times out and defaults to the last-booted option) then the boot
proceeds as
described immediately above, with NOOBS using the information on the settings
partition to
determine which partition to "soft-reboot" as the boot partition.
--------------------------
Booting RISC OS within NOOBS
--------------------------
The one small caveat to the above is that RISC OS doesn't understand partition
tables,
and so it has to be installed to a specific partition at a specific offset.
This is what the riscos-boot.bin file is for, and why the RISC OS 'root' partition
is still stored
as a raw partition and not as a tarball.
However NOOBS handles all these details for you automatically, and it's still
possible to install
other OSes alongside RISC OS.
================================================================================
AZARTICOLO: uv4l : Tutorials for RaspberryPi
================================================================================
https://www.linux-projects.org/uv4l/tutorials/
Overview
Features
Installation for ARM (Raspberry Pi)
Installation for x86-64
Documentation
Tutorials
RESTful API
Manuals
uv4l core
uv4l-server
uv4l-raspicam
uv4l-uvc
uv4l-mjpegstream
uv4l-raspidisp
uv4l-xscreen
uv4l-dummy
Demos
Downloads
RPi VideoConference Demo OS
xmpp-bridge
TC++PL exercise solutions
Drivers
et61x251
sn9c10x
w996[87]cf
zc0301
Contacts
Tutorials
First of all, if you have never installed UV4L on Raspbian Wheezy or Raspbian
Jessie, do it by
following these instructions, otherwise upgrade UV4L to the latest version:
Below is a list of some examples of how to use the UV4L suite of modules in
combination with
some applications. To show you the complete examples, I will be assuming that you
have not
installed the recent uv4l-raspicam-extras optional package yet, which provides a
system service
that automatically loads all the installed uv4l modules at boot. Remember that, in
all the cases,
to eventually “unload” uv4l, it’s enough to kill the corresponding system process.
Almost all the examples have been originally tested on the (old) Raspberry Pi 1 and
Compute Module 1.
The Raspberry Pi 2 and greater can perform much better in all the cases where the
CPU would
be a bottleneck.
===================================================================================
=========
AZARTICOLO:Project List
===================================================================================
=========
https://rbnrpi.wordpress.com/project-list/
===================================================================================
========
AZARTICOLO:How to control GPIO pins and operate relays with the Raspberry Pi
===================================================================================
=========
https://opensource.com/article/17/3/operate-relays-control-gpio-pins-raspberry-pi
Learn how to operate relays and control GPIO pins with the Pi using PHP and a
temperature sensor.
Ever wondered how to control items like your fans, lights, and more using your
phone or
computer from anywhere?
I was looking to control my Christmas lights using any mobile phone, tablet,
laptop... simply
by using a Raspberry Pi. Let me show you how to operate relays and control GPIO
pins with
the Pi using PHP and a temperature sensor.
Hardware requirements
------------------------------------
Raspberry Pi
SD Card with Raspbian installed (any SD card would work, but I prefer to use a 32GB
class 10 card)
Power adapter
Jumper wires (female to female and male to female)
Router (for Internet access, you need to have a port-forwarding supported router)
10K-ohm resistor
Software requirements
-----------------------------------
1. Insert the SD card into Raspberry Pi and connect it to the router using an
Ethernet cable
vi /etc/network/interfaces
After opening the file in vi you will see a screen like this:
5. Press CTRL + O to save it, and then CTRL + X to exit the editor.
At this point, everything is configured and all you need to do is reload the
network interfaces
by running:
(Warning: if you are connected using a remote connection it will disconnect now.)
Software configurations
------------------------------------
Apache is a popular web server application you can install on the Raspberry Pi to
allow
it to serve web pages. On its own, Apache can serve HTML files over HTTP, and with
additional
modules it can serve dynamic web pages using scripting languages such as PHP.
To change this default page and add your own html file, go to var/www/html:
cd /var/www/html
Installing PHP
----------------------
PHP is a preprocessor, meaning this is code that runs when the server receives a
request
for a web page. It runs, works out what needs to be shown on the page, then sends
that
page to the browser. Unlike static HTML, PHP can show different content under
different
circumstances. Other languages are capable of this, but since WordPress is written
in PHP
it's what you need to use this time. PHP is a very popular language on the web,
with large
projects like Facebook and Wikipedia written in it.
Install the PHP and Apache packages with the following command:
Testing PHP
vi index.php
Save the file. Next, delete "index.html" because it takes precedence over
"index.php":
rm index.html
/etc/init.d/apache2 reload
/etc/init.d/apache2 restart
Installing WiringPi
----------------------------
WiringPi is maintained under git for ease of change tracking; however, you have a
plan
B if you’re unable to use git for whatever reason.
(Usually your firewall will be blocking you, so do check that first!)
If you do not have git installed, then under any of the Debian releases
(e.g., Raspbian), you can install it with:
If you get any errors here, make sure your Pi is up to date with the latest version
of Raspbian:
If you have already used the clone operation for the first time, then:
It will fetch an updated version, and then you can re-run the build script below.
cd wiringPi ./build
The new build script will compile and install it all for you. It does use the
command at one
point, so you may wish to inspect the script before running it.
Testing WiringPi
-------------------------
Run the gpio command to check the installation:
This should give you some confidence that it’s working OK.
Connect:
VCC to 3V Pin 1
GPIO wire to Pin 7 (GPIO 04)
Ground wire to any GND Pin 9
Software Configuration
For using DS18B20 temperature sensor module with PHP, you need to activate the
kernel module for the GPIO pins on the Raspberry Pi and the DS18B20 by executing
the commands:
modprobe w1-gpio
modprobe w1-therm
You do not want to do that manually every time the Raspberry reboots, so you want
to enable these modules on every boot. This is done by adding the following lines
to the file /etc/modules:
vi /etc/modules/
w1-gpio
w1-therm
cd /sys/bus/w1/devices/
You should see your device information. In the device drivers, your DS18B20 sensor
should be listed as a series of numbers and letters. In this case, the device is
registered as 28-000005e2fdc3. You then need to access the sensor with the cd
command, replacing my serial number with your own: cd 28-000005e2fdc3.
The DS18B20 sensor periodically writes to the w1_slave file, so you simply use the
cat command to read it: cat w1_slave.
This yields the following two lines of text, with the output t= showing the
temperature in degrees Celsius. Place a decimal point after the first two digits
(e.g., the temperature reading I received is 30.125 degrees Celsius).
1. Take two jumper wires and connect one of them to the GPIO 24 (Pin18) on the Pi
and the other one to the GND Pin. You may refer the following diagram.
2. Now connect the other ends of the wire to the relay board. Connect the GND to
the GND on the relay and GPIO Output wire to the relay channel pin number, which
depends on the relay that you are using. Remember the GND goes to GND on the relay
and GPIO Output goes to the relay input pin.
Headers
------------------
Caution! Be very careful with the relay connections with Pi because if it causes a
backflow of current, you with have a short circuit.
3. Now connect the power supply to the relay, either using 12V power adapter or by
connecting the VCC Pin to 3.3V or 5V on the Pi.
Let's create a PHP script to control the GPIO pins on the Raspberry Pi, with the
help of the WiringPi software.
1. Create a file in the Apache server’s root web directory. Navigate using:
cd ../../../
cd var/www/html/
mkdir Home
vi on.php
<?php
?>
5. Save the file using CTRL + O and exit using CTRL + X
In the code above, in the first line you've set the GPIO Pin 24 to output mode
using the command:
6. To turn off the relay, create another file called off.php and replace “1” with
“0.”
<?php
?>
7. If you have your relay connected to the Pi, visit your web browser and type in
the IP Address of your Pi followed by the directory name and file name:
http://{IPADDRESS}/home/on.php
http://{IPADDRESS}/home/off.php
Now you need to control both these things from a single page without refreshing or
visiting the pages individually. For that you'll use AJAX.
{ $('#Off').click(function(){
a.open("GET", "off.php");
a.onreadystatechange=function(){
if(a.readyState==4){
if(a.status ==200){
a.send();
});
});
</script>
10. Save the file, go to your web browser, and open that page.
You’ll see two buttons, which will turn lights on and off. Based on the same idea,
you can create a beautiful web interface using bootstrap and CSS skills.
vi temperature.php
2. Add the following code to it, replace 10-000802292522 with your device ID:
<?php
//File to read
$file = '/sys/devices/w1_bus_master1/10-000802292522/w1_slave';
//Read the file line by line
$lines = file($file);
//Get the temp from second line
$temp = explode('=', $lines[1]);
//Setup some nice formatting (i.e., 21,3)
$temp = number_format($temp[1] / 1000, 1, ',', '');
//And echo that temp
echo $temp . " °C";
?>
3. Go to the HTML file that you just created, and create a new <div> with the id
“screen”: <div id=“screen”></div>.
4. Add the following code after the <body> tag or at the end of the document:
<script>
$(document).ready(function(){
setInterval(function(){
$("#screen").load('temperature.php')
}, 1000);
});
</script>
In this, #screen is the id of <div> in which you want to display the temperature.
It loads the temperature.php file every 1000 milliseconds.
I have used bootstrap to make a beautiful panel for displaying temperature. You can
add multiple icons and glyphicons as well to make it more attractive.
This was just a basic system that controls a relay board and displays the
temperature. You can develop it even further by creating event-based triggers based
on timings, temperature readings from the thermostat, etc.
===================================================================================
=========
AZARTICOLO:LXDE on Raspberry Pi
===================================================================================
=========
The Raspbian image comes with LXDE as default desktop environment which is very
snappy
and responsive. It is fast, lightweight and includes many useful applications and
utilities by default.
However, in case you want some more variety or a more appealing desktop
environment,
then Xfce is a good alternative. It is also lightweight but with more customisation
features.
And the best of all: it is surprisingly easy to install and set it up as default.
That's it. Now reboot and when you are back open again a terminal session and type:
cat /root/.cache/lxsession/LXDE-pi/run.log
===================================================================================
========
AZARTICOLO:UPDATING AND UPGRADING RASPBIAN DOCUMENTAZIONE UFFICIALE
===================================================================================
========
First, update your system's package list by entering the following command in
LXTerminal or from the command line:
apt-get update
apt-get upgrade
Next, upgrade all your installed packages to their latest versions with the
command:
apt-get dist-upgrade
Generally speaking, doing this regularly will keep your installation up to date, in
that it will be
equivalent to the latest released image available from
raspberrypi.org/downloads.
However, there are occasional changes made in the Foundation's Raspbian image that
require manual
intervention, for example a newly introduced package.
These are not installed with an upgrade, as this command only updates the packages
you already
have installed.
The kernel and firmware are installed as a Debian package, and so will also get
updates when
using the procedure above. These packages are updated infrequently and after
extensive testing.
When running apt-get dist-upgrade, it will show how much data will be downloaded
and how much space it will take up on the SD card. It's worth checking with df -h
that
you have enough disk space free, as unfortunately apt will not do this for you.
Also be aware that downloaded package files (.deb files) are kept in
/var/cache/apt/archives.
apt-get clean.
===================================================================================
=========
Raspbian GNU/Linux upgrade from Jessie to Raspbian Stretch 9
===================================================================================
=========
Introduction
-------------------
Recommendations
--------------------------------
Warning:
--------------
From this reason it is important to backup all your current databases before you
proceed
with a Debian 9 Stretch upgrade!
REFERENCE: debian.org
Fully Upgrade Current System
Start by fully upgrade your current Raspbian system before you proceed with a
Stretch
upgrade.
# apt-get update
# apt-get upgrade
System Check
---------------------
Last, chance to check for any system inconsistencies.
Perform database sanity and consistency checks for partially installed, missing and
obsolete packages:
# dpkg -C
# apt-mark showhold
The above command will replace any Jessie keyword occurrence to Stretch thus
effectively
enabling new Stretch repositories.
# apt-get update
We have come to the most exciting part, which is the actual Jessie upgrade to
Raspbian
Stretch system. During the upgrade you may be asked:
There are services installed on your system which need to be restarted when certain
libraries, such as libpam, libc, and libssl, are upgraded.
Since these restarts may cause interruptions of service for the system, you will
normally
be prompted on each upgrade for the list of services you wish to restart.
You can choose this option to avoid being prompted;
instead, all necessary restarts will be done for you automatically so you can avoid
being
asked questions on each library upgrade.
The choice is about whether you wish the system to restart your services
automatically
during the system upgrade or you wish to do it manually or after the system is
fully upgrade
to Stretch.
When ready, execute the bellow commands to commence the Debian Stretch upgrade
process:
# apt-get upgrade
# apt-get dist-upgrade
===================================================================================
=========
AZARTICOLO: Tutorial – Install Nginx and PHP on Raspbian
===================================================================================
=========
This is the first in a three part tutorial series on how to install and run NGINX
on a Raspberry Pi.
The first concentrates on installing and configuring Nginx web server and PHP on
Raspbian OS,
the second talks about installing MySQL server on Raspberry Pi, the third will walk
you through
installing WordPress on Nginx.
For many, Apache2 has become too bloated, and uses more resources than it needs to.
Nginx is a very light-weight web server, that works great on a Raspberry Pi.
Prerequisites
Before doing this tutorial I assume that you are familiar with Terminal, and are
proficient and
comfortable in command line interface.
There we go, we’ve now got nginx installed. Next, we want to launch nginx and test
that it’s working ok.
Type the following command into the command line interface:
/etc/init.d/nginx start
If all goes well, you should see this message:
If you visit your Raspberry Pi’s IP address in your web browser, you should see the
default Nginx page,
which looks a little something like this:
Nginx on a Raspberry Pi
Great success! You now have Nginx running on your Raspberry Pi. Next, we’ll install
PHP.
The packages required for PHP to work with Nginx is a little different to those
when using PHP
with Apache2. PHP runs as a FastCGI interface, so we need to install the PHP FPM
package by
typing the following command:
You’re almost there. Similar to Apache2, Nginx works on a virtual hosts principle,
but is arguably
easier to configure multiple vhosts on Nginx. We’ll look at this in a later
tutorial.
Next, we’re going to adjust the default configuration to allow Nginx to start
serving content
using PHP. Begin by typing the following command:
vi /etc/nginx/sites-available/default
The vi editor will appear. If you’re more comfortable using VI, use this command
instead:
vi /etc/nginx/sites-available/default
Scroll down the configuration file until you find the ‘server’ block with the
following lines contained within it:
#listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
Uncomment them both out by removing the first #, so that they read like this:
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
This allows Nginx to listen on port 80 (the default http port) and listen for both
IPv4 and IPv6
requests. Next we need to edit the name of our server to match our domain. In my
care,
the domain is dingleberrypi.com but be sure to substitute this with your own domain
or IP address.
This allows files with the name index.php to be served up as the default index
page,
and takes priority over index.html and index.htm. Now we need to tell the
configuration
how to handle PHP files. Scroll down until you see this:
#location ~ .php$ {
# fastcgi_split_path_info ^(.+.php)(/.+)$;
# # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
#
# # With php5-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php5-fpm:
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# include fastcgi_params;
#}
Uncomment some of the lines so that it reads like this:
location ~ .php$ {
fastcgi_split_path_info ^(.+.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# # With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
Be careful to edit the correct lines. We’re using a socket, so uncomment the
configuration accordingly.
Finally, we need to change the PHP configuration to fix a possible security
vulnerability.
Type the following command to edit the PHP configuration file:
vi /etc/php5/fpm/php.ini
Scroll down (or search for the line using CTRL + W in nano) for:
;cgi.fix_pathinfo=1
Uncomment the line by removing the semicolon from the start, and change the value
from 1 to 0. Save and exit nano.
Configure PHP with Nginx on Raspberry Pi
All we need to do now is restart php5-fpm and nginx to make the configuration
changes take:
Now all that’s left to do is to test to ensure PHP and Nginx are correctly
configured. Navigate to the default document root:
cd /usr/share/nginx/www
Create a file called index.php:
vi index.php
Add the following line to the file, save and exit nano:
That’s it! We’ve installed, configured and tested PHP5 and Nginx. Grab a brew,
you’ve earned it! Any questions or comments, feel free to add them below.
Next, we’ll look at installing MySQL on Raspberry Pi and creating a new database
and database user for WordPress to use.
===================================================================================
=========
AZARTICOLO:Tutorial – Install MySQL server on Raspbian
===================================================================================
=========
================================================================================
AZARTICOLO:Tutorial – Install Apache, PHP and MySQL on a Raspberry Pi 2
================================================================================
uname -a
Linux raspy 4.4.13-v7+ #894 SMP Mon Jun 13 13:13:27 BST 2016 armv7l GNU/Linux
reboot
Aggiorna il dispositivo
------------------
Installa Apache2
-------------
http://localhost/
http://192.168.1.10
hostname -I
/var/www/html/index.html.
Nota: La home directory era /var/www in Raspbian Wheezy ma ora e' /var/www/html in
Raspbian Jessie
notare che tutti permessi su tale directory sono assegnati a root ma posso cambiare
proprietario:
chown pi: index.html
Esegui il comando:
Viene poi richiesta la master password per l'accesso al database da parte dell
utente corrente (root)
Tale utente sara' proprietario del database appena creato e che utilizzero' nei
programmi per
connettermia a tale database. Doniamo i diritti di accesso al database a tale
utente:
===================================================================================
=========
AZARTICOLO:Add virtual hosts and subdomains to your Raspberry Pi Apache2 server
===================================================================================
=========
https://www.stewright.me/2013/08/add-virtual-hosts-and-subdomains-to-your-
raspberry-pi-apache2-server/
Vediamo come ospitare piu' virtual server o piu' sottodomini sul servizio apache.
Si suppone di aver gia' eseguito l'intallazione di apache2 mysql server e client e
php
come indicato nell'articolo:
https://www.stewright.me/2012/09/tutorial-install-apache-php-and-mysql-on-
raspberry-pi/
vi /etc/apache2/envvars
vi /etc/apache2/sites-available/raspicam.conf
vi /etc/apache2/sites-available/raspicam.conf
vi motion/motion.conf
vi apache2/ports.conf
Step 1 – Create the sites available file for your domain or subdomain
----------------------------------------------------------
cp /etc/apache2/sites-available/default
/etc/apache2/sites-available/video.dingleberrypi.com
dove e' definita la document root insieme con molte altre informazioni
La riga :
ServerAdmin [email protected]
ServerName azmyweb.no-ip.org
ServerName video.dingleberrypi.com
<VirtualHost *:80>
ServerAdmin [email protected]
ServerName azmyweb.no-ip.org
DocumentRoot /var/www/html
<Directory /var/www/html>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn
‘/var/www/html’:
Change the sites-available fileMake a note of the directory, we’ll create it next.
Now press CTRL + X to quit, and save when prompted.
Per la directory indicata esiste di seguito una sezione che ne specifica i permessi
di accesso,
ma ne posso creare di ulteriori per eventuali sottodirectory della document root, e
che in quanto
tali dovranno essere specificate nella URL di accesso al sito
mkdir /var/www/html/vhosts/
Occorre settare i permessi in modo che root possa scrivere e gli altri leggere:
chmod -R 755 /var/www/html/vhosts
mkdir /var/www/vhosts/video.dingleberrypi.com/
chmod -R 755 /var/www/html/vhosts/video.dingleberrypi.com/
vi /var/www/html/vhosts/video.dingleberrypi.com/index.php
Replace the index.php file with your subdomain or virtual host, and that’s it.
Just in case you wondered what video is on my video.dingleberrypi.com it’s below!
===================================================================================
=========
AZARTICOLO: Tutorial – Install PhpMyAdmin on your Raspberry Pi
===================================================================================
=========
https://www.stewright.me/2012/09/tutorial-install-phpmyadmin-on-your-raspberry-pi/
Poi mi vine chiesta la password per PhpMySQL, utilizzate la stessa del database.
vi /etc/apache2/apache2.conf
Include /etc/phpmyadmin/apache.conf
Accesso a phpmyadmin:
http://192.168.1.4/phpmyadmin
http://192.168.1.5:8080/phpmyadmin
=================================================================================
AZARTICOLO: How to build a REST Web API on a Raspberry PI in JavaScript
=================================================================================
One of the most useful reasons for providing your Raspberry Pi with a REST API is
to expose its
inputs and outputs to a web client (on any iPhone, laptop or desktop PC anywhere in
the world)
for remote monitoring and/or control. This is part 1 of a 2 part blog showing how
to implement
a REST API in JavaScript.
What’s REST ?
-------------
In recent years, the Web has turned from a network of webservers serving mainly
static pages to web browsers…
…into a full client-server architecture, where single-page client web apps use AJAX
principles
to communicate with server-side applications, increasingly via simple but powerful
RESTful APIs.
With REST, the idea is that, rather than using complex mechanisms such as CORBA,
RPC or
SOAP to connect between clients and servers, simple HTTP queries are used.
RESTful applications use HTTP requests to POST data (create and/or update data),
GET data (make queries), and delete data on the server.
Thus, REST uses HTTP for all four CRUD (Create/Read/Update/Delete) operations.
AJAX is a popular web development technique that makes web pages interactive using
JavaScript.
In AJAX, requests are sent to the server using XMLHttpRequest objects.
The response is used by the JavaScript code to dynamically change the current page.
Each XMLHttpRequest can be viewed as a REST service request, sent using GET.
And the response is often in JSON format.
For example, if our client application wants to get the ISBN for a book the user
knows the title
of, we might send our API server an HTTP GET with the URL :
http://www.myapiserver.com/books/ISBN/Catch-22
Using jQuery we can implement this AJAX request in our client application simply
like this:
$.getJSON("http://www.myapiserver.com/books/ISBN/Catch-22", function(data) {
console.log("The ISBN for this book is "+data );
});
The HTTP reply our server sends back to the client is the raw result data — not
embedded inside
an HTML page, not XML-encoded, just the data you need in a way you can immediately
use –
a String or a JSON object you can use directly.
https://api.twitter.com/1/statuses/home_timeline.json?include_entities=true
in your browser. Because you haven’t included a key in your request, you will see
an authentication
error response in the browser window, encoded as a JSON object, which looks
something like this:
As you may have noticed in these examples, REST can easily handle more complex
requests, including multiple parameters. In most cases, you’ll just use HTTP GET
parameters in the URL.
For example, if we can only uniquely specify a book by both title and author, our
API might accept a request like this: “http://myapiserver/books/ISBN?title=Catch-
22&author=Heller”
As a convention, HTTP GET requests should be for read-only queries; they should not
change the state of the server and its data. For creation, updating, and deleting
data, use POST requests.
To install Node.JS on your Raspberry Pi, see my earlier Blog post HOW TO INSTALL
NODE.JS ON A RASPBERRY PI
On the Raspberry Pi, we need to use the Node Package Manager npm to download and
install the other modules we will need to build our web application. We will be
using the express web application framework module initially, and also the connect
module it depends on.
On your RPi, create a new directory for your project, and download the node modules
you’ll need as follows :
$ mkdir myapp
$ cd myapp
$ npm init
$ npm install express --save
$ npm install connect --save
Or use the -g flag if you prefer the package to be installed globally, i.e. in
/usr/local where node is installed, rather than in ./node_modules. To install
global packages, you need to use to execute with superuser priviledges.
The node package manager will download and install the express framework.
We’re now going to build an example client-server application using our Raspberry
Pi as the server.
To build this full REST example, we need to create three source files on our
Raspberry Pi: The server-side Javascript code, a simple HTML page, and some client-
side Javascript.
myapi.js – our server-side Javascript code uses the Node and the Express framework
to provide simplistic Web server functionality and to expose a RESTful API.
index.html – the HTML page which the browser loads from the Raspberry Pi and uses
to render the presentation layer for our application.
myclient.js – Javascript code executed in the browser when our HTML page loads.
This code implements the AJAX client functionality to call our API and render the
results directly in the HTML page.
Now create a file called myapi.js on your Pi and copy the code below to build a
simple server in
Javascript, which processes API requests on port 3000 with a JSON object.
(Port 3000 is the standard port most commonly used for an express server).
First we need to let Node know we will be using the http and express packages,
call express to create our application server as an object, and assign it to a
variable.
Then configure Express to serve index.html and any other static pages stored in the
home directory,
such as your myclient.js JavaScript source file
app.use(express['static'](__dirname ));
Next we need to define the API middleware for our server-side application.
We use express’s get function to define routes for the API calls and/or page
requests to our server.
app.listen(3000);
console.log('App Server running at port 3000');
INDEX.HTML: the homepage
Our web page simply displays a title, and sets up an input div as a placeholder
that will be used
by our client-side JavaScript code in myclient.js to display the I/O values
retrieved from our RPi.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>My Express API server example</title>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script src="myclient.js"></script>
</head>
<body>
<H1>My Express API server example</H1>
<div id="input"></div>
</body>
</html>
MYCLIENT.JS: the client-side code
this JavaScript code will be loaded and executed on the client machine when the
browser loads our HTML page. It makes 2 calls to our API server running on the
Raspberry Pi to retrieve and display the state of two inputs.
window.onload = function () {
var url,
i,
jqxhr;
You can also download the full source code (client, server and html) for this
example from github here https://github.com/fatkahawai/rpi-webapp-express
Create or download the three source files into a new folder on your RPi.
To start up your web server on your RPi , invoke your application with node, from
the folder you have saved the source files in.
$ node myapi.js
App Server running at port 3000
$
(Making sure that you have first installed the express module using npm, as already
described above.)
Your web server is now running continuously in the background, waiting for API
calls.
Finally, using another machine on the same local network, open a web browser and
navigate to your App Server hosted on the RPi.
If your RPi has the local IP address 192.168.0.22, you would enter this in your
browser:
http://192.168.0.22:3000
This will cause the browser to load your index.html file from your RPi, which then
loads your javascript client code in myclient.js.
What’s Next ?
--------------------
One of the most useful reasons for providing your Raspberry Pi with a RESTful API
is to
expose its input and output ports to web clients for remote monitoring and
control.
So in our next exercise, we will do just this, exposing the real GPIO I/O ports
through a
RESTful API, which will allow you to control your Pi’s inputs and outputs from any
smartphone
or PC wherever you are in the world.
Next
I hope this exercise has been useful. If you have any feedback or spot any errors
or omissions,
feel free to leave a note in the comments section below.
===================================================================================
=========
AZARTICOLO: How to Write and Run a C Program on the Raspberry Pi
===================================================================================
=========
In this brief tutorial, I’ll discuss what a C program is, what C programming is
used for,
and finally, how to write and run a C program on the Raspberry Pi.
What is a C Program?
-------------------
The C programming language is one of the most widely used programming languages of
all time.
It is computationally faster and more powerful than Python. C is a middle level
programming
language because of its low level of abstraction to assembly language. High level
languages provide
the programmer with constructs, or commands that make it easy to do certain tasks
like printing
to the computer monitor, or logic functions like and, or, and not. Low level
programming languages
only give you access to the machine’s basic instruction set. C does have some of
these useful constructs,
but not as many as higher level languages like Python.
.arch armv6
.eabi_attribute 27, 3
.eabi_attribute 28, 1
.fpu vfp
.eabi_attribute 20, 1
.eabi_attribute 21, 1
.eabi_attribute 23, 3
.eabi_attribute 24, 1
.eabi_attribute 25, 1
.eabi_attribute 26, 2
.eabi_attribute 30, 6
C is so widely used that it can be compiled for almost any system with minimal
changes to the source code.
The C language is available on a wide range of computer platforms including
personal computers,
embedded microcontrollers, and supercomputers.
Operating systems
Large programs
Databases
Desktop utilities
Language compilers
Text/photo editors
Network drivers
The intent of this article is to give a high level view of the main programming
languages used on
the Raspberry Pi. If you’re looking for in depth information on C programming, a
great book is the
de facto standard, The C Programming Language by Brian Kernighan and Dennis
Ritchie.
It’s a useful text for anyone currently using C, or anyone that wants to learn it.
The coding process in C consists of four steps:
To start, open the vi text editor with a new file by entering vi hello-world.c
at the command prompt. When you create the initial uncompiled text file where you
will save the C code,
it must have a “.c” extension. Now, enter this code into nano:
#include <stdio.h>
int main()
{
printf("Hello, World! \n");
return 0;
}
After entering the code, enter Ctrl-X to save and exit nano.
The -o myfirstcprogram part tells the compiler to take the source file (hello-
world.c) and output
another file (myfirstcprogram) that we can make executable.
Hope this helps you get a basic idea on how to get started programming in C on the
Raspberry Pi.
===================================================================================
=========
AZARTICOLO: IBEX:bcm2835 by Mike McCauley Programming in C/C++
===================================================================================
=========
http://www.raspberry-projects.com/pi/programming-in-c/io-pins/bcm2835-by-mike-
mccauley
In the commands below change the .XX to match the current library version number,
e.g. ".50".
If you are using the GUI then open the command prompt using Menu > Other >
LXTerminal
Using your RPi download the .tar.gz file from the library page to your "/home/pi/"
root directory.
You can do this using wget on the command line:
cd /home/pi/
wget http://www.airspayce.com/mikem/bcm2835/bcm2835-1.50.tar.gz
cd bcm2835-1.XX
./configure
make
make check
make install
#include <bcm2835.h>
When you compile you also need to include -lbcm2835 so the libraries object file is
added to the final compilation.
Right click the project > Properties > Build > Linker > In the 'Libraries' section
press the
'…' button > Add Option… > Other Option > Enter: -lbcm2835
#include <bcm2835.h>
When you compile you also need to include -lbcm2835 so the libraries object file is
added to the final compilation.
For example at the command line:
all: output_file_name
output_file_name: main.o
gcc main.o -lbcm2835 -o output_file_name
main.o: main.c
gcc -c main.c
clean:
rm -rf *o output_file_name
cd examples/blink
gcc -o blink -l rt blink.c -l bcm2835
./blink
If you connect the positive pin of a 5V LED to pin 11 of the P1 header it should be
blinking. Use CTRL+Break or CTRL+SHIFT+C to stop the exe.
Problems With The Library
//Setup
bcm2835_gpio_fsel(RPI_BPLUS_GPIO_J8_40, BCM2835_GPIO_FSEL_INPT); //RPI1B+ &
RPi2B <<Set as input
bcm2835_gpio_fsel(RPI_BPLUS_GPIO_J8_40, BCM2835_GPIO_FSEL_OUTP); //RPI1B+ &
RPi2B <<Set as output
bcm2835_gpio_set_pud(RPI_BPLUS_GPIO_J8_40, BCM2835_GPIO_PUD_UP); //RPI1B+ &
RPi2B <<Set pull up
//Outputs
#define LED_GREEN(state)
bcm2835_gpio_write(RPI_BPLUS_GPIO_J8_40, !state) //RPI1B+ & RPi2B
//Inputs
//bcm2835_gpio_lev returns uint8_t
#define SW_A_INPUT
bcm2835_gpio_lev(RPI_BPLUS_GPIO_J8_40) //RPI1B+ & RPi2B
RPi1 V2 (old)
//Outputs
#define LED_GREEN(state)
bcm2835_gpio_write(RPI_V2_GPIO_P1_24, !state)
#define LED_YELLOW(state)
bcm2835_gpio_write(RPI_V2_GPIO_P1_26, !state)
//Inputs
//bcm2835_gpio_lev returns uint8_t
#define SW_A_INPUT
bcm2835_gpio_lev(RPI_V2_GPIO_P1_03)
===================================================================================
=========
AZARTICOLO:C and Python implementation for RaspberryPi to detect movement using
PIR motion sensor (HC-SR501)
===================================================================================
=========
https://bhavyanshu.me/tutorials/raspberrypi-to-detect-movement-using-pir-motion-
sensor-hc-sr501/11/21/2014
git clone https://github.com/bhavyanshu/rPiExperiments.git
Overview
I recently bought a motion detection sensor HC-SR501. First, we will see how to
connect it to
our raspberry pi and then we will run the C code which helps us detect motion.
Once the movement has been detected, it will set LED to HIGH and play an audio
(.wav) file.
There are a lot of python implementations for it out there but if you are
interested in specifically
using C for this, then you have come to the right place.
Hardware
Breadboard
Jumper Wires
4.7K ohm resistor (If using +5 volt - PIN 2) else no resistor required,
if using +3.3V (PIN 1).
See diagram below.
HC-SR501
3.5 mm jack speaker/headphones (Optional, if you want sound)
Raspberry Pi (I am using model B revision 2)
We connect board pin number 1 (+3.3 V) to the VCC of the sensor, pin number 6 for
GND and
finally pin number 7 as data input from the sensor to raspberry pi.
PIR sensors work by detecting a change in the infrared radiation level in the
detection region.
So when there is no movement, the digital out pin on the sensor will remain LOW but
as soon as
there is a movement in the detection range, it will go HIGH and our Raspberry Pi
will be able to
sense this change when we run our C program.
Next we connect anode of LED to pin number 11 and cathode to GND.
Look at the figure below to understand the connections.
It may not be the best diagram ever but this is all I have for now.
PIR
pir.c file :
---------
/**
* Program for PIRsensor. Detects movement and activates connected LED
* for 2 seconds.
* Connect on board pin number 07 to Sensor, 11 to LED
* - Refer RPiGPIOPin section of
* http://www.airspayce.com/mikem/bcm2835/group__constants.html
*/
#include <bcm2835.h>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
$ wget http://www.open.com.au/mikem/bcm2835/bcm2835-1.5.tar.gz
$ tar zxvf bcm2835-1.5.tar.gz
$ cd bcm2835-1.5
$ ./configure
$ make
$ make check
$ make install
and then compile the pir.c using
gcc pir.c -o pir -l bcm2835
To run it, use
./pir
It has to be run as root for it to be able to access hardware.
# Info - This program is for PIR sensor. Contionusly checks for state,
# set LED if movement detected and plays wav file on detection.
pygame.mixer.init()
pygame.mixer.music.load("beep.wav")
PIR = 7 # On-board pin number 7 (GPIO04)
LED = 11 # On-board pin number 11 (GPIO17)
state = False
val = False
try:
while True:
val = GPIO.input(PIR) # read input value
if (val == True): # check if the input is HIGH
GPIO.output(LED, True) # turn LED ON
if (state == False):
# ON
pygame.mixer.music.play()
state = True
else:
GPIO.output(LED, False) # turn LED OFF
if (state == True):
# OFF
time.sleep(2)
state = False;
except KeyboardInterrupt:
GPIO.cleanup()
===================================================================================
=========
AZDIET
===================================================================================
========
================================================================================
AZARTICOLO:INSTALLING OPERATING SYSTEM IMAGES ON LINUX
================================================================================
https://www.raspberrypi.org/documentation/installation/installing-images/linux.md
Etcher is typically the easiest option for most users to write images to SD cards,
so it is a good
place to start. If you're looking for more advanced options on Linux, you can use
the standard
command line tools below.
Note: use of the dd tool can overwrite any partition of your machine.
If you specify the wrong device in the instructions below, you could delete your
primary
Linux partition. Please be careful.
If your computer has a slot for SD cards, insert the card. If not, insert the card
into an SD
card reader, then connect the reader to your computer.
Run df -h again.
The naming of the device will follow the format described in the next paragraph.
Note that if the SD card was not automounted, you do not need to unmount later.
The left column of the results from df -h command gives the device name of your SD
card.
It will be listed as something like /dev/mmcblk0p1 or /dev/sdX1, where X is a
lower case
letter indicating the device. The last part (p1 or 1 respectively) is the partition
number.
You want to write to the whole SD card, not just one partition.
You therefore need to remove that section from the name.
You should see something like /dev/mmcblk0 or /dev/sdX as the device name for the
whole SD card. Note that the SD card can show up more than once in the output of
df.
It will do this if you have previously written a Raspberry Pi image to this SD
card, because
the Raspberry Pi SD images have more than one partition.
Now you have noted the device name, you need to unmount it so that files can't be
read
or written to the SD card while you are copying over the SD image.
Run umount /dev/sdX1, replacing sdX1 with whatever your SD card's device name is,
including the partition number.
If your SD card shows up more than once in the output of df, this shows that the
card has
multiple partitions. You should unmount all of these partitions.
In a terminal window, write the image to the card with the command below, making
sure
you replace the input file if= argument with the path to your .img file, and
the /dev/sdX
in the output file of= argument with the correct device name. This is very
important,
as you will lose all the data on the hard drive if you provide the wrong device
name.
Make sure the device name is the name of the whole SD card as described above, not
just
a partition. For example: sdd, not sdds1 or sddp1, and mmcblk0, not mmcblk0p1.
dd bs=4M if=2017-04-10-raspbian-jessie.img of=/dev/sdX
Please note that block size set to 4M will work most of the time.
If not, try 1M, although this will take considerably longer.
Also note that if you are not logged in as root you will need to prefix this with .
In Linux it is possible to combine the unzip and SD copying process into one
command,
which avoids any issues that might occur when the unzipped image is larger than
4GB.
This can happen on certain filesystems that do not support files larger than 4GB
(e.g. FAT),
although it should be noted that most Linux installsations do not use FAT and
therefore
do not have this limitation.
By default, the dd command does not give any information about its progress, so it
may
appear to have frozen. It can take more than five minutes to finish writing to the
card.
If your card reader has an LED, it may blink during the write process.
To see the progress of the copy operation, you can run the dd command with the
status option.
If you are using an older version of dd, the status option may not be available.
You may be able to use the dcfldd command instead, which will give a progress
report
showing how much has been written.
After dd has finished copying, you can check what has been written to the SD card
by
dd-ing from the card back to another image on your hard disk; truncating the new
image
to the same size as the original; and then running diff (or md5sum) on those two
images.
If the SD card is bigger than the original image size, dd will make a copy of the
whole card.
We must therefore truncate the new image to the size of the original image.
Make sure you replace the input file if= argument with the correct device name.
diff should
report that the files are identical.
================================================================================
AZARICOLO:INSTALLING OPERATING SYSTEM IMAGES
================================================================================
https://www.raspberrypi.org/documentation/installation/installing-images/README.md
We recommend most users download NOOBS, which is designed to be very easy to use.
However, more advanced users looking to install a particular image should use this
guide.
Official images for recommended operating systems are available to download from
the
Raspberry Pi website Downloads page.
If you're not using Etcher (see below), you'll need to unzip .zip downloads to get
the image file (.img) to write to your SD card.
Note: the Raspbian with PIXEL image contained in the ZIP archive is over 4GB in
size and uses the ZIP64 format.
To uncompress the archive, a unzip tool that supports ZIP64 is required.
The following zip tools support ZIP64:
7-Zip (Windows)
The Unarchiver (Mac)
Unzip (Linux)
You will need to use an image writing tool to install the image you have downloaded
on your SD card.
Etcher is a graphical SD card writing tool that works on Mac OS, Linux and Windows,
and is the easiest option for most users. Etcher also supports writing images
directly from the zip file,
without any unzipping required. To write your image with Etcher:
Download Etcher and install it.
Connect an SD card reader with the SD card inside.
Open Etcher and select from your hard drive the Raspberry Pi .img or .zip file you
wish to write to the SD card.
Select the SD card you wish to write your image to.
Review your selections and click 'Flash!' to begin writing data to the SD card.
For more advanced control of this process, see our system-specific guides:
Linux
Mac OS
Windows
================================================================================
AZARTICOLO:CONNESSIONE AD ARDUINO
================================================================================
https://oscarliang.com/raspberry-pi-and-arduino-connected-serial-gpio/
https://oscarliang.com/raspberry-pi-arduino-connected-i2c/
https://oscarliang.com/connect-raspberry-pi-and-arduino-usb-cable/
================================================================================
AZARTICOLO: House-Monitoring Framework with Arduino and Raspberry Pi: The Paranoid
App
================================================================================
http://www.allaboutcircuits.com/projects/house-monitoring-framework-with-arduino-
and-raspberry-pi/
June 03, 2016 by Cezar Chirila
So you have a Raspberry Pi and an Arduino and you want to develop a system to
monitor and
control your home. If I'm reading your mind correctly, after you're done reading
this article you
will be able to do exactly what you want.
There are plenty of articles on the internet, but most are either too basic or they
even skip some
of the steps. I will guide you through every step and make sure that you don’t run
into any known problems.
Introduction
-----------
First of all, why would you want to use an Arduino and a Raspberry Pi together?
The Pi has GPIOs that are great for simple Boolean tasks (On or Off) and for
reading a cheap
temperature sensor. Is that enough? No! For more complex systems, you will want to
use a
microcontroller to do the heavy work. It has an ADC with multiple channels
(Analog to Digital converter), PWM (Pulse Width Modulation) channels, and very
accurate timing.
For example, if you want to measure the electric energy consumption of your house,
you need a
current transformer and a basic circuit that will output a voltage that you can
measure using the
ADC. If you want to output something in between 1 and 0, let’s say to fade an LED,
you would
use the PWM outputs. Finally, you need a microcontroller if you need something with
very precise
timing like a PID system, multiplexing an LED array, or controlling a stepper
motor. In our case,
we will be using the Arduino Uno as the microcontroller.
Arduino Uno (Though you can use a different Arduino product if you wish.)
Raspberry Pi (I used a Pi Zero, but any will work.)
Raspberry Pi power supply
SD Card with Raspbian installed (The Raspbian Lite is ok, too.)
Sensors and other modules for the Arduino (This will be based on what you'd like to
accomplish.)
Basic knowledge of Arduino IDE, Raspbian, C/C++, HTML, and javascript
(Don't worry. If you already know C/C++, that'll be enough.)
The schematic is not very complicated and it varies depending on what you want to
achieve.
In this example, I used a temperature/humidity sensor and an LED.
Arduino Code
-----------------------
For the sake of simplicity, I will only show you here how to read temperature and
humidity from
a DHT11 sensor and how to remote blink an LED. For your actual project, you will
want something
more complex as this can be done with just a Raspberry Pi. In case you do want to
start with this,
here is the schematic:
Let’s start with the basics. The data is sent over the serial port at a baud rate
of 9600.
In the main function, we read the serial port and we check what we receive.
If we receive the string “thl”, it means that we need to send the data from the
sensors over
the serial port. For this function to work properly we use a while loop and send
the data over and
over again until we receive an “ok” to know that the data has reached the server.
If we receive the string “led”, we just blink the LED. Here you can add any
function and string
you want just remember to use “thl” for sending data.
What you need to know is that we send data in JavaScript Object Notation (JSON)
form.
JavaScript Object Notation is an open-source format to transmit data objects.
We use this because we can easily use this data within the main.html file using
javascript.
To use it, we will need a library called ArduinoJson which you can find here or
download below.
The function “send_data()” does as its name implies: It sends the data over the
serial port in
JSON form. To add data, you just need to add a line inside this function that looks
like this :
root["name_of_data"] = function_that_returns_data();
int function_that_return_data()
{
int data;
//insert code that reads data from a sensor and attributes the value to
variable 'data'
return (data);
}
That is all for the Arduino part. Below you can see the exact code that I have
written for this
particular case with the DHT11 sensor and the LED.
#include "ArduinoJson.h"
#include "dht.h"
void setup()
{
Serial.begin(9600);
}
void loop()
{
String str;
str = Serial.readString(); //Read serial
str.toLowerCase(); //Convert to lowercase
if (str == "thl")
do
{
str = Serial.readString(); //Read the serial again
send_data(); //Call send data function
} while (str != "ok"); //Continue to send data until we receive an "ok"
if (str == "led")
{
digitalWrite(LED_PIN, HIGH); // turn the LED on (HIGH is the
voltage level)
delay(1000); // wait for a second
digitalWrite(LED_PIN, LOW); // turn the LED off by making the
voltage LOW
}
}
void send_data()
{
StaticJsonBuffer<200> jsonBuffer;
JsonObject& root = jsonBuffer.createObject();
root["temp"] = get_temperature();
root["humidity"] = get_humidity();
root.printTo(Serial);
Serial.println();
}
apt-get update
apt-get upgrade
We want to install NGINX, PHP, and git (optional, but makes your life easier).
When asked, type ‘y’ and press enter.
Now, we need to change the default NGINX directory and make it work with PHP.
cd /etc/nginx
vi sites-enabled/default
server {
listen 80; ## listen for ipv4; this line is default and implied
listen [::]:80 default_server ipv6only=on; ## listen for ipv6
root /var/www;
index index.html index.php;
# Make site accessible from http://localhost/
server_name _;
location / {
index index.html index.php;
# First attempt to serve request as file, then as
# directory, then fall back to the CMS.
try_files $uri $uri/index.html;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
allow ::1;
deny all;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi.conf;
}
}
cd /var/www
vi test.php
<?php
phpinfo();
?>
If you see a page with PHP info like the one below, then it works and you should
proceed to the next step.
If it does not work, then read this part again and check to see if you did
something wrong.
The last step is to input this code to allow the user www-data, which is the user
that NGINX uses, to access the serial port.
Website Files
------------
You can manually download the files and put them into /var/www or you can execute
this command
and automatically download them from github:
cd /var/www
git clone https://github.com/alexonaci/Paranoid/tree/AAC
Now that we have the files, let’s examine them for a moment.
Just so you know, we are using bootstrap to model our website so that it is mobile-
compatible and looks good.
/img folder: Contains thumbnails and the background image for the index page
ArduinoCode.ino: The file that contains the Arduino sketch
PhpSerial.php: A library for PHP allowing us to communicate over serial with the
Uno using PHP
Style.css: The CSS for the page
Main.html: The most important page that contains the javascript, the buttons, and
the visual data
Relay.php: The file which initiates communication with the Arduino
You only need to worry about the main.html page; leave the rest as they are. Sure,
if you want,
you can customize them to your liking— it’s your project after all.
I will explain here how to add items. To add a new button, just add this line:
Thumbnail_Image is the path to the image you want to use as the thumbnail
(remember to place it in the /img folder). Name_action is the name that you want to
pick for your button.
You can check the types of buttons you can use here.
Navigate to the bottom of the file where you can see the line "$("#led-
button").click(blinkLED);" and add below it:
$("#Name_action").click(Function_Name);
function Function_Name ()
{
$.get(url + "Parameter")
}
“Parameter” is the string that it will be sent to your Arduino over serial when you
press the button.
It needs to be associated with a function inside the sketch. We talked about this
in the “Arduino Code” chapter.
To add a new item on the screen that will show a value that the Arduino sends, like
sensor data, add this type of item :
Where "Display_data" is the name that will appear before the data, such as
"temperature:",
and DataID is the identifier.
$("#DataID").html(parsedJSON.name_of_data);
Where “name_of_data” is the string that you have chosen for the data in the Arduino
Code section.
There is a function that will call this function every 10 seconds and that is it.
setInterval(getLuminosityTemperatureHumidity,10000);
All there is left is for me to explain to you is how the relay.php script works.
It is open every time a function like “getLuminosityTemperatureHumidity()” calls.
In order to work, it uses the PhpSerial library. The first 8 lines that start with
"$serial->" are
to establish a serial connection to your Arduino.
ATTENTION! Every time this script is executed, the Arduino will reset.
If you do not wish for this to happen, simply connect a 10uF capacitor with the
negative pin to
GND and positive pin to RESET.
Now that we've gotten that out of the way, let's continue.
The "sleep(2);" line is needed because the Arduino is unresponsive for the first
few moments
when we open the serial connection. After that we send the parameter that we
received
via GET method, "$_GET["command"]", to the Arduino, and if that command is "thl" we
read
incoming data from the microcontroller. After the data has been received, we send
an "ok" and
return the data. That's it.
Here is how your project should look after following these steps:
Debugging
--------
If you are having trouble, such as not receiving data, the easiest place to start
debugging is right
in your browser. You need to be using Chrome for these instructions:
Just press F12, go to the Network tab, click on it, press F5 to refresh and click
on
"relay.php?command=thl". If everything works, the data should appear like in the
screenshot below:
Enjoy your house monitoring system. If you have any questions, please put them in
the comments
section and I will do my best to help you.
=================================================================================
AZARTICOLO:Decode 433 MHz signals w/ Raspberry Pi & 433 MHz Receiver
=================================================================================
http://www.princetronics.com/how-to-read-433-mhz-codes-w-raspberry-pi-433-mhz-
receiver/
This post will show you how to read 433 MHz codes using a Raspberry Pi.
This tutorial was made to complement the Voice Controlling project which needed 433
MHz
Unit Code Values to control the wireless switches.
If you want to know how to read 433 MHz codes using an Arduino, go to this post!
I learned how to do this by reading this post. So credit goes to Paul Pinault for
making this project a reality.
Contents [hide]
1 Hardware Requirements
2 Installing WiringPi
3 Installing 433Utils
4 Connecting the 433 MHz receiver
5 Running the code
Hardware Requirements
Raspberry Pi(I used a Raspberry Pi Rev.2)
433 MHz receiver(Any type of 433 Mhz receiver should work, but for this tutorial I
used a 4 pin variant)
A breadboard
Some jumper wires
A 433 MHz transmitter(I used a 4 channel 433 MHz transmitter Remote)
Installing WiringPi
---------------
WiringPi is needed to control the pins on the Raspberry Pi. Which will be connected
to the 433 MHz Receiver.
To install WiringPi, SSH into your Raspberry Pi or open up a console, then run
these commands:
cd ~/
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
cd ~/
git clone git://git.drogon.net/wiringPi
cd wiringPi
./build
After running the last command, WiringPi should be installed!
Installing 433Utils
---------------
433Utils is made by GitHub user wolfeidau.
He gathered a bunch of code and wrote some himself, all about 433 MHz Radio
Transmissions,
then made a repo of it.
cd ~/
git clone git://github.com/ninjablocks/433Utils.git
cd 433Utils/RPi_utils
make
cd ~/
git clone git://github.com/ninjablocks/433Utils.git
cd 433Utils/RPi_utils
make
Now 433Utils should be installed!
As you can see in the picture, my 433 MHz receiver actually has two Data-pins.
Why it has two pins I don’t exactly know, but a possibility is it is used to easily
connect
two output-sources, or two different Arduinos.
In this project however we will only need to use one of the pins.
I used the one closest to the GND-pin.
If anybody knows why it has two Data-pins, let me know in the comments!
The code we will be running will be speaking out to the GPIO2 pin, according to
this site,
GPIO2 is GPIO pin 21 on Rev.1, or GPIO pin 27 on Rev.2
GPIO-Pins-Layout
Basically the connection between the receiver and Raspberry Pi can be described
with a table.
Here is how the connection looks like to me, I’m using a breakout board and a
breadboard.
rpi433Sniffer
To start listening for the 433 MHz codes, start the RFSniffer program we got from
433Utils,
using this command.
~/433Utils/RPi_utils/RFSniffer
I used a simple 4 channel 433 MHz Remote to send some 433 MHz codes to my receiver.
remote
Now bring your 433 MHz transmitter remote VERY close to your receiver, and press
some buttons.
The range of the receiver is not very far on the Raspberry Pi, so make sure you
bring the remote
as close as you can.
The received codes should print out as you press the buttons on the remote.
I’m using terminal and for me it looks like this:
RFSniffer
Pressing the buttons on my transmitter prints out values ranging between 16738081-
16738088.
Congrats, you now know how to print out 433 MHz codes using your Raspberry Pi & 433
MHz Receiver!
If you have any questions feel free to ask me by using the Contact page or by
commenting below.
===================================================================================
=======
AZARTICOLO:RASPBERRY PI AND ARDUINO CONNECTED USING I2C
===================================================================================
=======
https://oscarliang.com/raspberry-pi-arduino-connected-i2c/
Share this:
Facebook37GoogleTwitterReddit
With Raspberry Pi and I2C communication, we can connect the Pi with single or
multiple Arduino boards. The Raspberry Pi has only 8 GPIO’s, so it would be really
useful to have additional Inputs and outputs by combining the Raspberry Pi and
Arduino.
There are many ways of Linking them such as using USB cable and Serial Connection.
Why do we choose to use I2C? One reason could be it does not use your serial, USB
on the Pi. Given the fact that there are only 2 USB ports, this is definitely a big
advantage. Secondly, flexibility. You can easily connect up to 128 slaves with the
Pi. Also we can just link them directly without a Logic Level Converter.
In this article I will describe how to configure the devices and setup Raspberry Pi
as master and Arduino as slave for I2C communication. Article1 and Article2 if you
don’t know what is I2C.
In the next article I will be doing some Voice Recognition, if you are interested
see here Raspberry Pi Voice Recognition Works Like Siri
The Raspberry Pi is running at 3.3 Volts while the Arduino is running at 5 Volts.
There are tutorials suggest using a level converter for the I2C communication. This
is NOT needed if the Raspberry Pi is running as “master” and the Arduino is running
as “slave”.
The reason it works is because the Arduino does not have any pull-ups resistors
installed, but the P1 header on the Raspberry Pi has 1k8 ohms resistors to the 3.3
volts power rail. Data is transmitted by pulling the lines to 0v, for a “high”
logic signal. For “low” logic signal, it’s pulled up to the supply rail voltage
level. Because there is no pull-up resistors in the Arduino and because 3.3 volts
is within the “low” logic level range for the Arduino everything works as it
should.
Raspberry-PI-I2c-Arduino-connected
Remember though that if other I2C devices are added to the bus they must have their
pull-up resistors removed. For more information, see here.
These are the images showing where the I2C pins are on the Raspberry Pi and
Arduino.
Note that the built-in pull-up resistors are only available on the Pi’s I2C pins
(Pins 3 (SDA) and 5 (SCL), i.e. the GPIO0 and GPIO1 on a Rev. 1 board, GPIO2 and
GPIOP3 on a Rev. 2 board:
On the Arduino Uno, the I2C pins are pins A4 (SDA) and A5 (SCL), On the Arduino
Mega, they are 20 (SDA), 21 (SCL)
For information about the Arduino I2C Configuration and for other models of
Arduino, check out this documentation Wire library.
I will describe the process briefly here, if you are in doubt please refer to a
more detailed process here and here.
$ cat /etc/modprobe.d/raspi-blacklist.conf
# blacklist spi and i2c by default (many users don't need them)
blacklist spi-bcm2708
#blacklist i2c-bcm2708
Load i2c.dev in Module File
Add this to the end of /etc/modules
i2c-dev
Install I2C Tools
$ adduser pi i2c
Now reboot the RPI. After that you should see the i2c devices:
pi@raspberrypi ~ $ ll /dev/i2c*
crw-rw---T 1 root i2c 89, 0 May 25 11:56 /dev/i2c-0
crw-rw---T 1 root i2c 89, 1 May 25 11:56 /dev/i2c-1
Now we run a simple test, scan the i2c bus:
pi@raspberrypi ~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Hint: if you’re using the first revision of the RPI board, use “-y 0″ as parameter.
The I2C bus address changed between those two revisions.
Install Python-SMBus
This provides I2C support for Python, documentation can be found here.
Alternatively, Quck2Wire is also available.
Load this sketch on the Arduino. We basically define an address for the slave (in
this case, 4) and callback functions for sending data, and receiving data. When we
receive a digit, we acknowledge by sending it back. If the digit happens to be ‘1’,
we switch on the LED.
This program has only been tested with Arduino IDE 1.0.
[sourcecode language=”cpp”]
#include <Wire.h>
void setup() {
pinMode(13, OUTPUT);
Serial.begin(9600); // start serial for output
// initialize i2c as slave
Wire.begin(SLAVE_ADDRESS);
// define callbacks for i2c communication
Wire.onReceive(receiveData);
Wire.onRequest(sendData);
Serial.println(“Ready!”);
}
void loop() {
delay(100);
}
while(Wire.available()) {
number = Wire.read();
Serial.print(“data received: “);
Serial.println(number);
if (number == 1){
if (state == 0){
digitalWrite(13, HIGH); // set the LED on
state = 1;
}
else{
digitalWrite(13, LOW); // set the LED off
state = 0;
}
}
}
}
[/sourcecode]
I have written this testing program in Python. This is what it does: the Raspberry
Pi asks you to enter a digit and sends it to the Arduino, the Arduino acknowledges
the received data by send the exact same number back.
In the video, I used a built-in programming tool called “IDLE” in Raspberry Pi for
compiling.
[sourcecode language=”python”]
import smbus
import time
# for RPI version 1, use “bus = smbus.SMBus(0)”
bus = smbus.SMBus(1)
def writeNumber(value):
bus.write_byte(address, value)
# bus.write_byte_data(address, 0, value)
return -1
def readNumber():
number = bus.read_byte(address)
# number = bus.read_byte_data(address, 1)
return number
while True:
var = input(“Enter 1 – 9: “)
if not var:
continue
writeNumber(var)
print “RPI: Hi Arduino, I sent you “, var
# sleep one second
time.sleep(1)
number = readNumber()
print “Arduino: Hey RPI, I received a digit “, number
print
[/sourcecode]
For more read/write functions, check out this useful look up table for the
functions.
Finally, we need to connect the Raspberry Pi and Arduino on the I2C bus. Connection
is easy:
RaspberryPI-I2c-Arduino
pi@raspberrypi ~ $ i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- 04 -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
That’s the end of this article, for results, please see video on top. From here,
you can add sensors to the Arduino, to send data back to the Raspberry. Or have
servos and motors on the Arduino that can be controlled from the Raspberry Pi. It’s
just Fun.
Updates: 07/07/2013
Someone messaged me asking how to use logic level converter for i2c connection
between Raspberry Pi an d Arduino. I happen to have a spare Logic Level converter,
so I gave it a go.
But the result was a little weird. The data successfully sent to the Arduino, and
the data was also received successfully from the Arduino on the Pi, but the data
was wrong at the raspberry pi side.
Related
Raspberry Pi and Arduino Connected Over Serial GPIO
Raspberry Pi and Arduino Connected Over Serial GPIO
21st May 2013
In "Electronics"
Connect Raspberry Pi and Arduino with Serial USB Cable
Connect Raspberry Pi and Arduino with Serial USB Cable
20th May 2013
In "Electronics"
Raspberry Pi Face Recognition Using OpenCV
Raspberry Pi Face Recognition Using OpenCV
9th June 2013
In "Electronics"
Posted in Electronics, Featured, Raspberry Pi and tagged arduino, raspberry pi on
25th May 2013. 97 Replies
Post navigation← Raspberry Pi and Arduino Connected Over Serial GPIORaspberry Pi
Voice Recognition Works Like Siri →
97 thoughts on “Raspberry Pi and Arduino Connected Using I2C”
Michael
===================================================================================
=======
AZARTICOLO:COME TRASFORMARE LA NOSTRA RASPBERRY PI3 CON UNA SEMPLICE WEBCAM
IN UN SERVIZIO STREAMING LOCALE
===================================================================================
=======
Prima cosa installiamo sulla nostra raspberry i programmi che utilizzeremo per
lo streaming con i seguenti comandi:
Andiamo a cambiare stato di default del nostro demone motion scrivendo il comando:
$ vi /etc/default/motion
in “start_motion_daemon yes“
$ vi /etc/motio/motion.conf
E modifichiamo:
Per fermarlo:
$ motion stop
$ service motion stop
Infine aprimao il web browser aggiungendo :8081 alla fine dell’indirizzo IP della
nostra raspberry ( se non siete in grado di individuarlo, basta lanciare il
comando:
ifconfig)
es. 192.168.0.108:8081
Ricerca per:
Cerca …
ARTICOLI RECENTI
================================================================================
AZARTICOLO:SERVER MQTT CON RASPBERRY PI 3
================================================================================
http://www.robot-domestici.it/idea/?p=252
https://github.com/fabaff/mqtt-panel
Cattura
------------
-UTENTI LINUX: potete divertirvi dal terminale col comando dd oppure utilizzare
Unetbootin
UNetbootin
---------------
(Ci vorrà del tempo, dipende dalla classe della SD e dal vostro computer).
adesso incominciamo a configurare il nostro server.
digitare
apt update && apt upgrade && apt dist-upgrade && apt install mosquitto
aprire il file
vi /etc/network/interfaces
vi /etc/mosquitto/mosquitto,conf
pid_file /var/run/mosquitto.pid
persistence true
persistence_location /var/lib/mosquitto/
log_dest file /var/log/mosquitto/mosquitto.log
include_dir /etc/mosquitto/conf.d
crontab -e
poi premere sul 2 ed alla fine del file scrivere quanto segue.
reboot -h now
WhatsApp is one of the most popular messaging apps and you can use it with the
Raspberry Pi.
The Yowsup Python library enables you to use your WhatsApp account to exchange
messages with your contacts.
After the novelty of messaging your friends from the Raspberry Pi wears off, you
can use the Yowsup library to monitor and control the Pi by sending messages via
WhatsApp.
Before you can install the Yowsup library, fetch its dependencies with:
Then use:
to download the library under the current directory, and install it with:
$ cd yowsup
Once the library has been installed, it's time to register your mobile number with
WhatsApp.
In the yowsup directory, create a file called mydetails with the following:
$ vi mydetails
cc=44
phone=447712345678
--requestcode sms
After a few seconds, you should receive an SMS on the phone with the SIM card for
the number
you've entered in the mydetails file. The message contains a six-digit code.
Use this to register the phone number with WhatsApp:
xxx-xxx
Replace xxx-xxx with your code. After a second or two, you'll receive a response
from WhatsApp
on the Pi that will look something like this:
status: ok
kind: free
pw: jK0zdPJ9zz0BBC3CwmnLqmxuhBk=
price: 0.89
price_expiration: 1434674993
currency: EUR
cost: 0.89
expiration: 1463544490
login: 448375972334
type: new
The only bit of information we're interested in is the password mentioned with the
pw variable.
Copy it and paste it in the mydetails file, which should now read:
cc=44
phone=447712345678
password=jK0zdPJ9zz0M8G3CwmnLqmxuhBk=
That's all there's to it. The Yowsup library includes a demo application, which you
can use to
send and receive messages. Bring it up with:
This brings up the Yowsup command line client. Type /help to see all the available
commands.
The [offline] prompt indicates that you aren't connected to the WhatsApp servers.
Use the /L command, which picks up the authentication information from the
mydetails file and
connects to the server.
You can now send messages to other WhatsApp users. To send a message to
449988776655 enter:
/message send 449988776655 "Hiya mate, I'm sending this from the Raspberry Pi!"
The real advantage of the Yowsup library is that it can be used to invoke actions
on the Raspberry Pi, so for example you can send a WhatsApp message to check
certain details on the Raspberry Pi, such as its disk space or temperature, then
maybe update it or shut it down.
You can also use it to influence the GPIO pins and control any connected
peripherals – a door, for example. You can use the Python script in Listing 1 to
interact with the Raspberry Pi. The script listens to messages from a certain
predefined number, recognises certain keywords and responds accordingly.
Advertisement
----------------------
So if you send something like 'Hiya Pi', it greets you back. If it receives a
message that begins
with 'memory', the Raspberry Pi executes the df -h . command and messages you the
results.
$ wget http://www.mascal.it/public/wasend.py
$ wget http://www.mascal.it/public/wareceive.py
In the same directory, create a file called pitalk.py with the contents of Listing
2
(which again can be found here). Now create a shell script called talktome.sh that
calls the
pitalk.py Python script:
$ vi talktome.sh
#!/bin/bash
while :
do
python /home/pi/yowsup/pitalk.py
done
Now make it executable with chmod +x talktome.sh and make sure it runs
automatically whenever
the Pi boots up by pointing to it in the /etc/rc.local file:
$ vi /etc/rc.local
/home/pi/yowsup/talktome.sh
Save the file and reboot the Raspberry Pi, and the script starts automatically.
Let's break down the script to understand it better.
The credential() function at the top helps connect the script to the WhatsApp
server by using the
credentials for your account.
Make sure you edit both the parameters in this function. The Answer() function
specifies the WhatsApp number our Raspberry Pi communicates with. This is important
because we don't want just anybody to control our Raspberry Pi.
Then we define the functions that do the actual task we query the Raspberry Pi for
via the WhatsApp messages, eg the Refresh() function refreshes the repository list
and Restart() reboots the Raspberry Pi. The Temp() and Disk() functions are a
little more complex.
In the main part of the program (the while loop), the script waits for a message,
and when it gets one, it raises a MessageReceived exception. The received message
begins with a phone number followed by a message, such as "449876543210Message".
When it raises the exception, the script first converts the whole string to
lowercase with the value.lower() method. It then checks whether the message is from
the number it's supposed to respond to. If it isn't, the script appends it to a log
file and doesn't respond.
If, however, the phone number is correct, the script then strips the number from
the message and just leaves the textual bit. The If conditions then parse the
message to decide how to respond. We've used different types of matching to give
you an idea of what's possible.
The first two look for matching characters at the start of the text, eg if
received[:4]=="hiya": Answer("Hi chap!") is triggered if the first four characters
of the message are h, i, y and a, and responds with 'Hi chap!' . This condition is
met even if the message it receives is, 'Hiya Raspberry Pi, are you online?'
The second also looks for matching characters at the beginning of the message but
is triggered if it finds either of the two strings (restart or reboot). The next
three do a different kind of matching. They're triggered if their corresponding
text is in any part of the message and not just at the beginning.
Advertisement
So if you send a "What's the status of your disk?" message, the script picks up the
"disk" keyword and triggers the Disk() function. Similarly, if you send a 'You're
not running too hot, are you?' message, the script picks up the 'hot' keyword and
responds with a readout from its temperature sensor.
If it fails to pick up any keywords, the scripts just responds with the "Eh? What
was that?" message. You can extend this script for a whole variety of home
automation tasks. You can even hook up the Raspberry Pi camera module and use the
Python Picam library to take pictures or videos and send them to you via a WhatsApp
message.
Check the Yowsup library's wiki page for some examples of rolling the script into
usable applications.
Enjoyed this article? Expand your knowledge of Linux, get more from your code,
and discover the latest open source developments inside Linux Format. Read our
sampler today and take advantage of the offer inside.
===================================================================================
========
AZARTICOLO:How to guard your home with Raspberry Pi
===================================================================================
========
One of the most interesting areas of practical use is sensing the world around us,
and using the
data gathered in all sorts of ways. The world is full of data just waiting to be
recorded and manipulated
– for example, weather stations come with many different sensors to measure
temperature, wind speed,
humidity and pressure.
All this data can be stored and manipulated by a savvy hacker to produce graphs and
tables
that can be imported into other applications or projects. And of all the sensors on
the market,
the cheapest and most simple is the humble PIR, which is present in so many parts
of everyday life.
Raspberry Pi
PIR plans
Passive infrared sensors (PIR) are commonly used in devices such as triggers for
burglar alarms
in homes and offices. In fact, they are so cheap that they're found inside motion-
activated air fresheners,
which could be a ripe source of components for this project.
The PIR sensor works on the simple principle of sending a beam of infrared light
into a room.
If the beam remains unbroken – by which we mean there is no movement in the room –
no action is taken.
But the second the beam is broken, a signal is sent to a device that's programmed
to respond in
a certain manner. These PIR sensors are very cheap – around £4 (about $6, AU$8.40)
delivered on
eBay – and they are also an excellent starter project because they require very
little breadboarding
or prototyping.
For our project, we will set up a PIR sensor to watch an area for any movement.
Once movement is detected, it will trigger the code to complete a sequence of
events that will
capture a picture of the event and record a short 10-second video at a resolution
of 640 pixels by 480 pixels.
The project will culminate with a text message being sent to our phone, alerting us
to an intruder
or other event. To explain how this project will work, we'll illustrate it using
pseudocode, which is
a way of explaining a programming sequence using easy-to-understand language.
Here's how the project will work in pseudo code:
On receiving the signal, the Raspberry Pi will take a picture of the activity.
After the picture is created, the Pi will attempt to send a text alerting us to the
activity.
Once the text has been sent, the Pi will wait for 30 seconds before looping the
process.
In the summer there are lots of plants growing and animals moving in the sunshine,
so why not use your Raspberry Pi and this project to capture the joys of summer?
You could house this project in a weatherproof case and leave it outside to record
animal life.
In fact, a project similar to this was used to monitor the feeding patterns of
birds caring for their
offspring.
A sensor was placed near the nesting box, and this would record the comings and
goings of the
parent birds. This data was then linked to weather data for that area.
When comparing the data, it became clear that the natural food of birds – insects –
were not as abundant when the weather was rainy or windy.
This meant the offspring were not being fed as often.
Alert! Alert! In this project, we're choosing to alert the user via a text message,
because no
matter what type of phone you have, and what type of signal you receive, a text
message is more
reliable as a method of delivery than an email or tweet, which rely on 3G or Wi-Fi
coverage to
receive data.
This project can be built upon to include other methods of delivering the alert –
in fact, you can send more than one alert from the project.
To send an email, you can use the smtplib, and we found a great how-to.
You can also send a tweet from Python using the tweepy library.
In brief, our goal is to build an alarm system with our Raspberry Pi that's
triggered by a
PIR sensor, which detects movement.
Once the alarm is tripped, a camera will take a quick picture of the event, and
then record 10
seconds of video. To alert the user that the alarm has been triggered a text
message is sent.
So let's get started!
Raspberry Pi
Our PIR sensor needs three connections to work: VCC (5V), Out and Ground (GND).
To connect our sensor to the Raspberry Pi, we need to use female to female jumper
cables.
You can buy them from many online retailers. On the sensor, locate the VCC pin and
gently push
a cable until it is firmly in place.
On your Raspberry Pi, locate Pin 2 and gently push the VCC cable into place.
We connect the VCC pin on the PIR sensor to a 5V pin on a Raspberry Pi, which is
Pin 2.
When connecting anything to the GPIO, ensure that the Raspberry Pi is powered off
and that all connections are checked before powering on your Raspberry Pi.
Raspberry Pi
We then need to repeat the process and connect the GND pin of our sensor to GND on
a Raspberry Pi, which is Pin 6. Lastly, we connect our Out pin to Pin 7.
For our connection to the PIR sensor, we will require no resistors inline as the
PIR has a diode to protect the board, and the signal sent via the Out pin is 3V and
safe with our Raspberry Pi.
Our PIR sensor needs three connections to work: VCC (5V), Out and Ground (GND). To
connect our sensor to the Raspberry Pi, we need to use female to female jumper
cables. You can buy them from many online retailers. On the sensor, locate the VCC
pin and gently push a cable until it is firmly in place.
On your Raspberry Pi, locate Pin 2 and gently push the VCC cable into place. We
connect the VCC pin on the PIR sensor to a 5V pin on a Raspberry Pi, which is Pin
2. When connecting anything to the GPIO, ensure that the Raspberry Pi is powered
off and that all connections are checked before powering on your Raspberry Pi.
Raspberry Pi
Our next piece of hardware is the Raspberry Pi Camera, and to insert the camera,
you need to locate a plastic port between the HDMI and Ethernet port on the board.
Gently lift the plastic lock from the port and then slide the ribbon cable into the
slot, with the silver strips of the ribbon facing the HDMI port.
Once fully slid into place, press the plastic lock back into its original position.
The ribbon cable will now be locked in place.
Raspberry Pi
Now we have our hardware installed, it's time to configure the software that will
control it.
Firstly we need to set up our camera and that is done via this command – in a
terminal type:
raspi-config
In the menu, there is an option to 'Enable the camera' – move to there and then
press [Enter].
You will now be asked whether you would like to enable the camera, so move the
cursor to
'Enable' and press [Enter]. You will now return to the original menu, so move your
cursor to
'Finish' and press [Enter].
raspistill -o test.jpg
This command will launch an application to take a picture using the camera.
If you encounter any errors, check that you have the correct syntax and that the
camera is enabled
in the raspi-config menu.
The last thing to check should be the physical connection between the camera and
the Raspberry Pi.
Raspberry Pi
3. Install pip
------------------
In order to use the camera with Python, we need to download the library picamera,
and the best
way to do this is via a package manager for Python called pip.
Pip works in the same way that apt-get works on your Raspberry Pi, and it is a
great tool to keep
your projects up to date. To use pip we first need to install it via a terminal.
Raspberry Pi
4. Install picamera
---------------------------
apt-get update
Pip will now install the picamera library for Python. Now it is time to grab a copy
of the project code.
Download the project as a zip file.
To use the project files, we need to open idle, the Python editor, but because we
are using the
GPIO, we need to do so using:
idle
This will open the idle application, and in the application, go to 'File > Open'
and then navigate
to where your project files are located. We will be working with pir_alarm.py.
6. Added extras
------------------------
In our code we have a section that imports extra functionality; these are
libraries.
The first is time, which enables control of our program.
Next we import datetime, which enables our program to use calendar dates and clock
times.
Next we import the RPi.GPIO library but rename it to GPIO to make it easier to use.
We then import picamera which enables the use of the official Pi camera with
Python.
Raspberry Pi
Earlier we referred to connecting the Out pin of the PIR sensor to Pin 7 of our
Raspberry Pi.
Well, in order to be efficient with our code, we need to create a variable that
stores the pin
number ready for use in our code.
pir = 7
By doing this, we can easily change the pin in our code if we need to.
Creating a function called sms() on line 14 is a great way contain the code kindly
provided by
smspi.co.uk.
Using three arguments called to, message and hash we can easily pass the target
phone number,
the alert message and the unique hash which permits the use of the SMSpi text
message gateway.
To use the text message service, you will need to sign up for a free login and hash
to use in your project.
3. Easier coding
-------------------------
GPIO.setup(pir, GPIO.IN)
This line of code sets our pin 7, which is referenced as a variable called pir, as
an input, so that
it waits to receive a signal from the sensor.
The next line of code shortens the full picamera function down to just camera
making it easier
to work with.
camera = picamera.PiCamera()
SMSpi
-----------
The team at SMSpi project has kindly provided its Python code for this project.
SMSpi offers a free text messaging service for Pibased projects.
The SMSpi project is powered by Raspberry Pi; all your texts are routed via the
same device
that is powering our alarm.
Advertisement
----------------------
The API can be dropped into most common programming languages, including CURL,
PERL,
Python, PHP and Ruby.
To use the service, you need to sign up for a free login, which then allows access
to the network
via a hash that acts as your unique key.
Using the service, you can easily send SMS messages over the SMSpi network, as
proven by
this project, but you can also receive text messages and have them forwarded to an
email address
or posted to a web page for use in web apps.
Once you have your hash, paste it into your Python project code on line 11.
With your alarm now installed and working, you need to remotely access your
Raspberry Pi to
see the pictures and video.
The easiest way would be to remove the card and view the media on your computer.
But you could enable SSH on your Raspberry Pi via the raspi-config advanced menu
and then
use your file manager to SSHFS into the folder where the pics are.
If you are feeling adventurous, you could install lighttpd or nginx to serve the
content over a network.
The choice is yours but remember to be careful with sharing the images over an open
connection
to the internet.
Find out what else you can do with the tiny PC with our collection of Raspberry Pi
Projects
===================================================================================
============
AZARTICOLO:How to migrate MySQL to MariaDB on Linux
===================================================================================
============
http://xmodulo.com/migrate-mysql-to-mariadb-linux.html
Last updated on August 14, 2015 Authored by Kristophorus Hadiono Leave a comment
Since the Oracle's acquisition of MySQL, a lot of MySQL developers and users moved
away from
MySQL due to Oracle's more closed-door stance on MySQL development and maintenance.
The community-driven outcome of such movement is a fork of MySQL, called MariaDB.
Led by original MySQL developers, the development of MariaDB follows the open-
source philosophy and makes sure of its binary compatibility with MySQL.
The Linux distributions such as Red Hat families (Fedora, CentOS, RHEL), Ubuntu and
Mint,
openSUSE and Debian already started to use and support MariaDB as a drop-in
replacement of MySQL.
If you want to migrate your database from MySQL to MariaDB, this article is what
you are looking for. Fortunately, due to their binary compatibility, MySQL-to-
MariaDB migration process is pretty much straightforward. If you follow the steps
below, the migration from MySQL to MariaDB will most likely be painless.
Log in into MySQL from a terminal by typing your MySQL root user password.
$ mysql -u root -p
Create a database and a table.
Now create a backup of my.cnf file somewhere in your system before uninstalling
MySQL. This step is optional.
$ cp /etc/mysql/my.cnf /opt/my.cnf.bak
Uninstall MySQL Package
First, you need to stop the MySQL service.
$ /etc/init.d/mysql stop
Then go ahead and remove MySQL packages and configurations as follows.
MariaDB website provide an online tool to help you add MariaDB's official
repository
according to your Linux distribution.
This tool provides steps to add the MariaDB repository for openSUSE,
Arch Linux, Mageia, Fedora, CentOS, RedHat, Mint, Ubuntu, and Debian.
As an example, let's use the Ubuntu 14.04 distribution and CentOS 7 to configure
the MariaDB repository.
Ubuntu 14.04
$ apt-get install software-properties-common
$ apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80
0xcbcb082a1bb943db
$ add-apt-repository 'deb http://mirror.mephi.ru/mariadb/repo/5.5/ubuntu trusty
main'
$ apt-get update
$ apt-get install mariadb-server
CentOS 7
Create a custom yum repository file for MariaDB as follows.
$ vi /etc/yum.repos.d/MariaDB.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
$ yum install MariaDB-server MariaDB-client
After all necessary packages are installed, you may be asked to type a new password
for root user account. After setting the root password, don't forget to recover
my.cnf backup file.
$ cp /opt/my.cnf /etc/mysql/
Now start MariaDB service as follows.
$ /etc/init.d/mariadb start
Importing MySQL Database(s)
Finally, we have to import the previously exported database(s) back to MariaDB
server as follows.
To check whether or not the import process is completed successfully, log in into
MariaDB server and perform some sample queries.
$ mysql -u root -p
MariaDB [(none)]> show databases;
MariaDB [(none)]> use test01;
MariaDB [test01]> select * from pet;
Conclusion
As you can see in this tutorial, MySQL-to-MariaDB migration is not difficult.
MariaDB has a lot of new features than MySQL, that you should know about. As far as
configuration is concerned, in my test case, I simply used my old MySQL
configuration file (my.cnf) as a MariaDB configuration file, and the import process
was completed fine without any issue. My suggestion for the configuration is that
you read the documentation on MariaDB configuration options carefully before the
migration, especially if you are using specific MySQL configurations.
If you are running more complex setup with tons of tables and databases including
clustering or master-slave replication, take a look at the more detailed guide by
the Mozilla IT and Operations team, or the official MariaDB documentation.
Troubleshooting
1. While running mysqldump command to back up databases, you are getting the
following error.
$ mysqldump --all-databases --user=root --password --master-data > backupdb.sql
mysqldump: Error: Binlogging on server not active
By using "--master-data", you are trying to include binary log information in the
exported output, which is useful for database replication and recovery. However,
binary logging is not enabled in MySQL server. To fix this error, modify your
my.cnf file, and add the following option under [mysqld] section.
log-bin=mysql-bin
Save my.cnf file, and restart the MySQL service:
==============================================================
AZARTICOLO:Install Emoncms on Raspberry Pi (Raspbian Stretch)
==============================================================
https://github.com/emoncms/emoncms/blob/master/docs/RaspberryPi/readme.md
This guide will install the current full version of emoncms onto a Raspberry
Pi running the Raspbian Stretch operating system.
Due to the number of writes that the full version of emoncms makes, the
lifespan of an SD card will almost certainly be shortened, and it is therefore
recommended that you eventually move the operating system partition (root)
to an USB HDD or to lower the write frequency to the SD card by enabling
the low-write mode.
Preparation
---------------
Raspberry Pi v3 Compatibility
--------------------------------------
This section only applies to Raspberry Pi v3 and later.
To avoid UART conflicts, it's necessary to disable Pi3 Bluetooth and restore
UART0/ttyAMA0 over GPIOs 14 & 15;
vi /boot/config.txt
See RasPi device tree commit for pi3-disable-bt and forum thread discussion
The only other thing I can think of is to disable the loading of the drivers for
now:
/etc/modprobe.d/raspi-blacklist.conf
#wifi
blacklist brcmfmac
blacklist brcmutil
#bt
blacklist btbcm
blacklist hci_uart
rfcomm 37723 0
bluetooth 365780 3 rfcomm
evdev 12423 6
uinput 9125 3
binfmt_misc 7988 1
sg 20781 0
brcmfmac 292632 0
brcmutil 9863 1 brcmfmac
cfg80211 544545 1 brcmfmac
rfkill 20851 5 bluetooth,cfg80211
uio_pdrv_genirq 3923 0
fixed 3285 0
uio 10204 1 uio_pdrv_genirq
snd_bcm2835 24427 0
snd_pcm 98501 1 snd_bcm2835
snd_timer 23968 1 snd_pcm
snd 70032 3 snd_timer,snd_bcm2835,snd_pcm
Installation
--------------
a2enmod rewrite
This should be on, or very close to lines 161 and 172 of /etc/apache2/apache2.conf
vi /etc/apache2/apache2.conf
Save & exit, then restart Apache:
Git is a source code management and revision control system but at this
stage we use it to just download and update the emoncms application.
The following configuration commands gives 'sudoers' Mariadb root privileges from
within the local network, to administer all aspects of the databases and users.
It also removes an 'example' database and user, which is no longer required.
mysql -e "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost',
'127.0.0.1', '::1'); DELETE FROM mysql.user WHERE User=''; DROP DATABASE IF EXISTS
test; DELETE FROM mysql.db WHERE Db='test' OR Db='test\_%'; FLUSH PRIVILEGES;"
mkdir /var/lib/{phpfiwa,phpfina,phptimeseries}
vi settings.php
Update your settings to use your Database 'user' & 'password', which will enable
emoncms
to access the database:
$server = "localhost";
$database = "emoncms";
$username = "emoncms";
$password = "new_secure_password";
Further down in settings is an optional 'data structure store' - Redis, which acts
as a cache
for the data produced by emoncms, to ensure that it is efficiently written to disk.
Per fermarlo:
systemctl status redis-server
root@raspi:/var/www/emoncms# systemctl stop redis-server
root@raspi:/var/www/emoncms# systemctl disable redis-server
visudo
and edit the # User privilege specification section to be :
http://localhost/emoncms
If you want Emoncms to redirect from web root i.e load Emoncms with
http://localhost add reference in index.php and remove the default apache
index.html
test page:
The first time you run emoncms it will automatically set up the database and you
will be
taken to the register/login screen.
Create an account by entering your email and password and clicking register.
Check the Administration page - 'Setup > Administration' noting and acting upon any
messages reported.
Make a note of your 'Write API Key' from the 'Setup > My Account' page, and also
ensure
that the correct timezone is selected & saved.
Install Emonhub
--------------------------
Edit the emonhub configuration file, entering your emoncms 'Write API Key' and set
the
"local" emoncms address url = http://localhost/emoncms (emonhub sends to
http://emoncms.org
by default). Also set your RFM2Pi frequency, group & base id if necessary:
vi /etc/emonhub/emonhub.conf
Save & exit.
vi /boot/cmdline.txt
by changing the line to - dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2
rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait
Per fermarlo
# systemctl stop emonhub
# systemctl disable emonhub
poweroff
--------------
Once your Pi has stopped, disconnect the power lead and connect your RFM69Pi add-on
board, ensuring it's positioned correctly (see the photos in the OEM shop pages).
You should now have a fully working version of emoncms installed on your Raspberry
Pi,
if at this stage you don't, you may wish to check the emoncms log
- 'Setup > Administration > Logger' or report the issue in the OEM forum giving as
much detail as possible.
-----------------------
System Options
-----------------------
Enabling MQTT
Installing emoncms Modules
Updating emoncms
System Logs
================================================================================
AZARTICOLO:How to enable auto-login?
================================================================================
raspi-config
@Milliways I have tried going into raspi-config, and changed the boot option to,
console autologin but it doesn't work. –
# cp /lib/systemd/system/[email protected] \
/etc/systemd/system/[email protected]
# ln -s /etc/systemd/system/[email protected] \
/etc/systemd/system/getty.target.wants/[email protected]
systemctl daemon-reload
systemctl start [email protected]
Note that if you exit tty8 session, you wont be able to use it until next reboot or
manual
start by systemctl, except if you leave Restart as ‘always’, but I highly recommend
to avoid this according to security reasons.
source: fedoraproject.org/wiki
The simplest way I have found, if using Raspbian, is to edit the raspi-config file:
/etc/lightd/lightdm.con and set the autologin-user= parameter.
===================================================================================
=============
AZARTICOLO:Auto-login with GUI disabled in Raspbian
===================================================================================
=============
How can I make the RPi auto-login when booted, when the GUI is disabled?
You don't have to type a password, when logging in when GUI enabled, so there is
probably
an easy way of disabling the password prompt in the console.
Very dangerous, I missed the bit about not having a password and seemed to have
screwed
up the SD card. Be warned!
Note I have not tested this, check the manpage for getty for more details.
https://fedoraproject.org/wiki/
Systemd#How_do_I_set_automatic_login_on_a_virtual_console_terminal.3F
The FAQ is for Fedora but it should be very similar on Raspbian Jessie.
I have tested it; it works fine. Also, put something in ~/.bash_profile and that
will get run
automatically after you are logged in. – greggo Jan 18 '13 at 18:28
showing :
how to auto login to the shell prompt (using a method similar to above)
Run scripts at startup
Auto start the desktop using raspi-config
this article shows how to auto login to the desktop using raspi-config, but the
question
is asking how to auto login when there is no GUI or Desktop
(so bringing up the shell prompt).
However this article also shows how to auto login to the shell as well.
This worked for me with Jessie Lite:
-i
mkdir -pv /etc/systemd/system/[email protected]
nano /etc/systemd/system/[email protected]/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux
only catch is that I can't logon using SSH anymore - access denied. :-(
so lightdm.conf method didnt work for me, after a bit of playing around the easiest
method
I found was below.
cd /etc/systemd/system/
where [Username] is put the user you wish to login without the brackets.
now I did have pi auto login working using the raspi-config setup, but used the
above
method to change the autologin for a new user.
hope this helps
==============================================================
AZARTICOLO: DIFFERENZA TRA MBR E GPT
==============================================================
MBR disks
----------------------
MBR: Master Boot Record
----------------------
1 Partition Table Entry
----------------------
2 Partition Table Entry
----------------------
3 Partition Table Entry
----------------------
4 Partition Table Entry
----------------------
0x55AA
----------------------
C: Primary Partition
----------------------
D: Primary Partition
----------------------
E: Primary Partition
----------------------
F: Primary Partition
----------------------
G: Extended Partition
----------------------
H: Extended Partition
----------------------
GPT Disks
--------
GPT is the latest standard for laying out the partitions of a hard disk.
It makes use of globally unique identifiers (GUID) to define the partition and it
is part of the
UEFI standard. This means that on a UEFI-based system
(which is required for Windows 8 Secure Boot feature), it is a must to use GPT.
With GPT, you can create theoretically unlimited partitions on the hard disk, even
though it is
generally restricted to 128 partitions by most OSes.
Unlike MBR that limits each partition to only 2TB in size, each partition in GPT
can hold up to
2^64 blocks in length (as it is using 64-bit), which is equivalent to 9.44ZB for a
512-byte block
(1 ZB is 1 billion terabytes). In Microsoft Windows, that size is limited to 256TB.
GPT
---
------------------------------------
lba0: PMBR: Protective Master Boot Record
------------------------------------
lba1 Primary GPT Header
------------------------------------
lba2 | Entry1 | Entry2 | Entry3 | Entry4 |
------------------------------------
lba3 Entry 5-128
------------------------------------
lba34 Partition 1
------------------------------------
lba34 Partition 2
------------------------------------
lba-34 Partition (Others)
------------------------------------
lba-33 | Entry1 | Entry2 | Entry3 | Entry4 |
------------------------------------
lba-2 Entry 5-128
------------------------------------
lba-1 Secondary GPT Header
------------------------------------
From the GPT Table Scheme diagram above, you can see that there is a primary GPT at
the
beginning of the hard disk and a secondary GPT at the end.
This is what makes GPT more useful than MBR. GPT stores a backup header and
partition table
at the end of the disk so it can be recovered if the primary tables are corrupted.
It also carry out CRC32 checksums to detect errors and corruption of the header and
partition table.
In other words, GPT is a newer fashion, has the latest sizes, and is easier to use,
less confusing
sometimes. For example, GPT supports 128 primary partitions (I know, right?) while
MBR only
supports 3 (?). And in my honest opinion, the command parted handles GPT and MBR
disks
perfectly (unfortunately not exactly the case with fdisk).
GPT's have different sorts of BIOS and they usually are on, if not required, on
UEFI or EFI systems.
There really is not that much difference between Fedora on a GPT disk than a Fedora
on an
MBR disk. Super minor speed differences maybe.
There might be a tiny inconvenience using an MBR disk with resizing and adding
partitions,
but besides that, Fedora is a very adaptable,
smart system. Even if your disk is really strange, it can adjust. Don't worry too
much about that.
However, I would prefer GPT, because I have more than 2.0TB disks on me sometimes,
it is more convenient. Some OS's also only run on GPT, like Mac OSX.
HTH and if you can, choose GPT!
===================================================================================
========
AZARTICOLO:BACKUP DELLA SCHEDA SD
===================================================================================
========
fdisk -l
E prendere nota di come viene chiamata la Sd, ad esempio /dev/sdb1 oppure qualcosa
tipo
/dev/mmcblk0, dipende dalla distribuzione.
Ricordatevi che questi sono comandi da dare sul terminale del PC che utilizzerete
per fare il backup,
non sul Raspberry!
===================================================================================
==============
AZARTICOLO:Boot the Raspberry Pi From USB by techno guy in raspberry-pi
===================================================================================
============
Introduction:
--------------------
I thought it was really generous of him and I wanted to use it. Here's the problem,
I've only got 2 GB SD cards and the latest Raspbian image (2015-05-05) was
like 3.5 GB in size.
No problem, I'm a technology guy, surely I could figure this out, and I did.
So now I'm here showing a step-by-step picture guide as to how I did it.
This instructable assumes that the reader has at least some basic experience
with Ubuntu, the Raspberry Pi and the GParted partition editor.
If not, then this probably isn't for you.
This article is also centered around doing the whole process using Ubuntu
Type "-s" to get into a root shell, so you don't have to type again.
dd if=path/to/image of=path/to/flashdrive".
In my case I found the path to the flash drive from GParted, it was /dev/sdb
but it might be different for you.
If you want to know the status of the burn, you can install pv by typing in
"apt-get install pv" and then using the altered command of
"dd if=path/to/image | pv | dd of=path/to/flashdrive".
When the image is finished burning, the contents of the drive should look
more or less like they do in the picture of the GParted screen.
It should have one fat16 partition and one ext4 partition and maybe some
unallocated space if your drive is big enough.
Step 3: Prepare the SD Card
-----------------------------------
Add a new partition and make sure it is 56 MB in size while being labeled
"boot" and being a fat16 file system.
The point is to clone the boot partition on the flash drive over to the SD card
because the Raspberry Pi can't completely boot from a flash drive.
Then click "manage flags" and add the "lba" flag and you're done prepping
the SD card.
Get back into your root shell to prepare the boot partition transfer.
Again, use "dd" to transfer the partitions, my boot partition is /dev/sdb1 for
the flash drive and /dev/sdc1 for the SD card.
Notice the 1 at the end of each, that signifies the first logical partition
which I can see from the GParted screen.
Get into the SD card file system with your favorite file explorer and open up
the file called "cmdline.txt".
Then resize the ext4 partition by clicking "resize/move" and dragging each
end of the partitions to the corresponding ends.
Apply all operations and wait quite a bit of time for the partition to grow.
When it's finished, there should be only one partition, and ext4, that has
the same partition path (/dev/sdb2) as the original ext4 partition.
Now just insert your SD card into the Raspberry Pi along with the root flash
drive that we were working on.
Plug everything you need in like power, video, keyboard/mouse and wifi and turn it
on.
If all worked well for you, then you should see the Raspberry Pi boot up
normally and the setup screen come up for the first time.
CONGRATULATIONS!!!
If not, then something probably went wrong and you should try to see if
you can fix it by going backwards to see what went wrong or just redoing the
whole process again.
I typed in "startx" and the desktop interface came up, all is well and now I
can use the Pi normally.
===================================================================================
===================================================================================
==================
===================================================================================
===================================================================================
==================
===================================================================================
=========
AZARTICOLO:SETTING WIFI UP VIA THE COMMAND LINE documentazione ufficiale
===================================================================================
=========
https://www.debian.org/doc/manuals/debian-reference/
ch05.en.html#_the_basic_syntax_of_etc_network_interfaces
https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
This method is suitable if you don't have access to the graphical user interface
normally used to set up WiFi on the Raspberry Pi. It's especially suitable for use
with a serial console cable if you don't have access to a screen or wired Ethernet
network. Note also that no additional software is required; everything you need is
already included on the Raspberry Pi.
To scan for WiFi networks, use the command iwlist wlan0 scan.
This will list all available WiFi networks, along with other useful information.
Look out for:
IE: IEEE 802.11i/WPA2 Version 1. This is the authentication used; in this case it's
WPA2,
the newer and more secure wireless standard which replaces WPA.
This guide should work for WPA or WPA2, but may not work for WPA2 enterprise;
for WEP hex keys, see the last example here.
You'll also need the password for the WiFi network.
For most home routers this is located on a sticker on the back of the router.
The ESSID (ssid) for the network in this case is testing and the password (psk) is
testingPassword.
vi /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="The_ESSID_from_earlier"
psk="Your_wifi_password"
}
In the case of the example network, we would enter:
network={
ssid="testing"
psk="testingPassword"
}
Now save the file by pressing Ctrl+X then Y, then finally press Enter.
At this point, wpa-supplicant will normally notice a change has occurred within a
few seconds, and it
will try and connect to the network. If it does not, either manually restart the
interface with
ifdown wlan0 and ifup wlan0, or reboot your Raspberry Pi with reboot.
==============================================================
AZARTICOLO:CONFIGURAZIONE WIFI FUNZIONANTE
==============================================================
-----------------------------------------------------------------------
cat /etc/network/interfaces IP STATICO ANCHE SUL WI-FI
-----------------------------------------------------------------------
auto lo
iface lo inet loopback
#allow-hotplug eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
mtu 1492
metric 1
#up route add default gw 192.168.1.1 metric 1 dev eth0
#dns-nameservers 192.168.1.1 8.8.4.4
==============================================================
WPA_SUPPLICANT WPA2
==============================================================
root@raspi:/etc/wpa_supplicant# cat wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IT
network={
ssid="CISCOWIFI"
psk="intrapam123$"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="azcam"
}
==============================================================
configurazione del router fibra WPA2
==============================================================
Interfaccia Radio:
Attiva
Rete Wi-Fi (SSID): CISCOWIFI (Visibile)
Canale Radio: 1 (Automatico) Cerca canale
Ampiezza di banda (Canale): Auto 20 MHz / 40 MHz
Modalità di cifratura: WPA-PSK TKIP-AES 256 bit
Chiave di cifratura: intrapam123$ [ASCII]
Controllo Accesso: Disabilitato
==============================================================
configurazione del router fibra WPA1
==============================================================
Interfaccia Radio:
Attiva
Rete Wi-Fi (SSID):
CISCOWIFI (Visibile)
Canale Radio: 1 (Automatico) Cerca canale
Ampiezza di banda (Canale): Auto 20 MHz / 40 MHz
Modalità di cifratura: WPA-PSK TKIP 256 bit
Chiave di cifratura: intrapam123$ [ASCII]
Controllo Accesso: Disabilitato
==============================================================
WPA_SUPPLICANT WPA1
==============================================================
-----------------------------------------------------------------------------------
----------
CISCOWIFI WPA2
-----------------------------------------------------------------------------------
----------
# iwlist wlan0 scanning essid CISCOWIFI
-----------------------------------------------------------------------------------
----------
CISCOWIFI WPA1
-----------------------------------------------------------------------------------
----------
Connessione
----------------
==============================================================
AZARTICOLO:Doppio routing LAN/WLAN
==============================================================
ip route list
-----------------
source-directory /etc/network/interfaces.d
auto lo
auto eth0
auto wlan0
iface lo inet loopback
allow-hotplug eth0
#iface eth0 inet manual
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
up route add -net default gw 192.168.1.1 netmask 0.0.0.0 dev eth0 metric 1
down route del -net default gw 192.168.1.1 netmask 0.0.0.0 dev eth0 metric 1
dns-nameservers 192.168.1.1 8.8.8.8 4.2.2.1
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface azcam inet static
address 192.168.1.7
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
up route add -net default gw 192.168.1.1 netmask 0.0.0.0 dev wlan0 metric 2
down route del -net default gw 192.168.1.1 netmask 0.0.0.0 dev wlan0 metric 2
iface default inet dhcp
1.1 dev wlan0 metric 2
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.5
192.168.1.0/24 dev wlan0 proto kernel scope link src 192.168.1.7
================================================================================
AZARTICOLO::USING YOUR NEW RASPBERRY PI 3 AS A WIFI ACCESS POINT WITH HOSTAPD
================================================================================
https://frillip.com/using-your-raspberry-pi-3-as-a-wifi-access-point-with-hostapd/
One of my first thoughts was, can I use it as a SoftAP for some ESP8266 sensor
nodes?
As it turns out, you can, and it's not that difficult, as the BCM43438 chip is
supported
by the open-source brcmfmac driver!
PACKAGES
--------------
The first step is to install the required packages: apt-get install dnsmasq hostapd
hostapd - This is the package that allows you to use the built in WiFi as an access
point
dnsmasq - This is a combined DHCP and DNS server that's very easy to configure
If you want something a little more 'heavyweight', you can use the isc-dhcp-server
and bind9
packages for DHCP and DNS respectively, but for our purposes, dnsmasq works just
fine.
The first thing you'll need to do is to configure your wlan0 interface with a
static IP.
Note: This must be ABOVE any interface lines you may have added!
allow-hotplug wlan0
iface wlan0 inet static
address 172.24.1.1
netmask 255.255.255.0
network 172.24.1.0
broadcast 172.24.1.255
# wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Restart dhcpcd with service dhcpcd restart and then reload the configuration for
wlan0
with ifdown wlan0; ifup wlan0.
CONFIGURE HOSTAPD
-----------------------------
Next, we need to configure hostapd.
Create a new configuration file with vi /etc/hostapd/hostapd.conf with the
following contents:
# Use channel 6
channel=6
# Enable 802.11n
ieee80211n=1
# Enable WMM
wmm_enabled=1
# Use WPA2
wpa=2
We aren't quite done yet, because we also need to tell hostapd where to look for
the config
file when it starts up on boot. Open up the default configuration file with vi
/etc/default/hostapd
and find the line #DAEMON_CONF="" and replace it with
DAEMON_CONF="/etc/hostapd/hostapd.conf".
CONFIGURE DNSMASQ
-----------------------------
The shipped dnsmasq config file contains a wealth of information on how to use it,
but
the majority of it is largely redundant for our purposes. I'd advise moving it
(rather than
deleting it), and creating a new one with
mv /etc/dnsmasq.conf /etc/dnsmasq.conf.orig
vi /etc/dnsmasq.conf
Paste the following into the new file:
One of the last things that we need to do before we send traffic anywhere is to
enable packet forwarding.
To do this, open up the sysctl.conf file with vi /etc/sysctl.conf, and remove the #
from the
beginning of the line containing net.ipv4.ip_forward=1. This will enable it on the
next reboot,
but because we are impatient, activate it immediately with :
sh -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
We also need to share our Pi's internet connection to our devices connected over
WiFi by
the configuring a NAT between our wlan0 interface and our eth0 interface.
However, we need these rules to be applied every time we reboot the Pi,
so run sh -c "iptables-save > /etc/iptables.ipv4.nat" to save the rules to the
file /etc/iptables.ipv4.nat. Now we need to run this after each reboot, so open the
rc.local
file with vi /etc/rc.local and just above the line exit 0, add the following line:
And that's it! You should now be able to connect to the internet through your Pi,
via the on-board WiFi!
To double check we have got everything configured correctly, reboot with reboot.
EDIT4: Fixed race condition between dhcpcd and dnsmasq, wlan0 is no longer
configured by dhcpcd.
===================================================================================
=========
AZARTICOLO:Raspberry Pi Course Week 3 – Day 1.0 (WiFi Config)
===================================================================================
========
http://www.suntimebox.com/raspberry-pi-tutorial-course/week-3/day-1/
To achieve this, a file called interfaces needs to be edited with the correct
network information.
The interfaces file holds the information required to give the Raspberry Pi access
to the
wireless network or a wired network. The file exists in /etc/network/ folder.
Open a terminal window and enter the following.
$ vi /etc/network/interfaces
vi will load a file similar to this.
—————————————–
auto lo
Edit the last two lines with your SSID and your password.
Your SSID is the network ID that your Wi-Fi router is broadcasting.
Note that your SSID and password need to appear in between the quotes.
The word auto is used to identify the physical interface files that will be
brought on or offline.
The line auto wlan0 is an example of this. It will allow wlan0 to be shut down or
brought back
online when using commands or when the system boots up.
The iface refers to the interface which is followed by eth0, eth1 or wlan0
etc ,depending
on which device it is referencing. The inet dhcp is informing the raspberry pi
that you
require an IP address in order to access the network. Enter the following to
restart the system.
$ reboot
If you are still having problems connecting see the troubleshooting page on
Raspberry
Pi Wireless Network Setup Issues.
The Pi Store
The app store for the Raspberry Pi is much like any other app store found with
Apple, Microsoft
or the Android Play store. The app store gives you access to some of the software
available for
the Raspberry Pi which include both free and paid apps.
To access the Pi Store login to your desktop and double click on the Pi Store icon
which appears
on the desktop or you can visit http://store.raspberrypi.com.
Note
If your distribution does not appear to have a Pi Store icon, do not fear. You can
install it
by using the following command in a terminal.
Before you can access the store you will need to register. Click on the login link
located at the top right corner of the window and click register.
Fill in your email address, password and the security question. Click on the sign
me up button and you will be signed into your account. You can change your
username by clicking on the edit link which allows you to change your username and
upload an avatar for the account.
When you have completed the above process you will see the Pi Store. A list of
apps will be displayed which can filtered by clicking on the games, apps,
tutorials, dev tools & media menu buttons. Next to the menu buttons appears a
number. This number indicates how many apps are available for this type of
application. You can also filter by tags by clicking on one of the subjects that
appear on the left hand side of the window.
Note
Tags are very much like keywords so that the app can easily be searched and
recognised when looking for them.
To install an app on your Raspberry Pi, click on the Free Download button of the
Buy button.
When the app has successfully been downloaded and installed it will appear in the
My Library.
The my library button will display any apps that you have downloaded and installed
previously.
Raspberry Pi Address
We have talked about IP address and how to configure them and we have briefly
explained why you need one for the Raspberry Pi. A more in depth explanation of
IP addresses are needed so you can really understand the network around you and the
type of devices that require an IP address.
Every device from a computer to a phone requires a unique identifier to communicate
with other devices on a network or the internet. If you are to address a letter in
the mail, then you need to address with an exact address so that the post office
know where house address this id destined for. Most networks on the internet use
something called TCP/IP protocol to communicate. This is a common standard which
allows all devices to abide by these rules so that each device can communicate with
each other. This is no different from learning the French language so that you are
able to communicate with a French speaking person.
Currently, two standards for IP addresses exist and they are IPv4 and IPv6. The
main different between the two is that IPv6 is a new addition which allows more
devices to be connected to the internet and at the same time be unique. With IPv4
this would not be possible because there isn’t enough IP address available with
IPv4. Another difference is the way in which the IP addresses are represented.
IPv4 looks like this 192.168.100.100.
IPv6 is expressed like this 201c:cab7:0000:9832:0000:0000:ad01:fffa
This early part of course will only look at IPv4.
How can you get an IP address?
An IP address can either be dynamic of static. Dynamic means that the Raspberry Pi
will automatically get an IP address from a server of router. Static means that
the IP address has to be allocated to the Raspberry Pi manually.
Open a terminal window and type the following.
# ifconfig
The following information will be returned although your IP address and device may
be different.
eth0 Link encap:Ethernet HWaddr 08:10:27:ff:65:cc
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:feef:65bc/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:19 errors:0 dropped:0 overruns:0 frame:0
TX packets:52 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2372 (2.3 KiB) TX bytes:7776 (7.5 KiB)
cat /etc/network/interfaces
The line below is referring to the eth0 interface and that is should use DHCP.
ifconfig
Make a note of your current IP address, the broadcast IP and the Mask. This is
represented by the
Next you need to edit the interfaces file to set this static information. Enter
the following command.
vi /etc/network/interfaces
Save the file by pressing CTRL-X and select Y to save the changes.
When the raspberry Pi reads this file when booting up, it will look at the
interface eth0 and set
it to a static IP address. I will set the IP address to 192.168.0.6, the network
to 192.168.0.0,
the broadcast address and the gateway address so that it can find its way out of
the network.
This will ping your gateway address or router and will return :
64 bytes from 192.168.1.254: icmp_req=1 ttl=255 time=2.18
64 bytes from 192.168.1.254: icmp_req=2 ttl=255 time=2.43
64 bytes from 192.168.1.254: icmp_req=3 ttl=255 time=3.24
64 bytes from 192.168.1.254: icmp_req=4 ttl=255 time=2.20
64 bytes from 192.168.1.254: icmp_req=5 ttl=255 time=3.37
If you prefer, you can always make a reservation on your router or server.
For this you will have to make a note of the hardware address when you enter the
ifconfig command. The hardware address is represent as the HWaddr:
08:00:22:ef:65:bc.
Note that your hardware address will be different.
Please let me know if I have missed anything or you want to add something that will
benefit
someone or a comment saying thank you would be nice.
It makes it all worthwhile knowing that I helped someone and if I didn’t, let me
know where I went wrong.
This tutorial will teach you the basics of installing Apache Web Server on the
Raspberry Pi and
you will create a simple HTML page to verify that the page will being delivered to
the client using
a web browser.
To install the apache web server, which is also known as apache2 can be installed
using the following commands.
cd /var/www/html
Log into the Raspberry Pi desktop and open a web browser. In the web address bar
enter the following.
http://localhost
This will retrieve the index.html file and display something similar to this.
To confirm that additional HTML pages can be added we will create an html page and
store it in the
/var/www/html directory.
cd /var/www/html
vi mypage.html
When vi opens enter the following basic html code
<html>
<head>
<title>This is my Raspberry Pi Page</title>
</head>
<body>This is where the action happens</body>
</html>
Save this file by holding down CTRL-X. vi will prompt you to save the file.
Open a web browser and in the address bar enter
http://localhost/mypage.html
You will see a web page with the content being displayed.
Occorre per far diventare dinamiche le pagine ovvero che siano diverse in base alle
risposte date
dall utente o per i risultati di una query eseguita in un database
cd /var/www/html
vi index.php
Immettere il seguente codice:
<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
echo date('Y-m-d H:i:s');
echo "hello world";
phpinfo();
?>
</body>
</html>
==============================================================
AZARTICOLO: CISCO LEARNING:WEP, WPA, WPA2, TKIP, AES, CCMP, EAP.
==============================================================
Hi
WPA
-------
Implements the majority of IEEE 802.11i, but with different headers (so can operate
both
in same network). Designed to require only a firmware upgrade
(full 802.11i usually requires hardware change).
As designed, WPA uses TKIP and Michael for message integrity, based on RC4 for
encryption.
WPA (and WPA2) may operate in enterprise mode, using a RADIUS server to hold per-
user keys.
This allows individual access to be controlled in a large network.
For a small network, e.g. home network, without a RADIUS server a pre-shared key
(PSK)
may be used. The same key is used by all clients, so may require more work to
update.
In the context of wireless security this actually means TKIP vs. "AES-based CCMP"
(not just AES).
TKIP is a lower end encryption protocol (WEP2) and AES is a higher end
(WPA2/802.11i)
encryption protocol. AES is preferred.
TKIP+AES
----------------
This is what the encryption standards are for WEP2 (TKIP) and WPA2/802.11i (AES).
It will attempt to use AES if available and fall back to TKIP if not.
This setting offers the most compatibility but won't guarantee a higher level of
encryption
if a device falls back to TKIP.
Note: In some cases other optional features of 802.11i may be required, but
interoperability
may not be guaranteed.
Support for AES encryption and AES-based CCMP message integrity is mandatory
(is optional in WPA).
As well as mandatory AES, WPA2 also adds PMK (Pair-wise Master Key) and
Pre-authentication to help fast roaming.
EAP options
-------------------
AES-based CCMP
-------------------------
WPA2 mandates AES-based CCMP for message integrity and confidentiality.
TKIP (weaker) is optional.
WPA2 mixed
--------------------
Mixed mode allows device to try WPA2 first, and if that fails fall-back to WPA.
WEP
--------
WEP was supposed to provide Confidentiality, but has found to be vulnerable and
should
no longer be used, has been found to be vulnerable and is often the default;
this should be changed. Most devices that support WEP can be firmware/software
upgraded to WPA. Do not use unless some devices can not be upgraded to support WPA.
WEP has been outdated for years and has better replacements.
The 40-bit encryption is just not strong enough to keep data secure and can be
broken
rather easily. Newer encryption methods use stronger encryption and have yet to be
broken while WEP can be broken in a minute, use WPA where possible.
Preference Summary
----------------------------------
To keep things simple, the best options, in decreasing order of preference, may be:
WPA2 + AES
WPA + AES (only if all devices support it).
WPA + TKIP+AES (only if all devices can support it).
WPA + TKIP
Disabled (no security)
The most common two options will be WPA2 + AES and WPA + TKIP,
because they match the mandatory requirements in the standards
(WPA2 requires AES, WPA requires TKIP).
You can use WPA + AES for higher security than TKIP, but only if your devices
support it
(it is optional). For this reason it is not very common.
You also do not get the improved roaming features of WPA2.
WPA + TKIP+AES provides a fallback in case AES is not supported by a device in that
it
switches to the more common TKIP. The disadvantage is that it might switch to TKIP
unexpectedly but is more backwards compatible if needed.
The remaining combination, WPA2 + TKIP, is possible (as TKIP is optional in WPA2),
but doesn't make much sense because AES is more secure and mandatory for all
WPA2 devices.
================================================================================
AZARTICOLO:How-To: Turn a Raspberry Pi into a WiFi router
================================================================================
http://raspberrypihq.com/how-to-turn-a-raspberry-pi-into-a-wifi-router/
December 4, 2013admin
Raspberry Pi with Edimax Wifi Adapter
Share this: Share on FacebookShare on Google+Tweet about this on TwitterPin on
PinterestShare on RedditShare on LinkedIn
Do you want a separate WiFi network for your guests? or would you like to have
network running an alternative DNS configuration in your house? You no longer have
to buy a new WiFi router to do this – you can turn your Raspberry Pi into a WiFi
router.
This post will guide you through the process of setting up your Raspberry Pi as a
WiFi network.
If you need help connecting to the Raspberry Pi look at this post remotely using a
wired network connection.
After booting and logging-in you want to make sure that the Raspberry Pi found your
new wireless adapter. To look at which peripherals the operating system found when
booting run the following command:
dmesg | more
You can use the spacebar to scroll down a page at a time – towards the end you will
see something similar to the following lines:
[ 3.282651] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 3.394810] usb 1-1.2: New USB device found, idVendor=7392, idProduct=7811
[ 3.407489] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3.420530] usb 1-1.2: Product: 802.11n WLAN Adapter
This means that the operating system recognized the USB WiFi Adapter using one of
the built-in drivers (you can return to the terminal by pressing “q”). All that is
left is to configure your WiFi connection.
In order for the Raspberry Pi to act as a WiFi router and access point you need to
install some extra software on the Raspberry. You are going to need the following
pieces of software:
hostapd
HostAPD is a user space daemon for access point and authentication servers. That
means it can will turn your Raspberry Pi into a access point that other computers
can connect to. It will also handle security such that you can setup a WiFi
password.
isc-dhcp-server
isc-dhcp-server is the Internet Systems Consortium’s implementation of a DHCP
server. A DHCP server is responsible for assigning addresses to computers and
devices connection to the WiFi access point.
To install the DHCP software run the following command:
wget https://github.com/jenssegers/RTL8188-hostapd/archive/v1.1.tar.gz
tar -zxvf v1.1.tar.gz
cd RTL8188-hostapd-1.1/hostapd
make
make install
This will take a little time – while waiting for the program to compile send a
friendly thought to Jens Segers over at http://jenssegers.be for making this
software available.
To configure the DHCP server open the file /etc/dhcp/dhcpd.conf in your favorite
text editor. You can open it in vi using this command:
vi /etc/dhcp/dhcpd.conf
Find the following section and comment it out by placing a hashtag at the beginning
of the line.
# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;
The file now looks like this:
dhcpconfig1
Next we need to define the network and network addresses that the DHCP server will
be serving. This is done by adding the following block of configuration to the end
of file:
To save the file press Ctrl+O this will write the file to the disk – afterwards you
can exit vi by pressing Ctrl+X. If vi asks if you want to Save modified buffer?
press “Y” followed by hitting enter to confirm the filename.
vi /etc/default/isc-dhcp-server
Scroll down to the line saying interfaces and update the line to say:
INTERFACES="wlan0"
This will make the DHCP server hand out network addresses on the wireless
interface. Save the file and exit nano.
The last step in configuring the DHCP server is to configure a static ip address
for the wireless network adapter. This is done in the file /etc/network/interfaces
– before opening it make sure the WLAN interface is down. Do this with the
following commands:
ifdown wlan0
vi /etc/network/interfaces
Change the file to look like this:
interfaces
This will make the wireless adapter take the address 192.168.10.1 in our new local
network. Remember to comment out the last 3 lines of the file.
This concludes the setup of the DHCP server – however we still cannot connect to
our new network because we have not setup the access point yet. This is done by
configuring the hostapd application.
Configuring HostAPD
vi /etc/hostapd/hostapd.conf
The standard configuration will create a new wireless network called wifi with the
password YourPassPhrase. You can change the parameter “ssid=wifi” to the SSID wifi
name you want and the parameter “wpa_passphrase=YourPassPhrase” to your own
password.
This concludes the configuration of our access point software HostAPD. Next up is
enabling NAT.
Enable NAT
-----------------
The last step before we can start the access point is setting up Network Address
Translation (NAT). This will make sure that our network traffic will be able to
reach the internet using the Raspberry Pi’s Ethernet cable connection to your
internet router.
net.ipv4.ip_forward=1
Next start the translation right away by running:
ifup wlan0
Next step is setting up the actual translation between the ethernet port called
eth0 and the wireless card called wlan0.
With the NAT configured it is now time to run your access point for the first time.
You are now ready to start the DHCP server and the HostAPD access point
application.You can do so by running:
Finishing up …
While it is pretty cool you now have your Raspberry Pi running as a wireless access
point it is not so cool you have to login every time it reboots to start the
HostAPD and DHCP software…
Add the following to the end of the file /etc/network/interfaces to restore the
configuration when the network interface comes up:
interfaces_iptables
At this point try to reboot the raspberry pi just to make sure everything works as
intended
– you can reboot with the command:
reboot
Hopefully you will see your new access point come online again.
After it comes up again you should be able to connect to it and access the
internet!
================================================================================
AZARTICOLO: How to Set Up WiFi on the Raspberry Pi
================================================================================
http://www.circuitbasics.com/raspberry-pi-wifi-installing-wifi-dongle/
In the last post, I explained how to install the Raspbian operating system without
a monitor
or keyboard, and how to establish an SSH connection to your Raspberry Pi over an
ethernet
connection. Now I’ll explain how to use that SSH connection to setup a WiFi dongle
so you can
run your Raspberry Pi wirelessly from a remote desktop application.
This is a really useful way to set up your Raspberry Pi, because you will be able
to access your
it over the internet from anywhere in the world. You can use it from your iPhone,
iPad, or Laptop
from anywhere with an internet connection.
However, I prefer to use a WiFi dongle, which gives me more flexibility with the
physical locations
I can store the Raspberry Pi while it is running. Be careful when choosing a WiFi
dongle for the
Raspberry Pi though, because not all WiFi dongles will work without a lot of
configuration and headaches.
I found that this one from Kootek works great without any driver installations
needed.
Still, there are some things that need to be done in order to set up the WiFi
dongle to work
properly with your Raspberry Pi. I will go through them step by step in this
article.
You should already have set up the SSH over ethernet connection I described in part
one of this post.
Now, login to your Raspberry Pi over SSH through the PuTTY SSH client, and get to
the
pi@raspberrypi – $ command prompt:
Next, we need to will need to change a few configuration settings in two files:
/etc/network/interfaces, and /etc/wpa_supplicant/wpa_supplicant.conf.
To edit these files, we need to use the Raspbian text editor, Nano.
At the command prompt, type
vi /etc/network/interfaces to edit the /etc/network/interfaces file.
Pro Tip: If you ever want to copy something from your laptop/desktop and paste it
into
PuTTY, just copy it on your laptop/desktop, then right click with your mouse where
you
want to paste it into PuTTY and it will be inserted.
auto lo
iface lo inet loopback
iface eth0 inet dhcp
auto wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
etc,network,interfaces file
ctrl_interface=/var/run/wpa_supplicant
ctrl_interface_group=0
update_config=1
network={
ssid="YOUR WIFI NETWORK NAME"
psk="YOUR WIFI PASSWORD"
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
}
etc,wpa supplicant
The entry for ssid=”YOUR WIFI NETWORK NAME” should be the name of your wireless
network,
typed exactly as it shows when you connect to your WiFi from another computer. It
is case sensitive.
The entry for psk=”YOUR WIFI PASSWORD” is the password you normally use to login to
your
home wireless network.
Then re-enter your network name under the id_str=”YOUR WIFI NETWORK NAME” line.
Now press ctrl X, then Y, to save the changes to the file.
iwconfig2
If you see something like “Link Quality=0/100“ or “Signal Level=0/100“, go back and
make sure
that you have entered everything exactly as it is shown in the images.
All of the configuration settings should now be saved to work with your WiFi
dongle, so enter
poweroff into the command prompt to shut down the Raspberry Pi.
Now disconnect the ethernet cable and the power cord.
Wait about one minute, then plug the power cord back into it without the ethernet
cable.
Now we will need to use Advanced IP Scanner again to find the new local IP address
of the
Raspberry Pi when it is connected via WiFi. This has likely changed slightly from
when we used it
on the ethernet connection. It is useful to keep track of both IP’s if you will be
connecting with
ethernet at all in the future.
PuTTY is great if all you need to do is access your Raspberry Pi from the command
line.
However, many features are only available through the Raspbian desktop.
In order to access the desktop remotely, we need to install and configure a Remote
Desktop Connection.
Read How to Set Up Access to the Raspbian GUI via a Remote Desktop Connection for a
tutorial
on how to do that.
===============================================================================
AZARTICOLO: How to Set Up a Static IP on the Raspberry Pi
================================================================================
Have you ever tried to log into your Raspberry Pi via SSH and been denied because
the IP address
couldn’t be found? Do you have to scan your network every time you connect to find
your local IP
address? If the IP address of your Raspberry Pi changes all the time, it’s because
you’re using a
dynamic IP. If you want your Raspberry Pi to have an IP address that doesn’t change
automatically,
assign it a static IP address. With a static IP, you can be sure that the same IP
will work each
and every time. In this article, I’ll show you how to configure a static IP address
using a clean
installation of Raspbian Jessie and Raspbian Jessie Lite, but this should work with
newer versions
of Raspbian Wheezy as well. However, since there are pros and cons to each type of
IP, lets first
talk about why you would want a static IP vs. a dynamic IP.
Static IP vs Dynamic IP
--------------------
Dynamic IP
Dynamic IP’s are good to use if you are concerned about security.
If a hacker gets access to your IP address, you will be less vulnerable to attack
since your IP
changes frequently. A dynamic IP can change every time you log in, or only at
certain intervals.
A program installed on your network router called the dynamic host configuration
protocol (DHCP),
automatically changes and assigns new dynamic IP addresses to computers on your
network.
Static IP
--------
A static IP (as you could probably tell by the name) is one that doesn’t change.
This makes them more reliable when using services that depend on a stable internet
connection,
like online gaming, VOIP, or remote access applications. With a static IP, you’ll
be able to use
the same IP address every time you connect to your Pi via SSH or remote desktop
applications.
In this tutorial we’ll set up static IP’s for both WiFi and ethernet connections.
If you only need one or the other, just omit the code below for the connection you
don’t need.
Power up and log into your Raspberry Pi via WiFi or ethernet, then enter route -ne
at the command
prompt to see your network routing information:
Under the “Gateway” column, you can see your Default Gateway IP (10.0.0.1 in my
case)
for each interface (Iface) – ethernet (eth0) and WiFi (wlan0). Write down your
default gateway IP,
we will need it later.
Now we need to find out the IP addresses of your domain name servers.
Your Pi sends the domain names you enter into your browser (i.e. www.google.com) to
domain
name servers, which then converts them to IP addresses (i.e. 8.8.8.8) that your Pi
can use to
directly access the website’s server. Enter cat /etc/resolv.conf at the command
prompt to find
the list of domain name servers your Pi uses:
Copy these IP addresses to a text editor on your PC or write them down for later.
Configuration of Network Settings
-----------------------------
Now, without changing anything else in the file, add this code to the end of the
/etc/dhcpcd.conf file, replacing the IP addresses with your own IP addresses found
above:
interface eth0
static ip_address=10.0.0.100
interface wlan0
static ip_address=10.0.0.99
static routers=10.0.0.1
static domain_name_servers=75.75.75.75 75.75.76.76 2001:558:feed::1
2001:558:feed::2
Replace the addresses in the code above with your own addresses:
static ip_address= This is the static IP address you will use to SSH or remotely
connect to your Pi.
Take your default gateway IP (found in the steps above), and
change the last
number to any other number between 0 and 255.
static routers= This is your default gateway IP address.
static domain_name_servers= These are the IP’s we found in the /etc/resolv.conf
file above.
Seperate each IP with a single space.
The file should look like this (with your own IP addresses):
Once you’ve replaced the IP addresses in the example code with your own IP
addresses,
press Ctrl-X and Y to exit and save the /etc/dhcpcd.conf file.
Now enter reboot to reboot the Pi. Log in with your new static ethernet IP or
static WiFi IP:
You should probably test the connection by pinging Google with both eth0 and wlan0
(ethernet and WiFi) IP’s.
Another nice way to connect to your Pi is via a direct ethernet connection to your
laptop or desktop.
A direct connection is extremely fast and stable. If you connect to your Pi via SSH
a lot,
I would definitely recommend setting this up.
Check out our article, How to Connect to a Raspberry Pi Directly with an Ethernet
Cable to learn how.
I would definitely recommend setting this up.
Thanks for reading! Now that you have a static IP set up, your Pi’s connection to
the internet will
be a lot more reliable.
================================================================================
AZARTICOLO:Use the Raspberry Pi Serial Port to Connect to a Device
================================================================================
https://it.mathworks.com/help/supportpkg/raspberrypiio/ug/use-the-serial-interface-
on-raspberry-pi-hardware.html
This example shows how to create a connection to a serial device, write data to the
device,
and read data from the device.
By default, the serial console in the customized version of Raspian Wheezy on your
Raspberry Pi™ hardware is enabled.
To use the serialdev, the serial console must be disabled.
Warning
http://www.raspberrypi.org/technical-help-and-resource-documents.
mypi = raspi
Show the location of the Tx and Rx pins, GPIO 14 (UART0_TXD) and GPIO 15
(UART0_RXD),
on the GPIO header.
showPins (mypi)
To receive data, connect the GPIO 15 (UART0_RXD) pin on the Raspberry Pi board
to the
TxD pin on the serial device.
To transmit data, connect the GPIO 14 (UART0_TXD) pin on the Raspberry Pi board to
the
RxD pin on the serial device.
Connect a ground pin, GND, on the Raspberry Pi board to the GND pin on the serial
device.
Connect a +3.3V pin on the Raspberry Pi board to the VCC pin on the serial device.
Use serialdev to create a connection to the serial device and assign the connection
to a handle.
myserialdevice =
BaudRate: 115200
DataBits: 8
Parity: 'none'
StopBits: 1
Timeout: 10
If the serial device requires nondefault values, use a set of optional arguments to
override
those defaults.
myserialdevice = serialdev(mypi,'/dev/ttyAMA0',115200,8,'none',2)
myserialdevice =
BaudRate: 115200
DataBits: 8
Parity: 'none'
StopBits: 2
Timeout: 10
write(myserialdevice,[10 12],'uint16')
You can also read an array of values from the serial port.
output = read(myserialdevice,100)
This example reads a 100-element array of uint8 values from the serial device.
If the serial connection times out during read operations, you can adjust the time
out period
by assigning a new value to the Timeout property.
myserialdevice.Timeout = 20
myserialdevice =
BaudRate: 115200
DataBits: 8
Parity: 'none'
StopBits: 1
Timeout: 20
To use the serial console, enable the serial console and reboot the Raspberry Pi
hardware.
When the Raspberry Pi hardware finishes rebooting, you can communicate with the
Linux® command interface over a USB to TTL serial cable that is connected to the
serial
pins on the GPIO header.
However, you cannot use serialdev until you disable the console.
================================================================================
root@raspi:/lib/modules/4.4.15+# rpi-update
root@raspi:/lib/modules/4.4.15+# reboot
Connection to raspi closed by remote host.
Connection to raspi closed.
================================================================================
IFPLUGD
================================================================================
Options:
-q --no-shutdown Non lanciare lo script in fase di uscita del
daemon padre (quit =off)
-f --ignore-fail Non terminare sui fallimenti, invece
ritenta
(ovvero il fallimento
e' trattato come un DOWN) (off)
-u --delay-up=SECS Tempo di attesa prima di configurare
l'interfaccia (default 0)
-d --delay-down=SECS Tempo di attesa prima di sconfigurare l'interfaccia
(default 5)
-w --wait-on-fork Attendi fin quando la fork del daemon e'
terminata (default off)
-i --iface=IFACE Specifica interfaccia ethernet da
monitorare (eth0)
-I --ignore-retval Non uscire se il programma eseguito
termina con errore (off)
-b --no-beep Do not beep (off)
-U --no-beep-up Do not beep on interface up (off)
-D --no-beep-down Do not beep on interface down (off)
-a --no-auto Do not enable interface
automatically (off)
-n --no-daemon Do not daemonize (for debugging) (off)
-s --no-syslog Do not use syslog, use stderr instead
(for debugging) (off)
-F --ignore-fail-positive Ignore detection failure, retry instead (failure is
treated as UP) (off)
-r --run=EXEC Specify program to execute
(/etc/ifplugd/ifplugd.action)
-t --poll-time=SECS Specify poll time in seconds (1)
-T --poll-utime=USECS Specify poll time in microseconds, add to -t (0)
-m --api-mode=MODE Force API mode (mii, priv, ethtool, wlan, auto) (auto)
-p --no-startup Don't run script on daemon startup (off)
-l --initial-down Run "down" script on startup if no cable
is detected (off)
-W --wait-on-kill When run with -k, wait until the daemon died
(off)
-x --extra-arg Specify an extra argument for action
script
-M --monitor Use interface monitoring (off)
-h --help Show this help
-k --kill Kill a running daemon
-c --check-running Check if a daemon is currently running
-v --version Show version
-S --suspend Suspend running daemon
-R --resume Resume running daemon
-z --info Write status of running daemon to
syslog
===================================================================================
========
AZARTICOLO: Settare il WiFi Roaming con wpa_roaming
===================================================================================
========
Overview
-------------
Io invece desidero che la rete wireless sia su al boot e non sia mai scollegata
la rete ethernet deve essere normalmente down e se viene collegato il cavo deve
andare su ma solo come default gateway ovvero deve permettere il solo accesso in
uscita
fuori della LAN mentre tutto il traffico LAN deve comunque passare dal Wireless
tutto questo viene comandato dal daemon
/usr/sbin/ifplugd -i eth0 -q -f -u0 -d10 -w -I -b
Provo a disabilitarlo
systemctl disable ifplugd
al boot non e' stato ripristinato !
editiamolo:
vi /etc/wpa_supplicant/wpa-roam.conf
update_config=1
Esempio WEP
--------------------
network={
ssid="debian"
key_mgmt=NONE
wep_key0=6162636465
wep_tx_keyidx=0
}
Esempio WPA-WPA2PSK
------------------------------------
network={
ssid="aptosid_Worldwide"
psk="mysecretpassphrase"
}
ifup wlan0
wpa_cli status
First see Switching between cable and wireless because if its not set up correctly
switching
and connection to the network will not happen.
After setting up ifplugd the final config should look like this:
auto lo
iface lo inet loopback
#Added by user
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa-roam.conf
With the help of IDString and Priority you can direct to which network the box is
connected
at boot time. Highest priority is 1000, lowest priority is 0.
You have to add the id_str to /etc/network/interfaces as well.
First is for the connection to DHCP servers, the second is if you are provided with
a fixed
IP address. To adjust your settings:
# id_str="home_dhcp"
iface home_dhcp inet dhcp
# id_str="home_static"
iface home_static inet static
address 192.168.0.20
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.1
Practical Examples
-------------------------------
If you want to be automatically connected to your home WLAN when at home, give the
the IDString "home" and priority "15". If you are travelling, and want the laptop
to connect
to any free, non passworded network which is available, give it the IDString
"stalk" and priority
"1" (very low). But please, always check if your connection is legal and disconnect
if it is obviously
not intended to be free.
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa-roam.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="my_ssid"
scan_ssid=1
psk=123ABC ##here comes the passphrase in hexadecimal code!!
# psk="password_in_ascii" ##you dont need to
key_mgmt=WPA-PSK
pairwise=TKIP
group=TKIP
auth_alg=OPEN
priority=15
id_str="home"
}
network={
ssid=""
scan_ssid=1
key_mgmt=NONE
auth_alg=OPEN
priority=1
disabled=1 ## no automatic connection, one needs wpa_cli or wpa_gui
id_str="stalk"
}
WEP encryption
If you want to add WEP encrypted networks to your wpa-roam.conf permanently, the
syntax is:
network={
ssid="example wep network"
key_mgmt=NONE
wep_key0="abcde"
wep_key1=0102030405
wep_tx_keyidx=0
}
Notes
1. Easy to reuse
----------------------
Once set up, you can easily reuse your setup on other laptops or desktops with WLAN
cards.
Just copy /etc/network/interfaces (adjust the name of the interface if needed) and
/etc/wpa_supplicant/wpa-roam.conf to your new box.
There is no need of "installing" anything after that.
2. Backup
------------------
A good method to safely backup and encrypt the config files is with tar and gpg. As
root:
3. Hidden SSIDs
-----------------------
Hidden SSIDs are detected when scan_ssid=1 is defined in the network block.
Basic wireless modem/router security
Where you have control of the wireless router/modem, there are a few basic security
policies to implement to help protect your side of the network from intruders.
Passphrase / passwords
-----------------------------------
For a passphrase/password that is strong and not really able to be memorised, use
pwgen
in a terminal (also read: man pwgen):
$ pwgen -s 63 1
VltnfGmGKXovVv2rmrCFFXBZ55Mij5bA6WytVJnVoKUqRn6dfjldG6MBrRo0Cdi
$ pwgen 8 3
Sooxae2s Niew9ugh Hi7eeloo
Once you have generated the passphrase/password store it in a text file on a USB-
stick
and apply the passphrase/password to the other computers that use your wireless
network.
Do not store the passphrase/password on your computer.
Version: WPA2-PSK
Encryption: AES
PSK Password: VltnfGmGKXovVv2rmrCFFXBZ55Mij5bA6WytVJnVoKUqRn6dfjldG6MBrRo0Cdi
===================================================================================
=========
AZARTICOLO:CISCO ACCESS POINT
===================================================================================
=========
Cell 03 - Address: C4:EA:1D:5F:7C:21
Channel:5
Frequency:2.432 GHz (Channel 5)
Quality=70/70 Signal level=-19 dBm
Encryption key:on
ESSID:"CISCOWIFI"
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
Mode:Master
Extra:tsf=0000000000000000
Extra: Last beacon: 80ms ago
IE:
IEEE 802.11i/WPA2 Version 1 *
Group Cipher : CCMP *
Pairwise Ciphers (1) : CCMP *
Authentication Suites (1) : PSK
Prima era:
IE:
WPA Version 1
Group Cipher : TKIP
Pairwise Ciphers (1) : TKIP
Authentication Suites (1) : PSK
540397D22571F3C86DFB1021000B546563686E69636F6C6F721023000E4D656
469614163636573732054471024000D373939766E207632203547487A1042000
93135333754414D47461054000800060050F2040001101100154D6F64656D2054
656C65636F6D20414720706C7573100800020004103C0001011049000600372A
000120
IE: Unknown: DD090010180200000C0000
IE: Unknown:
DD180050F2020101000003A4000027A4000042435E0062322F00
===================================================================================
============
AZARTICOLO: UBUNTU:Connect to WiFi network from command line in Linux
===================================================================================
============
Following guide explains how you can connect to a WiFi network in Linux from
command Line.
This guide will take you through the steps for connecting to a WPA/WPA2 WiFi
network.
In case you’ve only got wired connection only, you can use this guide to setup DHCP
or static IP
address from command line in Linux.
Following tools are required to connect to WiFi network in Linux from command line
wpa_supplicant
iw
ip
ping
Before we jump into technical jargons let’s just quickly go over each item at a
time.
wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and Windows with
support for WPA and WPA2 (IEEE 802.11i / RSN).
It is suitable for both desktop/laptop computers and embedded systems.
Supplicant is the IEEE 802.1X/WPA component that is used in the client stations.
It implements key negotiation with a WPA Authenticator and it controls the roaming
and IEEE 802.11 authentication/association of the wlan driver.
iw – Linux Wireless
------------------------------
iw is a new nl80211 based CLI configuration utility for wireless devices.
It supports all new drivers that have been added to the kernel recently.
The old tool iwconfing, which uses Wireless Extensions interface, is deprecated and
it’s
strongly recommended to switch to iw and nl80211.
ip – ip program in Linux
----------------------------------
ping
--------
Good old ping For every ping, there shall be a pong …. ping-pong – ping-pong –
ping-pong …
that should explain it.
Step 1: Find available WiFi adapters – WiFi network from command line
-----------------------------------------------------------------------------------
---------------------
This actually help .. I mean you need to know your WiFi device name before you go
an
connect to a WiFi network. So just use the following command that will list all the
connected WiFi adapters in your Linux machines.
root@kali:~# iw dev
phy#1
Interface wlan0
ifindex 4
type managed
root@kali:~#
Connect to WiFi network in Linux from command line - Find WiFi adapters - blackMORE
Ops-1
By this time many of you are thinking, why two network devices.
The reason I am using two is because I would like to show how a connected and
disconnected
device looks like side by side. Next command will show you exactly that.
You can check that if the wireless device is up or not using the following command:
4: wlan0: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN mode DORMANT qlen 1000
link/ether 00:60:64:37:4a:30 brd ff:ff:ff:ff:ff:ff
root@kali:~#
As you can already see, I got once interface (wlan0) as state UP and wlan1 as state
DOWN.
Look for the word “UP” inside the brackets in the first line of the output.
Connect to WiFi network in Linux from command line - Check device status- blackMORE
Ops-2
In the above example, wlan1 is not UP. Execute the following command to
Step 3: Bring up the WiFi interface – WiFi network from command line
Note: If you’re using Ubuntu, Linux Mint, CentOS, Fedora etc. use the command
with ‘sudo’ prefix
Connect to WiFi network in Linux from command line - Bring device up - blackMORE
Ops-3
If you run the show link command again, you can tell that wlan1 is now UP.
Step 4: Check the connection status – WiFi network from command line
-----------------------------------------------------------------------------------
------------------------
You can check WiFi network connection status from command line using the following
command:
The above output shows that you are not connected to any network.
Step 5: Scan to find WiFi Network – WiFi network from command line
-----------------------------------------------------------------------------------
------------------
The 2 important pieces of information from the above are the SSID and the security
protocol
(WPA/WPA2 vs WEP). The SSID from the above example is blackMOREOps.
The security protocol is RSN, also commonly referred to as WPA2.
The security protocol is important because it determines what tool you use to
connect to
the network.
Connect to WiFi network in Linux from command line - Scan Wifi Network using iw -
blackMORE Ops - 5
Now we will generate a configuration file for wpa_supplicant that contains the pre-
shared key
(“passphrase”) for the WiFi network.
wpa_passphrase uses SSID as a string, that means you need to type in the passphrase
for the
WiFi network blackMOREOps after you run the command.
Connect to WiFi network in Linux from command line - Connect to WPA WPA2 WiFi
network - blackMORE Ops - 6
Note: If you’re using Ubuntu, Linux Mint, CentOS, Fedora etc. use the command with
‘sudo’ prefix
wpa_passphrase will create the necessary configuration entries based on your input.
Each new network will be added as a new configuration (it wont replace existing
configurations)
in the configurations file /etc/wpa_supplicant.conf.
Where,
Use the iw command to verify that you are indeed connected to the SSID.
(or)
root@kali:~#
Connect to WiFi network in Linux from command line - Check Routing and DHCP -
blackMORE Ops - 8
Step 9: Test connectivity – WiFi network from command line
Ping Google’s IP to confirm network connection (or you can just browse?)
Conclusion
-----------------
# iw dev
# ip link set wlan0 up
# iw wlan0 scan
network={
ssid="CISCOWIFI"
#psk="intrapam123$"
psk=0f1a94ca5722a564249371073210bc9911ad5c1993c1302e7d0dee3b17e5ebad
}
root@raspi:~# ifconfig
root@raspi:~# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT
group default qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Questo implica che se provo ad accedervi dal portatile in realta' il router non
avendo il
suo MAC ADDRESS mi mappa a livello arp eth0 e wlan0 sullo stesso mac della eth0
per cui se mi collego all indirizzo di wlan0 in realta' passo sempre per eth0 !!!
===================================================================================
============
AZARTICOLO:Configuring Raspberry Pi as a Wireless-to-Wired Ethernet Island
===================================================================================
============
http://www.glennklockwood.com/sysadmin-howtos/rpi-wifi-island.html
My apartment does not have hardwired ethernet, and the physical location of our
incoming cable
is such that it’s very difficult to position wired ethernet anywhere. I’ve
considered using a
powerline adapter to run ethernet over the apartment’s electric, but those adapter
kits are
a bit expensive. When I got my Raspberry Pi though, it occurred to me that I could
use it
to create an island of wired ethernet that feeds to the wifi connection we’ve got
set up.
This is a depiction of the setup I was going for to turn wireless internet into
wired.
I find iptables (and networking in Linux) extremely obtuse and hate having to
figure this stuff out, so now that I’ve got it working I will leave the necessary
configuration details below.
A much more comprehensive writeup on this concept has been developed by Robin
Newman, so if this guide is unclear, I highly recommend checking out Robin’s guide.
Ben Low also pointed out a handy tutorial that gives a much more sophisticated
treatment of this approach using Proxy ARP that is a good thing to check out if
this configuration is not good enough.
*filter
:INPUT ACCEPT [73:5085]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [72:6792]
-A FORWARD -i eth0 -j ACCEPT
-A FORWARD -i wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [43:2584]
:INPUT ACCEPT [2:278]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o eth0 -j MASQUERADE
-A POSTROUTING -o wlan0 -j SNAT --to-source 192.168.1.98
COMMIT
#!/bin/sh
IPT=/sbin/iptables
LOCAL_IFACE=eth0
INET_IFACE=wlan0
INET_ADDRESS=192.168.1.98
# Packet masquerading
$IPT -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_ADDRESS
================================================================================
AZARTICOLO:WATCHDOG:How do I hard reset a Raspberry Pi?
================================================================================
Obviously you can power cycle, but is there a more subtle way, like a reset pin?
It would be very useful to connect a watchdog in case the Raspberry Pi crashes
EDIT: The rev 2.0 board has a header you can connect a reset switch to.
hardware reset watchdog
shareimprove this question
Power cycling is dangerous. Be ready to say goodbye to the contents of the SD card
if you
use that method. Below I show the answer for the PI 3.
Using a reset button is rarely necessary, but is MUCH safer than power cycling.
You can use the BCM2708's hardware watchdog.
modprobe bcm2708_wdog
nano /etc/modules
bcm2708_wdog
nano /etc/watchdog.conf
watchdog-device = /dev/watchdog
This can be useful if you are accessing your Pi remotely, and it dies or locks up.
However, this is not the preferred method of restarting the system, but can be used
to
restart a locked system, where the only other option is to remove power from the
device.
Be warned that this can result in filesystem damage that could prevent the Pi from
booting
and operating correctly.
More info including a method to test this setup can be found in Gadgetoid's blog
post
--------------------------------------------------------------------------------
I found that I couldn't shut down my Pi for a clean power off. It would shut down,
the hardware watchdog kick in and reboot the system seconds after.
I've removed the options Wojciech suggested and have changed my
/etc/init.d/watchdog as follows:
stop)
if [ $run_watchdog = 1 ]
then
log_begin_msg "Stopping watchdog daemon..."
start-stop-daemon --stop --quiet --retry $STOP_RETRY_SCHEDULE \
--pidfile /var/run/$NAME.pid
modprobe -r bcm2708_wdog
log_end_msg $?
•
Reply
•
Share ›
Avatar
Gadgetoid Mod Pete • 4 years ago
You're correct. I often forget that I install chkconfig simply because I'm
familiar with it, and only recently came across update-rc.d.
Avatar
Wojciech Niziński • 5 years ago
To prevent hardware watchdog from being stopped, when watchdog process is killed,
please load module with additional options.
Create new file i.e. /etc/modprobe.d/watchdog.conf with content:
================================================================================
AZARTICOLO:Raspberry Pi Watchdog Timer
================================================================================
http://binerry.de/post/28263824530/raspberry-pi-watchdog-timer
This means that the functional system must trigger a heartbeat to the watchdog
(“feeding the dog”)
within a hard (hardware, not changeable) or soft (software, self-definable) time
period.
An absence of some heartbeats results in reaching the time limit and triggering the
reset/action.
Luckily the BCM2835 SoC has a hardware-based watchdog timer on board - but sadly
there are no further informations about it in the actual datasheet.
If i’m right informed this watchdog timeout register has 20 bits and counts down
every
16µs (source: Raspberry PI BB), so the the hardware timer limit is something around
16 seconds (16*2^20µs) which seems to be right according to bcm2708_wdog module
source.
The actual firmware includes the driver-module bcm2708_wdog (or if you compiled
your
kernel by yourself ensure that you have enabled BCM2835 watchdog support
[CONFIG_WATCHDOG=y, CONFIG_BCM2708_WDT=m|y]).
Just load it and add it if necessary to your modules-configuration for loading it
at startup:
If you want to use the watchdog within an own application scenario its recommended
to use ioctl-api. For feeding the watchdog you can insert WDIOC_KEEPALIVE via
ioctl.
You can get or set the soft timer limitvia WDIOC_GETTIMEOUT and WDIOC_SETTIMEOUT,
but remember that its hard limited to 16s, so if you set a soft-timeout larger
than this limit it will be just setted to 15s.
Also remember to disable the watchdog by writing a “V” for a straight program exit.
I have written a small test-snippet for demonstrating the use of the watchdog timer
within an own application. You can find it in my github-repository -
Just build it and play with it - It supports a clean and a failure exit
for testing purposes:
If you don’t want to control the watchdog by your own, of course you can use a
ready-to-use watchdog-daemon, which provides some more features than just feeding
the dog with heartbeats every 10 or 15s.
It can also run several tests to check the system healthfulness like monitoring
memory and load, checking ping-results, measuring temperature or performing
user-defined commands to do arbitrary tests and trigger reboot when they fail.
sudo bash
apt-get install watchdog chkconfig
chkconfig watchdog on
/etc/init.d/watchdog start
nano /etc/watchdog.conf
(enable line “watchdog-device = /dev/watchdog”)
So now its time to test if everything works as it should be. Ensure that there
aren’t any critical processes running and try to cause a kernel panic for example.
This can be tried with deactivating any swap space and a nasty forkbomb
(: (){ :|:& };:), but more reliable will be a fake kernel-module.
If everything is set up correctly the system will reboot a few seconds later.
So from now your system is protected by the watchdog.
================================================================================
AZARTICOLO:4 Awesome ways to find top CPU consuming processes in Linux.
================================================================================
https://linuxroutes.com/how-to-find-top-cpu-consuming-processes-in-linux/
Major part of sysadmin time goes into finding the cause of the load on the system
eg.
Finding processes which are consuming the resources.
This post will help you with how to quickly find top CPU consuming processes in
Linux.
There is one liner code available with ps command which will help you to find top
CPU
consuming processes in Linux.
Command:
Sample Output:
Lets say you don’t want single sample output of the command instead you want to
monitor
the output continuously. Yes you can do it using watch command as below:
Command:
Sample output:
Every 2.0s: ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%cpu | head
The same output of the ps command can also be achieved using the native top command
in linux to find top cpu consuming processes in Linux.
Command:
# top -b -n 1 | head -n 12 | tail -n 6
Sample output:
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
23236 root 20 0 102m 672 568 R 100.0 0.0 12:43.07 dd
23377 root 20 0 15084 1184 848 R 2.0 0.0 0:00.01 top
1 root 20 0 19396 1532 1228 S 0.0 0.0 0:01.34 init
2 root 20 0 0 0 0 S 0.0 0.0 0:00.01 kthreadd
3 root RT 0 0 0 0 S 0.0 0.0 0:05.08 migration/0
Like top command htop utility within linux which will help you to find the top cpu
consuming processes in Linux. To find it out use “htop” command.
Once you fired htop command, a continuous running window will open same like top as
below:
Now to sort out the processes by cpu utilization simply press “F6” button and then
select
cpu and press enter. You will now see the processes sorted according to cpu
utilization as below:
================================================================================
AZARTICOLO:X-based VNC server
================================================================================
Normally you will start Xvnc using the vncserver script, which is designed to
simplify the
process, and which is written in Perl.
You will probably want to edit this to suit your preferences and local conditions.
We recommend using vncserver rather than running Xvnc directly, but Xvnc has
essentially
the same options as a standard X server, with a few extensions.
Running Xvnc -h will display a list.
uinput
----------
uinput is a kernel module that makes it possible to emulate input devices from
userspace.
By writing to /dev/uinput (or /dev/input/uinput) device, a process can create a
virtual
input device with specific capabilities. Once this virtual device is created, the
process can
send events through it, that will be delivered to userspace and in-kernel
consumers.
Un device driver di input virtuale. Crea un device driver in cui scrivere eventi
relatvi a
tastiera o mouse e che poi saranno consegnati a /dev/input ovvero ai processi che
girano
nello user space come se fossero stati generati dalle periferiche fisiche
evdev
---------
evdev e' un interfaccia normalizzatrice degli eventi di input ovvero genera degli
eventi di
input con un interfaccia indipendente dal device di input.. Ovvia sia che l'evento
sia scaturito
da un mouse o da una tastiera il kernel attraverso tale device permette al processo
nello spazio user di
ricevere un evento dallostesso device e con un interfaccia comune. Altamente
consigliato
================================================================================
AZARTICOLO:Installazione di Raspbian su Raspberry Pi & utilizzando SSH e VNC
================================================================================
For starters you'll need a microUSB terminated AC adapter, an Ethernet cable & an
SD card.
I highly recommend that you use a 4GB SD card as a minimum. Also this tutorial
assumes that
you are running a Debian or Ubuntu Based Linux operating system on your PC.
I myself run Crunchbang Linux 11, which is based on Debian Wheezy 7.
If you are running a fresh install of Debian Wheezy please setup the utility
appropriately.
Plug in the SD card into the PC then run the following command in a terminal
window: "fdisk -l".
This will list all of the available drives available on your PC as shown in
Figure 1.
Figure 1. Display all hard/flash drives attached to the PC with the 'fdisk' command
Figure 1. Display all hard/flash drives attached to the PC with the 'fdisk'
command
From the output in Figure 1 you can see that the operating system detects two
drives,
"/dev/sda" is a 64.0GB SSD drive and the "/dev/sdb/" is our 8.0GB SD card.
The next step is to download the latest Raspbian Wheezy Linux distribution image
from this page.
Take note of SHA-1 hash string and the username (pi) and password (raspberry)
listed on the page.
Once downloaded, in a terminal window, navigate to the folder containing the
compressed Raspbian
image with "cd".** **
After a few seconds, a long string will be printed in the console window.
Compare this string with the one on the Raspbian download page.
If the Raspbian image is complete and not not corrupted, then both strings
(hash codes) should be identical.
Now that you verified the file integrity of the compressed Raspbian image,
uncompress it using
the following command:
"unzip 20xx-xx-xx-wheezy-raspbian.zip".
You should end up with another file called "20xx-xx-xx-wheezy-raspbian.img".
Copy the Raspbian image to the SD card using the following command:
"dd bs=1M if=20xx-xx-xx-wheezy-raspbian.img of=/dev/sdb".
Make sure that you specify the correct device found using the fdisk command.
This command will take a few minutes to complete.
Once the "dd" command completes, type into the same terminal "sync" to ensure the
write
cache is flushed properly and that you can safely remove the SD card.
Remove your SD card from the card reader and plug it into your RPi.
If there is an unused Ethernet port on the Linux PC, it can be used to allow the
RPi to share
the network/internet connection that the Linux PC is connected to through another
WiFi /Ethernet port.
Select "Wired Connection 1" and click on the "Edit" button. If you do not have a
wired connection profile,
click the "Add" button.
Figure 3
Figure 4.
Under the IPv6 settings tab and in the "Method" drop down list, select "Ignore".
and then press save.
Now Power up the RPi & connect it via Ethernet cable to the unused Ethernet port on
your PC.
Once the green "LNK" LED and the "10M" orange LED light up on the RPi board,
the Raspbian image has booted and an IP address has been assigned to the RPi.
Figure 5.
Figure 6
Now that we know the IP address of the RPi board, we we can login remotely via SSH.
SSH is an encrypted version of telnet (with a few additional goodies) that can give
us command
line access to the RPi over the network. To login into the Raspberry Pi over SSH
we need to type
in our terminal: "ssh 10.42.0.73 -l pi" (or ssh [email protected]). Basically we're
typing the name
of the command "ssh" followed by the IP address of the RPi, followed by the
username.
Remember the default username for the Raspbian Distribution is "pi" and the
password is "raspberry".
Choose yes if asked if this is a safe connection ( first time to ssh into the
RPi).
If all goes well, our terminal window is logged into the RPi.
Any commands that we type into that window from now on will affect the Raspberry Pi
and
not the Linux PC.
Figure 7. Logging into the RPi via SSH and typing "raspi-config"
The next step is to type "raspi-config". (see notice in Figure 7) Once you do this,
the raspi-config tool will run (figure 8).
From the raspi-config menu, first select "8 Advanced Options" -> "A5 Update" & hit
enter.
This will update the raspi-config tool to the latest version.
The Raspbian image is designed to expand into 2GB space on your SD card.
This means that if you are using a larger SD Card, say 4GB or 8GB, the additional
space is not
part of the root file system partition.
To use all the space on your SD card select "1 Expand Filesystem" and hit enter.
This will expand the root file system partition to fill the entire SD card.
The actual partition expansion will happen on reboot.
The other major option is "8 Advanced Options" -> "A3 Memory split".
Hit "Enter" and then choose an appropriate memory split ratio.
I recommend using 64MB for the GPU, but you can change this depending on what you
are doing.
For the other options, I highly recommend that you explore them.....
I don't recommend overclocking the RPi ( "7 Overclock" option) beyond 800MHz and I
keep the
default for the "8 Advanced Options" -> "A4 SSH" (run SSH server on start up) .
For "3 Enable Boot to Desktop" I always choose to boot into the command line
first.
When you're done, use the right/left arrow keys (or tab key) to select <Finish>.
This will cause the RPi to reboot with all the requested changes.
This reboot might take an additional minute or two if you selected to expand the
root file system
partition. Note that when you reboot, you lose your SSH connection and your console
window will
now be associated with your Linux PC once more.
When the RPi reboots, SSH into it again via "ssh 10.42.0.73 -l pi" as before.
Once at the RPi prompt shown (Figure 7), type "apt-get update" followed by "apt-get
upgrade" or alternatively we can do both at the same time
"apt-get update && apt-get upgrade".
The first command consults the /etc/apt/sources.list and updates the database of
available packages.
The second command checks updates for all installed packages and then prompts to
download and
install them. When it does this accept the updates (type Y) and hit enter.
When the second command completes ,you will have the most up-to-date Raspbian
Linux OS available for the RPi.
-------------------------------------------------------------------------------
Remote login into the Raspberry Pi Using VNC
-------------------------------------------------------------------------------
SSH is great if you want to remotely access the RPi from the command line.
The Raspbian OS also comes with a Desktop GUI environment called LXDE.
If can access the LXDE desktop over HDMI by typing "startx" in the command line
window.
This will not work over SSH. Luckily we can still remotely access the LXDE Desktop
from the Linux PC,
using the VNC protocol.
First we need to install the VNC server software on the the RPi.
To do this, SSH into the Raspberry Pi and type "apt-get install tightvncserver".
This will install the VNC server software on the RPi.
Then type "tightvncserver" to configure the VNC server for the first time.
You will then be asked to enter a password (8 characters only) & confirm it.
I used "raspberr". You will then be prompted to enter an optional "view only
password".
This is not needed and you can choose to not set one by saying no.
the next step is to type the following into the RPi SSH session to start the VNC
server:
This starts a VNC server on display number 1 with a resolution of 1280 by 720 and a
color depth of 24.
At this point the VNC server should be running on the Raspberry Pi.
Now open another console window on your Linux PC and install a VNC viewer (client)
on the
Linux PC with the command: "apt-get install xtightvncviewer ".
Then in the same console window (Linux PC) type "xtightvncviewer &".
This will open the VNC viewer on our Linux PC (a small messagebox...see Figure 9).
Type in the VNC server address that you want to connect to i.e. the RPi IP address
& display
number "10.42.0.73:1".
You will then be prompted to enter your VNC password. Type that in and press enter.
You should see the window shown in Figure 10.
You now have full control over your Raspberry Pi via both the command line with SSH
and the
desktop environment over VNC.
/usr/bin/vncagent service 16
Xtightvnc :1 -desktop X -auth /root/.Xauthority -geometry 1024x768 -depth 24 -
rfbwait 120000
-rfbauth /root/.vnc/passwd -rfbport 5901
-fp /usr/share/fonts/X11/misc/,/usr/share/fonts/X11/Type1/,/usr/share/
fonts/X11/75dpi/,/usr/share/fonts/X11/100dpi/
-co /etc/X11/rgb
/bin/sh /root/.vnc/xstartup
================================================================================
AZARTICOLO:Come far partire una sessione LXDE automaticamente dopo che il server
VNC e' salito in modo che sia pronta quando il vnclient si connette ?
================================================================================
I have system which is equipped with Intel Celeron processor 1.1 GHz s370 with 384
Mb of RAM
on Intel d815egew motherboard which supports wake-on-lan function.
I want to use such a PC for Internet sharing to the local network.
Also this PC is a DHCP+DNS server as well as router/gateway.
Based on above I decided to install Lubuntu as it is lightweight system.
I installed Lubuntu 10.04.4 LTS from alternate ISO. System has no auto login.
System boots and has acceptable performance.
eth0 – ethernet controller which is used for Local Network connections. Has
static address 10.0.0.1
eth1 – ethernet controller which is not used and not configured so far, I plan
to connect printer here later on.
eth2 - ethernet controller which is used to connect to Internet, which we plan
to share for the local network
wlan0 – wireless controller, it is used in role of access poit for local
Network and has address 10.0.0.2
cd /etc/init.d/
made a new file with command
vim wakeonlanconfig
Wrote the following lines to the newly created file, saved and closed it
#!/bin/bash
ethtool -s eth0 wol g
ethtool -s eth2 wol g
exit
Than we need to have a possibility to connect remotely to the host via SSH and VNC.
So, I installed following packets with the following commands:
apt-get update
apt-get install openssh-server tightvncserver
halt
Then I went to remote place, send magic paket and powered the Host up. System
started...
And I connected to the host via Putty from remote system under Windows.
Than logged in and run the command to start vnc server.
Log file is
/root/.vnc/gateway:2.log
Using UltraVNC Viewer programm under windows I connected to the host's vnc server,
enterd the
password and.... sow only mouse cursor in form of cross on a grey background of
800x600 dots,
no desktop.
#!/bin/sh
xrdb $HOME/.Xresources
xsetroot -solid grey
#x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#x-window-manager &
# Fix to make GNOME work
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
The Question:
---------------------
What I have to change and where to make LXDE session start automatically after
tightvncserver
starts?
/usr/bin/startlxde
I think if you install Lubuntu as the OS, then you get a slightly different
configuration than if you
installed lxde-desktop onto Ubuntu. In the first case /usr/bin/startlubuntu is
present,
in the second case likely /usr/bin/startlxde.
In Lubuntu 13.04, my ~/.vnc/xstartup looked like that shown earlier,and gives the
grey screen
with old-fashioned cursor - this indicates that the virtual desktop has been
created,
but there's nothing on the desktop.
and restarting tightserver, gives the panel on the desktop, from which you can
launch apps.
Unfortunately these app windows are not rendered with a title bar or borders, and
no taskbar
button. A number of icons are different too.
================================================================================
AZARTICOLO:Installare il VNC server.
================================================================================
/etc/init.d/vncserver
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: S
# Default-Stop: 0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:$
{DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
--------------------------------------------------------------------------------
root@azlampone:/etc/init.d# cat /etc/init.d/vncserver
--------------------------------------------------------------------------------
#!/bin/sh -e
### BEGIN INIT INFO
# Provides: vncserver
# Required-Start: networking
# Default-Start: S
# Default-Stop: 0 6
### END INIT INFO
PATH="$PATH:/usr/X11R6/bin/"
. /lib/lsb/init-functions
case "$1" in
start)
log_action_begin_msg "Starting vncserver for user '${USER}' on localhost:$
{DISPLAY}"
su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;
stop)
log_action_begin_msg "Stoping vncserver for user '${USER}' on localhost:${DISPLAY}"
su ${USER} -c "/usr/bin/vncserver -kill :${DISPLAY}"
;;
restart)
$0 stop
$0 start
;;
esac
exit 0
---------------------------------------------------------------------------------
insserv: warning: script 'mathkernel' missing LSB tags and overrides
---------------------------------------------------------------------------------
================================================================================
VNC Connect and Raspberry Pi (NUOVO)
================================================================================
https://www.realvnc.com/en/connect/docs/raspberry-pi.html
Premessa
--------------
VNC is a graphical desktop sharing system that allows you to remotely control the
desktop
interface of one computer (running VNC Server) from another computer or mobile
device
(running VNC Viewer).
VNC Viewer transmits the keyboard and either mouse or touch events to VNC Server,
and
receives updates to the screen in return.
You will see the desktop of the Raspberry Pi inside a window on your computer or
mobile
device. You'll be able to control it as though you were working on the Raspberry Pi
itself.
It consists of both VNC Server, which allows you to control your Raspberry Pi
remotely,
and VNC Viewer, which allows you to control desktop computers remotely from your
Raspberry Pi should you want to.
You must enable VNC Server before you can use it: instructions for this are given
below.
By default, VNC Server gives you remote access to the graphical desktop that is
running
on your Raspberry Pi, as though you were sitting in front of it.
However, you can also use VNC Server to gain graphical remote access to your
Raspberry Pi
if it is headless or not running a graphical desktop.
For more information on this, see Creating a virtual desktop, further below.
RealVNC have ported their VNC server and viewer applications to Pi, and they are
now integrated
with the system. To enable the server, select the option on the Interfaces tab in
Raspberry Pi
Configuration; you’ll see the VNC menu appear on the taskbar, and you can then log
in to your Pi
and control it remotely from a VNC viewer.
The RealVNC viewer is also included – you can find it from the Internet section of
the
Applications menu – and it allows you to control other RealVNC clients, including
other Pis.
Please note that if you already use xrdp to remotely access your Pi, this conflicts
with the
RealVNC server, so you shouldn’t install both at once.
If you’re updating an existing image, don’t run the apt-get install realvnc-vnc-
server line
in the instructions below. If you want to use xrdp on a clean image, first
uninstall the
RealVNC server with apt-get purge realvnc-vnc-server before installing xrdp.
(If the above paragraph means nothing to you, then you probably aren’t using xrdp,
so you don’t have to worry about any of it!)
Also included is the new SenseHAT emulator, which was described in a blog post a
couple of weeks ago;
have a look here for all the details.
From the September 2016 version of Raspbian, VNC Server is built-in to the
Raspberry Pi,
licensed for non-commercial use and ready to use.
If you have Raspbian Jessie with PIXEL, VNC Connect is included with your Raspberry
Pi.
It’s completely free for non-commercial use.
VNC Connect consists of two apps, VNC Server and VNC Viewer:
VNC Server enables you to connect to your Pi from a desktop computer or mobile
device,
watch its screen in real-time, and exercise control as though you were
sitting in front
of it.
VNC Viewer enables you to connect to and control a desktop computer (or another Pi)
from your Pi, should you want to.
VNC Connect is included with Raspbian but you still have to enable it.
First, run the following commands to make sure you have the latest version of VNC
Server
and VNC Viewer:
apt-get update
apt-get install realvnc-vnc-server
apt-get install realvnc-vnc-viewer
You can enable VNC Server at the command line using raspi-config:
raspi-config
From now on, VNC Server will start automatically every time you boot your Raspberry
Pi. S
By default, VNC Server remotes the graphical desktop running on your Raspberry Pi.
However, if your Pi is headless (not plugged into a monitor) or not running a
graphical desktop,
VNC Server can still give you graphical remote access using a virtual desktop.
There are two ways to connect; you can use either or both.
Please make sure you’ve downloaded our VNC Viewer app to computers or devices you
want to control from.
Direct connections are quick and simple providing you’re joined to the same private
local
network as your Raspberry Pi (for example, a wired or Wi-Fi network at home, school
or in the office).
If you’re connecting over the Internet, it’s much safer and more convenient to
establish
a cloud connection.
On your Raspberry Pi, discover its private IP address by double-clicking the VNC
Server
icon on the taskbar and examining the status dialog:
https://www.realvnc.com/en/connect/download/viewer/
On the device you will use to take control, run VNC Viewer and enter the IP address
in the search bar
Cloud connections are convenient and encrypted end-to-end, and highly recommended
for connections over the Internet. There’s no firewall or router reconfiguration,
and you
don’t need to know the IP address of your Raspberry Pi, or provide a static one.
You’ll need a RealVNC account; it’s completely free to set up and only takes a few
seconds.
We’ll give you a special version of our Home subscription that enables both cloud
and direct
connectivity, and also in-session features such as system authentication, file
transfer, printing and chat.
You can apply your Home subscription to five Raspberry Pis and/or desktop computers
in total.
Please note you revert to the standard feature set for Windows, Mac and Linux
desktop computers.
Sign up for a RealVNC account by entering your email address in the box on this
page,
and following the instructions.
On your Raspberry Pi, select Licensing from the VNC Server status menu, choose
Sign in to your RealVNC account, and enter your new account email and password:
On the device you will use to take control, run VNC Viewer and sign in using the
same
account credentials.
If you're connecting from the compatible VNC Viewer app from RealVNC, enter the
user
name and password you normally use to log in to your user account on the Raspberry
Pi.
By default, these credentials are pi and raspberry.
If you're connecting from a non-RealVNC Viewer app, you'll first need to downgrade
VNC Server's authentication scheme, specify a password unique to VNC Server, and
then
enter that instead.
If you are in front of your Raspberry Pi and can see its screen, open the VNC
Server dialog
on your Raspberry Pi, select Menu > Options > Security, and choose VNC password
from
the Authentication dropdown.
Or if you're configuring your Raspberry Pi remotely from the command line, then to
make
the changes for Service Mode (the default configuration for the Raspberry Pi):
VNC Server can remote the screen of Raspberry Pi apps that use a directly rendered
overlay,
such as Minecraft, the text console, the Pi camera module, and more.
You can remotely access apps which use a directly rendered overlay, such as
Minecraft,
the text console, the Raspberry Pi Camera Module, and more.
On the device you'll use to take control, run VNC Viewer and connect.
Note: existing connections must be restarted in order for these changes to take
effect.
You can transfer files to and from your Raspberry Pi providing you’re connecting
from
VNC Viewer running on a Windows, Mac or Linux desktop computer.
To transfer files to your Raspberry Pi, click the VNC Viewer toolbar button and
follow the
instructions. Detailed steps are here.
To transfer files from your Raspberry Pi, use VNC Viewer to open the VNC Server
dialog
remotely, select Menu > File transfer, and follow the instructions.
Then, use VNC Viewer to select File > Print remotely (or whatever the standard
command
is for the page or file you want to print). VNC Server directs the output to VNC
Viewer, and
spools it to your local printer. There’s more information about remote printing
here.
https://www.realvnc.com/en/connect/docs/printing.html#printing
If your Raspberry Pi is headless (that is, not plugged into a monitor) or embedded
in a robot,
it’s unlikely to be running a graphical desktop.
VNC Server can run in Virtual Mode to create a resource-efficient virtual desktop
on demand,
giving you graphical remote access even when there is no actual desktop to remote.
This virtual desktop exists only in your Raspberry Pi’s memory:
To do this:
B) Lanciamo:
# vncserver
On some distributions (in particular Red Hat), you may get a better experience by
running vncserver-virtual in conjunction with the system Xorg server, rather
than the old version built-in to Xvnc.
More desktop environments and applications will likely be compatible.
I vecchi processi:
/usr/share/fonts/X11/100dpi/:unscaled,
/usr/share/fonts/X11/Type1,
/usr/share/fonts/X11/100dpi,built-ins
0 S root /bin/sh /root/.vnc/xstartup
4 S root /usr/bin/vncserverui virtual 14
0 S root /usr/bin/vncserverui -statusicon 6
xrdb $HOME/.Xresources
xsetroot -solid grey
export XKL_XMODMAP_DISABLE=1
/etc/X11/Xsession
A virtual desktop persists until you explicitly destroy it. Run the following
command
when you are sure it is no longer needed:
Note this command will terminate any current connections without warning to those
users.
You can operate VNC Server exclusively at the command line or via SSH if you
prefer.
Common commands for Raspbian Jessie (which is based on Debian 8, and uses systemd)
are:
If this menu is not available, or you want more control, specify settings in the
/boot/config.txt file:
See the Raspberry Pi documentation for more hdmi_mode options, and information on
/boot/config.txt in general. You will need to reboot your Raspberry Pi for any
changes to
take effect.
Note that settings you specify in this file override monitors you subsequently plug
in
(unless you revert hdmi_force_hotplug), so pick a ‘headless’ resolution compatible
with
your regular monitor.
If you run VNC Server in Virtual Mode to create a virtual desktop, you can specify
the
screen resolution (geometry) at start up, for example:
vncserver -randr=1366x768
You can even specify multiple screen resolutions and cycle between them.
On your Raspberry Pi, open the VNC Server dialog and select Menu > Options >
Expert.
Change the Encryption parameter to AlwaysOff.
Restart any existing connections.
================================================================================
AZARTICOLO: RealVNC : How do I use VNC Server in Virtual Mode
in conjunction with
the latest Xorg server?
================================================================================
By default under Linux, VNC Server in Virtual Mode uses a version of the Xorg
server built-in to Xvnc.
This is old, and hard to update.
From VNC Connect 6.2.0, you can configure VNC Server to utilise the latest version
of the
Xorg server present on your system instead. More desktop environments, applications
and extensions will likely be compatible out-of-the-box, giving a much better user
experience, especially on Red Hat-compatible distributions.
Note: If you are using Ubuntu, SUSE or Raspbian, you should continue to use Xvnc.
This means that under Ubuntu and SUSE you will still need to switch desktop
environment
in order to avoid the grey screen. There's no issue under Raspbian, however, as the
default
PIXEL desktop environment works well with Xvnc.
Requirements
---------------------
Xorg and the Xorg dummy video driver must be installed. For example:
To enable the system Xorg server for all users, run vncinitconfig -enable-system-
xorg as root.
Run without root privileges to enable just for you.
To disable the system Xorg server and use Xvnc again, run vncinitconfig -disable-
system-xorg.
VNC Server parameters can be specified in the following new configuration files:
Note that the vncinitconfig -enable-system-xorg script offers to copy over existing
parameters
from /etc/vnc/config.d/Xvnc and ~/.vnc/config.d/Xvnc respectively for you.
Note: The RandR VNC Server parameter cannot enable users to switch between
available
screen resolutions. See Xorg configuration, below.
Xorg options
--------------------
/etc/vnc/config
/etc/vnc/config.custom
~/.vnc/config (ignored if the -config flag is used, below)
These options are passed directly to the system Xorg server. Consult the Xorg man
page
for a list of valid options; invalid options cause errors.
Note that the following options supported by Xvnc are not supported:
-blackpixel, -whitepixel, -linebias, -pixdepths, -pixelformat, -screen.
You can specify the -geometry WxH and -depth N options in any of the locations
specified
in Xorg options, above, or appended to vncserver-virtual at the command line.
By default, the initial geometry must be a standard resolution
(for example, 640x480, 800x600 or 1024x768); see Xorg configuration, below, for
specifying
non-standard resolutions. Consult the Xorg man page and your chosen desktop
environment
for supported depth values.
Xorg configuration
----------------------------
Note the VNC Server RandR parameter cannot be used to enable a connected VNC Viewer
user to cycle between available screen resolutions during a remote control session.
The connected user should use the standard Screen Display or Monitor app instead.
Xstartup
------------
Xstartup scripts can continue to be used to specify desktop environments and
applications
for virtual desktops in the same way as for Xvnc.
Known issues
----------------------
When using the Xfce or KDE desktop environments, some fonts may appear small,
depending
on the screen resolution.
To fix this for Xfce, navigate to Applications > Settings > Appearance and enable
Custom DPI
setting on the Fonts tab, making sure this is set to 96.
To fix this for KDE, navigate to System Settings > Application Appearance and
enable
Force fonts DPI on the Fonts tab, making sure this is set to 96.
================================================================================
Secure your connection
realjjaveweb edited this page on Mar 18, 2022 · 19 revisions
Pages 12
Find a page…
Home
Compiling TigerVNC for Windows
Debug Logs
Development
Development: DesktopSize
Development: Latency
Development: Making a Release
Development: SetDesktopSize Cleanup
Keyboard shortcuts
Secure your connection
What is a X.509 certificate?
Certificate from an External Certificate Authority
Create a self-signed certificate
Windows
Linux
Manage the certificates
Use the certificate with TigerVNC
Setup TigerVNC server (Windows)
Systemd unit for x0vncserver
Clone this wiki locally
https://github.com/TigerVNC/tigervnc.wiki.git
What is a X.509 certificate?
"X.509" is a standard type of certificate commonly used for websites. However, they
are also useful for securing TigerVNC.
Certificates prove the identity of the computer you are viewing (the one with the
TigerVNC server).
Certificates keep private the contents of the communication between you and the
remote computer.
When it comes to obtaining a certificate, you can use an External Certificate
Authority if you own a domain name, or create a self-signed certificate.
If your public website is example.com, rename your local network to something like
local.example.com
Obtain a certificate for computer1.local.example.com. Assuming computer1 is not
available to the public internet, you need to use a DNS-01 challenge. (If you are
using Let's Encrypt, see https://letsencrypt.org/docs/challenge-types/#dns-01-
challenge)
When you want to connect to computer1 on your network, type the hostname as
computer1.local.example.com
Note: External Certificate Authorities have certificate transparency requirements
that post the details of every certificate publicly. So don't name your computers
after any secret company projects.
Once you obtain your certificate, see Use the certificate with TigerVNC
Windows
Unfortunately TigerVNC doesn't understand Windows-style certificates saved in the
Windows certificate store or that end with the file extension .pfx. However, you
can download OpenSSL to do the job.
Find out the local IP address of the computer running the TigerVNC server. See
LifeHacker's instructions.
Visit
http://wiki.overbyte.eu/wiki/index.php/ICS_Download#Download_OpenSSL_Binaries_.28re
quired_for_SSL-enabled_components.29 (Of the binaries suggested by OpenSSL, this is
the simplest to run.)
Choose the latest .zip download that matches your computer system (probably the
first one labeled "Win-64")
Uncompress the zip file.
Go to the uncompress folder and double click openssl.exe.
If you have Windows Defender SmartScreen, you may have to choose More info > Run
anyway.
Type the following (replace both instances of "192.168.1.5" with the local IP
address you found in step 1 above) req -x509 -newkey rsa -days 365 -nodes -config
openssl.cnf -keyout vnc-server-private.pem -out vnc-server.pem -subj
'/CN=192.168.1.5' -addext "subjectAltName=IP:192.168.1.5"
Linux
Find out the local IP address of the computer running the TigerVNC server. See
Stackoverflow instructions.
Open Terminal (if you haven't already)
Install OpenSSL
On RedHat/CentOS/Fedora, type: sudo yum install openssl
On Debian/Ubuntu, type: sudo apt-get install openssl
Create a self-signed certificate. Type the following (replace both instances of
"192.168.1.5" with the local IP address you found in step 1 above) openssl req -
x509 -newkey rsa -days 365 -nodes -config openssl.cnf -keyout vnc-server-
private.pem -out vnc-server.pem -subj '/CN=192.168.1.5' -addext
"subjectAltName=IP:192.168.1.5"
On Ubuntu (and related distros), you may also need to change the path to
openssl.cnf to /usr/lib/ssl/openssl.cnf
The certificate you created expires in 365 days. A year from now, you will need to
go through these steps again and create a new certificate.
Right click the TigerVNC icon in the system tray (bottom right in Windows) and
choose Options
Under "Session encryption" choose TLS with X.509 certificates, and uncheck None and
Anonymous TLS.
Choose Load X.509 Certificate. Browse to the public key file you saved above ("vnc-
server.pem").
Choose Load X.509 Certificate key. Browse to the private key file you saved above
("vnc-server-private.pem").
Choose Apply
Copy the public key file ("vnc-server.pem") to your remote computer. Save it in the
same folder as the TigerVNC viewer. This avoids some problems with the TigerVNC
viewer on Windows.
On the remote (client) computer:
================================================================================
AZARTICOLO: REALIZZAZIONE RETE
================================================================================
Tolto NetworManager connman wicd
~# ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING> mtu 65536
inet 127.0.0.1 netmask 255.0.0.0
loop txqueuelen 1 (Local Loopback)
RX packets 40 bytes 4751 (4.6 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 40 bytes 4751 (4.6 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
-----------------------------------------------------------------------------------
-----------------------------------------------
root@raspi:/etc/network# cat interfaces
-----------------------------------------------------------------------------------
-----------------------------------------------
# interfaces(5) file used by ifup(8) and ifdown(8)
#AZPATCH
auto lo wlan0
iface lo inet loopback
#allow-hotplug eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
metric 1
#up route add default gw 192.168.1.1 metric 1 dev eth0
dns-nameservers 192.168.1.1 8.8.4.4
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface azcam inet static
address 192.168.1.7
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
wireless-power off
metric 2
#up route add default gw 192.168.1.1 metric 2 dev wlan0
#down route del default gw 192.168.1.1 metric 2 dev wlan0
dns-domain homenet.telecomitalia.it
dns-nameservers 192.168.1.1 8.8.8.8
iface default inet dhcp
-----------------------------------------------------------------------------------
-----------------------------------------------
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
-----------------------------------------------------------------------------------
-----------------------------------------------
update_config=1
country=IT
network={
ssid="CISCOWIFI"
psk="intrapam123$"
proto=WPA
key_mgmt=WPA-PSK
pairwise=TKIP
auth_alg=OPEN
id_str="azcam"
}
-----------------------------------------------------------------------------------
-----------------------------------------------
ip link
----------
ma dopo 5 min muore per cui occorre risolvere il problema del wifi poweroff
===================================================================================
========
AZARTICOLO Wireless and eth0 Static IP on Raspberry PI with Wi-Pi
===================================================================================
========
I just received my Raspberry PI and had a few problems configuring the static IP on
the
wireless connection. I use the Wi-Pi official WLAN USB module and I really need to
use
the Raspbery PI without any cables attached (except for the power suppy).
It is quite easy after you know how to do it, so here are the steps that will help
you
understand how to configure your Raspberry PI to use manual (static) IP and so get
rid of
the problem of having a new IP every time you reboot it.
First time you’ll have to connect to ssh, login and then use the following
commands:
raspberry pi ifconfig
2 – vi /etc/wpa_supplicant/wpa_supplicant.conf
– this second command will allow you to edit the wpa_supplicant.conf file
wpa_supplicant.conf
-------------------
You must change the text “home” in the ssid line with the one that you have
configured
on your wireless router, then change the password too.
The most important thing is to add the last line:
id_str="acasa"
This will be your WLAN id from now on (you may change its name to a different one,
I used acasa in my case).
After you finished editing the file press CTRL + O and then Enter to write your
code to the file then press CTRL + X to exit.
3 – vi /etc/network/interfaces
this is the third command and will show you the content of the interfaces
file where
you need to add the following text (edit the IP, gateway and netmask as you
desire)
auto lo
auto eth0
allow-hotplug wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface acasa inet static
address 192.168.0.104
netmask 255.255.255.0
gateway 192.168.0.1
raspberry pi interfaces
After you finished editing the file press CTRL + O and then Enter to write your
code to the f
ile then press CTRL + X to exit.
4 /etc/init.d/networking restart
– this is the last command and will restart your network.
If by bad luck your wi-fi connection doesn’t start up then use this command ifup
wlan0
As you can see in the picture above the USB module is ON and if you succeeded too
then
you can enjoy the freedom of the wireless connection on your Raspberry Pi.
===================================================================================
=========
AZARTICOLO:BridgeNetworkConnectionsProxyArp
===================================================================================
=========
Translation(s): English
Indice
Introduction
-------------------
This document describes a means to bridge IP traffic between two interfaces using
Proxy ARP, /32 host routes and standard Linux routing/forwarding.
For a Layer 2 solution - an ethernet bridge - refer to BridgeNetworkConnections.
The benefit of using an IP / Layer 3 solution is that it will work when the
outward-facing
interface is a wireless ethernet client, without using WDS and without resorting to
NAT.
Simple Layer 2 bridging does not work in this case due to the vagaries of wireless
AP
client behaviour; WDS may help but AP support can be patchy.
Using Proxy ARP permits the bridged clients to be part of the existing network and
supports bidirectional traffic, e.g. for a server or printer.
DHCP and mDNS will also work using the appropriate helpers.
One scenario is connecting a wired network to a wireless LAN using a host that has
both
wifi (wlan0) and ethernet (eth0) interfaces.
No static configuration is required other than the wifi SSID and authentication for
the Pi -
the Pi and printer acquire DHCP addresses from the existing DHCP server, and the
printer
continues to be reachable via mDNS and otherwise operates as if it were patched to
a
wired port on the main network.
The term 'bridge' in this document refers to the host doing the proxy-arp and
routing
between the two networks, though keep in mind there is no layer 2 bridging
involved.
The 'outside' network is the existing network that hosts the DHCP server, gateway
router, etc.
The 'inside' network is the one with the hosts that need to be bridged and made to
appear
to be on the outside network.
Summary
----------------
Proxy ARP is a technique by which a device on a given network answers the ARP
queries
for a network address that is not on that network, that is to make the hosts on one
network
appear to be logically part of a different physical network.
The bridge host will proxy ARP requests from the inside network to the outside, and
respond to
ARPs from the outside network on behalf of inside hosts. Linux will only do this
for hosts that are
known via the routing table, so a /32 host route must be created pointing to the
inside host
(one for each inside host). The route is also required for IP forwarding to work,
i.e. when IP
traffic arrives after the ARP process has completed.
As an example, to manually configure and test this out where the primary LAN has a
network address of 10.42.0.0/24:
ping from the inside host to an outside host, and examine the ARP table:
insidehost$ ping -c 1 10.42.0.2
PING 10.42.0.2 (10.42.0.2) 56(84) bytes of data.
64 bytes from 10.42.0.2: icmp_req=1 ttl=64 time=14.7 ms
Note that no IP address is required on the bridge's inside ethernet interface for
proxy ARP
to work (though see below re. DHCP relay).
If you run tcpdump on the bridge's ethernet and wlan interfaces, you'll see the ARP
request from the inside host being proxied to the outside interface, with the ARP
source
being the bridge's outside-facing interface's MAC address. The ARP table on the
inside hosts
will show the bridge's inside interface MAC for all outside hosts, and similarly
for outside
hosts the MAC for all inside hosts will be the bridge's outside interface MAC.
DHCP Relay
------------------
DHCP is a Layer 2 protocol and can't traverse the Layer 3 'bridge' so we use the
dhcp-helper
utility to listen for DHCP requests from the inside network and relay them to the
DHCP server
on the outside network. The relayed DHCP request will contain the IP address of the
bridge's
inside interface in order for the DHCP server to know which network to allocate an
IP address for the new client from. We want the DHCP allocation to be from the same
network as the outside LAN, the simplest implementation is to reflect the outside
interface's IP address on to the inside interface. i.e. the bridge's inside and
outside interfaces will have the same IP address; though the inside interface's
network
will be a host /32 netmask so as not to upset routing.
Alternatively the bridge inside interface can be assigned a static IP from the
outside network,
in which case the post-up step in /etc/network/interfaces configuration below can
be omitted.
parprouted does not handle packet forwarding nor DHCP or mDNS, so these features
need to be enabled separately.
The following assumes wlan0 is the already-configured outside interface, eth0 the
unconfigured inside interface. Tested on Debian Wheezy 7.8 on 2015-08-02, on armv6l
(Raspberry Pi v1).
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet manual
auto wlan0
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
post-up /usr/sbin/parprouted eth0 wlan0
post-down /usr/bin/killall /usr/sbin/parprouted
# clone the dhcp-allocated IP to eth0 so dhcp-helper will relay for the correct
subnet
post-up /sbin/ip addr add $(/sbin/ip addr show wlan0 | perl -wne 'm|^\s+inet
(.*)/| && print $1')/32 dev eth0
post-down /sbin/ifdown eth0
net.ipv4.ip_forward=1
[reflector]
enable-reflector=yes
Reboot, and hosts connected to the bridge's ethernet should acquire a DHCP address
and have full IP connectivity!
===================================================================================
===========
AZWAN:wpa_supplicant: GUI and wpa_action
===================================================================================
===========
I’ve made two new interesting discoveries about wpa_supplicant since writing my
last
blog post on the subject. (Actually, I pretty much made both of them while reading
documentation in order to write it, and have been lame about writing them up).
Using wpa_gui
It turns out that wpa_gui not only allows you to select existing networks, but also
to scan
for and add new networks to your configuration file. In addition, you can run it as
yourself,
without needing to it. In order to do so, you need to add two lines to
/etc/wpa_supplicant/wpa_supplicant.conf:
ctrl_interface_group=netdev
update_config=1
network={
ssid="nelhage"
id_str="nelhage"
key_mgmt=NONE
}
And then I add a new virtual interface to interfaces, corresponding to the id_str:
In conclusion…
This setup actually seems pretty close to the correct design for a roaming wifi
architecture, to me.
Unfortunately, my experience is that it hasn’t worked well for me;
For some reason, when I put it in roaming mode, it fails to associate with networks
that it
otherwise works fine with. I suspect that this is related to madwifi suckage as
much as
wpa_supplicant suck, though, so I’d encourage everyone else who’s been fighting
with wifi
to try it out and report back if it works for them.
-----------------------------------------------------------------------------------
---------------------------------------------
AZARTICOLO: Disable power management on Raspberry Pi USB Wifi interface
-----------------------------------------------------------------------------------
---------------------------------------------
Too early to tell whther this solved my problem but recording for posterity anyway.
In theory this will stop my Raspberry Pi from dropping off the network after it has
been
idle for a while.
Before
pi@dashboard ~ $ iwconfig
lo no wireless extensions.
Then
vi /etc/network/interfaces
add line: wireless-power off
After
pi@dashboard ~ $ iwconfig
wlan0 IEEE 802.11bgn ESSID:"Professor Ping"
Mode:Managed Frequency:2.437 GHz Access Point: B8:E6:25:9B:62:02
Bit Rate=26 Mb/s Tx-Power=20 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Power Management:off
Link Quality=43/70 Signal level=-67 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:29 Invalid misc:8 Missed beacon:0
lo no wireless extensions.
eth0 no wireless extensions.
Note: Power Management:off
cat /usr/lib/pm-utils/sleep.d/60_wpa_supplicant
#!/bin/sh
# /etc/pm/sleep.d/60_wpa_supplicant
PATH=/sbin:/usr/sbin:/bin:/usr/bin
WPACLI=wpa_cli
case "$1" in
suspend|hibernate)
$WPACLI suspend
;;
resume|thaw)
$WPACLI resume
;;
esac
exit 0
touch /etc/pm/sleep.d/60_wpa_supplicant
chmod 644 /etc/pm/sleep.d/60_wpa_supplicant
# Instructions said no exec flag
ne risulta :
-rw-r--r-- 1 root root 0 nov 5 19:16 60_wpa_supplicant
I rebooted for good measure. We'll see whether this one takes.
===================================================================================
=========
AZARTICOLO::How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 1
===================================================================================
=========
If you want a wifi router, ignore Part 2, and go from this part straight to Part 3.
Need internet access ? Part 2 or 3 is the go depending on your need
QuickLinks:
Also if you are using a RTL8188CUS based device check this forum thread
Update
-----------
Looks like the newest version of the Raspbian distro adds an extra line to
/etc/network/interfaces which needs to be removed or commented out.
** Update – 2016-11-06 **
---------------------------------
As requested, I’ve added some information from the comments – courtesy of Jakimfett
To find out what driver your USB WiFi stick uses, you can use lshw -C network to
find out.
The driver info is shown under the configuration section.
If lshw is not installed, you can install it via apt-get – apt-get install lshw
Introduzione
--------------------
* IBSS
* managed
* AP
* AP/VLAN
* WDS
* monitor
* mesh point
I installed hostapd so that I could run an access point off the Raspberry Pi.
After I installed hostapd, I had to modify a few files before hostapd would run.
Before I go modifying the files though, I need to give my WiFi adapter a static IP
address.
In /etc/network/ there is a file called interfaces.
This file contains the details for the network adapters.
DAEMON_CONF="/etc/hostapd/hostapd.conf"
ctrl_interface=/var/run/hostapd
ctrl_interface_group=0 # These 2 are just parameters so that the hostap daemon
runs.
wpa_key_mgmt=WPA-PSK
wpa_pairwise=CCMP
rsn_pairwise=CCMP
# I've set these to WPA-PSK to indicate that we are using a Pre-Shared Key with
CCMP encryption.
# Otherwise, hostapd also has a built in RADIUS server that we can use for
authentcation
# But I'll leave that to another post.
# Other settings
----------------------------
beacon_int=100 # This sets how often the WiFi will send a beacon out.
auth_algs=3
wmm_enabled=1
** Note ** You may need to strip out all the comments when you save your
configuration file as hostapd does not have consistent comment handling.
With the above configuration file saved, I downloaded dnsmasq in order to give my
Raspberry Pi the ability to hand out IP addresses to clients that connected to the
RaspAP.
apt-get install dnsmasq
For now, we’ll only do a base configuration of dnsmasq, just enough for it to hand
out IP addresses so we can test out our new RasAP.
In the next post, we will turn the Raspberry Pi into a bridge so that it can act as
a wireless access point.
If you have found this post useful, please consider donating by pressing on the
button below. Donating will help keep this site up and running 🙂
-----------------------------------------------------------------------------------
--------------------------------------------------
AZARTICOLO:How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 2
-----------------------------------------------------------------------------------
-----------------------------------------------
In this part, we will turn the Raspberry Pi into a Wireless Access point.
-----------------------------------------------------------------------------------
---------------------------------------------------
All it will do is forward packets from the WiFi adapter to ethernet and vice versa.
It will allow you to access your network via WiFi without needing a WiFi router.
To do this, we need to bridge the ethernet and wifi connections, and tell hostapd
that we are now using a bridge connection.
In /etc/hostapd/hostapd.conf, we need to add the following line.
bridge=br0
#auto br0
iface br0 inet dhcp
bridge_ports eth0 wlan0
pre-up ifconfig eth0 0.0.0.0 up
pre-up ifconfig wlan0 0.0.0.0 up
pre-up brctl addbr br0
pre-up brctl addif br0 eth0
post-down ifconfig wlan0 0.0.0.0 down
post-down ifconfig eth0 0.0.0.0 down
post-down brctl delif br0 eth0
post-down brctl delbr br0
Once the lines are in /etc/network/interfaces, you can type in ifup br0 as root to
bring up the bridge. If you are ssh’ed into the Pi, this will drop your connection.
Once it’s up, the Raspberry Pi will forward anything from the WiFi to ethernet and
vice versa.
This let’s the Raspberry Pi act as a Wireless Access Point without any sort of
routing. On a WiFi device, you will be able to connect to RaspAP, and it will act
is if it was on the network, i.e. it will get an IP address from your normal
router.
-----------------------------------------------------------------------------------
--------------------------------------------------
AZARTICOLO:How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 3
-----------------------------------------------------------------------------------
--------------------------------------------------
QuickLinks
Part 1 – How to create a wireless network on your RPi
Part 2 – How to make your RPi into a Wireless Access Point
Part 3A – Issues with HostAPD ? Click here
Part 3B – Issues with HostAPD ? Click here!
In Part 3, we will turn the Raspberry Pi into a router. The Pi will use the
ethernet port as the “WAN” port, and the wireless adapter as the “LAN” side of
things.
First thing we need to do is to enable packet forwarding.
In the file /etc/sysctl.conf, we need to uncomment the following line (should be
line 28).
#net.ipv4.ip_forward=1
After changing that, run this command to re-read the sysctl.conf file
sysctl -p
We will also need to install the iptables utilities if they are not already
installed, and alter the dnsmasq.conf file so that dnsmasq will assign a gateway to
the computers.
dhcp-option=3,10.0.0.1
iptables -F
iptables -X
chmod +x /etc/network/if-up.d/router
Once that router.sh file has been run, it should start forwarding traffic from the
WiFi Interface to the LAN interface !
** UPDATE **
As a few people have found out, the IP address of the Pi does not get set correctly
until you take down wlan0 and bring it back up after hostapd starts.
I have not found out why yet, but the workaround I am currently using consists of
editing /etc/init.d/hostapd, and modifying the start case statement to include
ifdown wlan0 && ifup wlan0 at the end of it.
I failed to copy the statement I am talking about, but if you’re familiar with
scripting it shouldn’t be too hard to figure out. Otherwise I’ll get the code I
modified up here soon.
** UPDATE 2 **
Looks like a Pi user has successfully gotten hostapd running on the realtek
devices.
Info can be found here
-----------------------------------------------------------------------------------
----------
AZARTICOLO:Raspberry Pi As A Wireless Access Point/Router Part 3A!
-----------------------------------------------------------------------------------
------------
Linux, Raspberry Pi, Tutorials 1 Response »
So a few people have tried to follow Part 3 of this series of posts, and had issues
with the connections once everything is setup.
The main cause for that, was that hostapd would take away the IP address of wlan0
for some reason.
I worked around it by modifying the /etc/init.d/hostapd startup file.
In that file, there is a switch case statement which controls what the file does
depending on how you run the file.
The example below is what you will see part way down the file. What we need to do
is add in some commands into that block of code.
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
log_end_msg "$?"
;;
stop)
Which brings up wlan0 with the specified IP address. The IP address should have
been setup in Part 3 of this series.
case "$1" in
start)
log_daemon_msg "Starting $DESC" "$NAME"
start-stop-daemon --start --oknodo --quiet --exec "$DAEMON_SBIN" \
--pidfile "$PIDFILE" -- $DAEMON_OPTS >/dev/null
log_end_msg "$?"
ifup wlan0
;;
stop)
Alternatively to force wlan0 to use an ip.address, replace ifup wlan0 with this
ifconfig wlan0 10.0.0.1 netmask 255.255.255.0 up
Hopefully this helps everyone when they come to making their Pi a WiFi Router ! 😀
-----------------------------------------------------------------------------------
--------------------------------------------
AZARTICOLO:How To : Use The Raspberry Pi As A Wireless Access Point/Router Part 3…
B!
-----------------------------------------------------------------------------------
--------------------------------------------
So, I figured out why wlan0 doesn’t get an IP address when hostapd starts up.
ifplugd messes about with the interfaces when they go up and down, so the simplest
solution is to disable ifplugd for wlan0 !
INTERFACES="auto"
HOTPLUG_INTERFACES="all"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
Simply changing it to this
INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
will ensure that wlan0 will not lose it’s static IP address that’s configured in
/etc/network/interfaces when wlan0 goes up.
-----------------------------------------------------------------------------------
--------------------------------------------
Il sottoscritto ha la seguente configurazione:
cat /etc/default/ifplugd
Io attualmente utilizzo :
INTERFACES="wlan0 eth0"
HOTPLUG_INTERFACES=""
ARGS="-q -f -u0 -d10 -w -I -b"
SUSPEND_ACTION="stop"
===================================================================================
=========
AWLAN : Principali Parametri del Daemon ifplug.
===================================================================================
=========
===================================================================================
=========
/etc/wpa_supplicant/wpa_supplicant.conf DEFINITIVO
===================================================================================
=========
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=IT
network={
ssid="CISCOWIFI"
psk="intrapam123$"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
id_str="azcam"
}
===================================================================================
=========
/etc/network/inetrfaces DEFINITIVO
===================================================================================
=========
#AZPATCH
#auto lo wlan0
auto lo
iface lo inet loopback
#allow-hotplug eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
mtu 1492
metric 1
#up route add default gw 192.168.1.1 metric 1 dev eth0
#dns-nameservers 192.168.1.1 8.8.4.4
N.B: DEROGA 1
===================================================================================
=========
/etc/ifplugd/action.d/ifupdown DEFINITIVO
===================================================================================
=========
#!/bin/sh
# AZPATCH Gestione della wlan0 demandata a wpa_action
set -e
case "$2" in
up)
# if [ "$1" == eth0 ]; then /sbin/ifdown wlan0 ; fi # Riga Inserita
/sbin/ifup $1
;;
down)
/sbin/ifdown $1
# if [ "$1" == eth0 ]; then /sbin/ifup wlan0 ; fi # Ruga Inserita
;;
esac
N.B: DEROGA 2
===================================================================================
=========
/etc/ifplugd/action.d# cat /etc/rc.local DEFINITIVO
===================================================================================
=========
#!/bin/sh -e
#
# rc.local
#
# This script is executed at the end of each multiuser runlevel.
# Make sure that the script will "exit 0" on success or any other
# value on error.
#
# In order to enable or disable this script just change the execution
# bits.
#
# By default this script does nothing.
#/var/www/command/player_wdog.sh startup & > /dev/null 2>&1
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/dbus/system_bus_socket
DBUS_SESSION_BUS_PID=`cat /run/dbus/pid`
#pulseaudio --start
exit 0
N.B. Tale script viene eseguito una sola volta allo startup della macchina
==============================================================
AZARTICOLO:Switching between wired and wireless networks in Raspbian & Debian
==============================================================
http://www.aoakley.com/articles/2013-07-31-raspberry-pi-networking.php
Assunzioni
-----------------
Se il cavo di rete e' inserito si suppone che sono in casa e pertanto utilizzo un
indirizzo statico
Ignoro completamente il WIFI anche se ho il Dongle inserito
Se il cavo e' staccato ma sono in casa, utilizzo lo stesso indirizzo statico ma sul
WIFI
Se il cavo e' scollegato e non sono in casa il WIFI deve essere configurato con IP
Statico o
dinamico, in questo caso occorre un display o un network scanner per sapere quale
e'.
Il cav puo' essere scollegato anche durante il funzionamento, ma non si puo' fare
cosi con
il Dongle WIFI
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="aoakley-home"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="aoakley-home"
}
network={
ssid="PlusnetWireless9AAAA9"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="inlaws"
}
network={
ssid="aoakley-mifi"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="aoakley-mifi"
}
Nel file di esempio abbiamo tre reti tutte con sicurezza WPA-PSK security;
Nei casi piu' semplici posso avere anche una sola configurazione WIFI ma la stringa
identificativa
deve sempre esistere, la quale viene utilizzata nel file /etc/network/interfaces:
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface aoakley-home inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
dpkg-reconfigure ifplugd
#!/bin/sh
set -e
case "$2" in
up)
if [ "$1" == eth0 ]; then /sbin/ifdown wlan0 ; fi # Riga Inserita
/sbin/ifup $1
;;
down)
/sbin/ifdown $1
if [ "$1" == eth0 ]; then /sbin/ifup wlan0 ; fi # Ruga Inserita
;;
esac
Ovvero quando il kernel ci indica che eth0 e' su viene tirata su la configurazione,
viceversa
se il link cade l'interfaccia eth0 viene sconfigurata
DEROGA 2
----------------
La personalizzazione consiste nel fare anche l'esatto opposto per l'interfaccia
wlan0
Tuttavia io non ho proceduto a inserire tali righe perche' demando il compito della
gestione
di wlan0 a wpa_action
Ora occorre sincerarsi che eth0 sia definito come pluggabile ovvero occore
definire per essa
allow-hotplug nel file /etc/network/interfaces , oltre che assegnargli lo stesso
indirizzo
statico di wlan0:
allow-hotplug eth0
DEROGA 1
----------------
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.5
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface aoakley-home inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
Il problema e' che il WIFI USB consuma in maniera eccessiva, molto piu' di un mouse
o
di una keyboard e spegnerla ed accenderla crea una eccessiva fluttuazione di
amperaggio
N.B: Auto indica che l'interfaccia deve essere caricata al boot della macchina e
non spenta
fino allo shutdown
allow-hotplug permette agli script di gestione di portare l'interfaccia
nello stato di
on o off
Pertanto i due parametri non possono coesistere!
Effettua il reboot con Reboot con shutdown -r now , ed il gioco e' fatto!
==============================================================
AZARTICOLO:WPA ed eth0 entrambe attive (ma con subnet diverse)
==============================================================
L'obbietivo sarebeb utilizzare la LAN per andare verso la NAS con indirizzo statico
ed il
WIFI per collegarsi ad Internet
eth0: utilizza indirizzo statico e si connette solo alla LAN per andare verso
la NAS
pertanto non ha default gateway
cat /etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.101
netmask 255.255.255.0
auto wlan0
allow-hotplug wlan0
iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
address 192.168.0.157
netmask 255.255.255.0
broadcast 192.168.0.255
gateway 192.168.0.1
cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="****"
scan_ssid=1
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="****"
id_str="home"
priority=5
}
cat /etc/default/ifplugd
INTERFACES="eth0"
HOTPLUG_INTERFACES="eth0"
ARGS="-q -f -u0 -d10 -w -I"
SUSPEND_ACTION="stop"
Poi Nel file che personalizza lo startup mi assicuro che wlan0 sia salito (a volte
non lo fa!)
ed uccido il processo ifplugd daemon :
cat /etc/rc.local
#!/bin/sh -e
E tutto funziona!
Difatti costui in conseguenza del cambio di stato del link dopo aver gestito di
conseguenza
l'interfaccia monitorata (eth0) manda in esecuzione tale script per compiere
l'azione
complementare sull altra interfaccia (che comunque puo' essere specificata) wlan0
Di conseguenza se cancello il link ifplugd non riesce piu' a mandare in esecuzione
lo script che gestisce l'altra interfaccia!
Questo script esegue wpa_cli -i wlan0 reconnect se il cavo eth0 e' disconnesso
wpa_cli -i wlan0 disconnect se
il cavo eth0 e' connesso
Il link viene utilizzato proprio per chiamare tale script da dentro ifplugd quando
si
modifica lo stato di eth0
================================================================================
RASPBERRY:Boot options in config.txt
================================================================================
START_FILE, FIXUP_FILE
These options specify the firmware files transferred to the Videocore GPU prior to
booting.
START_X, START_DEBUG
DISABLE_COMMANDLINE_TAGS
CMDLINE
cmdline is the alternative filename on the boot partition from which to read the
kernel command line string; the default value is cmdline.txt.
KERNEL
kernel is the alternative filename on the boot partition to use when loading
the kernel. The default value on the Pi 1, Pi Zero, and Compute Module is
kernel.img, and on the Pi 2, Pi 3, and Compute Module 3 it is kernel7.img.
If kernel8.img is present on the Pi 3 or Compute Module 3, it will be loaded in
preference and entered in 64-bit mode.
KERNEL_ADDRESS
kernel_address is the memory address to which the kernel image should be loaded.
32-bit kernels are loaded to address 0x8000 by default,
and 64-bit kernels to address 0x80000. If kernel_old is set, kernels are loaded
to the address 0x0.
KERNEL_OLD
ramfsfile is the optional filename on the boot partition of a ramfs to load. More
information is available here.
RAMFSADDR
INITRAMFS
The initramfs command specifies both the ramfs filename and the memory address to
which to load it. It performs the actions of both ramfsfile and ramfsaddr in one
parameter. Example values are: initramfs initramf.gz 0x00800000. NOTE: This option
uses different syntax from all the other options, and you should not use a =
character here.
INIT_UART_BAUD
init_uart_baud is the initial UART baud rate. The default value is 115200.
INIT_UART_CLOCK
init_uart_clock is the initial UART clock frequency. The default value is 48000000
(48MHz). Note that this clock only applies to UART0 (ttyAMA0 in Linux), and that
the maximum baudrate for the UART is limited to 1/16th of the clock. The default
UART on the Pi 3 and Pi Zero is UART1 (ttyS0 in Linux), and its clock is the core
VPU clock - at least 250MHz.
BOOTCODE_DELAY
This is particularly useful to insert a delay before reading the EDID of the
monitor, for example if the Pi and monitor are powered from the same source, but
the monitor takes longer to start up than the Pi. Try setting this value if the
display detection is wrong on initial boot, but is correct if you soft-reboot the
Pi without removing power from the monitor.
BOOT_DELAY
BOOT_DELAY_MS
DISABLE_SPLASH
If disable_splash is set to 1, the rainbow splash screen will not be shown on boot.
The default value is 0.
===============================================================
DISABILITARE WIFI
===============================================================
blacklist brcmfmac
blacklist brcmutil
sudo crontab -e
How would you use the blacklist method to disable the ethernet (eth0)?
To completely disable the onboard WiFi from the firmware on the Pi3, add
dtoverlay=pi3-disable-wifi
in /boot/config.txt.
to re-enable the wifi adapter you should write two times "sudo iwconfig wlan0
txpower auto".
but as a say you should write it two times otherwise it wont work
(i believe there is some glitch in the firmware)
Apart from blacklisting which has the risk of a lockout in case you need to
reboot and no ethernet is available, you can also unload the kernel module
as follows:
But I'm not sure unloading the device drivers is a good idea as I fear the
wlan0 device may still draw power and even more so if the device drivers'
power management features are not loaded, currently I keep drivers loaded
and simply make sure the default route via wlan0 is disabled:
This will make sure all traffic will go via eth0 and (hopefully) be more stable
and so forth for example for the ntp daemon.
We have measured the RF from the Pi 3 (when used as a WiFi hotspot) and
confirmed that this statement disables the Pi's WiDi transmitter when used
as a hot spot:
exit 0
===============================================================
README WIFI OVERLAY
===============================================================
https://github.com/raspberrypi/firmware/tree/master/boot/overlays
Introduction
==========
This directory contains Device Tree overlays. Device Tree makes it possible
to support many hardware configurations with a single kernel and without the
need to explicitly load or blacklist kernel modules. Note that this isn't a
"pure" Device Tree configuration (c.f. MACH_BCM2835) - some on-board devices
are still configured by the board support code, but the intention is to
eventually reach that goal.
device_tree=
to your config.txt, which should cause your Pi to revert to the old way of
doing things after a reboot.
In /boot you will find a .dtb for each base platform. This describes the
hardware that is part of the Raspberry Pi board. The loader (start.elf and its
siblings) selects the .dtb file appropriate for the platform by name, and reads
it into memory. At this point, all of the optional interfaces (i2c, i2s, spi)
are disabled, but they can be enabled using Device Tree parameters:
dtparam=i2c=on,i2s=on,spi=on
GPIO numbering uses the hardware pin numbering scheme (aka BCM scheme) and
not the physical pin numbers.
raspi-config
==========
The Advanced Options section of the raspi-config utility can enable and disable
Device Tree use, as well as toggling the I2C and SPI interfaces. Note that it
is possible to both enable an interface and blacklist the driver, if for some
reason you should want to defer the loading.
Modules
=======
As well as describing the hardware, Device Tree also gives enough information
to allow suitable driver modules to be located and loaded, with the corollary
that unneeded modules are not loaded. As a result it should be possible to
remove lines from /etc/modules, and /etc/modprobe.d/raspi-blacklist.conf can
have its contents deleted (or commented out).
Using Overlays
==============
In the pre-DT world this would be loaded from /etc/modules, with an explicit
"modprobe lirc-rpi" command, or programmatically by lircd.
With DT enabled, this becomes a line in config.txt:
dtoverlay=lirc-rpi
dtoverlay=lirc-rpi,gpio_out_pin=17,gpio_in_pin=13
Parameters always have default values, although in some cases (e.g. "w1-gpio")
it is necessary to provided multiple overlays in order to get the desired
behaviour. See the list of overlays below for a description of the parameters
and their defaults.
===============================
The Overlay and Parameter Reference
===============================
audio Set to "on" to enable the onboard ALSA audio interface (default
"off")
i2c_arm Set to "on" to enable the ARM's i2c interface
(default "off")
i2c_vc Set to "on" to enable the i2c interface usually reserved for the
VideoCore processor
(default "off")
i2c An alias for i2c_arm
i2c_arm_baudrate Set the baudrate of the ARM's i2c interface (default
"100000")
i2c_vc_baudrate Set the baudrate of the VideoCore i2c interface (default
"100000")
i2c_baudrate An alias for i2c_arm_baudrate
i2s Set to "on" to enable the i2s interface
(default "off")
spi Set to "on" to enable the spi interfaces
(default "off")
random Set to "on" to enable the hardware random number
generator (default "on")
sd_overclock Clock (in MHz) to use when the MMC framework requests
50MHz
sd_force_pio Disable DMA support for SD driver (default off)
sd_pio_limit Number of blocks above which to use DMA for SD card
(default 1)
sd_debug Enable debug output from SD driver
(default off)
uart0 Set to "off" to disable uart0 (default "on")
uart1 Set to "on" or "off" to enable or disable uart1
(default varies)
watchdog Set to "on" to enable the hardware watchdog (default
"off")
act_led_trigger Choose which activity the LED tracks.Use "heartbeat"
for a nice load indicator.
(default "mmc")
act_led_activelow Set to "on" to invert the sense of the LED (default "off")
N.B. For Pi3 see pi3-act-led overlay.
act_led_gpio Set which GPIO to use for the activity LED (in case you
want to connect it to an external device)
(default "16" on a non-Plus board, "47" on a Plus
or Pi 2)
N.B. For Pi3 see pi3-act-led overlay.
pwr_led_trigger
pwr_led_activelow
pwr_led_gpio As for act_led_*, but using the PWR LED.
Not available on Model A/B boards.
-----------------------------------------------------------------------------------
-----------
N.B. It is recommended to only enable those interfaces that are needed.
Leaving all interfaces enabled can lead to unwanted behaviour
(i2c_vc interfering with Pi Camera, I2S and SPI hogging GPIO pins, etc.)
Note also that i2c, i2c_arm and i2c_vc are aliases for the physical interfaces
i2c0 and i2c1. Use of the numeric variants is still possible but deprecated
because the ARM/VC assignments differ between board revisions.
The same board-specific mapping applies to i2c_baudrate, and the other
i2c baudrate parameters.
-----------------------------------------------------------------------------------
-----------
Name: adau1977-adc
Info: Overlay for activation of ADAU1977 ADC codec over I2C for control
and I2S for data.
Load: dtoverlay=adau1977-adc
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: adau7002-simple
Info: Overlay for the activation of ADAU7002 stereo PDM to I2S converter.
Load: dtoverlay=adau7002-simple,<param>=<val>
Parametri:
card-name Override the default, "adau7002", card name.
-----------------------------------------------------------------------------------
-----------
Name: ads1015
Info: Overlay for activation of Texas Instruments ADS1015 ADC over I2C
Load: dtoverlay=ads1015,<param>=<val>
Parametri:
addr I2C bus address of device. Set based on how the
addr pin is wired. (default=0x48 assumes addr
is pulled to GND)
cha_enable Enable virtual channel a. (default=true)
cha_cfg Set the configuration for virtual channel a.
(default=4 configures this channel for the
voltage at A0 with respect to GND)
cha_datarate Set the datarate (samples/sec) for this channel.
(default=4 sets 1600 sps)
cha_gain Set the gain of the Programmable Gain
Amplifier for this channel. (default=2 sets the
full scale of the channel to 2.048 Volts)
-----------------------------------------------------------------------------------
-----------
Name: ads1115
Info: Texas Instruments ADS1115 ADC
Load: dtoverlay=ads1115,<param>[=<val>]
Parametri:
addr I2C bus address of device. Set based on how the
addr pin is wired. (default=0x48 assumes addr
is pulled to GND)
cha_enable Enable virtual channel a.
cha_cfg Set the configuration for virtual channel a.
(default=4 configures this channel for the
voltage at A0 with respect to GND)
cha_datarate Set the datarate (samples/sec) for this channel.
(default=7 sets 860 sps)
cha_gain Set the gain of the Programmable Gain
Amplifier for this channel. (Default 1 sets the
full scale of the channel to 4.096 Volts)
-----------------------------------------------------------------------------------
-----------
Name: ads7846
Info: ADS7846 Touch controller
Load: dtoverlay=ads7846,<param>=<val>
Parametri:
cs SPI bus Chip Select (default 1)
speed SPI bus speed (default 2MHz, max 3.25MHz)
penirq GPIO used for PENIRQ. REQUIRED
penirq_pull Set GPIO pull (default 0=none, 2=pullup)
swapxy Swap x and y axis
xmin Minimum value on the X axis (default 0)
ymin Minimum value on the Y axis (default 0)
xmax Maximum value on the X axis (default 4095)
ymax Maximum value on the Y axis (default 4095)
pmin Minimum reported pressure value (default 0)
pmax Maximum reported pressure value (default 65535)
xohms Touchpanel sensitivity (X-plate resistance)
(default 400)
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
dtoverlay=akkordion-iqdacplus,24db_digital_gain
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
-----------------------------------------------------------------------------------
-----------
Name: allo-boss-dac-pcm512x-audio
Info: Configures the Allo Boss DAC audio cards.
Load: dtoverlay=allo-boss-dac-pcm512x-audio,<param>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
"dtoverlay=allo-boss-dac-pcm512x-audio,
24db_digital_gain"
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
slave Force Boss DAC into slave mode, using Pi a
master for bit clock and frame clock. Enable
with "dtoverlay=allo-boss-dac-pcm512x-audio,
slave"
-----------------------------------------------------------------------------------
-----------
Name: allo-digione
Info: Configures the Allo Digione audio card
Load: dtoverlay=allo-digione
Parametri:
<None>
-----------------------------------------------------------------------------------
-----------
Name: allo-piano-dac-pcm512x-audio
Info: Configures the Allo Piano DAC (2.0/2.1) audio cards.
(NB. This initial support is for 2.0 channel audio ONLY! ie. stereo.
The subwoofer outputs on the Piano 2.1 are not currently supported!)
Load: dtoverlay=allo-piano-dac-pcm512x-audio,<param>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control.
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
-----------------------------------------------------------------------------------
-----------
Name: allo-piano-dac-plus-pcm512x-audio
Info: Configures the Allo Piano DAC (2.1) audio cards.
Load: dtoverlay=allo-piano-dac-plus-pcm512x-audio,<param>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control.
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
glb_mclk This option is only with Kali board. If enabled,
MCLK for Kali is used and PLL is disabled for
better voice quality. (default Off)
-----------------------------------------------------------------------------------
-----------
Name: applepi-dac
Info: Configures the Orchard Audio ApplePi-DAC audio card
Load: dtoverlay=applepi-dac
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: at86rf233
Info: Configures the Atmel AT86RF233 802.15.4 low-power WPAN transceiver,
connected to spi0.0
Load: dtoverlay=at86rf233,<param>=<val>
Parametri:
interrupt GPIO used for INT (default 23)
reset GPIO used for Reset (default 24)
sleep GPIO used for Sleep (default 25)
speed SPI bus speed in Hz (default 3000000)
trim Fine tuning of the internal capacitance
arrays (0=+0pF, 15=+4.5pF, default 15)
-----------------------------------------------------------------------------------
-----------
Name: audioinjector-addons
Info: Configures the audioinjector.net audio add on soundcards
Load: dtoverlay=audioinjector-addons
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: audioinjector-wm8731-audio
Info: Configures the audioinjector.net audio add on soundcard
Load: dtoverlay=audioinjector-wm8731-audio
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: audremap
Info: Switches PWM sound output to pins 12 (Right) & 13 (Left)
Load: dtoverlay=audremap,<param>=<val>
Parametri:
swap_lr Reverse the channel allocation, which will also
swap the audio jack outputs (default off)
enable_jack Don't switch off the audio jack output
(default off)
-----------------------------------------------------------------------------------
-----------
Name: bmp085_i2c-sensor
Info: This overlay is now deprecated - see i2c-sensor
Load: dtoverlay=bmp085_i2c-sensor
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: dht11
Info: Overlay for the DHT11/DHT21/DHT22 humidity/temperature sensors
Also sometimes found with the part number(s) AM230x.
Load: dtoverlay=dht11,<param>=<val>
Parametri:
gpiopin GPIO connected to the sensor's DATA output.
(default 4)
-----------------------------------------------------------------------------------
-----------
Name: dionaudio-loco
Info: Configures the Dion Audio LOCO DAC-AMP
Load: dtoverlay=dionaudio-loco
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: dionaudio-loco-v2
Info: Configures the Dion Audio LOCO-V2 DAC-AMP
Load: dtoverlay=dionaudio-loco-v2,<param>=<val>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
"dtoverlay=hifiberry-dacplus,24db_digital_gain"
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24dB_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
-----------------------------------------------------------------------------------
-----------
Name: dpi18
Info: Overlay for a generic 18-bit DPI display
This uses GPIOs 0-21 (so no I2C, uart etc.), and activates the output
2-3 seconds after the kernel has started.
Load: dtoverlay=dpi18
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: dpi24
Info: Overlay for a generic 24-bit DPI display
This uses GPIOs 0-27 (so no I2C, uart etc.), and activates the output
2-3 seconds after the kernel has started.
Load: dtoverlay=dpi24
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: dwc-otg
Info: Selects the dwc_otg USB controller driver which has fiq support. This
is the default on all except the Pi Zero which defaults to dwc2.
Load: dtoverlay=dwc-otg
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: dwc2
Info: Selects the dwc2 USB controller driver
Load: dtoverlay=dwc2,<param>=<val>
Parametri:
dr_mode Dual role mode: "host", "peripheral" or "otg"
g-rx-fifo-size Size of rx fifo size in gadget mode
-----------------------------------------------------------------------------------
-----------
[ The ds1307-rtc overlay has been deleted. See i2c-rtc. ]
-----------------------------------------------------------------------------------
-----------
Name: enc28j60
Info: Overlay for the Microchip ENC28J60 Ethernet Controller on SPI0
Load: dtoverlay=enc28j60,<param>=<val>
Params: int_pin GPIO used for INT (default 25)
-----------------------------------------------------------------------------------
-----------
Name: enc28j60-spi2
Info: Overlay for the Microchip ENC28J60 Ethernet Controller on SPI2
Load: dtoverlay=enc28j60-spi2,<param>=<val>
Parametri:
int_pin GPIO used for INT (default 39)
-----------------------------------------------------------------------------------
-----------
Name: fe-pi-audio
Info: Configures the Fe-Pi Audio Sound Card
Load: dtoverlay=fe-pi-audio
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: goodix
Info: Enables I2C connected Goodix gt9271 multiple touch controller using
GPIOs 4 and 17 (pins 7 and 11 on GPIO header) for interrupt and reset.
Load: dtoverlay=goodix,<param>=<val>
Parametri:
interrupt GPIO used for interrupt (default 4)
reset GPIO used for reset (default 17)
-----------------------------------------------------------------------------------
-----------
Name: googlevoicehat-soundcard
Info: Configures the Google voiceHAT soundcard
Load: dtoverlay=googlevoicehat-soundcard
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: gpio-ir
Info: Use GPIO pin as rc-core style infrared receiver input. The rc-core-
based gpio_ir_recv driver maps received keys directly to a
/dev/input/event* device, all decoding is done by the kernel - LIRC is
not required! The key mapping and other decoding parameters can be
configured by "ir-keytable" tool.
Load: dtoverlay=gpio-ir,<param>=<val>
Params:
gpio_pin Input pin number. Default is 18.
gpio_pull Desired pull-up/down state (off, down, up) Default is
"down".
rc-map-name Default rc keymap (can also be changed byir-keytable),
defaults to "rc-rc6-mce"
-----------------------------------------------------------------------------------
-----------
Name: gpio-poweroff
Info: Drives a GPIO high or low on poweroff (including halt). Enabling this
overlay will prevent the ability to boot by driving GPIO3 low.
Load: dtoverlay=gpio-poweroff,<param>=<val>
Parametri:
gpiopin GPIO for signalling (default 26)
-----------------------------------------------------------------------------------
-----------
Name: gpio-shutdown
Info: Initiates a shutdown when GPIO pin changes.
The given GPIO pin is configured as an input key that generates
KEY_POWER events.
This event is handled by systemd-logind by initiating a shutdown.
Systemd versions older than 225 need an udev rule enable listening to
the input device:
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: hifiberry-amp
Info: Configures the HifiBerry Amp and Amp+ audio cards
Load: dtoverlay=hifiberry-amp
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: hifiberry-dac
Info: Configures the HifiBerry DAC audio card
Load: dtoverlay=hifiberry-dac
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: hifiberry-dacplus
Info: Configures the HifiBerry DAC+ audio card
Load: dtoverlay=hifiberry-dacplus,<param>=<val>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
"dtoverlay=hifiberry-dacplus,24db_digital_gain"
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24dB_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
slave Force DAC+ Pro into slave mode, using Pi as
master for bit clock and frame clock.
-----------------------------------------------------------------------------------
-----------
Name: hifiberry-digi
Info: Configures the HifiBerry Digi and Digi+ audio card
Load: dtoverlay=hifiberry-digi
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: hifiberry-digi-pro
Info: Configures the HifiBerry Digi+ Pro audio card
Load: dtoverlay=hifiberry-digi-pro
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: hy28a
Info: HY28A - 2.8" TFT LCD Display Module by HAOYU Electronics
Default values match Texy's display shield
Load: dtoverlay=hy28a,<param>=<val>
Params:
speed Display SPI bus speed
rotate Display rotation {0,90,180,270}
fps Delay between frame updates
debug Debug output level {0-7}
xohms Touchpanel sensitivity (X-plate resistance)
resetgpio GPIO used to reset controller
ledgpio GPIO used to control backlight
-----------------------------------------------------------------------------------
-----------
Name: hy28b
Info: HY28B - 2.8" TFT LCD Display Module by HAOYU Electronics
Default values match Texy's display shield
Load: dtoverlay=hy28b,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: i2c-bcm2708
Info: Fall back to the i2c_bcm2708 driver for the i2c_arm bus.
Load: dtoverlay=i2c-bcm2708
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: i2c-gpio
Info: Adds support for software i2c controller on gpio pins
Load: dtoverlay=i2c-gpio,<param>=<val>
Parametri:
i2c_gpio_sda GPIO used for I2C data (default "23")
-----------------------------------------------------------------------------------
-----------
Name: i2c-mux
Info: Adds support for a number of I2C bus multiplexers on i2c_arm
Load: dtoverlay=i2c-mux,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: i2c-pwm-pca9685a
Info: Adds support for an NXP PCA9685A I2C PWM controller on i2c_arm
Load: dtoverlay=i2c-pwm-pca9685a,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: i2c-rtc
Info: Adds support for a number of I2C Real Time Clock devices
Load: dtoverlay=i2c-rtc,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: i2c-rtc-gpio
Info: Adds support for a number of I2C Real Time Clock devicesusing the
software i2c controller
Load: dtoverlay=i2c-rtc-gpio,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: i2c-sensor
Info: Adds support for a number of I2C barometric pressure and temperature
sensors on i2c_arm
Load: dtoverlay=i2c-sensor,<param>=<val>
Parametri:
addr Set the address for the BME280, BMP280, TMP102,
HDC100X, LM75 or SHT3x
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: i2c1-bcm2708
Info: Enable the i2c_bcm2708 driver for the i2c1 bus
Load: dtoverlay=i2c1-bcm2708,<param>=<val>
Parametri:
sda1_pin GPIO pin for SDA1 (2 or 44 - default 2)
scl1_pin GPIO pin for SCL1 (3 or 45 - default 3)
pin_func Alternative pin function (4 (alt0), 6 (alt2) - default 4)
-----------------------------------------------------------------------------------
-----------
Name: i2s-gpio28-31
Info: move I2S function block to GPIO 28 to 31
Load: dtoverlay=i2s-gpio28-31
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: iqaudio-dac
Info: Configures the IQaudio DAC audio card
Load: dtoverlay=iqaudio-dac,<param>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
"dtoverlay=iqaudio-dac,24db_digital_gain"
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
-----------------------------------------------------------------------------------
-----------
Name: iqaudio-dacplus
Info: Configures the IQaudio DAC+ audio card
Load: dtoverlay=iqaudio-dacplus,<param>=<val>
Parametri:
24db_digital_gain Allow gain to be applied via the PCM512x codec
Digital volume control. Enable with
"dtoverlay=iqaudio-dacplus,24db_digital_gain"
(The default behaviour is that the Digital
volume control is limited to a maximum of
0dB. ie. it can attenuate but not provide
gain. For most users, this will be desired
as it will prevent clipping. By appending
the 24db_digital_gain parameter, the Digital
volume control will allow up to 24dB of
gain. If this parameter is enabled, it is the
responsibility of the user to ensure that
the Digital volume control is set to a value
that does not result in clipping/distortion!)
auto_mute_amp If specified, unmute/mute the IQaudIO amp when
starting/stopping audio playback.
unmute_amp If specified, unmute the IQaudIO amp once when
the DAC driver module loads.
-----------------------------------------------------------------------------------
-----------
Name: iqaudio-digi-wm8804-audio
Info: Configures the IQAudIO Digi WM8804 audio card
Load: dtoverlay=iqaudio-digi-wm8804-audio,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: justboom-dac
Info: Configures the JustBoom DAC HAT, Amp HAT, DAC Zero and Amp
Zero audio cards
Load: dtoverlay=justboom-dac,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: justboom-digi
Info: Configures the JustBoom Digi HAT and Digi Zero audio cards
Load: dtoverlay=justboom-digi
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: lirc-rpi
Info: Configures lirc-rpi (Linux Infrared Remote Control for Raspberry Pi)
Consult the module documentation for more details.
Load: dtoverlay=lirc-rpi,<param>=<val>
Parametri:
gpio_out_pin GPIO for output (default "17")
gpio_in_pin GPIO for input (default "18")
gpio_in_pull Pull up/down/off on the input pin (default "down")
sense Override the IR receive auto-detection logic:
"0" = force active-high
"1" = force active-low
"-1" = use auto-detection (default "-1")
-----------------------------------------------------------------------------------
-----------
Name: mcp23017
Info: Configures the MCP23017 I2C GPIO expander
Load: dtoverlay=mcp23017,<param>=<val>
Parametri:
gpiopin Gpio pin connected to the INTA output of the
MCP23017 (default: 4)
-----------------------------------------------------------------------------------
-----------
Name: mcp23s17
Info: Configures the MCP23S08/17 SPI GPIO expanders.
If devices are present on SPI1 or SPI2, those interfaces must be enabled
with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
If interrupts are enabled for a device on a given CS# on a SPI bus, that
device must be the only one present on that SPI bus/CS#.
Load: dtoverlay=mcp23s17,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: mcp2515-can0
Info: Configures the MCP2515 CAN controller on spi0.0
Load: dtoverlay=mcp2515-can0,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: mcp2515-can1
Info: Configures the MCP2515 CAN controller on spi0.1
Load: dtoverlay=mcp2515-can1,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: mcp3008
Info: Configures MCP3008 A/D converters
For devices on spi1 or spi2, the interfaces should be enabled
with one of the spi1-1/2/3cs and/or spi2-1/2/3cs overlays.
Load: dtoverlay=mcp3008,<param>[=<val>]
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: midi-uart0
Info: Configures UART0 (ttyAMA0) so that a requested 38.4kbaud actually
gets 31.25kbaud, the frequency required for MIDI
Load: dtoverlay=midi-uart0
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: midi-uart1
Info: Configures UART1 (ttyS0) so that a requested 38.4kbaud actually gets
31.25kbaud, the frequency required for MIDI
Load: dtoverlay=midi-uart1
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: mmc
Info: Selects the bcm2835-mmc SD/MMC driver, optionally with overclock
Load: dtoverlay=mmc,<param>=<val>
Parametri:
overclock_50
Clock (in MHz) to use when the MMC framework requests 50MHz
-----------------------------------------------------------------------------------
-----------
Name: mpu6050
Info: Overlay for i2c connected mpu6050 imu
Load: dtoverlay=mpu6050,<param>=<val>
Parametri:
interrupt GPIO pin for interrupt (default 4)
-----------------------------------------------------------------------------------
-----------
Name: mz61581
Info: MZ61581 display by Tontec
Load: dtoverlay=mz61581,<param>=<val>
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: papirus
Info: PaPiRus ePaper Screen by Pi Supply (both HAT and pHAT)
Load: dtoverlay=papirus,<param>=<val>
Parametri:
panel Display panel (required):
1.44": e1144cs021
2.0": e2200cs021
2.7": e2271cs021
-----------------------------------------------------------------------------------
-----------
Name: pi3-act-led
Info: Pi3 uses a GPIO expander to drive the LEDs which can only be accessed
from the VPU. There is a special driver for this with a separate DT
node, which has the unfortunate consequence of breaking the
act_led_gpio and act_led_activelow dtparams.
This overlay changes the GPIO controller back to the standard one and
restores the dtparams.
Load: dtoverlay=pi3-act-led,<param>=<val>
Parametri:
activelow Set to "on" to invert the sense of the LED
(default "off")
-----------------------------------------------------------------------------------
-----------
Name: pi3-disable-bt
-----------------------------------------------------------------------------------
-----------
Name: pi3-disable-wifi
-----------------------------------------------------------------------------------
-----------
Name: pi3-miniuart-bt
Info: Switch Pi3 Bluetooth function to use the mini-UART (ttyS0) and restore
UART0/ttyAMA0 over GPIOs 14 & 15.
Note that this may reduce the maximum usable baudrate.
N.B. It is also necessary to edit /lib/systemd/system/hciuart.service
and replace ttyAMA0 with ttyS0, unless you have a system with udev rules
that create /dev/serial0 and /dev/serial1, in which case use /dev/serial1
instead because it will always be correct. Furthermore, you must also
set core_freq=250 in config.txt or the miniuart will not work.
Load: dtoverlay=pi3-miniuart-bt
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: piscreen
-----------------------------------------------------------------------------------
-----------
Name: piscreen2r
Parametri:
-----------------------------------------------------------------------------------
-----------
Name: pisound
Info: Configures the Blokas Labs pisound card
Load: dtoverlay=pisound
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: pitft22
Info: Adafruit PiTFT 2.2" screen
Load: dtoverlay=pitft22,<param>=<val>
Parametri:
speed Display SPI bus speed
rotate Display rotation {0,90,180,270}
fps Delay between frame updates
debug Debug output level {0-7}
-----------------------------------------------------------------------------------
-----------
Name: pitft28-capacitive
Info: Adafruit PiTFT 2.8" capacitive touch screen
Load: dtoverlay=pitft28-capacitive,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: pitft28-resistive
Info: Adafruit PiTFT 2.8" resistive touch screen
Load: dtoverlay=pitft28-resistive,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: pitft35-resistive
Info: Adafruit PiTFT 3.5" resistive touch screen
Load: dtoverlay=pitft35-resistive,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: pps-gpio
Info: Configures the pps-gpio (pulse-per-second time signal via GPIO).
Load: dtoverlay=pps-gpio,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: pwm
Info: Configures a single PWM channel Legal pin,function combinations
for each channel:
N.B.:
Load: dtoverlay=pwm,<param>=<val>
Params:
N.B.:
1) Pin 18 is the only one available on all platforms, and
it is the one used by the I2S audio interface.
Pins 12 and 13 might be better choices on an A+, B+ or Pi2.
2) The onboard analogue audio output uses both PWM channels.
3) So be careful mixing audio and PWM.
4) Currently the clock must have been enabled and configured
by other means.
Load: dtoverlay=pwm-2chan,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: qca7000
Info: I2SE's Evaluation Board for PLC Stamp micro
Load: dtoverlay=qca7000,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: raspidac3
Info: Configures the RaspiDAV Rev.3x audio card
Load: dtoverlay=raspidac3
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rotary-encoder
Info: Overlay for GPIO connected rotary encoder.
Load: dtoverlay=rotary-encoder,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: rpi-backlight
Info: Raspberry Pi official display backlight driver
Load: dtoverlay=rpi-backlight
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rpi-cirrus-wm5102
Info: Configures the Cirrus Logic Audio Card
Load: dtoverlay=rpi-cirrus-wm5102
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rpi-dac
Info: Configures the RPi DAC audio card
Load: dtoverlay=rpi-dac
Params: <None>
Name: rpi-display
Info: RPi-Display - 2.8" Touch Display by Watterott
Load: dtoverlay=rpi-display,<param>=<val>
Params:
speed Display SPI bus speed
rotate Display rotation {0,90,180,270}
fps Delay between frame updates
debug Debug output level {0-7}
xohms Touchpanel sensitivity (X-plate resistance)
swapxy Swap x and y axis
-----------------------------------------------------------------------------------
-----------
Name: rpi-ft5406
Info: Official Raspberry Pi display touchscreen
Load: dtoverlay=rpi-ft5406
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rpi-proto
Info: Configures the RPi Proto audio card
Load: dtoverlay=rpi-proto
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rpi-sense
Info: Raspberry Pi Sense HAT
Load: dtoverlay=rpi-sense
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rpi-tv
Info: Raspberry Pi TV HAT
Load: dtoverlay=rpi-tv
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: rra-digidac1-wm8741-audio
Info: Configures the Red Rocks Audio DigiDAC1 soundcard
Load: dtoverlay=rra-digidac1-wm8741-audio
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: sc16is750-i2c
Info: Overlay for the NXP SC16IS750 UART with I2C Interface
Enables the chip on I2C1 at 0x48. To select another address,
please refer to table 10 in reference manual.
Load: dtoverlay=sc16is750-i2c,<param>=<val>
Params:
int_pin GPIO used for IRQ (default 24)
addr Address (default 0x48)
-----------------------------------------------------------------------------------
-----------
Name: sc16is752-spi1
Info: Overlay for the NXP SC16IS752 Dual UART with SPI Interface
Enables the chip on SPI1.
N.B.: spi1 is only accessible on devices with a 40pin header, eg:
A+, B+, Zero and PI2 B; as well as the Compute Module.
Load: dtoverlay=sc16is752-spi1,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: sdhost
Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock.
N.B. This overlay is designed for situations where the mmc driver is
the default, so it disables the other (mmc) interface - this will kill
WiFi on a Pi3. If this isn't what you want, either use the sdtweak
overlay or the new sd_* dtparams of the base DTBs.
Load: dtoverlay=sdhost,<param>=<val>
Params:
overclock_50 Clock (in MHz) to use when the MMC framework
requests 50MHz
force_pio Disable DMA support (default off)
pio_limit Number of blocks above which to use DMA (default 1)
debug Enable debug output (default off)
-----------------------------------------------------------------------------------
-----------
Name: sdio
Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock,
and enables SDIO via GPIOs 22-27.
Load: dtoverlay=sdio,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: sdio-1bit
Info: Selects the bcm2835-sdhost SD/MMC driver, optionally with overclock,
and enables 1-bit SDIO via GPIOs 22-25.
Load: dtoverlay=sdio-1bit,<param>=<val>
Params:
sdio_overclock SDIO Clock (in MHz) to use when the MMC framework
requests 50MHz
poll_once Disable SDIO-device polling every second
(default on: polling once at boot-
time)
-----------------------------------------------------------------------------------
-----------
Name: sdtweak
Info: Tunes the bcm2835-sdhost SD/MMC driver
N.B. This functionality is now available via the sd_* dtparams in the
base DTB.
Load: dtoverlay=sdtweak,<param>=<val>
Params:
overclock_50 Clock (in MHz) to use when the MMC framework requests 50MHz
force_pio Disable DMA support (default off)
pio_limit Number of blocks above which to use DMA (default 1)
debug Enable debug output (default off)
-----------------------------------------------------------------------------------
-----------
Name: smi
Info: Enables the Secondary Memory Interface peripheral. Uses GPIOs 2-25!
Load: dtoverlay=smi
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: smi-dev
Info: Enables the userspace interface for the SMI driver
Load: dtoverlay=smi-dev
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: smi-nand
Info: Enables access to NAND flash via the SMI interface
Load: dtoverlay=smi-nand
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: spi-gpio35-39
Info: Move SPI function block to GPIO 35 to 39
Load: dtoverlay=spi-gpio35-39
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: spi-rtc
Info: Adds support for a number of SPI Real Time Clock devices
Load: dtoverlay=spi-rtc,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: spi0-cs
Info: Allows the (software) CS pins for SPI0 to be changed
Load: dtoverlay=spi0-cs,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: spi0-hw-cs
Info: Re-enables hardware CS/CE (chip selects) for SPI0
Load: dtoverlay=spi0-hw-cs
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: spi1-1cs
Info: Enables spi1 with a single chip select (CS) line and associated spidev
dev node. The gpio pin number for the CS line and spidev device node
creation are configurable.
N.B.: spi1 is only accessible on devices with a 40pin header, eg:
A+, B+, Zero and PI2 B; as well as the Compute Module.
Load: dtoverlay=spi1-1cs,<param>=<val>
Params:
cs0_pin GPIO pin for CS0 (default 18 - BCM SPI1_CE0).
cs0_spidev Set to 'disabled' to stop the creation of auserspace device
node /dev/spidev1.0 (default is 'okay' or enabled).
-----------------------------------------------------------------------------------
-----------
Name: spi1-2cs
Info: Enables spi1 with two chip select (CS) lines and associated spidev
dev nodes. The gpio pin numbers for the CS lines and spidev device node
creation are configurable.
N.B.: spi1 is only accessible on devices with a 40pin header, eg:
A+, B+, Zero and PI2 B; as well as the Compute Module.
Load: dtoverlay=spi1-2cs,<param>=<val>
Params:
cs0_pin GPIO pin for CS0 (default 18 - BCM SPI1_CE0).
cs1_pin GPIO pin for CS1 (default 17 - BCM SPI1_CE1).
cs0_spidev Set to 'disabled' to stop the creation of a
userspace device node /dev/spidev1.0 (default
is 'okay' or enabled).
cs1_spidev Set to 'disabled' to stop the creation of a
userspace device node /dev/spidev1.1 (default
is 'okay' or enabled).
-----------------------------------------------------------------------------------
-----------
Name: spi1-3cs
Info: Enables spi1 with three chip select (CS) lines and associated spidev
dev nodes. The gpio pin numbers for the CS lines and spidev device node
creation are configurable.
N.B.: spi1 is only accessible on devices with a 40pin header, eg:
A+, B+, Zero and PI2 B; as well as the Compute Module.
Load: dtoverlay=spi1-3cs,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: spi2-1cs
Info: Enables spi2 with a single chip select (CS) line and associated spidev
dev node. The gpio pin number for the CS line and spidev device node
creation are configurable.
N.B.: spi2 is only accessible with the Compute Module.
Load: dtoverlay=spi2-1cs,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: spi2-2cs
Info: Enables spi2 with two chip select (CS) lines and associated spidev
dev nodes. The gpio pin numbers for the CS lines and spidev device node
creation are configurable.
N.B.: spi2 is only accessible with the Compute Module.
Load: dtoverlay=spi2-2cs,<param>=<val>
Params:
cs0_pin GPIO pin for CS0 (default 43 - BCM SPI2_CE0).
cs1_pin GPIO pin for CS1 (default 44 - BCM SPI2_CE1).
cs0_spidev Set to 'disabled' to stop the creation of a userspace
device node /dev/spidev2.0 (default is 'okay' or
enabled).
cs1_spidev Set to 'disabled' to stop the creation of a userspace
device
node /dev/spidev2.1 (default is 'okay' or enabled).
-----------------------------------------------------------------------------------
-----------
Name: spi2-3cs
Info: Enables spi2 with three chip select (CS) lines and associated spidev
dev nodes. The gpio pin numbers for the CS lines and spidev device node
creation are configurable.
N.B.: spi2 is only accessible with the Compute Module.
Load: dtoverlay=spi2-3cs,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: tinylcd35
Info: 3.5" Color TFT Display by www.tinylcd.com
Options: Touch, RTC, keypad
Load: dtoverlay=tinylcd35,<param>=<val>
Params:
Examples:
Params:
-----------------------------------------------------------------------------------
-----------
Name: vc4-fkms-v3d
Info: Enable Eric Anholt's DRM VC4 V3D driver on top of the dispmanx
display stack.
Load: dtoverlay=vc4-fkms-v3d,<param>
Params:
-----------------------------------------------------------------------------------
-----------
Name: vc4-kms-v3d
Info: Enable Eric Anholt's DRM VC4 HDMI/HVS/V3D driver. Running startx or
booting to GUI while this overlay is in use will cause interesting
lockups.
Load: dtoverlay=vc4-kms-v3d,<param>
Params:
-----------------------------------------------------------------------------------
-----------
Name: vga666
Info: Overlay for the Fen Logic VGA666 board
This uses GPIOs 2-21 (so no I2C), and activates the output 2-3 seconds
after the kernel has started.
Load: dtoverlay=vga666
Params: <None>
-----------------------------------------------------------------------------------
-----------
Name: w1-gpio
Info: Configures the w1-gpio Onewire interface module.
Use this overlay if you *don't* need a GPIO to drive an external pullup.
Load: dtoverlay=w1-gpio,<param>=<val>
Params:
gpiopin GPIO for I/O (default "4")
pullup Non-zero, "on", or "y" to enable the parasitic power
(2-wire, power-on-data) feature
-----------------------------------------------------------------------------------
-----------
Name: w1-gpio-pullup
Info: Configures the w1-gpio Onewire interface module.
Use this overlay if you *do* need a GPIO to drive an external pullup.
Load: dtoverlay=w1-gpio-pullup,<param>=<val>
Params:
-----------------------------------------------------------------------------------
-----------
Name: wittypi
Info: Configures the wittypi RTC module.
Load: dtoverlay=wittypi,<param>=<val>
Params:
led_gpio GPIO for LED (default "17")
led_trigger Choose which activity the LED tracks (default "default-on")
Troubleshooting
===============
If you are experiencing problems that you think are DT-related, enable DT
diagnostic output by adding this to /boot/config.txt:
dtdebug=on
Further reading
=============
http://www.raspberrypi.org/documentation/configuration/device-tree.md
==============================================================
What is LIRC ?
==============================================================
http://www.lirc.org/
LIRC is a package that allows you to decode and send infra-red signals of
many (but not all) commonly used remote controls.
The most important part of LIRC is the lircd daemon which decodes
IR signals received by the device drivers and provides the information on a
socket. It also accepts commands for IR signals to be sent if the hardware
supports this.
The user space applications allows you to control your computer with your
remote control. You can send X11 events to applications, start programs and
much more on just one button press.
There are some config files for remote controls at the remotes database.
This is about 2500 devices and counting. These devices should work with
the general drivers or (if it lacks timing info) the driver used to create them.
If you can't find your remote control here it does not mean that your remote
control is not supported. It's just that there is no config file for it yet.
All remote controls that are supported by learning remote controls i.e.,
almost any, should also work with LIRC.
Besides a remote control you also need a capture device to read the data
from the remote. Former versions focussed on home-brew capture hardware
connected to the serial or parallel port.
Documentazione
http://www.lirc.org/html/index.html
==============================================================
How to listen to Spotify on the Raspberry Pi
=================================================================
TOPICS:ChromiumRaspbianSpotify
How to listen to Spotify on the Raspberry Pi
POSTED BY: STEPHEN LOVELY JUNE 29, 2017
Raspbian is the dominant operating system on the Raspberry Pi, and for
good reason – it makes the tiny Raspberry Pi feel like a full-sized computer,
giving users access a web browser, utilities, and even games.
But Raspbian doesn’t support every program out of the box, and Spotify fans will be
disappointed to learn that their Raspberry Pi can’t play Spotify in the Chromium
web browser that comes standard on Raspbian. Luckily, we can perform a few tweaks
to make Spotify work on our Raspberry Pi and send music out over your choice of the
HDMI connection or the headphone jack, which is perfect for feeding into your
stereo system’s auxiliary input. Here’s how to listen to Spotify on the Raspberry
Pi.
We’ll be using Raspbian and the Chromium web browser in this project, but as we’ll
see, that’s not enough to start Spotify. What we have to do is download a specific
Chrome extension that will trick Spotify into thinking that we’re running
Microsoft’s Internet Explorer. With the help of this little white lie, Spotify will
work fine on Chromium.
Once you have Raspbian installed, you’ll have a great operating system that you can
use to perform basic computer functions (like word processing, web browsing, and
more) or as the starting point to any of the nearly countless Pi projects that use
Raspbian as their base. But one thing you won’t be able to do out of the box is use
the included Chromium web browser to access Spotify’s web player. If you try,
you’ll encounter a redirect or a screen that says: “Playback of protected content
is not enabled.”
Bummer! Luckily for us, though, we have three more steps left in which to right
this wrong. Let’s get started.
Step 2: Open Chromium and add the extension “User-Agent Switcher for Chrome”
Loyal readers will remember this extension from our guide to watching Netflix on
the Raspberry Pi. We’re using it for the same purpose this time around: we’ll be
tricking the website we want to use into thinking that we’re running one of their
supported browsers, even though we’re not. This is a Chrome extension, but like
many Chrome extensions, it works fine on the lighter-weight Chromium browser as
well.
Step 3: Pretend to be using Internet Explorer 10
Now we just need to choose our new “user agent” before we try to access Spotify’s
web player. Internet Explorer 10 will work, so let’s go ahead and do that: navigate
to Internet Explorer > Internet Explorer 10 in User-Agent Switcher for Chrome’s
settings.
If you’re content to use the headphone jack, we’re really already done here! Now
that Spotify is blissfully unaware that we’re using the Chromium web browser, it
will play nice with us. By default, this project will send the audio out of your
Raspberry Pi’s headphone jack (rather than its HDMI port), which means you’ll have
to plug in an auxiliary cord or some headphones to enjoy your tunes. This makes it
perfect, though, for connecting to a larger stereo system!
If you want to use the HDMI connection instead, you just have one simple step left.
In your terminal, run the command sudo raspi-config. This will give you a menu in
your terminal window. Navigate to Advanced Options > A4 Audio > Choose the audio
output: 2 Force HDMI. That’s it!
==============================================================
Configurare un Cloud privato sul Raspberry Pi con ownCloud
==============================================================
Indice
Per gestire i dati, vi servono un computer con il giusto software per il server,
con il quale trasferire i dati in rete. Ci sono molti motivi che sottolineano i
vantaggi dell’uso di un Raspberry Pi come host per ownCloud: da una parte il prezzo
di realizzazione per il computer e tutte le altre componenti è molto conveniente,
infatti difficilmente si troverà un miglior rapporto qualità-prezzo per un Cloud
gestito autonomamente. Dall’altra l’uso della corrente del piccolo computer è molto
basso, un punto senz’altro a favore per un server che dovrebbe rimanere sempre in
funzione.
Componenti necessari
-----------------
Una scheda microSD con uno spazio di archiviazione sufficiente (sono consigliati
almeno 8 GB). Di quanto spazio avete bisogno dipende ovviamente dal tipo e dalla
quantità di file che volete memorizzare e se volete immagazzinarli solo sulla
scheda o su un altro supporto collegato al Raspberry Pi. ownCloud può anche
utilizzare una memoria esterna su Internet (via FTP o WebDAV) e si possono pure
integrare altri servizi cloud come Dropbox o Amazon S3. In questo tutorial il
sistema operativo utilizzato è Raspbian Jessie, che deve essere installato sulla
scheda microSD. Se il vostro Raspberry Pi funziona ancora con la versione
precedente Wheezy, scaricate Jessie sul sito ufficiale, per seguire meglio questa
guida, e installatelo sul mini computer.
Una connessione ad Internet (meglio se tramite cavo di rete, altrimenti Wi-Fi).
Elettricità tramite cavo micro-USB.
L’uso di un altro supporto di memoria (un disco fisso esterno o una pen drive) è
opzionale, in quanto è essenziale solo per avere più spazio a disposizione per i
vostri file. Comunque deve essere configurato separatamente. Inoltre, in alcuni
casi, può essere utile una ventola o un refrigeratore passivo (meno potente e per
questo silenzioso), specialmente se praticate l’overcklocking sul piccolo computer
(possibile almeno nei modelli precedenti al Raspberry Pi 3 B). Ma anche se
utilizzate sempre il Raspberry Pi come host per ownCloud, un sistema di
raffreddamento non guasta.
Quasi come ogni server, anche quello presentato qui sotto può essere amministrato
“headless”, quindi senza schermo, tastiera o mouse. Dato che questa risulta la
soluzione più facile e a maggior risparmio energetico, è possibile apportare delle
modifiche al server tramite accesso SSH. Client SSH come WinSCP o PuTTY per Windows
e OpenSSH per i sistemi operativi UNIX consentono un pratico accesso remoto al
server dal computer o da uno smartphone: collegateli tra di loro, inserendo
l’indirizzo IPv4 nel client SSH del Raspberry Pi e attivando la connessione.
sudo raspi-config
Come accade prima di ogni installazione sul Raspberry Pi, anche per la
configurazione di ownCloud dovreste aggiornare il computer e i pacchetti
installati. Qui date i comandi corrispondenti dal terminale:
Il Cloud privato sul Raspberry Pi non è composto solo dal software ownCloud, ma ci
sono anche diversi programmi che possono essere installati per gradi. Se non viene
specificato altro, inserite i comandi nella console del Raspberry Pi.
Per verificare se l’installazione del web server sia andata a buon fine, inserite
l’indirizzo IP del Raspberry Pi nella barra degli indirizzi del vostro browser: se
compare una pagina bianca con la frase “it works”, funziona tutto correttamente.
Per rendere raggiungibile il vostro ownCloud in rete, attivate sul vostro router il
port forwarding e inoltrate le richieste del router dalla porta 433 al Raspberry
Pi. Su ogni router funziona però diversamente, ma si possono trovare i giusti
tutorial per i diversi modelli. Una volta impostato correttamente il port
forwarding, il vostro Raspberry Pi è ora raggiungibile su Internet al suo indirizzo
IP (o al suo nome di dominio, qualora utilizziate il servizio DDNS). Senza il port
forwarding avete accesso solo alla rete locale sul web server.
Installare ownCloud
Ora sono state prese tutte le misure necessarie per installare ownCloud sul
Raspberry Pi. Scaricate il software in formato .zip dalla sezione download del sito
ufficiale alla voce del menu “Archive File” e copiatelo sul Raspberry Pi.
Alternativamente potete installare il programma tramite la console, dove dovete
anche inserire la versione di ownCloud che vorreste impostare. In questo tutorial
viene utilizzato ownCloud 9.1.0.
wget https://download.owncloud.org/community/owncloud-9.1.0.zip
sudo reboot
Configurare ownCloud
-----------------
===================================================================
DISABILITA NTP SERVER
===================================================================
/etc/init.d/ntp start
/etc/init.d/ntp stop
systemctl disable systemd-timesyncd.service
apt-get ntpdate
ntpdate-debian
oppure
ntpdate 0.it.pool.ntp.org
server italiani
server 0.it.pool.ntp.org
#server 1.it.pool.ntp.org
#server 2.it.pool.ntp.org
#server 3.it.pool.ntp.org
# The settings in this file are used by the program ntpdate-debian, but not
# by the upstream program ntpdate.
# Set to "yes" to take the server list from /etc/ntp.conf, from package ntp,
# so you only have to keep it in one place.
#NTPDATE_USE_NTP_CONF=yes
NTPDATE_USE_NTP_CONF=no
To stop ntpd:
/etc/init.d/ntp stop
o
service ntp stop
Check:
----------------------------------------------------------------------------------
15.16. Configure ntpdate Servers
----------------------------------------------------------------------------------
The purpose of the ntpdate service is to set the clock during system boot.
This was used previously to ensure that the services started after ntpdate would
have the correct time and not observe a jump in the clock.
The use of ntpdate and the list of step-tickers is considered deprecated and so
Fedora uses the -g option to the ntpd command and not ntpdate by default.
The ntpdate service in Fedora is mostly useful only when used alone without ntpd.
With systemd, which starts services in parallel, enabling the ntpdate service will
not ensure that other services started after it will have correct time unless
they specify an ordering dependency on time-sync.target, which is provided by the
ntpdate service. The ntp-wait service (in the ntp-perl subpackage) provides the
time-sync target for the ntpd service.
In order to ensure a service starts with correct time, add After=time-sync.target
to the service and enable one of the services which provide the target
(ntpdate or sntp, or ntp-wait if ntpd is enabled).
To check if the ntpdate service is enabled to run at system start, issue the
following command:
To enable the service to run at system start, issue the following command as root:
------
KODITV
------
cat /etc/ntp/step-tickers
# List of NTP servers used by the ntpdate service.
ntp2.inrim.it
ntp1.inrim.it
ntpserver
--------------------------------------------------------------------------------
[root@koditv default]# systemctl stop ntpdate
[root@koditv default]# systemctl start ntpdate
[root@koditv default]# systemctl status ntpdate
================================================================================
AZARTICOLO:How to enable auto-login?
================================================================================
cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]
ln -s /etc/systemd/system/[email protected]
/etc/systemd/system/getty.target.wants/[email protected]
...
ExecStart=-/sbin/mingetty --autologin USERNAME %I
Restart=no
...
Alias=getty.target.wants/[email protected]
Note that if you exit tty2 session, you wont be able to use it until next reboot
or manual start by systemctl, except if you leave Restart as ‘always’, but
I highly recommend to avoid this according to security reasons.
source: fedoraproject.org/wiki
The simplest way I have found, if using Raspbian, is to edit the raspi-config file:
/etc/lightd/lightdm.conf and set the autologin-user= parameter.
How can I make the RPi auto-login when booted, when the GUI is disabled?
You don't have to type a password, when logging in when GUI enabled, so there is
probably
an easy way of disabling the password prompt in the console.
Very dangerous, I missed the bit about not having a password and seemed to have
screwed
up the SD card. Be warned!
Note I have not tested this, check the manpage for getty for more details.
https://fedoraproject.org/wiki/
Systemd#How_do_I_set_automatic_login_on_a_virtual_console_terminal.3F
The FAQ is for Fedora but it should be very similar on Raspbian Jessie.
I have tested it; it works fine. Also, put something in ~/.bash_profile and that
will get run
automatically after you are logged in. – greggo Jan 18 '13 at 18:28
showing :
how to auto login to the shell prompt (using a method similar to above)
Run scripts at startup
Auto start the desktop using raspi-config
this article shows how to auto login to the desktop using raspi-config, but the
question is asking how to auto login when there is no GUI or Desktop
(so bringing up the shell prompt).
However this article also shows how to auto login to the shell as well.
-i
mkdir -pv /etc/systemd/system/[email protected]
nano /etc/systemd/system/[email protected]/autologin.conf
[Service]
ExecStart=
ExecStart=-/sbin/agetty --autologin pi --noclear %I 38400 linux
only catch is that I can't logon using SSH anymore - access denied. :-(
/etc/systemd/system/
A good answer should give an indication as to why it works.
What do the those two steps do?
Can you really say it works if it breaks SSH?
so lightdm.conf method didnt work for me, after a bit of playing around the easiest
method
I found was below.
cd /etc/systemd/system/
to
now I did have pi auto login working using the raspi-config setup,
but used the above method to change the autologin for a root user.
hope this helps
/etc/pam.d/lightdm-autologin
/etc/systemd/system/[email protected]
--------------------------------------------------------------------------------
Autologin is performed as part of systemd's getty target:
root@raspberrypi:/etc/systemd/system/getty.target.wants#
# pwd
/etc/systemd/system/getty.target.wants
ls -l
total 0
lrwxrwxrwx 1 root root 38 Sep 24 18:14 [email protected] ->
/etc/systemd/system/[email protected]
ln -fs /lib/systemd/system/[email protected]
/etc/systemd/system/getty.target.wants/[email protected]
ln -fs /etc/systemd/system/[email protected]
/etc/systemd/system/getty.target.wants/[email protected]
=================================================================================
AZARTICOLO:Raspberry Pi: Extending the life of the SD card
=================================================================================
Recently I posted about how I believe that the Raspberry Pi is the perfect small
server .
One question came up about the SD storage.
SD cards are said to have a finite amount of writes that are possible,
before they start to fail.
It could be, even though posts about SD card failures are scattered but
not entirely conclusive. I started to look at ways to minimize the number of
writes to the SD card, which in theory should help extend its life.
Just going from a 4GB to 8 GB card will cut the number of writes to the same area
of the card in half.
Stick with name brands. There are a lot of posts that mention sticking to top
brands.
I didn't compile a list nor do I endorse any specific brands, but fortunately there
are enough posts out there that show the top brands and their failure rates.
Tweak GNU/Linux to write to RAM instead of the SD card. This uses a feature called
"tmpfs", which a really cool feature of GNU/Linux. Tmpfs can write to RAM as if
it was an ordinary filesystem.
It's fast, efficient, and easy to use. More details on that below.
Using Tmpfs
-----------
The kernel will do the rest for you by managing the writes to the RAM on this
virtual filesystem.
The really neat part about this is that the kernel will only use the amount of RAM
required for writing files, not the entire size of the mount.
So, for example, say we add this line to the /etc/fstab file:
The kernel will mount /var/log to RAM, however it will not use any RAM until files
are written to /var/log. When files are written to /var/log, the kernel will save
them to RAM and only use space to save the files. When files are removed from
/var/log,
the associated RAM to store them is freed up.
This means that it only uses what RAM it needs to in order to store the files,
which makes it very efficient.
In /etc/fstab, you can also specify the total size to allocate for each mount.
In the example above, we set "size=100m" so that /var/log can use up to 100 MB of
space and no more. This avoids a filesystem from using up all of the RAM which can
cause the system to slow down or even crash.
By running the "mount" command, we can see in the example above that /var/log is
mounted as a tmpfs volume to RAM, 100 MB in size.
There are a variety of locations that GNU/Linux likes to make frequent writes.
This is a list of entries below that I use as a starting point that should fit
for most distributions.
As you can see I make use of the "size=" parameter to avoid using up huge amounts
of RAM in case something tries to save a huge amount of data.
The "noatime" and "nosuid" parameters are also recommended for security and
performance,
and "mode=" along with "gid=" matches the permissions and group of the original
filesystem
to what was located on the SD card originally.
Yep, tmpfs can also handle permissions. As usual, entries in /etc/fstab mount
over the top of what is on the SD card, as standard Unix/Linux types do.
So if for some reason the mounts fail, writes will still work to the SD card.
One additional point to keep in mind is that anything mounted with tmpfs will be
lost on a reboot.
So, logs in /var/log in the example above will be wiped out if the computer is shut
down or rebooted.
So you will not want to save any files with tmpfs that need to be persistent among
reboots.
I'm actively using these settings and so far having great results.
Time will tell how the Pi and/or SD card hold up, but there are a lot of posts
out there with some great uptimes, as we know GNU/Linux itself doesn't need
frequent
rebooting like other operating systems. The steps above should hopefully hold up,
especially if you intend to run the Pi 24x7x365.
===================================================================
AZARTICOLO:Introduction to XFS
===================================================================
http://landoflinux.com/linux_xfs_filesystem_introduction.html
What is XFS?
------------
XFS is a highly scalable, high-performance file journalling file system which was
originally designed at Silicon Graphics, Inc in 1993. Originally XFS was used on
Silicon Graphics Inc s own operating system Irix, however, it was later ported to
the Linux kernel in 2001. Today XFS is supported by most Linux distributions and
has now become the default filesystem on RHEL (Red Hat Enterprise Linux),
Oracle Linux 7, CentOS 7 and many other distributions.
Originally XFS was created to support extremely large filesystems with sizes of
XFS supports metadata journalling allowing for quicker recovery after a system
crash.
The XFS file system can also be de-fragmented and enlarged while mounted and
active.
The XFS file system can not be reduced in size !
a data section,
a log section,
and a real-time section.
Using the default mkfs.xfs options, the real-time section is absent, and the log
area is contained within the data section. The log section can be either separate
from the data section or contained within it.
The filesystem sections are divided into a certain number of blocks, whose size
is specified with the -b option of the mkfs.xfs command.
The number and size of the allocation groups are chosen by mkfs.xfs so that there
is normally a small number of equal sized groups. The number of allocation groups
controls the amount of parallelism available in file and block allocation.
It should be increased from the default if there is sufficient memory and a lot
of allocation activity. The number of allocation groups should not be set very
high, since this can cause large amounts of CPU time to be used by the filesystem,
especially when the filesystem is nearly full.
More allocation groups are added (of the original size) when xfs_growfs is run.
An example of this command in use can be seen in the xfs_growfs example below.
The log section (or area, if it is internal to the data section) is used to store
changes to the file system metadata while the file system is running until those
changes are made to the data section. Changes are written sequentially during
normal operation and read only during a mount.
When mounting a file system after a crash, the log is read to complete operations
that were in progress at the time of the crash.
These files have an attribute bit set through xfsctl after file creation, before
any data was written to the file. The real-time section is divided into a number
of extents of fixed size (specified at mkfs.xfs time). Each file in the real-time
section has an extent size that is a multiple of the real-time section extent size.
The next three sectors contain information for block and inode allocation within
the allocation group. Also contained within each allocation group are data
structures
to locate free blocks and inodes. These are located through the header structures.
Each XFS file system is labelled with a Universal Unique Identifier (UUID).
The UUID is stored in every allocation group header and is used to help distinguish
one XFS filesystem from another, therefore you should avoid using the "dd" utility
or any other block by block copying programs to copy XFS filesystems.
If two XFS filesystems on the same machine have the same UUID, xfsdump may become
confused when carrying out an incremental backup or a resumed dump.
xfsdump and xfsrestore are recommended for making copies of XFS filesystems.
(see also xfs_copy)
To create a XFS file system, you can use the command mkfs.xfs /dev/device.
When using mkfs.xfs on a block device containing an existing file system, you
should use the -f option to force an overwrite of that file system.
# mkfs.xfs /dev/sdb1
# df -hT
Generally to increase space you would use LVM (Logical Volume Manager.
In the following example we will create a partition with a type of "8e" which
denotes LVM.
In this example, we are going to create a partition using the disk partitioning
tool
"fdisk". The commands used to create the partition can be seen in the output below:
# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
From the above output we can see that a Primary partition was created on device
"/dev/sdb" with a partition number of "1" (/dev/sdb1).
Type "8e" was specified for use with Logical Volume Management.
The partition layout was then previewed using the option "p", and then our
changes were written using the "w" option.
Our next step is to create a Physical Volume comprising of the /dev/sdb1 partition.
Next we then create a Volume Group called "vg01" and finally we create a Logical
Volume
that will use all available space within our Volume Group.
The commands issued can be seen in the output below:
# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
You can use the command "pvs" and "vgs" commands to display PV (Physical Volume)
# pvs
# vgs
From the above output we can see that the "pvs" command displays our device
"/dev/sdb1" and its associated VG "vg01". The output from the "vgs" command
indicates that our PV is only associated with one Volume Group and has a size
of 2GB.
Before you can use the storage that has been created, you will need to create a
file system on the Logical Volume (LV). This is achieved using the "mkfs.xfs"
command.
# mkfs.xfs /dev/vg01/lv01
meta-data=/dev/vg01/lv01 isize=256 agcount=4, agsize=130816 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0
data = bsize=4096 blocks=523264, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
real-time =none extsz=4096 blocks=0, rtextents=0
The "mkfs.xfs" command was issued against the path to the Logical Volume
"/dev/vg01/lv01".
Once the file system has been successfully mounted, it is available for use.
To display information about our mounted file system we can use the "df" command.
In the example below, we used the "-h" parameter to display sizes in MB, GB...
and the "-T" option displays the file system type. (In this example xfs)
From the above output we can see that our xfs file system is 2GB in size and has
the mount point of "/xfs_test".
Generally when you create a file system, you will want your file system to be
automatically mounted after a system reboot. To auto mount your file system,
you will need to add a line similar to the one below into your mount table
"/etc/fstab":
In the above example, we have specified our device, its mount point, a type of
"xfs".
We are using the default settings and have specified no checking or dumping
options.
For more information regarding the mount table see our link: Mount Table
In next part of this example we are going to add an additional disk to our system.
Once this disk has been added, we will then add this space to the existing
Volume Group "vg01" and then extend the Logical Volume "lv01".
The commands used for this can be seen in the output below:
# fdisk /dev/sdc
Welcome to fdisk (util-linux 2.23.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
Here we are adding our new space to the existing Volume Group "vg01".
This extra space will be then available to our Logical Volume.
The command to add the new partition to our Volume Group is "vgextend".
Check PV and VG
---------------
If we now issue the "pvs" and vgs" commands again, we will now see the new
additions:
# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 7.51g 0
/dev/sdb1 vg01 lvm2 a-- 2.00g 0
/dev/sdc1 vg01 lvm2 a-- 508.00m 508.00m
# vgs
VG #PV #LV #SN Attr VSize VFree
centos 1 2 0 wz--n- 7.51g 0
vg01 2 1 0 wz--n- 2.49g 508.00m
From the above "pvs" command we can see that the new PV has been added with 508MB
of space. The "vgs" command is now indicating that there are now two Physical
Volumes
associated with the Volume Group "vg01".
To extend the Logical Volume, we are going to use the "lvextend command.
In the example below we are extending the Logical Volume by 500MB.
The file system will be automatically resized because we are using the "-r" option.
We can verify that the file system has now increased by issuing the "df" command.
The output from this can be seen below.
We can now see from the above output that we have 2.5GB of space now available
to our xfs file system.
Important: You can not reduce a XFS filesystem, if you try you will get the
following message:
----------------------------------------------------------------------
Method 2 for extending a XFS File System using the utility xfs_growfs
---------------------------------------------------------------------
The following method allows you to extend the file system by using the "xfs_growfs"
command.
The xfs_growfs command is used to increase the size of a mounted XFS file system
only if there is space on the underlying devices to accommodate the change.
The xfs_growfs command does not require LVM to extend the file system as per the
previous example.
The mount point argument that is passed is the pathname to the directory where the
filesystem is mounted. The xfs filesystem must be mounted first before it can be
grown.
The contents of the file system are undisturbed, and the added space is then made
available for additional file storage.
Our next step is to then create a XFS file system by issuing the "mkfs.xfs"
command.
The resulting file system can be seen after issuing the "df -hT" command.
After the file system was initially created, I then increased the size of the
underlying disk by using the following VirtualBox command:
Next we need to mount the file system using the mount command
(syntax: mount /dev/device /mount_point)
We can use the "df" command again to look at the size of our mounted xfs file
system:
KODITV
-------
df -hT
File system Tipo Dim. Usati Dispon. Uso% Montato su
We can now see that our file system is mounted at mount point /xfs_test.
You may wish to add your disk/filesystem into "/etc/fstab" so that it will be
automatically mounted at system reboot.
To do this, simply add a line similar to the one below into the file "/etc/fstab".
KODITV
-------
The shutdown command "shutdown -h now" can be used to cleanly shutdown your
partition.
Unfortunately, VirtualBox only allows the disk to be increased when it is not in
use.
The following command will be issued from the host computer.
The "host" computer is the computer that is running the VirtualBox software.
The above command has now resized the virtual disk "CentOS7_XFS_Test1.vdi" to
a size of 2GB. Notice the double quotes around the path name.
Double quotes are needed as there are spaces within the path name name.
If you are unsure of the name of the Virtualdisk that you created originally
for your partition, you can "right click" on the name of your VM in the VirtualBox
manager and select the option to "Show in file manager".
Here you will see a list of all the virtual disks that have been allocated to your
server.
Once we have increased the under lying disk space, we will need to restart our
server. Next we are going to use fdisk to delete our original partition and then
recreate it again with more space. The disk in the example is known as "/dev/sdb".
Below are the steps taken using fdisk to accomplish the above task.
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
We can issue the "df" command again to display our file system information.
N.B:
From the above we can see that the file system on "xfs_test" is still indicating
its original size.
-------
KODITV
------
xfs_growfs /
meta-data=/dev/mapper/fedora-root isize=512 agcount=4, agsize=354560 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1418240, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 1418240 to 1918976
The important information to look for when you issue this command can be found
within the last line of the output. You are looking for an increase in size
relating to data blocks.
We can now issue the "df" command again to verify that the xfs_growfs command
was successful:
This time we can see that the file system is now 2GB in size.
----------------------------------------------------------------
Overview of Options that can be passed to the xfs_growfs utility
----------------------------------------------------------------
SYNOPSIS
xfs_growfs [ -dilnrx ] [ -D size ] [ -e rtextsize ] [ -L size ] [ -m
maxpct ] [ -t mtab ] [ -R size ] mount-point
xfs_growfs -V
d | -D size
The "-d or -D" option is used to specify that the data section of the filesystem
should be grown. If the "-D" size option is passed, then the data section is grown
to the specified size. The "-d" option specifies that the data section is grown
to the largest possible size. The size is specified in file system blocks.
-e
-l | -L size
Specifies that the log section of the filesystem should be grown, shrunk, or moved.
If the -L size option is given, the log section is changed to be that size, if
possible.
The size is expressed in file system blocks. The size of an internal log must be
smaller
than the size of an allocation group (this value is printed at mkfs time).
If neither -i nor -x is given with -l, the log continues to be internal or external
as it was before. [NOTE: These options are not implemented]
-m
Specify a new value for the maximum percentage of space in the file system that
can be allocated as inodes. In mkfs.xfs(8) this is specified with -i maxpct=nn.
-n
-r | -R size
Specifies that the real time section of the file system should be grown.
If the -R size option is given, the real time section is grown to that size,
otherwise the real time section is grown to the largest size possible with the
-r option. The size is expressed in filesystem blocks. The filesystem does not
need to have contained a real time section before the xfs_growfs operation.
-t
-V
Prints the version number and exits.
The mount point argument is not required with -V.
Although both of the methods used allowed you to increase the size of the XFS
file system. Neither of the methods allowed us to reduce the size.
The most common method of resizing a file system is to use the
LVM (Logical Volume Manager) approach. LVM gives you the advantage of being able
to add additional disk easily to an existing Volume Group and then use the
lvextend command to increase the size of your filesystem.
----------------------------------
An Overview of other xfs Utilities
----------------------------------
xfs_repair /dev/device
xfs_repair -L /dev/device
For full details regarding the xfs_repair utility, please consult the relevant
man pages: man xfs_repair
xfs_quota gives the administrator the ability to manage limits on disk space.
XFS quotas can control or report usage on users, groups or directory project level.
XFS quotas are enabled at mount time. You may specify the "noenforce" option which
allows reporting of usage, however, it does not enforce any limits.
For full details of XFS quotas see the relevant man page: man xfs_quota
The command to suspend access or resume write activity to a xfs file system is
"xfs_freeze". Generally this option is used for suspending write activity thus
allowing hardware based device snapshots to be used to capture the file system
in a consistent state.
The xfs_freeze utility is provided by the package "xfsprogs", note, this is only a
vailable to x86_64 architecture.
The -f flag requests that the specified XFS filesystem should be set to a state
of frozen, immediately stopping any modifications from being made.
When this option is selected, all ongoing transactions in the file system are
allowed to complete. Any new write system calls are halted.
xfs_freeze -u /mount/point
The -u flag is used to unfreeze the file system and allow operations to continue
again. Any file system modifications that were blocked by the freeze option are
unblocked and allowed to complete.
If you are taking a LVM snapshot, then it is not necessary to run the "xfs_freeze"
utility as the LVM utility will automatically suspend the relevant xfs file system.
You can also use the "xfs_freeze" utility to freeze or unfreeze an ext3, ext4
and btrfs, file system.
xfs_copy
--------
Copy the contents of a XFS file system. xfs_copy should only be used to copy
unmounted file systems, read-only mounted file systems, or file systems that
have been frozen with the xfs_freeze utility.
OPTIONS
-d Create a duplicate (true clone) filesystem. This should be done
only if the new filesystem will be used as a replacement for the
original filesystem (such as in the case of disk replacement).
/var/tmp/.fsrlast_xfs
xfs_fsr /path/to/file
xfs_bmap
--------
For further information regarding this utility, please consult the relevant man
page: man xfs_bmap
xfs_info
--------
To view your XFS file system information, the command "xfs_info" can be issued:
xfs_admin
----------
xfs_metadump
-------------
xfs_metadump is a debugging tool that copies XFS file system metadata to a file.
The xfs_metadump utility should only be used to copy unmounted, read-only, or
frozen/suspended file systems; otherwise, generated dumps could be corrupted or
inconsistent. For a full list of available option please consult the relevant
man page: man xfs_metadump
xfs_mdrestore
--------------
xfs_db
------
xfs_estimate
------------
The xfs_estimate utility is used to estimate the amount of space that a xfs file
system will take.
xfs_estimate parameters:
xfs_mkfile
----------
-n No bytes. Create a holey file - that is, do not write out any
data, just seek to the end of the file and write a block.
xfs_io
------
xfs_logprint
-------------
The second mode starts printing out information from the beginning of the log.
Some error blocks might print out in the beginning because the last log record
usually overlaps the oldest log record.
A message is printed when the physical end of the log is reached and when the
logical end of the log is reached. A log record view is displayed one record at
a time. Transactions that span log records may not be decoded fully.
-C filename
Copy the log from the filesystem to the file filename. The log
itself is not printed.
-d Dump the log from front to end, printing where each log record
is located on disk.
-l logdev
External log device. Only for those filesystems which use an
external log.
-n Do not try and interpret log data; just interpret log header
information.
xfs_rtcp
-------
xfs_rtcp copies a file to the real-time partition on a XFS file system.
If there is more than one source and target, the final argument (the target)
must be a directory which already exists.
OPTIONS
-e extsize
Sets the extent size of the destination real-time file.
xfs_ncheck
----------
The utility xfs_ncheck is used to generate a list of inode numbers along with path
names.
Options:
-l logdev
Specifies the device where the filesystem external log
resides. Only for those filesystems which use an external
log. See the mkfs.xfs -l option, and refer to xfs(5) for a
detailed description of the XFS log.
-i ino Limits the report to only those files whose inode numbers fol‐
low. May be given multiple times to select multiple inode
numbers.
xfsdump
--------
xfsrestore
----------
================================================================================
AZARTICOLO: Migrating from LVM to partitions
================================================================================
So, the Linux Volume Manager (LVM) vas created, to overcome the limitations of the
traditional partitioned disk usage. Some of the limitations are: inability to
mirror or
span volumes, a maximum number of partitions which sometimes may be too small.
LVM has many advantages, such as ability to create a volume spanning many disk
drives,
ability to grow a voluume, ability to add more disks to the volume group.
But it has a big disadvantage: there aren't too many replication/cloning tools
available.
The major drawback of LVM is that it doesn't contain a filesystem, but logical
volumes
and each logical volume may be split across multiple phisical volumes.
This is the main reason why cloning applications such as Ghost, Clonezilla or
Acronis
TrueImage do not copy data stored on LVM as a filesystem, but as a raw data.
This process may be much slower than copying a filesystem.
Cloning tools must also be capable of understanding a specific filesystem to copy
it.
While NTFS, reiserfs, ext2 and ext3 are popular and supported by many cloning
tools,
ext4 is relatively new and at the time when I wrote this, the only tool able to
clone ext4
filesystems is Clonezilla.
Other tools may clone an ext4 filesystem, but using the raw copy method.
CentOS is a popular linux distribution, which by default uses LVM for storage
devices.
If someone wants to make a copy of the disk where the operating system is
installed,
it must use a disk equal to or larger than the one where the operating system is
installed.
Also, if the LVM configuration includes multiple disks, the cloning task is no
longer an option,
and other methods must be used. One of them is to use LVM's mirroring mechanism,
but this require strong knowledge of LVM and it's utilities.
If the storage requirements are modest, migrating from LVM to the traditional
partitioning scheme is a possible option.
For someone looking to clone fast a disk with Linux on it, using a cloning tool
like
Clonezilla or Acronis True Image may be much easier than using other methods.
Since many Linux installers prefer to use LVM, the user must manually partition the
disk at install time, or install it using the defaults and convert it from LVM to
partitions later.
# /etc/fstab
# Created by anaconda on Thu Aug 11 11:03:32 2011
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
-----------------------------------------------------------------------------
File system Tipo Dim. Usati Dispon. Uso% Montato su
-----------------------------------------------------------------------------
/dev/mapper/VolGroup-lv_root / ext4 defaults 1 1
UUID=dbea6d02-7b89-4148-9ac1-da79af1c7027 /boot ext4 defaults 1 2
/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
-----------------------------------------------------------------------------
-------
KODITV
------
#LABEL="BOOTEFI"
#UUID=B7C7-D61F /boot/efi vfat
umask=0077,shortname=winnt 0 3
UUID=4B3E-8363 /boot/efi vfat
umask=0077,shortname=winnt 0 3
--------------------------------------------------------------------------------
blkid
--------------------------------------------------------------------------------
[root@koditv bin]# blkid
--------------------------------------------------------------------------------
blkid /portatile2009.swp
So, an exact replica of the LVM configuration from one disk to another can't be
done on a single system while both disks are accessible.
Copying LVM is possible with tools like modorescue, but the entire LVM
configuration
and data must be migrated from the local LVM to a remote machine or to an
intermediate storage medium.
/boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/mapper/VolGroup-lv_root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title centos (2.6.32-71.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.i686 ro root=/dev/mapper/VolGroup-lv_root
rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap rd_NO_LUKS rd_NO_MD
rd_NO_DM LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc
KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.el6.i686.img
------
KODITV
------
cat /boot/efi/EFI/fedora/grubenv
# GRUB Environment Block
kernelopts=root=/dev/mapper/fedora-root ro rd.lvm.lv=fedora/root LANG=it_IT.UTF-8
audit=0 ipv6.disable=1 audit=0 selinux=0 vconsole.keymap=it2 acpi=off
boot_success=0
n.b:
The boot loader configuration references the root file system location, which is
provided as a kernel parameter. rd_LVM_LV, a kernel parameter which instructs
LVM to initialize only the volume names referenced by rd_LVM_LV kernel parameters.
A boot loader must be installed on the target, the boot loader configuration must
be adjusted. As well, the /etc/fstab contents must be modified according to the
new coordinates of the filesystems.
n.b:
an important thing which must not be forgot:
on systems running with SeLinux enabled, after copying the data, an automatic
relabel must be triggered for the next boot.
Otherwise, the system may refuse to boot properly.
A disk which is fine enough is the CentOS 6 DVD, used with the third boot option:
'Rescue installed system'. Afer keyboard selection, optional network configuration
and
startup, at the 'Rescue' dialog select 'Continue' if you want to find your linux
installation
mounted read-write on /mnt/sysimage. After that, a shell must be started.
Now, in the shell prompt, the first task is to identify the drives.
The /mnt/sysimage is mounted with the detected linux installation.
# mkdir /mnt/newdisk
# mount /dev/sdb2 /mnt/newdisk
# cd /mnt/newdisk; mkdir {dev,mnt,boot,opt,usr,var,tmp,home,data}
# mount /dev/sdb1 /mnt/newdisk/boot
# mount /dev/sdb6 /mnt/newdisk/var
# mount /dev/sdb7 /mnt/newdisk/tmp
# mount /dev/sdb8 /mnt/newdisk/usr
# mount /dev/sdb9 /mnt/newdisk/home
# mount /dev/sdb10 /mnt/newdisk/data
# mount /dev/sdb11 /mnt/newdisk/opt
And it's good to adjust the file modes for some entries:
# chmod +t /mnt/newdisk/tmp
# chmod go+rw /mnt/newdisk/tmp
And the data located on the root filesystem too, but exclude the contents of the
special directories /dev, /proc, /selinux and /sys:
# umount /mnt/sysimage/selinux
# for dir in $(ls -1 /mnt/sysimage | grep -v '\(boot\|var\|tmp\|usr\|home\|opt\|
sys\|proc\|dev\|mnt\|lost\)'); do \
> echo dir; \
> cp -v -ax /mnt/sysimage/$dir /mnt/newdisk/;\
> done;
# mkdir /mnt/newdisk/{proc,sys,dev}
# chmod -w /mnt/newdisk/proc
# chmod go+w /mnt/newdisk/dev
# chmod +t /mnt/newdisk/dev
To make the target disk bootable, it's time to install the grub boot loader on it:
# vi /boot/grub/grub.conf
:s-/dev/mapper/VolGroup-lv_root-LABEL=root-g
:s-rd_LVM_LV=VolGroup/lv_root rd_LVM_LV=VolGroup/lv_swap-rd_NO_LVM-g
:wq
# cat /boot/grub/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=LABEL=root
# initrd /initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title centos (2.6.32-71.el6.i686)
root (hd0,0)
kernel /vmlinuz-2.6.32-71.el6.i686 ro
root=LABEL=root rd_NO_LVM
rd_NO_LUKS rd_NO_MD rd_NO_DM
LANG=en_US.UTF-8 SYSFONT=latarcyrheb-sun16
KEYBOARDTYPE=pc KEYTABLE=us crashkernel=auto rhgb quiet
initrd /initramfs-2.6.32-71.el6.i686.img
pertanto:
rd_LVM_LV=VolGroup/lv_root
root=/dev/mapper/VolGroup-lv_root
diventa
root=LABEL=root
aggiungo ma solo se non uso piu' LVM:
rd_NO_LVM
sparisce (perche' e' una partizione extended)
rd_LVM_LV=VolGroup/lv_swap
The contents of /etc/fstab from the target disk must be modified too:
# vi /etc/fstab
# the old mount point for / and swap location
#UUID=dbea6d02-7b89-4148-9ac1-da79af1c7027 /boot ext4 defaults
1 2
#/dev/mapper/VolGroup-lv_swap swap swap defaults 0 0
LABEL=root / ext3 defaults 1 1
LABEL=swap swap swap defaults 1 2
LABEL=boot /boot ext3 defaults 1 2
LABEL=home /home ext3 defaults 1 2
LABEL=var /var ext3 defaults 1 2
LABEL=tmp /tmp ext3 defaults 1 2
LABEL=usr /usr ext3 defaults 1 2
LABEL=opt /opt ext3 defaults 1 2
LABEL=data /data ext3 defaults 1 2
And finally, exit the chroot and schedule a complete filesystem selinux relabel,
otherwise the new installation won't be bootable:
# exit
# touch /mnt/newdisk/.autorelabel
# touch /mnt/newdisk/var/.autorelabel
# touch /mnt/newdisk/tmp/.autorelabel
# touch /mnt/newdisk/usr/.autorelabel
# touch /mnt/newdisk/home/.autorelabel
# touch /mnt/newdisk/opt/.autorelabel
Now it's time to power off the system, unplug the old disk, power on and boot from
the new disk.
On the first boot it will take a time for relabel to complete and it may require
a reboot.
After that, your new partitioned CentOS 6 system will be clonable and resizable
with standard imaging tools.
===================================================
SITUAZIONE INTERMEDIA
===================================================
Salito lasciando la sd-card inserita ed pertanto il boot originale, senza
ricompilare
grub ma semplicemente cambiando la linea di comando sul menu dell boot linux
]# mount
/dev/mapper/fedora-root on /run/media/root/075aac84-b44e-4061-a6c2-0a91d5066a9e
type xfs
(rw,nosuid,nodev,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota,uhelper=u
VECCHIA ROOT
/dev/mmcblk0p1 on /boot/efi type vfat
(rw,relatime,fmask=0077,dmask=0077,codepage=437,iocharset=ascii,shortname=winnt,err
ors=remount-ro) VECCHIO BOOT EFI
/dev/mmcblk0p2 on /boot type xfs
(rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota) VECCHIO BOOT
================================================================================
AZARTICOLO:How to set up swap space?
================================================================================
Raspberry Pi has only 256 MB of RAM, so I would like to use swap space
(either on SD card or attached USB storage).
How do I set it up?
Swap on the Pi (and similar devices) can be painfully slow, and anything that
actually ends up using swap extensively will practically bring the system to
a standstill. Careful!
/etc/dphys-swapfile
CONF_SWAPSIZE=100
cat /etc/dphys-swapfile
CONF_SWAPSIZE=1173
CONF_SWAPFILE=/var/swap
If you want to change the size, you need to modify the number and restart
dphys-swapfile:
/etc/init.d/dphys-swapfile stop
/etc/init.d/dphys-swapfile start
Edit: On Raspbian the default location is /var/swap, which is (of course) located
on the SD card.
I think it is a bad idea, so I would like to point out, that the /etc/dphys-
swapfile can have
the following option too: CONF_SWAPFILE=/media/btsync/swapfile
I only problem with it, the usb storage is automounted, so a potential race here
(automount vs. swapon)
This is the correct answer. None of other answers mentioned the dphys-swapfile.
On any flash-based storage device (SD card, SDD, USB thumb drives) you are also
likely to see system-wide pauses while a large group of flash blocks is erased.
Possible exceptions:
no doubt swapping on a USB bey will kill your key very fast,
swapping on the SD card is also dangerous, even if newer ( class 10 )
SD cards could support it better.
You would think that with the ReadyBoost technology in Windows that someone would
make a USB Drive (or eSata, not sure if ReadyBoost can use that, would be of no
use
to raspberry pi, but would be interesting) that used actual RAM so you could boost
your computer performance.
Although it would probably be easier and cheaper to just buy a new motherboard
that supported the amount of RAM you need.
I used a swap file on an external drive to compile a large library over the course
of a few days.
It's slow as dead monkeys floating in molasses, but that doesn't meant that you
should "not do this at all."
You just have to be careful, and yes, there are usually better options, but
sometimes
you just do what you have to do.
For example, if your USB drive is /dev/sdx, you would use (you must be root for
this):
$ mkswap /dev/sdx
$ swapon /dev/sdx
Note that this would use the whole device and you will probably lose all the
existing
data on it.
When you no longer need the swap file (if you want to eject the USB drive for
example),
you must use swapoff <device>. Not doing so will probably result in system crash.
I think you should change this to avoid users copy and pasting and accidentally
running mkswap on their root partition. I think sdx is a good convention.
Users who choose to enable SWAP may be interested in adjusting kernel swappiness.
Raspbian Jessie has swappiness 1 by default.
It is a pity that the Raspberry Pis do not have GigaBit Ethernet but it is at least
theoretically possible to have swap space on a network device - the Linux Terminal
Server Project can offer it from the server to the clients according to this item
on their wiki.
You can also create a swap file (by using a loop device) like this:
dd if=/dev/zero of=/portatile2009.swp bs=1M count=1024 # For 1GB swap file
swapoff -a
chmod 600 /portatile2009.swp
mkswap /portatile2009.swp
swapon /portatile2009.swp
-----------------------------------------------------------------------------
swapoff -a
swapon -a
swapon --show=NAME,TYPE,SIZE,UUID,LABEL
NAME TYPE SIZE UUID LABEL
/portatile2009.swp file 1024M c6a3c9e0-4ea9-4723-824b-49ab89d1dfcb SWAPAREA
================================================================================
AZARTICOLO: How to migrate (move) logical volumes and volume groups from one disk
to another
disk online without reboot in Linux
================================================================================
In this article I will show you two methods to migrate a logical volume
/dev/rhel/lv1
from one disk to another without reboot assuming you have the extra disk already
available on your system.
Also in the end of the article a quick example to migrate all my logical volumes to
new partition (disk)
LVM Mirroring
LVM pvmove command
---------------------------------
Method 1: LVM Mirroring
--------------------------------
First of all let's check the mapped devices with the logical volumes,
here as you see my logical volume lv1 is residing on /dev/sdb1
-----------------------------------------------------------------------------------
------------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
root@koditv bin]# lvs -o+devices
[root@golinuxhub-server ~]# df -h
-----------------------------------------------------------------------------------
-----------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
df -h
On this partition I have a single file which we will use to monitor our migration
So lets create a partition /dev/sdc1 on my newly added disk with partition type as
"Linux LVM"
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
-----------------------------------------------------------------------------------
------------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
# pvs
-----------------------------------------------------------------------------------
------------------------------
Next extend the "rhel" volume group with the new physical volume
[root@golinuxhub-server ~]# vgextend rhel /dev/sdc1
Volume group "rhel" successfully extended
Use "-v" to enable the verbose option and see the list of partitions used for the
"rhel" volume group
[root@golinuxhub-server ~]# vgdisplay rhel -v
PV Name /dev/sdb1
PV UUID VqVvQi-I0BM-epGZ-lhpf-n48v-LM0u-yGGjgK
PV Status allocatable
Total PE / Free PE 496 / 240
PV Name /dev/sdc1
PV UUID 6Rzgfb-NOeK-MT5F-TrQ5-cM6i-si8v-192uWO
PV Status allocatable
Total PE / Free PE 511 / 511
-----------------------------------------------------------------------------------
------------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
-----------------------------------------------------------------------------------
-----------------------------
So everything looks correct, next again before starting with our migration last
time
lets again validate the partition used by our lv1 which is /dev/sdb1
As you see we have only single dependency and it is mapped to 8,17 which you see
below is for /dev/sdb1
-----------------------------------------------------------------------------------
------------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
brw-rw---- 1 root disk 8, 0 19 dic 14.35 sda
brw-rw---- 1 root disk 8, 1 19 dic 14.36 sda1
Are you sure you want to convert linear LV rhel/lv1 to raid1 with 2 images
enhancing resilience? [y/n]: y
Logical volume rhel/lv1 successfully converted.
If we see the list of devices, it is a bit different because we are spanning two
underlying
devices as we are in a mirror formation
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
Devices
lv1 rhel rwi-aor--- 1.00g 100.00
lv1_rimage_0(0),
lv1_rimage_1(0)
root rhel -wi-ao---- <13.10g
/dev/sda2(401)
swap rhel -wi-ao---- <1.57g
/dev/sda2(0)
Now we can break the mirror and get rid of old device which we wanted to remove
--------------------------------------
-----------------------------------------------------------------------------------
------------------------------
KODITV
-----------------------------------------------------------------------------------
-----------------------------
lvconvert -m 0 fedora/root /dev/mmcblk0p3
The final test is to validate our file and its content which looks same as it was
before migration
[root@golinuxhub-server ~]# cat /lv1/myfile
This is a test file
Now since everything is done we don't need /dev/sdb1 anymore and can be safely
removed from "rhel" volume group
[root@golinuxhub-server ~]# vgreduce rhel /dev/sdb1
Removed "/dev/sdb1" from volume group "rhel"
Now time to migrate our logical volume from /dev/sdc1 to /dev/sdb1, the below
command may take some time
[root@golinuxhub-server ~]# pvmove -n lv1 /dev/sdc1 /dev/sdb1
/dev/sdc1: Moved: 1.56%
/dev/sdc1: Moved: 100.00%
Currently as you see my root and swap partition reside on /dev/sda which I intend
to move to /dev/sdd
[root@golinuxhub-server ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 15.7G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 14.7G 0 part
├─rhel-root 253:0 0 13.1G 0 lvm /
└─rhel-swap 253:1 0 1.6G 0 lvm [SWAP]
sdd 8:48 0 20G 0 disk
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
Extend our "rhel" volume group with the new disk /dev/sdd
[root@golinuxhub-server ~]# vgextend rhel /dev/sdd
Volume group "rhel" successfully extended
As you see my root and swap logical volume is now residing on /dev/sdd
[root@golinuxhub-server ~]# lvs -o+devices
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
Devices
root rhel -wi-ao----
<13.10g /dev/sdd(0)
swap rhel -wi-ao----
<1.57g /dev/sdd(3353)
emergency.service
loaded inactive dead Emergency Shell
● fcoe.service
not-found inactive dead fcoe.service
[email protected]
loaded active running Getty on tty1
[email protected]
loaded active running Getty on tty2
gssproxy.service
loaded active running GSSAPI Proxy Daemon
import-state.service
loaded active exited Import network configuration from initramf
initrd-cleanup.service
loaded inactive dead Cleaning Up and Shutting Down Daemons
initrd-parse-etc.service
loaded inactive dead Reload Configuration from the Real Root
initrd-switch-root.service
loaded inactive dead Switch Root
initrd-udevadm-cleanup-db.service
loaded inactive dead Cleanup udevd DB
irqbalance.service
loaded active running irqbalance daemon
● iscsi-shutdown.service
not-found inactive dead iscsi-shutdown.service
● iscsi.service
not-found inactive dead iscsi.service
● iscsid.service
not-found inactive dead iscsid.service
kmod-static-nodes.service
loaded active exited Create list of static device nodes for the
ldconfig.service
loaded inactive dead Rebuild Dynamic Linker Cache
● livesys-late.service
not-found inactive dead livesys-late.service
lm_sensors.service
loaded active exited Hardware Monitoring Sensors
● lvm2-activation-early.service
not-found inactive dead lvm2-activation-early.service
● lvm2-activation.service
not-found inactive dead lvm2-activation.service
lvm2-lvmpolld.service
loaded inactive dead LVM2 poll daemon
lvm2-monitor.service
loaded active exited Monitoring of LVM2 mirrors, snapshots etc.
lvm2-pvscan@179:3.service
loaded active exited LVM event activation on device 179:3
lxdm.service
loaded inactive dead LXDM (Lightweight X11 Display Manager)
mdmonitor.service
loaded inactive dead Software RAID monitoring and management
mlocate-updatedb.service
loaded inactive dead Update a database for mlocate
multipathd.service
loaded inactive dead Device-Mapper Multipath Device Controller
● network.service
not-found inactive dead network.service
● NetworkManager-wait-online.service
loaded failed failed Network Manager Wait Online
NetworkManager.service
loaded active running Network Manager
nfs-blkmap.service
loaded inactive dead pNFS block layout mapping daemon
nfs-convert.service
loaded inactive dead Preprocess NFS configuration convertion
nfs-idmapd.service
loaded inactive dead NFSv4 ID-name mapping service
nfs-mountd.service
loaded inactive dead NFS Mount Daemon
nfs-server.service
loaded inactive dead NFS server and services
nfs-utils.service
loaded inactive dead NFS server and client services
● nfsdcld.service
not-found inactive dead nfsdcld.service
● ntpd.service
not-found inactive dead ntpd.service
ntpdate.service
loaded active exited Set time via NTP
ostree-remount.service
loaded inactive dead OSTree Remount OS/ Bind Mounts
pcscd.service
loaded inactive dead PC/SC Smart Card Daemon
plymouth-quit-wait.service
loaded inactive dead Hold until boot process finishes up
plymouth-quit.service
loaded inactive dead Terminate Plymouth Boot Screen
plymouth-read-write.service
loaded inactive dead Tell Plymouth To Write Out Runtime Data
plymouth-start.service
loaded inactive dead Show Plymouth Boot Screen
plymouth-switch-root.service
loaded inactive dead Plymouth switch root service
polkit.service
loaded active running Authorization Manager
● rbdmap.service
not-found inactive dead rbdmap.service
rc-local.service
loaded inactive dead /etc/rc.d/rc.local Compatibility
rescue.service
loaded inactive dead Rescue Shell
rngd.service
loaded active running Hardware RNG Entropy Gatherer Daemon
rpc-gssd.service
loaded inactive dead RPC security service for NFS client and se
rpc-statd-notify.service
loaded active exited Notify NFS peers of a restart
rpc-statd.service
loaded inactive dead NFS status monitor for NFSv2/3 locking.
● rpc-svcgssd.service
not-found inactive dead rpc-svcgssd.service
rpcbind.service
loaded inactive dead RPC Bind
rsyslog.service
loaded active running System Logging Service
rtkit-daemon.service
loaded active running RealtimeKit Scheduling Policy Service
selinux-autorelabel-mark.service
loaded inactive dead Mark the need to relabel after reboot
● sntp.service
not-found inactive dead sntp.service
[email protected]
loaded inactive dead OpenSSH ecdsa Server Key Generation
[email protected]
loaded inactive dead OpenSSH ed25519 Server Key Generation
[email protected]
loaded inactive dead OpenSSH rsa Server Key Generation
sshd.service
loaded activating auto-restart OpenSSH server daemon
sssd-kcm.service
loaded inactive dead SSSD Kerberos Cache Manager
switcheroo-control.service
loaded inactive dead Switcheroo Control Proxy service
● syslog.service
not-found inactive dead syslog.service
systemd-ask-password-console.service
loaded inactive dead Dispatch Password Requests to Console
systemd-ask-password-plymouth.service
loaded inactive dead Forward Password Requests to Plymouth
systemd-ask-password-wall.service
loaded inactive dead Forward Password Requests to Wall
systemd-binfmt.service
loaded inactive dead Set Up Additional Binary Formats
systemd-boot-system-token.service
loaded inactive dead Store a System Token in an EFI Variable
systemd-firstboot.service
loaded inactive dead First Boot Wizard
systemd-fsck-root.service
loaded active exited File System Check on Root Device
systemd-hwdb-update.service
loaded inactive dead Rebuild Hardware Database
systemd-initctl.service
loaded inactive dead initctl Compatibility Daemon
systemd-journal-catalog-update.service
loaded inactive dead Rebuild Journal Catalog
systemd-journal-flush.service
loaded active exited Flush Journal to Persistent Storage
systemd-journald.service
loaded active running Journal Service
systemd-logind.service
loaded active running Login Service
systemd-machine-id-commit.service
loaded inactive dead Commit a transient machine-id on disk
systemd-modules-load.service
loaded active exited Load Kernel Modules
systemd-quotacheck.service
loaded inactive dead File System Quota Check
systemd-random-seed.service
loaded active exited Load/Save Random Seed
systemd-remount-fs.service
loaded active exited Remount Root and Kernel File Systems
systemd-rfkill.service
loaded inactive dead Load/Save RF Kill Switch Status
systemd-sysctl.service
loaded active exited Apply Kernel Variables
systemd-sysusers.service
loaded inactive dead Create System Users
systemd-timesyncd.service
loaded inactive dead Network Time Synchronization
systemd-tmpfiles-clean.service
loaded inactive dead Cleanup of Temporary Directories
systemd-tmpfiles-setup-dev.service
loaded active exited Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service
loaded active exited Create Volatile Files and Directories
systemd-udev-settle.service
loaded active exited udev Wait for Complete Device Initializati
systemd-udev-trigger.service
loaded active exited udev Coldplug all Devices
systemd-udevd.service
loaded active running udev Kernel Device Manager
systemd-update-done.service
loaded inactive dead Update is Completed
systemd-update-utmp-runlevel.service
loaded inactive dead Update UTMP about System Runlevel Changes
systemd-update-utmp.service
loaded active exited Update UTMP about System Boot/Shutdown
systemd-user-sessions.service
loaded active exited Permit User Sessions
systemd-vconsole-setup.service
loaded inactive dead Setup Virtual Console
udisks2.service
loaded active running Disk Manager
unbound-anchor.service
loaded inactive dead update of the root trust anchor for DNSSEC
upower.service
loaded active running Daemon for power management
[email protected]
loaded active exited User Runtime Directory /run/user/0
[email protected]
loaded active running User Manager for UID 0
● [email protected]
not-found inactive dead [email protected]
zram-swap.service
loaded active exited Enable compressed swap in memory using zra
systemd-fsck@dev-disk-by\x2duuid-983cb62e\x2d687a\x2d49e0\x2d9a7c\
x2db9a403fc4027.service loaded active exited File System Check on
/dev/disk/by-uuid/983
systemd-fsck@dev-disk-by\x2duuid-B7C7\x2dD61F.service
loaded active exited File System Check on /dev/disk/by-uuid/B7C
================================================================================
UBUNTU partition scheme for dual boot with android-x86
================================================================================
For an old Inspiron 1420 laptop, how can I dual boot (not VirtualBox) with
android-x86? What options do I select when installing Ubuntu 16.04 that the
partition scheme will work for both OS's.
However, I'm not terribly familiar with GPT and would have to do quite a bit of
reading to understand the codes it uses for different types of formatting.
add a comment
1 Answer
active
oldest
votes
0
I believe this is adaptable for use on any Ubuntu distribution to dual boot with
Android X86 without having to use separate partitions for each OS.
This works thanks to the ability to use the same ext4 journaling file system for
both operating systems. It took me a couple days to compile this.
If your Ubuntu or Android X86 distribution are different, simply remember to make
the appropriate terminal command changes (Android X86 4.4 to 5.1 would look like;
initrd /android-4.4-r3/initrd.img} to initrd /android-5.1-r1/initrd.img}).
Check system for 64 bit support before downloading .ISO files.
If your system does not support 64 bit, use 32 bit, or 86 bit.
How to install dual boot of Android 4.4 x86 r3 and Ubuntu (on the same partition)
(Works with other revisions and versions of Android X86)
Begin by downloading Unetbootin, and .ISO files for both Android x86, and Ubuntu.
Enter BIOS on PC with formatted HDD and enable booting from USB/CD.
Reboot PC with USB flash drive inserted containing Ubuntu .ISO and complete a full
install.
Reboot PC with USB flash drive inserted containing Android x86 4.4 r3 and begin
install following these exceptions:
When prompted, select HDD sda1 and DO NOT format or select another file system.
When prompted, DO NOT install GRUB, or EFI GRUB 2.
When prompted, select as read and write.
Remove all media and boot the PC (it will automatically load Ubuntu).
sudo -i
nano /etc/grub.d/40_custom
Using the arrow keys, navigate the the line below the last current entry in the
custom boot loader menu and make the following four entries:
menuentry "Android-x86" {
set root='(hd0,1)'
linux /android-4.4-r3/kernel quiet root=/dev/ram0 androidboot.hardware=generic_x86
acpi_sleep=s3_bios,s3_mode SRC=/android-4.4-r3
initrd /android-4.4-r3/initrd.img}
Press and hold ctrl, x, then press y, and then press Enter
Type:
Immediately after BIOS loads, press and hold the Shift key until GRUB loads.
RECOMMENDED! Load Ubuntu first, and create a disk image (.ISO file) of your new
dual boot set-up and flash it to another USB flash drive and store it as a backup.
You can do this after you apply any updates, or install any programs you wish.
The result should be a dual booted Ubuntu and Android X86 utilizing the default
Ubuntu GRUB2 boot loader menu with the benefits of; no separate partition for
OS's, shared Linux swap space, same file system (ext4), space for installation of
Android applications limited ONLY to the space remaining on your HDD
(not a weak 2Gb-??Gb partition), and the ability to file browse between Ubuntu
and Android X86. Essentially you have installed Android X86 within Ubuntu.
note: Unetbootin now has a self contained application downloadable and compatible
with Windows.
================================================================================
dracut --regenerate-all --force -v
================================================================================
===================================================================================
===========
AZARTICOLO:Simple I/O device driver for RaspberryPi
===================================================================================
===========
https://www.codeproject.com/Articles/1032794/Simple-I-O-device-driver-for-
RaspberryPi
Introduction
------------
The fancy little gadget Raspberry Pi is for sure a nice toy to play with.
But running the wheezy Linux it also is a complete Linux embedded system running on
an ARM platform. That makes it quite interesting for programming and brought me to
the idea to implement an I/O device driver on it, just to set on and off a digital
output and
to read the state of a input.
To compile a device driver on Linux there are some special source files necessary.
These files build the interface to the kernel and they are called kernel header
files.
These header files must be of the same version as the kernel the driver should work
whit later on and they are not included in the Wheezy distributions.
Normally the kernel header files can be obtained by the simple command (entered in
a XTerminal)
This command reads the actual kernel version by “uname -r”, downloads the correct
header files and installs them in the correct directory.
By some reason the kernel header files that fit to the available Wheezy
distributions
cannot be found like this. Even though there are header files of almost the same
version
available, that should not be considered.
A kernel driver can be compiled whit these header files but it will not be
loadedinto the
Kernel if the version does not fit exactly.
So there is only one solution: A new Kernel must be compiled and installed.
That installs the suitable kernel header files as well.
https://www.raspberrypi.org/documentation/linux/kernel/
There is a good description how the download, compile and install an new kernel
with
following commands:
apt-get install bc
Now there should be a directory “linux” in the working directory of the current
user.
Change to this directory by “cd linux” and from there the new kernel should be
configured
before it can be compiled. For this there are different opinions now:
The Raspi page recommends to use the default configuration by the command
make bcmrpi_defconfig
I did so and that worked fine.
In some descriptions they use the old configuration of the current kernel by
make oldconfig
This is basically possible.
But keep in mind: The new kernel will offer many new features that were not
configured
in the old configuration. So you might be asked many strange questions like
Now the kernel compilation can be started and Raspy can be left on its one for a
while.
Call the commands
make
make modules
make modules_install
If everything goes well, a new file “Image” should be in the directory
“arch/arm/boot/”
something around 8 hours later. This is our new kernel.
This file should be renamed to “kernel.img” and copied into the “/boot” directory
of the
system by
uname –r
The kernel header files are installed now and can be found in the directory
“/lib/modules/”
A Linux device driver must have a defined structure that contains at least
following functions:
int init_module(void)
to load the driver
void cleanup_module(void)
to unload the driver.
Beside these two functions we need some more to read or write into our device and a
function to open and one close the device.
static ssize_t device_read(struct file *filp, char *buffer, size_t length, loff_t
* offset)
static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t
* off)
static int device_open(struct inode *inode, struct file *file)
static int device_release(struct inode *inode, struct file *file)
These functions have to be registered in the kernel when the driver is loaded.
Therefore the structure file_operations is used. In this structure for each
function there is a pre-defined reference that gets a pointer to the corresponding
function. That looks like this
init_module(void)
The register_chrdev function basically gets the Major number of the driver as first
parameter. For the kernel the Major number is the identifier of a driver and it
will be linked to the device name handed to the register_chrdev function as the
second parameter.
The Major number can be a fixed number or just a 0 as here. If it is 0, the kernel
will check what Major number is available on the system and give this to our driver
by self. This might be the best solution if a driver is meant to be distributed and
installed on different systems. On a small embedded system where the environment
does not change during its live time, the Major number can be set to a fixed number
as well. In this case an available Major number must be defined by the developer
himself. Therefore the file /proc/devices must be checked and a number that is not
already in use there must be found.
If the registration succeeds, the function returns the Major number that has been
given to our device. This number must be kept as we need it again for unloading the
driver.
Now the driver needs to check whether the I/O region or the Mem region it wants to
read or write to is not occupied by somebody else and reserve this area for
himself. Therefore we have to have a look into the hardware of Raspi. Now there is
another small difference to at least the i86 world. On Raspi the I/O’s are kept in
the memory range and not in the I/O range and if that wouldn’t be enough. This
memory area is mapped to another area J
https://www.raspberrypi.org/wp-content/uploads/2012/02/BCM2835-ARM-Peripherals.pdf
the control addresses of the GPIO port are explained like that.
But as I mentioned: That’s not where they really are. The address 0x7E20 0000 is
mapped to 0x2020 0000 and so on. So to check the memory area we need the command
check_mem_region(PORT, RANGE)
with
cleanup_module(void)
The cleanup_module function is called when the driver is unloaded. It releases the
memory area and unregisters the driver. Therefore the commands
release_mem_region(PORT, RANGE);
unregister_chrdev(Major, DEVICE_NAME);
should be called (here we need the Major number again).
That’s for the loading and unloading of the driver. How exactly the loading and
unloading is done will be explained further down.
If everything went fine so far, we can start using the device now. That means, we
can set up the ports the way we want to use them. Therefore we have to do another
remapping of the address range we want to use. The kernel function ioremap returns
the needed remapped address to a pointer.
writel(cmd, (addr+4));
to the base address plus an offset of 4 we get to the “function select 1” register.
The offset 4 will be converted to 4 byte addresses because addr is a byte pointer.
That’s important to know. If addr would be of another type, that would have to be
considered in the addressing. In case we want to use a u32 pointer the offset found
in the hardware documentation needed to be divided by 4. Of course it is possible
and o.k. to do it like this, but it’s not too clear if one wants to see how things
work. So maybe better stay with the u8 pointer for the addressing :-)
cmd = 0;
writel(cmd, (addr+4));
Then I can set up pin 10 as output by:
cmd = 1;
writel(cmd, (addr+4));
That’s all we have to do here.
static ssize_t device_write(struct file *filp, const char *buff, size_t len, loff_t
* off)
To set or clear our GPIO pin we implement the device_write function. Raspy provides
the “GPIO pin output set 0” and “GPIO pin output set 1” register to set an output.
We have to use the first one to set pin 10. The pins are set bit coded. That means
we have a 32 bit value and each bit represents one pin. Pin 10 is represented by
the bit 10 and to set pin 10 we can use the commends
To clear the pin we have to do the same on the “GPIO pin output clear 0” register.
static ssize_t device_read(struct file *filp, char *buffer, size_t length, loff_t *
offset)
Reading the state of the inputs is implemented in the device_read function. We can
read the state of the pins 0 to 31 in the “GPIO pin level 0” register. Here we get
the state of each pin bit coded again.
res = readl(addr+0x34);
returns the state into the u32 variable res. From this variable I extract the 4 u8
parts and copy them into the array buf by:
index = 4;
while (length && (index >= 0))
{
put_user(*(msg_Ptr++), buffer++);
length--;
index--;
bytes_read++;
}
return bytes_read;
Whth this implementation an application can read the bit coded state of all the
GPIO pins by one device_read call.
obj-m := raspy_io.o
all:
make -C /lib/modules/4.0.9+/build M=$(PWD) modules
clean:
make -C /lib/modules/4.0.9+/build M=$(PWD) clean
I’m using the Kernel version 4.0.9+ and the Kernel header files are in
/lib/modules/4.0.9+. From there the Kernel modules should be included. My own
source files are in the same directory as the make file is. Therefore I can just
set the current path as source path by “M=$(PWD)”. When we start compilation be the
command “make” (in the same directory), the compiler looks for the raspy_io.c file,
compiles and links it to a raspy_io.ko. This is the module that can by loaded into
the kernel.
insmod raspy_io.ko
That’s quite easy.
But now the complicate part begins. To create the knot we need to know the “Major
number” of the device we implemented in our driver. There are two ways to get this
number now. One way is to set the Major number fix in the code of our driver in the
function register_chrdev that we have to call in the init_module function. But for
this we need to know a Major number that is available on the system we want to use
our driver. Basically we can look up all the used numbers in the file devices in
the /proc directory and us one that is not listed there. That could work on a small
embedded system that would remain as is for all the time. But as we probably want
to use our driver on a system where other drivers could be installed later on, we
should go the other way and let the system give us an available Major number
dynamically while inserting the driver into the Kernel and find out which one we
got by self. I implemented my driver in this way already.
The insmod command calls the init_module function and orders a Major number from
the Kernel. This number is listed in the /pro/devices file immediately and we can
read this number from the devices file. To do this I use the magnificent AWK tool.
AWK is a mighty tool, but a hell of complicate :-)
The command to get the Major number in a shell script looks like this:
module="raspy_io.ko"
device="io_dev"
major=`cat /proc/devices | awk "{if(\\$2==\"$device\")print \\$1}"`
The command cat /proc/devices lists all entries from devices an hands this to awk
as a table containing all the Major numbers in the first row and the device names
in the second row. Awk parses all lines now and checks if the value of the second
row (the $2) is our "io_dev". If yes, it thakes the value of the first row ($1) and
returns it to our “major” script variable. Using this major variable I first make
sure the knot I want to create is deleted and create it new by
rm -f /dev/${device} c $major 0
mknod /dev/${device} c $major 0
Now I have to set the permission’s to read and write the device by
I put this commands into a shell script named “load.sh”. This script can be called
as root and inserts and registers the device ready for use.
int fd;
fd = open("/dev/io_dev", O_RDWR);
If this succeeds, fd will be > 0 and we can read or write by
char buf[4];
char wbuf[4];
read(fd, buf, sizeof(buf));
Set pin 14 by
wbuf[0] = 1;
wbuf[1] = 0;
write(fd, wbuf, sizeof(wbuf));
and clear it by
wbuf[0] = 0;
wbuf[1] = 0;
write(fd, wbuf, sizeof(wbuf));
At the end we have to release the driver again by
close(fd);
To compile an application using a device driver the fcntl.h mus be included by
#include <fcntl.h>
To edit the driver source and the test application is used Geany (to install “apt-
get install geany”). Geany is a handy little C-editor. The GCC compiler should be
pre-installed on Raspy. That’s all I needed :-)
Points of Interest
For deeper studies I recommend the book Linux Device Drivers by O’Reilly‘s. That’s
a very comprehensive book (as O’Reilly‘s books usually are :-) ) very helpful for
programming Linux Device Drivers.
License
This article, along with any associated source code and files, is licensed under
The Code Project Open License (CPOL)
Share
TWITTER
About the Author
Mosi_62
Software Developer (Senior) Güdel AG, Langenthal
Switzerland Switzerland
Computers are very straight... They always do exactly what we tell them to do...
Only, much too often what we tell them to do is not really what we want them to do
Smile | :)
Writing Software is one of the most creative tings one can do. I have been doing
this for more than ten years now and still having a lot of fun with it. Besides
doing software for HMI's on C# for business, I enjoy very much to implement
interesting algorithms and analyse the mathematics they are based on in my leisure
time Smile | :)
www.mosismath.com
=================================================================================
===================================================================================
=========
AZARTICOLO:RPI vcgencmd usage
===================================================================================
=========
RPI vcgencmd usage
Verified commands
vcgencmd commands
(I've just checked on a more recent firmware version and there's now also
get_camera, get_mem
and hdmi_status_show commands)
Shows clock frequency, clock can be one of arm, core, h264, isp, v3d, uart, pwm,
emmc, pixel, vec, hdmi, dpi.
root@raspberrypi:~# \
> for src in arm core h264 isp v3d uart pwm emmc pixel vec hdmi dpi ; do \
> echo -e "$src:\t$(vcgencmd measure_clock $src)" ; \
> done
arm: frequency(45)=700000000
core: frequency(1)=250000000
h264: frequency(28)=0
isp: frequency(42)=250000000
v3d: frequency(43)=250000000
uart: frequency(22)=3000000
pwm: frequency(25)=0
emmc: frequency(47)=100000000
pixel: frequency(29)=154000000
vec: frequency(10)=0
hdmi: frequency(9)=163682000
dpi: frequency(4)=0
Shows voltage.
id can be one of core, sdram_c, sdram_i, sdram_p, and defaults to
core if not specified.
root@raspberrypi:~# \
> for id in core sdram_c sdram_i sdram_p ; do \
> echo -e "$id:\t$(vcgencmd measure_volts $id)" ; \
> done
core: volt=1.20V
sdram_c: volt=1.20V
sdram_i: volt=1.20V
sdram_p: volt=1.23V
vcgencmd measure_temp
Shows core temperature of BCM2835 SoC.
Shows if the specified codec is enabled, codec can be one of H264, MPG2, WVC1,
MPG4, MJPG, WMV9.
Please note this was run on a Pi with the MPG2 and VC1 licences enabled.
root@raspberrypi:~# \
> for codec in H264 MPG2 WVC1 MPG4 MJPG WMV9 ; do \
> echo -e "$codec:\t$(vcgencmd codec_enabled $codec)" ; \
> done
H264: H264=enabled
MPG2: MPG2=enabled
WVC1: WVC1=enabled
MPG4: MPG4=enabled
MJPG: MJPG=enabled
WMV9: WMV9=enabled
If you also follow the instructions in this Forum post then the codec options
for VP6 and VP8 (WEBM) also work, this is experimental and unsupported at present
so any changes are at your own risk.
vcgencmd get_config [config|int|str] Will print the configurations you have set.
Argument can ether be a specific option or int, showing all configs with number-
datatype,
or str showing all configurations with datatype sting (aka text).
Shows how much memory is split between the CPU (arm) and GPU.
vcgencmd version
Displays the contents of the OTP (One Time Programmable) memory embedded inside the
SoC.
Locations 28 and 30 store the Serial and Revision values that get displayed by
/proc/cpuinfo
(the Serial is also used to determine the Ethernet MAC address on Model B boards),
and location
32 stores the value of the warranty bit. Purpose of values in other locations is
unknown.
vcgencmd set_backlight
Currently unusable, might be used in the future to control the backlight of LCD
displays
vcgencmd render_bar
Debug function created by Dom, used in OMXPlayer
vcgencmd display_power 0
Turns off video output.
vcgencmd display_power 1
Turns on video output.
Links
===================================================================================
=========
AZARTICOLO:Custom Conky on the Raspberry Pi 2
===================================================================================
=========
One problem that took me quite a while to solve was how to actually get Conky to
launch at startup,
as none of the usual methods seemed to work. In the end I found two ways of calling
a startup script.
First, create a simple Bash script, like this:
startConky.sh
#!/bin/bash
sleep 10 && conky -c ~/Scripts/.conkyrc_raspberry-pi-2 -d
Save it e.g. as ~/Scripts/startConky.sh.
Then, make the script execute at startup in one of the following two ways:
-----------------------
My Conky config:
----------------------
.conkyrc_raspberry-pi-2
# Avoid flicker
double_buffer yes
# Window
# Own window to run simultaneous 2 or more conkys
own_window yes
own_window_type normal
own_window_hints undecorated, below, sticky, skip_taskbar, skip_pager
#own_window_transparent yes
# Borders
draw_borders no
# Shades
draw_shades yes
# Position
gap_x 0
gap_y 34
alignment top_middle
# Behaviour
update_interval 2
# Font
#font arial
use_xft yes
#xftfont arial:size=8
xftfont Bitstream Vera Sans Mono:size=8
#xftfont Terminus:size=8
xftalpha 1 # Text alpha when using Xft
# Colours
#default_color d1d3c9
#default_shade_color 000000
own_window_colour 2B2B2B
TEXT
${font Arial:size=12}${color #ddaa00}${time %I:%M %p}${font} $alignc$
{color #9fb6cd}UpTime: ${color }$uptime $alignr${color #9fb6cd}Temp.: ${color
ff0000}${execi 2 vcgencmd measure_temp | sed 's/[^0-9.]*//g'} °C
${color }${hr}
${color #9fb6cd}CPUs${color }
${color #9fb6cd}1: ${color }${cpugauge cpu1 30, 60} ${cpugraph cpu1, 30, 125
ffff00 ff0000 -t} $alignr${color #9fb6cd}2: ${color }${cpugauge cpu2 30, 60} $
{cpugraph cpu2, 30, 125 ffff00 ff0000 -t}
${color #9fb6cd}3: ${color }${cpugauge cpu3 30, 60} ${cpugraph cpu3, 30, 125
ffff00 ff0000 -t} $alignr${color #9fb6cd}4: ${color }${cpugauge cpu4 30, 60} $
{cpugraph cpu4, 30, 125 ffff00 ff0000 -t}
${color }${hr}
${color #9fb6cd}MEM
${color }${memgauge 30, 60} $alignr${memgraph 30, 380 0000ff ffff00 -t}
${color }${hr}
${color #9fb6cd}UP $alignc${color #9fb6cd}IP: ${color }${addr wlan0} $alignr${color
#9fb6cd}DOWN
${color }${upspeedgraph wlan0 30, 220 0000ff ff0000 -t} $alignr${downspeedgraph
wlan0 30, 220 0000ff 00ff00 -t}
--------------------------------------------------------------------------------
cd /root/.conky
cat conky-startup.sh
#!/bin/sh
# No widgets enabled!
## =============================================================================
## Openbox autostart (OK)
## =============================================================================
# Run the system-wide support stuff
# . $GLOBALAUTOSTART
#export LC_CTYPE=it_IT.utf8
#export XMODIFIERS=@im=SCIM
#export GTK_IM_MODULE=scim
#export QT_IM_MODULE=scim
## =============================================================================
## Note*: some programs, such as 'nm-applet' are run via XDG auto-start.
## Run '/usr/lib/openbox/openbox-xdg-autostart --list' to list any
## XDG autostarted programs.
## GNOME PolicyKit and Keyring
# /usr/lib/polkit-1-gnome/polkit-gnome-authentication-agent-1 &
# eval $(gnome-keyring-daemon -s --components=pkcs11,secrets,ssh,gpg) &
# xfce4-power-manager &
# Start the Clipboard manager after 3 <span class="IL_AD"
id="IL_AD10">seconds</span> wait
# clipit &
# start volume manager after 3 seconds
# volti &
# Programs to launch at startup
#hsetroot ~/wallpaper.png &
#xcompmgr -c -t-5 -l-5 -r4.2 -o.55 &
# SCIM support (for typing non-english characters)
#scim -d &
# Programs that will run after Openbox has started
#tint2 &
#fbpanel -p fbpanel &
#feh -F --bg-scale /root/Immagini/cubi.jpg
## =============================================================================
#xset -dpms &
#xset r rate 200 25 &
#thunar --daemon &
#xfdesktop -W &
#xfce4-panel -d &
cat conky.desktop
---------------
[Desktop Entry]
Type=Application
Exec=sh "/root/.conky/conky-startup.sh"
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_IN]=Conky
Name=Conky
Comment[en_IN]=
Comment=
[root@koditv autostart]#
[Desktop Entry]
Name=conky
Type=application
Exec=/home/pi/Scripts/startConky.sh
===================================================================================
==
Raspberry Pi Documentation DOCUMENTAZIONE UFFICIALE
===================================================================================
=
https://www.raspberrypi.org/documentation/
Contents
---------
raspi-config
The Raspberry Pi configuration tool in Raspbian, which allows you to easily enable
features
such as the camera, and to change your specific settings such as keyboard layout
config.txt
The Raspberry Pi configuration file
TCP/IP networking
Configuring the TCP/IP network stack on the Raspberry Pi
Using a proxy
Setting up your Pi to access the internet via a proxy server
HDMI Config
Setting up your HDMI device, including custom settings
Audio config
Switching your audio output between HDMI and the 3.5mm jack
Camera config
Installing and setting up the Raspberry Pi camera board
Localisation
Setting up your Pi to work in your local language and time zone
UART configuration
Setting up the on-board UARTs
---------------------------------------------------------------------------------
Raspbian
---------------------------------------------------------------------------------
https://www.raspberrypi.org/documentation/raspbian/
Raspbian is the recommended operating system for normal use on a Raspberry Pi.
Raspbian is a free operating system based on Debian, optimised for the Raspberry Pi
hardware.
Raspbian comes with over 35,000 packages: precompiled software bundled in a nice
format for
easy installation on your Raspberry Pi.
Contents
---------
Installing Raspbian
Installing software in Raspbian
Updating/Upgrading Raspbian
Configuring Raspbian
raspi-config
config.txt
screensaver
Applications
Camera
OMXPlayer
vcgencmd
vcdbg
tvservice
--------------------------------------------------------------------------------
DOCUMENTATION > RASPBIAN > APPLICATIONS > OMXPLAYER
--------------------------------------------------------------------------------
OMXPlayer uses the OpenMAX (omx) hardware acceleration interface (API) which is the
officially
supported media API on the Raspberry Pi.
Basic usage
----------
The simplest command line is omxplayer <name of media file>.
The media file can be audio or video or both.
For the examples below, we used an H264 video file that is included with the
standard
Raspbian installation.
omxplayer /opt/vc/src/hello_pi/hello_video/test.h264
You can also specify which part of the video you want to be displayed: this is
called a crop window.
This portion of the video will be scaled up to match the display, unless you also
use the window option.
If you are using the Raspberry Pi Foundation's touchscreen display, and you want to
use it for
video output, use the display option to specify which display to use.
n is 5 for HDMI,
4 for the touchscreen.
With the Raspberry Pi 4 you have two options for HDMI output.
n is 2 for HDMI0
and 7 for HDMI1.
There are a number of options available during playback, actioned by pressing the
appropriate key.
Not all options will be available on all files. The list of key bindings can be
displayed using
omxplayer --keys:
1 decrease speed
2 increase speed
< rewind
> fast forward
z show info
j previous audio stream
k next audio stream
i previous chapter
o next chapter
n previous subtitle stream
m next subtitle stream
s toggle subtitles
w show subtitles
x hide subtitles
d decrease subtitle delay (- 250 ms)
f increase subtitle delay (+ 250 ms)
q exit omxplayer
p / space pause/resume
- decrease volume
+ / = increase volume
left arrow seek -30 seconds
right arrow seek +30 seconds
down arrow seek -600 seconds
up arrow seek +600 seconds
This is a full list of options available in the build from 23rd September 2016,
displayed using omxplayer --help:
Custom filename is not yet supported, therefore both audio/video files are
downloaded as "videoplayback". The audio file has the mime-type: "audio/mp4" and
therefore should have the file extension: "m4a" or "mp4" but some browsers may
require you to add the extension manually.
Otherwise you can always manually convert the Dash audio file to any format with
ffmpeg. To do so, you need to know your audio's bitrate, which was shown in the
download menu. If you don’t remember the bitrate you can check it by running
ffprobe INPUT_FILE
in the Command Prompt window. Just replace INPUT_FILE with the downloaded audio
file name.
Then you need to convert the bitrate from kbit/s to bit/s. To do so just add three
zeroes after the bitrate (ex.: 128 kbit/s audio would be 128000 bit/s). Thereafter
you need to execute the following command in the Command Prompt window:
ffmpeg -i INPUT_FILE -ab BITRATE -vn OUTPUT_FILE
--------------------------------------------------------------------------------
AZARTICOLO: HOWTO Convert video files
--------------------------------------------------------------------------------
https://linuxreviews.org/HOWTO_Convert_video_files
Converting video files between common file containers and codecs can easily be done
from the
command-line on Linux systems. Starting a conversion job can be done quicker than
graphical tools
when you know the basic commands.
Note: This article is about video conversion and manipulation using the command-
line in terminal.
Take a look at avidemux and VLC if you want a graphical program which lets you
quickly convert
from one format to another.
See kdenlive and Pitivi if you are looking for a full-featured timeline video
editor
Contents
1 When to convert
1.1 Sometimes file-size matters
1.2 Playability
2 The Basic Tools for ALL Your Video Conversion Needs
3 ffmpeg for beginners
3.1 Specifying audio and video format
3.2 Moving on to more advanced encoding
3.3 "strict experimental"
3.4 Encoding options for H264 / MPEG-AVC video
3.5 Encoding options for VP9
3.6 Resizing a video to lower resolutions
3.6.1 Resizing a video to higher resolutions
3.7 HOWTO Make a VideoCD/VCD
4 Special use-cases
4.1 Making a .webm to post on that image-board
4.2 HOWTO make animated .gif files
5 Corner-case errors
6 Questions?
When to convert
There are many good reasons to convert video files you made yourself - or video
files forwarded to you which you plan to distribute. Good reasons to change a video
file can be:
A video-file reduced by 100 MB will save you 100 GB of bandwidth if 1000 people
download it;
The reduction of 100 MB per. file will save you 1 GB of hard-drive space if you
host 10 video-files on a web-server.
This adds up. You will likely want files to be as small as possible without
reducing the video quality.
Playability
If you are distribution your video on the web to a general audience then
proprietary H264 (MPEG/AVC) video with AAC is the best choice for maximum
playability.
If your audience is primarily Linux-focused then VP9 video with Opus audio in
a .webm container is the best choice.
iToddlers can't play Webm and Apple appears to be hell-bent on keeping it that way.
You will see your shareholder value decrease if you only provide videos in Webm
format on your website if it is targeting a broad audience.
Three other tools do exist: mencoder, ffmpeg2theora and transcode. They are wildly
outdated and not worth your time. mencoder has been barely updated to ensure it
still compiles the last decade. transcode hasn't even got that much attention.
ffmpeg2theora is no longer relevant since VP9 has deprecated the theora video
format.
You need to enable rpmfusion to get a fully featured version of ffmpeg on Fedora
due to imaginary property laws in the US.
Shell command:
ffmpeg -i YourAwesomeMovie-Input.dv YourAwesomeMovie-Output.webm
That's it. This is, ffmpeg -i input.ext output.ext is all you need do remember when
it comes to the most basic use-case. ffmpeg detect the input file automatically and
will look at the output file extension and try to intelligently decide what audio
and video codecs to use.
You can specify the audio and video codecs used by input files. There is rarely a
need, the built-in input detection does work perfectly in 99% of all cases.
An output filename with the .mp4 extension will make ffmpeg assume that you want a
file with H.264/AVC video and AAC 2.0 audio. These happen to be the correct choices
for HTML5 web video files which can be played on all devices.
An output file with the .webm extension will use VP9 video and Opus audio. This is
a great choice for videos posted on websites that are not visited by too many
Apple-users.
An output filename signalling the .mkv container will get h264 video and vorbis
audio. This is likely NOT what you want in a .mkv file.
Specifying audio and video format
Add -c: and a for audio or v for video to set the audio and video codecs (-c:v for
video and -c:a).
If you want VP8 video with vorbis audio in a .webm container you use -c:v libvpx -
c:a libvorbis like this:
Shell command:
ffmpeg -i wjsn-save-you-save-me.mp4 -c:v libvpx -c:a libvorbis wjsn-is-the-best-we-
love-them.webm
Kemonomimi rabbit.svg Note: ffmpeg supports a large variety of encoders depending
on how it was compiled. You can get a very large list of all the encoders your
version supports by running ffmpeg -encoders. You probably want to pipe it to a
pager like less, ffmpeg -encoders
Moving on to more advanced encoding
The secret ffmpeg manual page is very long. It contains lots of detailed
information about the numerous options available when using this tool. Whole books
can be are being written about the advanced options listed in the manual page.
A general rule is: You can have low file-size OR high picture quality, but you can
NOT have both. You will have to compromise.
This may give you an acceptable quality video file on lower resolutions like 720p:
Shell command:
ffmpeg -i YourAwesomeMovie.dv -r 25 -b:a 128k -b:v 4000k YourAwesomeMovie.mp4
..and this will absoltely NOT, because 256k is not enough bandwidth for acceptable
quality even at tiny resolutions:
Shell command:
ffmpeg -i YourAwesomeMovie.dv -r 25 -b:a 64k -b:v 256k YourAwesomeMovie.mp4
"strict experimental"
Some versions of ffmpeg will refuse to use certain codecs unless you specify -
strict experimental
Try adding it if ffmpeg refuses to do something when your options should work.
Output quality can be adjusted in many ways. We recommend sticking with the
Constant Rate Factor encoding option set by -crf. The -crf switch values worth
considering are 20 to 30 where 20 produces very high quality and produces 30
acceptable quality. You can use lower values for even better quality or higher
values for worse; the allowed range is 0-51. 20-30 is what you want to use.
You should also add a -preset option and the choices are ultrafast, superfast,
veryfast, faster, fast, medium (default), slow, slower and veryslow. The presets
allow you to choose encoding speed at the cost of size. Thus; if you use a fixed
quality setting like crf you will get the exact same quality with superfast and
veryslow but the file size will be bigger when using superfast. The medium default
is fine.
Do note that -preset will change quality if you are using fixed constant bitrate
encoding.
An example of encoding H264 with a Constant Rate Factor of 21: An example of using
-crf to set quality would be:
Shell command:
ffmpeg -i inputfile.mkv -c:v libx264 -preset slow -crf 21 output.mp4
You might want to make a simple script for encoding a format you use frequently
such as:
File: $HOME/bin/ffmpeg-encode-h264-hq.sh
#!/bin/bash
inputf="$*"
inputnoext="${inputf%.*}"
outputf="${inputnoext}.hq.mp4"
Shell command:
ffmpeg-encode-h264-hq.sh inputfile.mkv
and get a H264 file named inputfile.hq.mp4.
You can obviously throw in more options such as -vf scale if you, for example,
convert video to 720p regularly:
File: $HOME/bin/ffmpeg-encode-h264-720p.sh
#!/bin/bash
inputf="$*"
inputnoext="${inputf%.*}"
outputf="${inputnoext}.hq.mp4"
For libvpx-vp9 Constant Quality or Constrained Quality are the best choices. The
difference is that Constrained Quality allows you to set a roof for how high the
variable bitrate required for the constant quality you selected goes. These modes
are invoked by the switch -crf with a value between 0-63 together with -b:v and
bitrate cap. This cap must be specified as 0 if you want no cap.
CRF values for VP9 differ x264. Lower values mean better quality, higher worse. The
CRF value required for good visual quality is variable when using libvpx-vp9. 30 is
a good choice for 1080p, 33 is a good choice for 720p and 16 works fine at 4K.
Shell command:
ffmpeg -i WJSN-LaLaLa.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -c:a opus WJSN-LaLaLa.webm
And Constrained Quality mode is archived by setting -b:v to a bitrate value instead
of 0:
Shell command:
ffmpeg -i WJSN-LaLaLa.mp4 -c:v libvpx-vp9 -crf 30 -b:v 9000k -c:a opus WJSN-
LaLaLa.webm
libvpx-vp9 is very single-threaded when using the default options. You will
probably want to use all of these options in addition to -crf when encoding:
threads 4
row-mt 1
tile-columns 6
frame-parallel 1
auto-alt-ref 1
lag-in-frames 25
What do all those options do? Nobody knows, mystery remains unsolved. The sum of
them a) does produce slightly better quality and b) makes ffmpeg encode using more
than just one core. The threads option will obviously limit how many.
File: $HOME/bin/ffmpeg-encode-VP9.sh
#!/bin/bash
inputf="$*"
inputnoext="${inputf%.*}"
outputf="${inputnoext}.webm"
-vf scale="'if(gt(iw,1280),1280,iw)':-1"
This makes ffmpeg decide the correct height based on the aspect ratio and the
width.
Shell command:
ffmpeg -i 4kvideofile.mkv -vf scale="'if(gt(iw,1280),1280,iw)':-1" -c:v libvpx-vp9
-c:a opus downscaledto720p.webm
Resizing a video to higher resolutions
Doing so would simply be foolish as you gain nothing in terms of quality while the
file-size would be increased dramatically.
ffmpeg can make VCD mpeg video files using -target where the target can be "vcd",
"svcd", "dvd", "dv", "pal-vcd", "ntsc-svcd". These switches will set the output
format options (bitrate, codecs, buffer sizes) automatically.
Shell command:
ffmpeg -i myfile.avi -target vcd /tmp/vcd.mpg
A ntsc vcd:
Shell command:
ffmpeg -i myfile.avi -hq -target ntsc-vcd /tmp/vcd.mpg
Converting a file for VCD format using a and b frames for MPEG 2:
Shell command:
ffmpeg -i myfile.avi -target ntsc-vcd -bf 2 /home/user/Video/vcd.mpg
Special use-cases
Making a .webm to post on that image-board
That image-board will not accept webm files with VP9 videos.
Shell command:
ffmpeg -i cute-kpop-queen-dancing.mp4 -map 0:0 -c:v libvpx -b:v 1.4M -threads 4
cutekpopqueen.webm
The important options here are:
-map 0:0 specifies that only the video track (0:0) from the input should be
included.
-c:v libvpx specifices VP8 video.
-b:v 1.4M specifies a bitrate of 1.4M. This is low. File-size restrictions do
apply. You may want to convert a few times starting with -b:v 1M or -b:v 2M. Adjust
the bitrate up or down depending on how close you are to the end-result being
within the (3M on "that" imageboard) required limit.
HOWTO make animated .gif files
The outdated video-player mplayer combined with the image manipulation toolbox lets
you convert short video files to .gif files.
Make sure your video file is short. This is highly important as you do want to make
sure your animated .gif ends up being reasonably small.
Convert your video file to a very small resolution. Again, a 20 MB .mp4 file is
alright, a 20 MB .gif file is NOT.
First, use mplayer's -vo option to produce a series of images, either png or jpg.
Shell command:
mplayer -vo png myvideoclip.mp4
or
Shell command:
mplayer -vo jpeg myvideoclip.mp4
You should now have a folder full of incriminating images. You can use them all or
delete a few (every 4 images, for example).
It is now time to use the awesome power of imagemagick's convert tool (secret
convert manual page) to merge all the png (or jpg) images into one big
animated .gif file:
Shell command:
convert *.png animation.gif
Beware that convert has a secret -delay option which could be used to set the time
between images in the animated .gif file.
Corner-case errors
Too many packets buffered for output stream 0:1.
[libopus @ 0x562117d06100] 1 frames left in the queue on closing
This can happen when trying to convert some files created with OBS. It can happen
if the file has sparse audio or video frames. Adding this parameter to ffmpeg will
solve it:
-max_muxing_queue_size 400
While it's somewhat unclear why this seemingly randomly happens the -
max_muxing_queue_size 400 option appears to solve it every time.
Questions?
avatar
Anonymous user #1
6 months ago
Score 0++
Avdshare Video Converter is just the professional MP4 to XviD converter that we
will recommend. Avdshare Video Converter can convert any MP4 file with any codec or
obtained from any source to XviD codec for the XviD compatible devices or players.
Permalink | Reply
avatar
Anonymous user #2
Introduction
Video file merging requires that the files you want to merge have the same
resolution and file format. You have to convert if they don't, see HOWTO Convert
video files.
This will only work if the files have the same resolution and the same video and
audio formats.
The concat filter is required if they do not have the same video format or audio
format or container:
Kemonomimi rabbit.svg Note: complex filter still requires that the files have the
same frame-rate and resolution. You can't just merge some 720p with a 1080p file
using this method. You will have to convert the file(s) so that they have the same
frame-rate and resolution.
Do notice how the complex works: You need to add a video and an audio option for
each file and a number option to concat=. You need to add more if you want to merge
say 3 files:
You can go on adding these options and merge 10 files but at that point you're
better off considering a video editor like kdenlive or pitivi.
=================================================================================
AZARTICOLO:Che cos'è la risoluzione video 4K
=================================================================================
Attualmente si sono solo poche sorgenti da cui puoi scaricare 4K video. La più
popolare è YouTube,
dove si trova un contenuto con una super-risoluzione sempre più elevata.
Sfortunatamente,
Google e YouTube non permettono di scaricare video direttamente dal sito.
Ma ciò non vuole dire che sia impossibile.
Quindi, per riassumere, se hai problemi con lo scaricamento dei video VEVO da
YouTube, aspetta
un po' e noi ripareremo il problema
================================================================================
AZARTICOLO:How to Upgrade Raspbian Stretch to Raspbian Buster
================================================================================
https://pimylifeup.com/upgrade-raspbian-stretch-to-raspbian-buster/
by Emmet Jul 10, 2019 Guides
In this guide, we will show you how to upgrade Raspbian Stretch to Raspbian Buster.
Before upgrading your Raspberry Pi from Raspbian Stretch to Buster you should first
make a
backup of your SD Card. There is always a chance that this upgrade process will
break your
existing installations.
If you have some critical software running on your Raspberry Pi, it’s best to do a
quick search
to ensure there aren’t any compatibility issues on the latest release.
1. We need first to ensure that our current Raspbian operating system is entirely
up to date.
Upgrading all the currently installed packages ensures that we will have a cleaner
upgrade path to
Raspbian Buster.
Let’s first update all the currently installed packages by running the following
command.
2. Next, let’s go ahead and also update the Raspberry Pi’s firmware.
rpi-update
Once all the update processes have completed, we can now proceed to upgrade the
Raspbian
installation from Stretch to Raspbian Buster.
1. Now that we have prepared our Raspbian Stretch installation, we can now start
the process of
moving to Buster.
vi /etc/apt/sources.list
2. Within this file, find the following line and change “Stretch” to “Buster“.
This change will allow the package manager to search the Raspberry Pi package
repository under
the “Buster” distribution instead of the “Stretch” distribution.
Find
deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
Replace With
deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
Once you have replaced all occurrences of “stretch” within the file you can save it
by pressing CTRL + X
then Y followed by ENTER.
Find
Once you have again finished switching “Stretch” to “Buster“, you can save the file
by pressing
CTRL + X then Y and then ENTER.
5. Now before we do the final push to Raspbian Buster, we will first remove the
“apt-listchanges”
package.
The reason for removing this package is to give us a faster and smoother upgrading
process.
Without removing this package, the Raspbian operating system will have to load a
fairly large
changelog file which will slow down your upgrade process considerably.
Feel free to re-install this package after the upgrade process has completed.
Run the command below to uninstall the “apt-listchanges” package.
6. Finally, with the source files now modified to mention the “Buster” build
instead of “Stretch”
we are now ready to begin the upgrade process.
The first command will update the package lists stored on the Raspberry Pi.
The second command will then update all the packages to their Raspbian Buster
versions.
apt update
apt dist-upgrade
Please note that this process can take considerable time as there are a fair few
packages that
will need to be updated.
Additionally, you may be required to answer prompts, so don’t stray too far from
your Raspberry Pi.
7. Once the Buster upgrade process has completed, we will need to get rid of some
new applications
that will automatically be installed.
These packages are not supported by the Raspberry Pi foundation and are recommended
to be removed.
We can remove these packages by running the following command on your Raspberry Pi.
8. Next, we need to run a few more commands to ensure we have cleaned up everything
leftover
from the upgrade.
The first command that we will be running is the package managers “autoremove”
command.
This command will remove any packages that have been marked as no longer needed
due to
changed dependencies.
apt autoremove -y
apt autoclean
reboot
--------------------------------------------------------------------------------
How to Upgrade Raspbian Stretch to Raspbian Buster
--------------------------------------------------------------------------------
by Emmet Jul 10, 2019 Guides
In this guide, we will show you how to upgrade Raspbian Stretch to Raspbian Buster.
If you have some critical software running on your Raspberry Pi, it’s best to do a
quick search to ensure there aren’t any compatibility issues on the latest release.
Upgrading all the currently installed packages ensures that we will have a cleaner
upgrade path to Raspbian Buster.
Let’s first update all the currently installed packages by running the following
command.
2. Next, let’s go ahead and also update the Raspberry Pi’s firmware.
sudo rpi-update
Once all the update processes have completed, we can now proceed to upgrade the
Raspbian installation from Stretch to Raspbian Buster.
This change will allow the package manager to search the Raspberry Pi package
repository under the “Buster” distribution instead of the “Stretch” distribution.
Find
Find
5. Now before we do the final push to Raspbian Buster, we will first remove the
“apt-listchanges” package.
The reason for removing this package is to give us a faster and smoother upgrading
process. Without removing this package, the Raspbian operating system will have to
load a fairly large changelog file which will slow down your upgrade process
considerably.
Feel free to re-install this package after the upgrade process has completed.
The first command will update the package lists stored on the Raspberry Pi. The
second command will then update all the packages to their Raspbian Buster versions.
Additionally, you may be required to answer prompts, so don’t stray too far from
your Raspberry Pi.
7. Once the Buster upgrade process has completed, we will need to get rid of some
new applications that will automatically be installed.
These packages are not supported by the Raspberry Pi foundation and are recommended
to be removed.
We can remove these packages by running the following command on your Raspberry Pi.
sudo apt purge timidity lxmusic gnome-disk-utility deluge-gtk evince wicd wicd-gtk
clipit usermode gucharmap gnome-system-tools pavucontrol
8. Next, we need to run a few more commands to ensure we have cleaned up everything
leftover from the upgrade.
The first command that we will be running is the package managers “autoremove”
command. This command will remove any packages that have been marked as no longer
needed due to changed dependencies.
This autoclean command will clear out the package cache. It automatically removes
any package files that are no longer available for download and thus are largely
useless.
-------------------------------------------------------------------------------
Reducing SD Card Writes With Raspbian
--------------------------------------------------------------------------------
A common concern of those running applications on a Raspberry Pi is SD Card
exhaustion.
It seems that after some amount of write activity, some SD cards fail to record
further data.
I first noticed this on an APRS system when system updates disappeared upon reboot.
The systemd journal is a useful tool that has largely replaced the syslog in modern
Linux systems. It can also be redirected from the SD card to volatile memory.
Note that by changing this you will reduce the number of SD card writes but your
journal will not survive reboots.
[Journal]
#Storage=auto
[Journal]
Storage=volatile
---------------------------------------------------------------------------------
Disable unwanted Raspbian Services
---------------------------------------------------------------------------------
# WiFi
blacklist brcmfmac
blacklist brcmutil
# Bluetooth
blacklist btbcm
blacklist hci_uart
EOF
Disable bluetooth
The bluetooth service is not required
sudo reboot
At this point, you should now have successfully updated your Raspberry Pi from
Raspbian Stretch
to Raspbian Buster. You can now go do some more projects using the Raspberry Pi
using your newly
updated version of Raspbian.
================================================================================
AZARTICOLO:Raspberry Pi Networking - Switching between wired and wireless networks
================================================================================
Quite often I want to run my Raspberry Pis "headless" - that is to say, without a
keyboard, mouse or monitor. That means I have to manage without the desktop tools
to configure the network; I have to use the command-line network tools over an SSH
connection.
Another problem I have is that I want the Raspberry Pi to use a static IP if it's
in my house - with no monitor, I can't read the IP address off the screen, so the
IP address needs to stay the same so I know where to connect to. However if I'm
taking it elsewhere, I want to be able to quickly and easily configure it for
another wireless network.
Here's my assumptions:
If the network cable is plugged in, assume that we must be at home, and use a
static IP. Meanwhile, ignore WiFi completely regardless of whether the USB WiFi
nano dongle is plugged in or not.
If the network cable is unplugged, and we are at home, use the same static IP on
WiFi that I would otherwise be using through the ethernet cable.
So if I'm at home, no matter whether the network cable is plugged or unplugged, the
Raspberry Pi will always be on the same IP.
If the network cable is unplugged, and we are not at home, use any configured WiFi,
which may be configured with a static IP but more likely will use a dynamic IP.
I'll have to either plug the Pi in to a display to find out the dynamic IP, or use
a network scanner.
I may "hot-plug" the network cable by plugging it or unplugging it whilst the
Raspberry Pi is running. However I will never remove or insert the USB nano WiFi
adaptor whilst the Pi is running - that usually ends up with the Pi rebooting
anyway. So the network cable may come and go whilst the Pi is switched on, but the
WiFi adaptor is either always there, or never there.
You have a backup of your SD card (or you don't care about making mistakes), you're
happy editing files using Nano or our favourite text editor, and you understand
that all of this work will be done as root (use sudo su - to get a root prompt ;
exit to go back to being a normal user).
Static IP on some WiFi connections but dynamic on others
Let's deal with the easy problem first; static IPs on some WiFi connections but
dynamic on others. This is done by setting an id_str in the
/etc/wpa_supplicant/wpa_supplicant.conf file:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="aoakley-home"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="aoakley-home"
}
network={
ssid="PlusnetWireless9AAAA9"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="inlaws"
}
network={
ssid="aoakley-mifi"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP TKIP
group=CCMP TKIP
psk="PASSWORD"
id_str="aoakley-mifi"
}
In the wpa_supplicant.conf file above, we have three known WiFi networks, all with
WPA-PSK security; aoakley-home , PlusnetWireless9AAAA9 and aoakley-mifi . Each has
been given an id_str so they can be identified in the /etc/network/interfaces file.
For aoakley-home and aoakley-mifi I've set the id_str the same as the ssid , but
for ease of identification, I've set the id_str of the Plusnet connection at my
wife's parents' house to id_str="inlaws" (there are a lot of Plusnet WiFi routers
out there - no doubt another will join my list soon).
You'll need to customise this wpa_supplicant.conf file to represent your known WiFi
networks. If your Pi never leaves home, then you'll probably just have one WiFi
network listed - but make sure it has an id_str.
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface aoakley-home inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
You'll notice in the settings above, that I have defined a static IP for aoakley-
home , but nothing for any of the other id_strs. Any id_str which is not mentioned
in /etc/network/interfaces will use the default setting, which in my config is
DHCP: iface default inet dhcp
You'll need to customise the address, netmask, network, broadcast and gateway
settings so that they are suitable for your home LAN. For example, your LAN might
use 192.168.1.xxx rather than 192.168.0.xxx . You can usually find this information
in your broadband router manual.
Reboot with shutdown -r now and it's job done. We now have a static IP for the
aoakley-home WiFi network, but dynamic IP everywhere else, and we can quickly and
easily add new WiFi networks to wpa_supplicant.conf without having to reconfigure
anything else.
I want the same static IP at home regardless of whether I'm using WiFi or a wired
network cable. However, if both the eth0 and wlan0 interfaces try to use the same
IP address at the same time, this can cause a lot of problems; usually an
unresponsive network.
There are a gazillion ways around this problem. Look up "Linux route metrics" if
you want to learn the hard-core way of doing it. My solution is a lot more simple:
turn off WiFi if a wired network cable is inserted.
The ifplugd daemon provides a neat foundation that we can build on. If your eth0
interface is declared as hot-pluggable, ifplugd runs a special script whenever a
cable is inserted or removed. We can customise this script to turn the wlan0
interface off or on.
#!/bin/sh
set -e
case "$2" in
up)
/sbin/ifup $1
if [ "$1" == eth0 ]; then /sbin/ifdown wlan0 ; fi # This is a new bit
;;
down)
/sbin/ifdown $1
if [ "$1" == eth0 ]; then /sbin/ifup wlan0 ; fi # Another new bit
;;
esac
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp
iface aoakley-home inet static
address 192.168.0.5
netmask 255.255.255.0
network 192.168.0.0
broadcast 192.168.0.255
gateway 192.168.0.254
I'll repeat my previous bit of advice here: don't set the wlan0 interface as hot-
pluggable, as in any case, most attempts to remove or re-insert a USB WiFi adaptor
whilst your Raspberry Pi is switched on, will probably result in your Pi rebooting
(or worse, not rebooting... ever... and a puff of magic smoke). My guess is that
this is because a USB WiFi adaptor consumes a lot more milliamps than a mouse or a
keyboard, and the Pi is already pretty sensitive to amperage fluctuations. It's a
twenty-five quid computer; if you need to remove or insert the WiFi adaptor, just
shut down the Pi first. The auto parameter for wlan0 defines the WiFi interface as
something that should be brought up at boot time and not disconnected until
shutdown. However if the dongle isn't there, the Pi will continue to boot without
it.
If it all goes wrong, restore your backup, or connect a screen to see what's
happening, or put the SD card in a desktop/laptop Linux PC and examine the /etc
files there.
By the way, this setup has also been tested on a Raspberry Pi Model A which doesn't
have an eth0 interface at all. It'll boot up and connect to WiFi just fine, so if
you have lots of Raspberry Pis, you can use this recipe for all of them.
================================================================================
AZARTICOLO:How to configure Wifi and USB wifi dongles from command-line
================================================================================
Contents
Configure wifi from your Raspberry Shake’s internal web configuration page
http://rs.local
To configure the wifi from the command-line, start by opening a terminal and
opening a connection to your Shake Pi:
$ ssh [email protected]
For SSH instructions, see: How to access your Raspberry Shake’s computer via ssh.
If you are a Windows user, you would use PuTTY for this step.
$ cat /etc/network/interfaces
And verify that the following lines exist
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
If they aren’t there, edit the file, add the lines above, and save
network={
ssid="SSID of your wifi"
psk="password of your wifi"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
The ” are necessary. If you want to connect to a WiFi network with no password, use
this configuration:
network={
ssid="SSID of your wifi"
key_mgmt=NONE
}
Now reboot your shake:
$ sudo reboot
Advanced topics
How to encrypt wifi password from command-line
Execute this commmand:
network={
ssid="mywifi"
#psk="mypasswd"
psk=175c63e5acd5b9bb66cfe2f89857db9060f2edf3989c89c19e5a54e5044cd2a4
}
Copy this output to /etc/wpa_supplicant/wpa_supplicant.conf and remove the #psk
line to make it fully encrypted
If an ethernet cable is plugged in, and the setting in the configuration file is
off, WiFi drivers will be automatically turned off at system boot to avoid
unnecessary spikes in the signal.
If no ethernet cable is plugged in, and if WiFi is properly configured, a
connection will be made to the WiFi network; the setting in the WiFi configuration
file is ignored.
If an ethernet cable is plugged in, and the end-user wants a dual network
connection over a WiFi network, then WiFi must be properly configured and the
setting in the WiFi configuration file must be set to ON (see below).
Per #3, if you wish to enable both WiFi and Ethernet interfaces, changing the
configuration file at /opt/settings/user/enable-wifi.conf will allow you to do so.
By default this file contains the following lines:
OFF
Edit this file
$ sudo reboot
How can I set up a USB Wifi Dongle
First you’ll need to verify if your USB was tested on Raspberry Pi computer (RPi):
https://elinux.org/RPi_USB_Wi-Fi_Adapters
Then plug your USB Dongle into your RPi and see if the RPi recognizes the device.
For example,
$...
[Fri Aug 3 13:45:11 2018] usb 1-1.4: new high-speed USB device number 4 using
dwc_otg
[Fri Aug 3 13:45:11 2018] usb 1-1.4: New USB device found, idVendor=0bda,
idProduct=8176
[Fri Aug 3 13:45:11 2018] usb 1-1.4: New USB device strings: Mfr=1, Product=2,
SerialNumber=3
[Fri Aug 3 13:45:11 2018] usb 1-1.4: Manufacturer: Realtek
[Fri Aug 3 13:45:11 2018] usb 1-1.4: SerialNumber: 00e04c000001
[Fri Aug 3 13:45:12 2018] usbcore: registered new interface driver rtl8192cu
Now try this command and see if the RPi mounts the Dongle as wlan
$ iwconfig
eth0 no wireless extensions.
lo no wireless extensions.
The next step will be to adjust your config file to match your wifi parameters and
reboot your RPi.
$ iwconfig
lo no wireless extensions.
This defeats the purpose of using the USB WiFi, because the internal module will
generate radiofrequency noise that will affect the data, which is what we are
trying to avoid by using the dongle in the first place.
dtoverlay=pi3-disable-wifi
Add the internal module to the modprobe blacklist:
blacklist brcmfmac
blacklist brcmutil
Now, restart the Shake, run iwconfig, and check to make sure that only the wlan0
device appears.
How can I check if my USB Wifi Dongle sees the wifi networks
You can use the following command
$ network={
ssid="yourHiddenSSID"
scan_ssid=1
psk="Your_wifi_password"
}
================================================================================
AZARTICOLO:Connect the UART GPS Module u-blox NEO 6M on the Raspberry Pi 3 B - part
1
================================================================================
[22:18, 24/9/2021] angelo zinnai: FULVIO GUARDA CHE ARTICOLO FAVOLOSO, QUELLO CHE
VOLEVI TU
http://satsignal.eu/ntp/Raspberry-Pi-NTP.html
[22:18, 24/9/2021] angelo zinnai: MI PRUDONO LE MANI !
[22:27, 24/9/2021] angelo zinnai: UNITO CON QUESTO HAI FATTO BINGO
https://www.hackster.io/bhushanmapari/interfacing-u-blox-neo-6m-gps-module-with-
raspberry-pi-3d15a5
[22:41, 24/9/2021] angelo zinnai: GRANDE FELIPE
https://felipeogutierrez.blogspot.com/2018/08/connect-uart-gps-module-u-blox-neo-
6m.html
part 1 - Connect the UART GPS Module u-blox NEO 6M on the Raspberry Pi 3 B
part 2 - Publishing gps data from Raspberry Pi to an IoT gateway (ThingsBoard)
part 3 - Using gpsd library to retrieve data from Raspberry Pi in Java
part 4 - Using gpsd library to retrieve data from Raspberry Pi in C
Raspberry Pi uses the GPIO pins to communicate with other devices. These pins work
over 3 different protocols (e.g.: I2C, SPI, and UART). This post describes how to
connect a GPS device based on the UART protocol to a Raspberry Pi B 3.
1. Hardware requirements
-------------------------------------
By default, the UART transmit and receive pins are on GPIO 14 and GPIO 15
respectively, which are pins 8 and 10 on the GPIO header.
Gps module VCC to Raspberry Pi Pin 1 (3.3V)
Gps module GND to Raspberry Pi Pin 6 (Gnd)
Gps module RX to Raspberry Pi Pin 8, which is TX (GPIO14)
Gps module TC to Raspberry Pi Pin 10, which is RX (GPIO15)
You may find other links requesting you to connect the VCC pin from the gps module
to the Pin 2 or 4 on you raspberry Pi (5.0 volts). I didn’t test it because the
original documentation of the gps module says it uses only 3.3v [3]. So I recommend
you to not use 5v.
2. Software requirements
----------------------------------
Update the Raspberry Pi OS and install the clients.
I am using Raspbian GNU/Linux 9 (stretch) and I didn’t test with other versions.
You will need to disable the gpsd systemd service by running the following
commands:
sudo raspi-config
Go to [5] interfaces option > Find serial [P6] > Select it and turn off
Would you like a login shell to be accessible over serial? > Select NO
Would you like the serial port hardware to be enable > Select YES
The serial login shell is disabled
The serial interface is enabled > OK > Finish > Reboot
If you need visual help on this section use this link [8].
1
cp /boot/cmdline.txt /boot/cmdline.txt.bkp
After removing the string the file “/boot/cmdline.txt” will contain only this
content.
Through the last command you already can see that the /dev/serial0 port is
listening values. So now we just start the GPSD on that serial port.
The original site [7] documentation says the module can take up to 30 minutes to
receive data when it is running for the first time. The red light will blink when
the module is receiving data. You can already start the gpsmon interface to see if
it is receiving data or the cgps -s.
https://felipeogutierrez.blogspot.com/2018/08/connect-uart-gps-module-u-blox-neo-
6m.html
You can use the "cgps" command to show this client interface of the gps or emit the
values on
your terminal using the "gpspipe -r -p -P -n 10" command line.
=================================================================================
AZARTICOLO:Publishing gps data from Raspberry Pi to an IoT gateway (ThingsBoard) -
part 2
================================================================================
part 1 - Connect the UART GPS Module u-blox NEO 6M on the Raspberry Pi 3 B
part 2 - Publishing gps data from Raspberry Pi to an IoT gateway (ThingsBoard)
part 3 - Using gpsd library to retrieve data from Raspberry Pi in Java
part 4 - Using gpsd library to retrieve data from Raspberry Pi in C
This is a use case to publish data from a GPS sensor at an IoT gateway. The GPS
sensor is connected to a Raspberry Pi B3. The IoT gateway is used as a graphical
interface to the latitude and longitude. The Raspberry Pi B3 sends data through
MQTT protocol using a publish and subscriber policy. The IoT gateway used is an
open-source software called ThingsBoard.
To start the use case you can implement the static mode of publishing data to the
IoT gateway. You will need only 3 files. Two of them comprise the data to publish
and the third is the script which uses MQTT client. The online reference is from
the original ThingsBoard website.
{"firmware_version":"1.0.1", "serial_number":"SENSE2"}
This is the mosquitto.sh file which sends the Json data to the ThingsBoard IoT
gateway.
#!/bin/sh
However, as you can see in the previous post we already have real and dynamic data
been generated by a neo 6 M GPS sensor. What we have to build now is a scheduler
which reads the gps data from the Raspberry Pi and sends it to the IoT gateway. We
also are going to use MQTT protocol to send data but now using the Eclipse Paho
library. The Eclipse Paho project provides open-source client implementations of
MQTT and MQTT-SN messaging protocols aimed at new, existing, and emerging
applications for the Internet of Things (IoT).
Here is how the Mqtt client looks like. We have the methods connect, publish, and
disconnect. The connect method needs a client Id, the token of the device where we
desire to publish the message, the name of the device, the IP of the device (it
uses TCP connection and port 1883), and some kind of persistence. For now we are
using memory persistence. This is the link for the source code.
package org.cloud.sense.client;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.eclipse.paho.client.mqttv3.*;
import org.eclipse.paho.client.mqttv3.persist.MemoryPersistence;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.nio.charset.StandardCharsets;
@Slf4j
public class MqttClient {
@Getter
private final String deviceToken;
@Getter
private final String deviceName;
@Getter
private final String clientId;
private final MqttClientPersistence persistence;
private final MqttAsyncClient client;
@Override
public void onFailure(IMqttToken iMqttToken, Throwable e) {
log.error("[{}] failed to connect to Thingsboard!", deviceName,
e);
}
}).waitForCompletion();
} catch (MqttException e) {
log.error("Failed to connect to the server", e);
}
return client.isConnected();
}
@Override
public void onFailure(IMqttToken asyncActionToken, Throwable exception)
{
log.error("[{}] Data update failed!", deviceName, exception);
}
});
if (sync) {
deliveryToken.waitForCompletion();
}
}
}
Additionally, we also need the scheduler to read the gps data from the Raspberry
Pi.
We use the command line "gpspipe -r -n 50" to collect the gps data and take the
average of it.
This schedule only run 10 times, just for test porpuses. The link for the source
code can be found here.
package org.cloud.sense.device;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Getter;
import org.cloud.sense.client.MqttClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
public GpsPublish() {
}
try {
while ((line = input.readLine()) != null) {
// log.info(line);
if (line != null && line.contains("GPGGA")) {
log.info(line);
String[] arr = line.split(",");
log.info(arr[2] + " - " + arr[4]);
latitudes.add(Double.parseDouble(arr[2]));
longitudes.add(Double.parseDouble(arr[4]));
} else if (line != null && line.contains("GPRMC")) {
log.info(line);
String[] arr = line.split(",");
log.info(arr[3] + " - " + arr[5]);
latitudes.add(Double.parseDouble(arr[3]));
longitudes.add(Double.parseDouble(arr[5]));
}
}
} catch (IOException e) {
e.printStackTrace();
}
}
}).start();
p.waitFor();
} catch (IOException e) {
e.printStackTrace();
} catch (InterruptedException e) {
e.printStackTrace();
}
if (!latitudes.isEmpty() && !longitudes.isEmpty()) {
Double latitudeAvg = latitudes.stream().mapToDouble(i ->
i).average().getAsDouble();
Double longitudeAvg = longitudes.stream().mapToDouble(i ->
i).average().getAsDouble();
log.info(String.valueOf(latitudeAvg));
return coo;
}
log.error("No coordinates found.");
return new Coordinates(0, 0);
}
/**
* Convert Degree Minute Second (DMS) to coordinates (latitude and longitude)
* Degree +minutes /60+seconds /3600/10000
*
* @return
*/
public Coordinates convertDMSToCoordinate(String dmsLat, boolean dmsLatNorth,
String dmsLng, boolean dmsLngEast) {
================================================================================
AZARTICOLO:Using gpsd library to retrieve data from Raspberry Pi in Java - part 3
================================================================================
part 1 - Connect the UART GPS Module u-blox NEO 6M on the Raspberry Pi 3 B
part 2 - Publishing gps data from Raspberry Pi to an IoT gateway (ThingsBoard)
part 3 - Using gpsd library to retrieve data from Raspberry Pi in Java
part 4 - Using gpsd library to retrieve data from Raspberry Pi in C
It is possible to get the values from the gps sensor using the gpsd library.
According to the
documentation, you can build a client which connects direct to the host through the
port 2947.
This is the same approach that gpspipe, gpsmon, and cgps do. So, you can create a
client that
connects to the gpsd daemon service of the Raspberry Pi. The documentation explains
how to create client using C programming language and Python.
I show in this post a client implemented in Java which retrieves more relevant data
from the gpsd library.
The gpsd library retrieves data from the gps sensor according to some mode which
goes from 0 to 3.
package org.cloud.sense.device;
import com.codahale.metrics.ConsoleReporter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ivkos.gpsd4j.client.GpsdClient;
import com.ivkos.gpsd4j.client.GpsdClientOptions;
import com.ivkos.gpsd4j.messages.DeviceMessage;
import com.ivkos.gpsd4j.messages.enums.NMEAMode;
import com.ivkos.gpsd4j.messages.reports.SKYReport;
import com.ivkos.gpsd4j.messages.reports.TPVReport;
import lombok.Getter;
import org.cloud.sense.client.MqttClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.concurrent.TimeUnit;
public GpsPublishIvkos() {
}
public void publishGpsData(Double lat, Double lng, Double alt, Double speed,
LocalDateTime t) {
try {
String value = "{";
if (NMEAMode.TwoDimensional.equals(tpv.getMode()) ||
NMEAMode.ThreeDimensional.equals(tpv.getMode())) {
publishGpsData(lat, lon, altitude, speed, t);
} else {
log.info("GPS data not available");
}
})
.addHandler(SKYReport.class, sky -> {
log.info("We can see [{}] satellites",
sky.getSatellites().size());
publishSatelliteData(sky.getSatellites().size());
});
gpsClient.setSuccessfulConnectionHandler(client -> {
DeviceMessage device = new DeviceMessage();
device.setPath("/dev/serial0");
device.setNative(true);
} catch (InterruptedException e) {
log.error("Could not receive data from GPS sensor. Reason: [{}]",
e.getMessage());
e.printStackTrace();
} catch (Exception e) {
log.error("Could not Publish GPS data: [{}]", e.getMessage());
e.printStackTrace();
}
}
In order to improve the use case of part 2 I have add more gadgets monitors on the
ThingsBoard dashboard. Besides the map, you can see the altitude and speed of the
gps sensor. The first chart depicts how many satellites the gps sensor is receiving
data.
=================================================================================
AZARTICOLO:Using gpsd library to retrieve data from Raspberry Pi in C - part 4
================================================================================
part 1 - Connect the UART GPS Module u-blox NEO 6M on the Raspberry Pi 3 B
part 2 - Publishing gps data from Raspberry Pi to an IoT gateway (ThingsBoard)
part 3 - Using gpsd library to retrieve data from Raspberry Pi in Java
part 4 - Using gpsd library to retrieve data from Raspberry Pi in C
In this post, I show a piece of code written in C which uses the gpsd library to
connect to a GPS device. I connected the GPS device to a Raspberry Pi B 3 through
the UART port (Universal asynchronous receiver-transmitter). This port uses only 2
pins of the Raspberry Pi. The table below you can see the comparison of the three
protocols available at a Raspberry Pi (e.g.: I2C, SPI, and UART).
===================================================================================
Summarizing the code, it uses mainly three functions of the library. gps_open to
open a connection to the sensor. gps_stream to subscribe to a channel of the
library which gives a stream of GPS data. gps_waiting blocks the thread until the
gps device sends new data, which comes in about 1 second. gps_read to read the
data. The github repository of this code is here.
/*
* gpsClient.h
*
* Created on: Aug 24, 2018
* Author: felipe
*/
#ifndef GPS_GPSCLIENT_H_
#define GPS_GPSCLIENT_H_
int runGpsStreamClient();
#endif /* GPS_GPSCLIENT_H_ */
/*
* gpsClient.c
*
* command line to compile the source code
* # gcc -o gpsClient gpsClient.cpp -lm -lgps
*
* Created on: Aug 22, 2018
* Author: felipe
*/
#include <gps.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <sys/time.h>
#include "gpsClient.h"
#include "../utils/metrics.h"
int runGpsStreamClient() {
int rc;
int count = 0;
clock_t cpu_start;
struct timeval user_start;
struct gps_data_t gps_data;
gettimeofday(&user_start, NULL);
cpu_start = clock();
if ((rc = gps_open("localhost", "2947", &gps_data)) == -1) {
printf("code: %d, reason: %s\n", rc, gps_errstr(rc));
return EXIT_FAILURE;
}
get_cpu_and_user_time(cpu_start, user_start, "gps_open");
gettimeofday(&user_start, NULL);
cpu_start = clock();
gps_stream(&gps_data, WATCH_ENABLE | WATCH_JSON, NULL);
get_cpu_and_user_time(cpu_start, user_start, "gps_stream");
gettimeofday(&user_start, NULL);
cpu_start = clock();
/* wait for 2 second to receive data */
if (gps_waiting(&gps_data, 20000000)) {
get_cpu_and_user_time(cpu_start, user_start, "gps_waiting");
gettimeofday(&user_start, NULL);
cpu_start = clock();
int rc = gps_read(&gps_data);
get_cpu_and_user_time(cpu_start, user_start, "gps_read");
/* read data */
if (rc == -1) {
printf(
"error occurred reading gps data. code: %d, reason: %s\n",
rc, gps_errstr(rc));
} else {
/**
* MODE_NOT_SEEN 0 mode update not seen yet
* MODE_NO_FIX 1 none
* MODE_2D 2 good for latitude/longitude
* MODE_3D 3 good for altitude/climb too
*/
if ((status == STATUS_FIX)
&& (mode == MODE_2D || mode == MODE_3D)
&& !isnan(lat) && !isnan(lon)) {
printf("GPS data OK - ");
printf("status[%d], ", status);
printf("mode[%d], ", mode);
printf("latitude[%f], ", lat);
printf("longitude[%f], ", lon);
printf("altitude[%f], ", alt);
printf("speed[%f], ", speed);
printf("v speed[%f]\n", climb);
print_time(seconds);
print_current_time();
printf("\n");
} else {
printf("GPS data NOK.\n");
}
}
} else {
get_cpu_and_user_time(cpu_start, user_start, "gps_waiting");
printf(
"counter[%d]. Timeout to retrieve data from gpsd. Maybe increase gps_waiting.\
n",
count);
}
count++;
// sleep(1);
}
return EXIT_SUCCESS;
}
The piece of code below just shows how to retrieve the time difference of the CPU
and user on the Operating System.
/*
* metrics.h
*
* Created on: Aug 27, 2018
* Author: felipe
*/
#ifndef UTILS_METRICS_H_
#define UTILS_METRICS_H_
#endif /* UTILS_METRICS_H_ */
/*
* metrics.c
*
* Created on: Aug 27, 2018
* Author: felipe
*/
#include <stdio.h>
#include <unistd.h>
#include <time.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <math.h>
#include "metrics.h"
void print_current_time() {
char buffer[100];
int millisec;
struct tm* tm_info;
struct timeval tv;
gettimeofday(&tv, NULL);
tm_info = localtime(&tv.tv_sec);
clock_gettime(CLOCK_REALTIME, &spec);
ms = round(spec.tv_nsec / 1.0e6); // Convert nanoseconds to milliseconds
if (ms > 999) {
ms = 0;
}
The table below shows the comparison between the C and Java code in milliseconds.
Afterward, I show the measurement of the C code. The gpsd library collects raw data
from the gps sensor and emits it every second. If you want to reduce the time of
this publishing mechanism you have to change the baud rate configured at part 1 of
these posts. However, the vendors do not advise for that because it can lead to
precision errors on the measurements. Considering that, the waiting time the
listener receives new data from the gpsd library is pretty good (~1000
milliseconds). The only bottleneck is to connect to the gpsd library, which is 3
milliseconds with C code and ~2480 milliseconds using Java code.
References
Posted by Felipe
Enviar por e-mail
Postar no blog!
Compartilhar no Twitter
Compartilhar no Facebook
Compartilhar com o Pinterest
Labels: C, gps, gpsd, IoT, Raspberry Pi, sensors
Location: Berlin, Germany
Nenhum comentário:
Postar um comentário
================================================================================
AZARTICOLO:Navigation with navit on RaspberryPi
================================================================================
https://github.com/navit-gps/raspbian-ua-netinst
https://github.com/navit-gps/navit peodotto completo incluso Android
http://libresmartphone.com/navigation-system-with-the-ultimate-gps-and-raspberry-
pi/
I've tested it and it works pretty cool, this is why I finally documented it here.
Prerequisites
------------------
The gpsd is the daemon which is connected by navit to get the current position.
Preparation
----------------
Installation of navit
--------------------------
But if you want to get an up-to-date version, you can easily build it on
your own, by just grabbing a copy of the current version from the subversion
repository (as also recommend by the team!) an compile it on your own:
svn co https://navit.svn.sourceforge.net/svnroot/navit/trunk/navit/
navit_repository
cd navit_repository
mkdir build
cd build
cmake ..
make
The “make” takes about 30 minutes on the Raspberry Pi an then you are
done so far. Finally just copy the folder with the build-result to a destination
of your choice, which can be found now in “~/navit_repository/build/navit”.
I copied mine to pi's home, so mine can be accessed now by going to:
cd ~/navit
If you have a look in the final build result, the folder should look somehow
like this one:
Before starting the first time, a map of the current GPS region is needed,
so that there is something to see at the current GPS-position.
The big advantage here is, that maps from the open street map project
can be taken. The part of the map can easily be chosen as required,
which is really cool! That gives a high flexibility in regards of the size of
the used SD-card and the region I'm interested in.
To grab a map, just use the offered navit service Navit Planet Extractor.
Just mark a region and save the binary mapfile of the marked region on
the RaspberryPi. In this example is a region chosen, covering the south of
Danmark and the north of Germany (that's currently enough for me,
but I could also choose the world, which has a size of 15GB today).
Size of my chosen map is 356MB, which is pretty small in size for such a
big area with really(!) up-to-date map data right from yesterday!
pi@gpsraspberrypi ~ $ ls -alh --color=auto ~/navit/maps/insgesamt 360M
Find the section with “<map type=“binfile” […]” and modify to your needs:
Set all other mapsets to “no”, to ensure, that only the new OSM-map is loaded an
used:
<mapset enabled="no">
[...]
That's it :-).
Run navit
--------------
If all former steps are done, navit could be started.
There are two options, one is running on local X-session and another is by
using the ssh connection from another linux (or system running an X-server).
Just connect the RaspberryPi with ssh by forwarding X (param -X) and
skipping forwarding to X11 SECURITY extension controls (param -Y):
ssh -X -Y [email protected]
cd navit
./navit
==============================================================
AZARTICOLO:Navigating with Navit on the Raspberry Pi
==============================================================
Mark Williams
A Raspberry PI 3
The official Raspberry Pi Display
BerryGPS-IMU
SmartPi Touch
Navit can be installed without a GPS connected to your Raspberry Pi, but you will
not be able to
use the real-time turn by turn navigation. You will however be able to browse maps.
If you are
not going to use a GPS, you can skip to the next step.
As we are using the BerryGPS-IMU, we will be following the guide in the link below.
As most GPS modules use serial to communication, this guide can be followed for
other GPS modules.
The images below shows how we have connected the BerryGPS-IMU to the Raspberry Pi 3
whilst it is in the SmartPi Touch case.
If you plan on testing this out in your car, you need to be mindfully of where you
place your BerryGPS. In my setup and I have placed it in the air vent as shown
below, and BerryGPS gets a good strong signal.
Raspberry Pi GPS
If you are using an external antenna, then there is no need to worry about where
your BerryGPS is placed.
navit-gif
Navit
Install Navit;
pi@raspberrypi ~/ $ apt-get install navit espeak
We will copy the default Navit config folder under the home directory.
pi@raspberrypi ~/navit-build $ mkdir ~/.navit
pi@raspberrypi ~/navit-build $ cp /etc/navit/navit.xml .navit/navit.xml
Download Maps
Navit can use Garmin or OpenStreetMaps(OSM). In this guide we are using OSM.
The Navit config file needs to be edited to include the new map. While we are there
we will also disable the sample map that came with the source.
pi@raspberrypi ~/ $ vi ~/.navit/navit.xml
<!-- If you dont want to use the sample map, either set enabled="no" in the next
line or remove the xml file from the maps directory -->
<mapset enabled="yes">
<xi:include href="$NAVIT_SHAREDIR/maps/*.xml"/>
</mapset>
<!-- If you dont want to use the sample map, either set enabled="no" in the next
line or remove the xml file from the maps directory -->
<mapset enabled="no">
<xi:include href="$NAVIT_SHAREDIR/maps/*.xml"/>
</mapset>
And set it to enabled and specify the location of the bin file which was just
downloaded. And set enabled to yes.
<speech type="cmdline" data="echo 'Fix the speech tag in navit.xml to let navit
say:' '%s'" cps="15"/>
The default locale is set to United Kingdom/English. Which means that the default
country when searching for an address will be United Kingdom.
If you are not in the United Kingdom, then it is best to change this.
In navit.xml, look for
<config xmlns:xi="http://www.w3.org/2001/XInclude">
As I am in Australia, I have set it to en_AU. Now when I search for an address the
default country is Australia.
and change it to
When using Navit in navigation mode, we want the screen to update as the vehicle
moves.
By default, the screen will only update once the vehicle reaches the edge of the
screen.
and change it to
Customise Navit
-------------
With the default config file, Navit is hard to use with a touchscreen, an example
of this is
in the screenshot with Munich above.
navit0
If you are using a 3.5″ TFT, like PiScreen or PiTFT, download this config file or
use wget;
pi@raspberrypi ~/ $ wget ozzmaker.com/downloads/navit-OSD-480-320.txt
Extract the icons from the zip file into the directory where Navit stores icon
images;
pi@raspberrypi ~/ $ unzip navit_icons.zip -d /usr/share/navit/icons/
No we will added the config from the downloaded text file to the Navit config file.
Open the config file;
pi@raspberrypi ~/ $ vi ~/.navit/navit.xml
The next time you start Navit, it should look as shown in the above screenshot.
Other Useful Navit Modifications
Width & Height
To specify the width and height of the Navit window, look for this
<graphics type="gtk_drawing_area"/>
=================================================================================
https://github.com/lucadentella/raspberry-dgc.git
=================================================================================
Installation floppy_disk
sudo raspi-config
cd validatorServer
npm install
cd validatorServer
node app.js
cd cameraClient
python3 cameraClient.py
--------------------------------------------------------------------------------
USB Auto mount - Raspbian Stretch Lite [Solved]
--------------------------------------------------------------------------------
Hi all,
The ultimate goal is to have any USB drive to auto-mounting when plugged into the
Raspberry PI 2.
If it is not possible to achieve this for all drives, then as a worst case scenario
I would be ok to
auto-mount specific HDDs by specifying their UUIDs.
I have been looking into this for hours, but I could not find a solid and simple
solution online.
I would truly appreciate if someone could please post a working solution in here.
Moreover, below you can see the output of my sudo blkid.
In this case I want the USB hdd assigned to /dev/sda1 tblk0: PTUUID="896c5641"
PTTYPE="dos"
/dev/sda1: UUID="93ddc2e0-48e1-457c-9d59-f6a34596e6e1" TYPE="ext4" PARTLABEL="SSD-
120GB" PARTUUID="9eea6391-2399-4983-889c-d5a651c73952"
PS I find it very inconvenient that such functionality is not built into Raspbian
out of the box for the
Command Line environment (I know that auto-mount works when in desktop
environment).
Thank you!
man fstab
man mount
then
Code: Select all
cat /etc/fstab
The above method won't automount if you hot plug a drive but the easy way around
that is either
Code: Select all
sudo mount -a
It might be possible to mount a hot plugged drive with systemd and/or udev but I'
don't know enough to help you with that. Disconnecting a USB drive without first
unmounting it is definitely not a good idea.
Edit:
A quick google for "udev mount" returned this:
https://www.axllent.org/docs/view/auto- ... b-storage/ No idea if it actually wokrs
though.
I'm a volunteer. Take me for granted or abuse my support and I will walk away
All advice given is based on my experience. it worked for me, it may not work for
you.
Need help? https://github.com/thagrol/Guides
reinis
Posts: 5
Joined: Fri Mar 11, 2016 12:34 pm
Re: USB HDD Auto Mount - Raspbian Stretch
Sat Feb 10, 2018 6:45 am
Thanks a lot for the input. The problem is that I tried fstab 10x times but it did
not work for me. I tried it with UUID and LABEL - still would not mount the drive
on boot. It returns exit code error 32. A quick google search show why - it seems
that raspberry pi 2 simply does not manage to detect the usb drive before fstab is
executed. You can read about it [ur=viewtopic.php?f=28&t=99491l]here[/url] and
here.
The good news is that I found a very simple alternative (at least in terms of
installation, not sure about how "native" the solution is) - a package called
usbmount. I can confirm that with usbmount I can auto-mount on boot and hot-plug
any USB device in Raspbian Stretch Lite on my Raspberry Pi 2!
Best,
Reinis
spectre-nz
Posts: 2
Joined: Sat Nov 25, 2017 9:43 am
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Sat Apr 07, 2018 4:22 am
Great thanks!
Worked for me on a Pi 3 Model B+ after it stopped recognising USB drives.
yuvarajoo
Posts: 2
Joined: Sat Apr 28, 2018 12:35 pm
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Sun Apr 29, 2018 6:22 am
The problem with using fstab is it won't boot if the drive is not plugged in first.
The system gets stuck looking for it.
donbrew wrote: ↑
Sun Jun 17, 2018 8:56 pm
The problem with using fstab is it won't boot if the drive is not plugged in first.
The system gets stuck looking for it.
There's an easy fix for that: add "nofail" to the mount options in your fstab
entry.
I'm a volunteer. Take me for granted or abuse my support and I will walk away
All advice given is based on my experience. it worked for me, it may not work for
you.
Need help? https://github.com/thagrol/Guides
DaveL17
Posts: 1
Joined: Sat Jan 26, 2019 7:44 pm
Re: USB HDD Auto Mount - Raspbian Stretch
Sat Jan 26, 2019 7:50 pm
thagrol wrote: ↑
Sat Feb 10, 2018 12:11 am
[*]Backup your existing /etc/fstab e.g.:
Code: Select all
Cheers,
Dave
lekso
Posts: 1
Joined: Wed Mar 20, 2019 11:20 pm
Re: USB HDD Auto Mount - Raspbian Stretch
Wed Mar 20, 2019 11:29 pm
reinis wrote: ↑
Sat Feb 10, 2018 6:45 am
Thanks a lot for the input. The problem is that I tried fstab 10x times but it did
not work for me. I tried it with UUID and LABEL - still would not mount the drive
on boot. It returns exit code error 32. A quick google search show why - it seems
that raspberry pi 2 simply does not manage to detect the usb drive before fstab is
executed. You can read about it [ur=viewtopic.php?f=28&t=99491l]here[/url] and
here.
The good news is that I found a very simple alternative (at least in terms of
installation, not sure about how "native" the solution is) - a package called
usbmount. I can confirm that with usbmount I can auto-mount on boot and hot-plug
any USB device in Raspbian Stretch Lite on my Raspberry Pi 2!
Best,
Reinis
This solution not only solved my usb self-loading issues, but also the automatic
start of my VNC server. Thank you!
Oh!Lee
Posts: 14
Joined: Fri Jun 10, 2016 8:58 am
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Thu Mar 21, 2019 9:17 am
spectre-nz wrote: ↑
Sat Apr 07, 2018 4:22 am
Great thanks!
Worked for me on a Pi 3 Model B+ after it stopped recognising USB drives.
Does NOT work for me on my Pi 3 Model B+ :?
followed the instructions, but when I want to copy a file
the error occurs "cp: cannot create regular file '/media/usb/test.bla': Permission
denied".
Any idea?
Oh!Lee
Posts: 14
Joined: Fri Jun 10, 2016 8:58 am
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Fri Mar 22, 2019 1:26 pm
Problem indentified:
On my systemin /etc/usbmount/usbmount.conf the variable FS_MOUNTOPTIONS was not
set.
I changed it to
FS_MOUNTOPTIONS="-fstype=vfat,gid=users,dmask=0007,fmask=0117"
and it works perfectly now!
Beric_
Posts: 10
Joined: Mon May 29, 2017 7:14 am
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Thu Jun 13, 2019 7:54 am
Hello,
Im having the same problem. I just install a new image of Raspian Strech. These are
the steps that I followed:
Code: Select all
MountFlags=slave to MountFlags=shared
In this point, doesnt work. I followed the instructions of this post and try this:
Code: Select all
FS_MOUNTOPTIONS="-fstype=vfat,gid=users,dmask=0007,fmask=0117"
And This
Code: Select all
FS_MOUNTOPTIONS="-fstype=auto,gid=users,dmask=0007,fmask=0117"
How can i active debug to usbmount ? Is there another log hat can help me?
Best regards !
User avatarthagrol
Posts: 6363
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Thu Jun 13, 2019 11:12 am
Beric_ wrote: ↑
Thu Jun 13, 2019 7:54 am
Code: Select all
All advice given is based on my experience. it worked for me, it may not work for
you.
Need help? https://github.com/thagrol/Guides
Beric_
Posts: 10
Joined: Mon May 29, 2017 7:14 am
Re: USB Auto mount - Raspbian Stretch Lite [Solved]
Thu Jun 13, 2019 11:30 am
================================================================================
AZARTICOLO:GUIDA RASPBERRY
================================================================================
Computers
Getting started
Raspberry Pi OS
Configuration
The config.txt file
The Linux kernel
Remote access
Introduction to Remote Access
How to Find your IP Address
Setting up an SSH Server
Set up your Local Network
Enabling the Server
Secure Shell from Linux or Mac OS
Secure Shell from Windows 10
Passwordless SSH Access
Checking for Existing SSH Keys
Generate new SSH Keys
Copy your Key to your Raspberry Pi
Adjust Directory Permissions
Using Secure Copy
Copying Files to your Raspberry Pi
Copying Files from your Raspberry Pi
Copying Multiple Files
Copying a Whole Directory
Using rsync
Network File System (NFS)
Setting up a Basic NFS Server
Configuring an NFS Client
A More Complex NFS Server
Troubleshooting
Samba (SMB/CIFS)
Installing Samba Support
Mount a Folder Shared from Windows
Sharing a Folder from your Raspberry Pi
Virtual Network Computing (VNC)
Installing VNC on Raspberry Pi
Enabling the VNC Server
Connecting to your Raspberry Pi
Using Directly Rendered Applications
Creating a Virtual Desktop
Setting up an Apache Web Server
Installing Apache
Test the Web Server
Installing PHP for Apache
Network boot your Raspberry Pi
Client Configuration
Ethernet MAC address
Server Configuration
Using pxetools
Network booting using IPv6
How it works
Test Setup
Debugging
Camera software
Raspberry Pi hardware
Compute Module hardware
Processors
Remote access
NOTE
If you are using a display with your Raspberry Pi and if you boot to the command
line instead of
the desktop, your IP address should be shown in the last few messages before the
login prompt.
Otherwise open a Terminal window and type
hostname -I
Browse to the list of connected devices or similar (all routers are different), and
you should see
some devices you recognise. Some devices are detected as PCs, tablets, phones,
printers, etc.
so you should recognise some and rule them out to figure out which is your
Raspberry Pi.
Also note the connection type; if your Raspberry Pi is connected with a wire there
should be
fewer devices to choose from.
If your device supports mDNS, you can reach your Raspberry Pi by using its hostname
and the
.local suffix. The default hostname on a fresh Raspberry Pi OS install is
raspberrypi,
so by default any Raspberry Pi running Raspberry Pi OS responds to:
ping raspberrypi.local
If the Raspberry Pi is reachable, ping will show its IP address:
PING raspberrypi.local (192.168.1.131): 56 data bytes
64 bytes from 192.168.1.131: icmp_seq=0 ttl=255 time=2.618 ms
If you don’t remember the hostname of the Raspberry Pi, but have a system with
Avahi installed,
you can browse all the hosts and services on the LAN with the avahi-browse command.
nmap command
The nmap command (Network Mapper) is a free and open-source tool for network
discovery,
available for Linux, macOS, and Windows.
To install on Linux, install the nmap package e.g. apt install nmap.
To use nmap to scan the devices on your network, you need to know the subnet you
are connected to.
First find your own IP address, in other words the one of the computer you’re using
to find your
Raspberry Pi’s IP address:
On macOS, go to System Preferences then Network and select your active network
connection
to view the IP address
On Windows, go to the Control Panel, then under Network and Sharing Center, click
View
network connections, select your active network connection and click View status of
this
connection to view the IP address
Now you have the IP address of your computer, you will scan the whole subnet for
other devices.
For example, if your IP address is 192.168.1.5, other devices will be at addresses
like 192.168.1.2,
192.168.1.3, 192.168.1.4, etc. The notation of this subnet range is 192.168.1.0/24
(this covers 192.168.1.0 to 192.168.1.255).
Now use the nmap command with the -sn flag (ping scan) on the whole subnet range.
This may take a few seconds:
Here you can see a device with hostname raspberrypi has IP address 192.168.1.8.
Note, to see the hostnames, you must run nmap as root by prepending sudo to the
command.
fd00::ba27:ebff:feb6:f293 2001:db8:494:9d01:ba27:ebff:feb6:f293
The example shows two IP addresses. The first one is a so called unique local
unicast address(fc00::/7). The second one is the global unicast address(2000::/3).
It is also possible to see only one of them depending on your network (router)
configuration. Both addresses are valid for reaching the Raspberry Pi within your
LAN. The address out of 2000::/3 is accessible world wide, provided your router’s
firewall is opened.
Now use one of IPs from the first step to ping all local nodes:
-I with the IP address, it sets the interface and the source address of the echo
request, it is necessary to choose the interface’s IP address, eth0 isn’t
sufficient - the answer would be the local link address(fe80::/10), we need the
global or local unicast address
ff02::1 is a well known multicast address for all nodes on the link, so it behaves
like a local broadcast,
usually it is defined in /etc/hosts so you can also use the name (ip6-allnodes or
ipv6-allnodes)
instead of the literal address
Some newer systems expect the interface ID behind the multicast address.
ssh pi@2001:db8:494:9d01:dea6:32ff:fe23:6be1
The authenticity of host '2001:db8:494:9d01:dea6:32ff:fe23:6be1
(2001:db8:494:9d01:dea6:32ff:fe23:6be1)' can't be established.
ECDSA key fingerprint is SHA256:DAW68oen42TdWDyrOycDZ1+y5ZV5D81kaVoi5FnpvoM.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '2001:db8:494:9d01:dea6:32ff:fe23:6be1' (ECDSA) to the
list of known hosts.
pi@2001:db8:494:9d01:dea6:32ff:fe23:6be1's password:
Linux raspberrypi4 4.19.75-v7l+ #1270 SMP Tue Sep 24 18:51:41 BST 2019 armv7l
...
pi@raspberrypi4:~ $
The Fing app is a free network scanner for smartphones. It is available for Android
and iOS.
Your phone and your Raspberry Pi have to be on the same network, so connect your
phone to
the correct wireless network.
When you open the Fing app, touch the refresh button in the upper right-hand corner
of the screen.
After a few seconds you will get a list with all the devices connected to your
network.
Scroll down to the entry with the manufacturer "Raspberry Pi".
You will see the IP address in the bottom left-hand corner, and the MAC address in
the bottom
right-hand corner of the entry.
Network File System (NFS) allows you to share a directory located on one networked
computer with other computers or devices on the same network. The computer where
the directory is located is called the server, and computers or devices connecting
to that server are called clients. Clients usually mount the shared directory to
make it a part of their own directory structure. The shared directory is an example
of a shared resource or network share.
For smaller networks, an NFS is perfect for creating a simple NAS (Network-attached
storage) in a Linux/Unix environment.
Suppose we want to export our users' home directories, which are in /home/users.
First we create the export filesystem:
/etc/default/nfs-kernel-server
/etc/default/nfs-common
/etc/exports
[Mapping]
Nobody-User = nobody
Nobody-Group = nogroup
However, note that the client may have different requirements for the Nobody-User
and Nobody-Group. For example, on RedHat variants, it is nfsnobody for both. If
you’re not sure, check via the following commands to see if nobody and nogroup are
there:
cat /etc/passwd
cat /etc/group
This way, server and client do not need the users to share same UID/GUID. For those
who use LDAP-based authentication, add the following lines to the idmapd.conf of
your clients:
[Translation]
Method = nsswitch
This will cause idmapd to know to look at nsswitch.conf to determine where it
should look for credential information. If you have LDAP authentication already
working, nsswitch shouldn’t require further explanation.
/export 192.168.1.0/24(rw,fsid=0,insecure,no_subtree_check,async)
/export/users 192.168.1.0/24(rw,nohide,insecure,no_subtree_check,async)
Portmap lockdown (optional)
The files on your NFS are open to anyone on the network. As a security measure, you
can restrict access to specified clients.
Please ensure that the list of authorised IP addresses includes the localhost
address (127.0.0.1), as the startup scripts in recent versions of Ubuntu use the
rpcinfo command to discover NFSv3 support, and this will be disabled if localhost
is unable to connect.
rpcbind : ALL
By blocking all clients first, only clients in /etc/hosts.allow (added below) will
be allowed to access the server.
Use of LDAP
Use of DNS
Use of NIS
Note that you have to be careful on systems where the main user has root access:
that user can change UIDs on the system to allow themselves access to anyone’s
files. This page assumes that the administrative team is the only group with root
access and that they are all trusted. Anything else represents a more advanced
configuration, and will not be addressed here.
Group permissions
A user’s file access is determined by their membership of groups on the client, not
on the server. However, there is an important limitation: a maximum of 16 groups
are passed from the client to the server, and if a user is member of more than 16
groups on the client, some files or directories might be unexpectedly inaccessible.
/home @myclients(rw,sync,no_subtree_check)
/usr/local @myclients(rw,sync,no_subtree_check)
The example above shares /home and /usr/local to all clients in the myclients
netgroup.
/home 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check)
/usr/local 192.168.0.0/255.255.255.0(rw,sync,no_subtree_check)
Here, rw makes the share read/write, and sync requires the server to only reply to
requests once any changes have been flushed to disk. This is the safest option;
async is faster, but dangerous. It is strongly recommended that you read man
exports if you are considering other options.
Restart services
By default, rpcbind only binds to the loopback interface. To enable access to
rpcbind from remote machines, you need to change /etc/conf.d/rpcbind to get rid of
either -l or -i 127.0.0.1.
If any changes are made, rpcbind and NFS will need to be restarted:
IPSec works by encrypting traffic to the server with the server’s public key, and
the server sends back all replies encrypted with the client’s public key. The
traffic is decrypted with the respective private keys. If the client doesn’t have
the keys that it is supposed to have, it can’t send or receive data.
Troubleshooting
Mounting an NFS share inside an encrypted home directory will only work after you
are successfully logged in and your home is decrypted. This means that using
/etc/fstab to mount NFS shares on boot will not work, because your home has not
been decrypted at the time of mounting. There is a simple way around this using
symbolic links:
rmdir /home/user/Music
ln -s /nfs/music/ /home/user/Music
Samba (SMB/CIFS)
----------------------------
You can use Samba to mount a folder shared from a Windows machine so it appears on
your Raspberry Pi, or to share a folder from your Raspberry Pi so it can be
accessed by your Windows machine.
Turn on sharing
Open the Networking and Sharing Centre by right-clicking on the system tray and
selecting it
Save changes
Click on the Sharing tab, and then the Advanced Sharing button
Select Share this folder; by default, the share name is the name of the folder
For this example, select Everyone and Full Control (you can limit access to
specific users if required); click OK when done, then OK again to leave the
Advanced Sharing page
Click on the Security tab, as we now need to configure the same permissions
Select the same settings as the Permissions tab, adding the chosen user if
necessary
Click OK
Right-click and select New Share, which will start up the Sharing Wizard; click
Next
Select Custom and set the required permissions, and click OK, then Finish
mkdir windowshare
Now, we need to mount the remote folder to that location. The remote folder is the
host name or IP address of the Windows PC, and the share name used when sharing it.
We also need to provide the Windows username that will be used to access the remote
machine.
cd windowshare
ls
"Host is down" error
This error is caused by a combination of two things: A SMB protocol version
mismatch, and the CIFS client on Linux returning a misleading error message. In
order to fix this a version entry needs to be added to the mount command. By
default Raspberry Pi OS will only use versions 2.1 and above, which are compatible
with Windows 7 and later. Older devices, including some NAS, may require version
1.0:
Version Description
1.0
2.0
The SMBv2.002 protocol. Windows Vista Service Pack 1, and Windows Server 2008
2.1
3.0
3.02
The SMBv3.0.2 protocol. Microsoft Windows 8.1 and Windows Server 2012R2
3.11
3
The SMBv3.0 protocol version and above
cd ~
mkdir shared
chmod 0740 shared
Now we need to tell Samba that there is a pi user when accessing that folder. When
asked, enter the password of the pi user - this can be the default password, but
that is well known and should be changed for better security.
sudo smbpasswd -a pi
Now we need to tell Samba to share this folder, using the Samba configuration file.
[share]
path = /home/pi/shared
read only = no
public = yes
writable = yes
In the same file, find the workgroup line, and if necessary, change it to the name
of the workgroup of your local Windows network.
VNC is a graphical desktop sharing system that allows you to remotely control the
desktop interface
of one computer (running VNC Server) from another computer or mobile device
(running VNC Viewer).
VNC Viewer transmits the keyboard and either mouse or touch events to VNC Server,
and receives
updates to the screen in return.
You will see the desktop of the Raspberry Pi inside a window on your computer or
mobile device.
You’ll be able to control it as though you were working on the Raspberry Pi itself.
VNC Connect from RealVNC is included with Raspberry Pi OS. It consists of both VNC
Server,
which allows you to control your Raspberry Pi remotely, and VNC Viewer, which
allows you to
control desktop computers remotely from your Raspberry Pi should you want to.
You must enable VNC Server before you can use it.
By default, VNC Server gives you remote access to the graphical desktop that is
running on
your Raspberry Pi, as though you were sitting in front of it.
However, you can also use VNC Server to gain graphical remote access to your
Raspberry Pi
if it is headless or not running a graphical desktop. For more information on this,
see
Creating a virtual desktop, further below.
VNC is already installed on the full Raspberry Pi OS image, and can be installed
via Recommended
Software from the Preferences menu on other versions.
If you are not using a desktop you can install it from the command line as follows:
sudo raspi-config
Now, enable VNC Server by doing the following:
On your Raspberry Pi (using a terminal window or via SSH) use these instructions or
run ifconfig
to discover your private IP address.
You are entitled to use RealVNC’s cloud service for free, provided that remote
access is for
educational or non-commercial purposes only.
Sign up for a RealVNC account here: it’s free and it only takes a few seconds.
On your Raspberry Pi, sign in to VNC Server using your new RealVNC account
credentials:
On the device you’ll use to take control, download VNC Viewer. You must use the
compatible app from RealVNC.
Sign in to VNC Viewer using the same RealVNC account credentials, and then either
tap or click to connect to your Raspberry Pi:
If you’re connecting from the compatible VNC Viewer app from RealVNC, enter the
user name
and password you normally use to log in to your user account on the Raspberry Pi.
By default,
these credentials are pi and raspberry.
If you’re connecting from a non-RealVNC Viewer app, you’ll first need to downgrade
VNC Server’s
authentication scheme, specify a password unique to VNC Server, and then enter
that instead.
If you are in front of your Raspberry Pi and can see its screen, open the VNC
Server dialog on
your Raspberry Pi, select Menu › Options › Security, and choose VNC password from
the
Authentication dropdown.
Or if you’re configuring your Raspberry Pi remotely from the command line, then to
make the
changes for Service Mode (the default configuration for the Raspberry Pi):
On the device you’ll use to take control, run VNC Viewer and connect.
NOTE
Existing connections must be restarted in order for these changes to take effect.
Please note that direct screen capture is an experimental feature.
If you’re connecting from a desktop computer and mouse movements seem erratic,
try pressing F8 to open the VNC Viewer shortcut menu and selecting Relative Pointer
Motion.
VNC Server can create a virtual desktop for you, giving you graphical remote access
on demand.
This virtual desktop exists only in your Raspberry Pi’s memory:
On the device you’ll use to take control, enter this information into VNC Viewer.
On its own, Apache can serve HTML files over HTTP, and with additional modules can
serve dynamic web pages using scripting languages such as PHP.
Installing Apache
First, update the available packages by typing the following command into the
Terminal:
Browse to the default web page either on the Raspberry Pi or from another computer
on the network and you should see the following:
Navigate to this directory in a terminal window and have a look at what’s inside:
cd /var/www/html
ls -al
This will show you:
total 12
drwxr-xr-x 2 root root 4096 Jan 8 01:29 .
drwxr-xr-x 12 root root 4096 Jan 8 01:28 ..
-rw-r--r-- 1 root root 177 Jan 8 01:29 index.html
This shows that by default there is one file in /var/www/html/ called index.html
and it is owned by the root user (as is the enclosing folder). In order to edit the
file, you need to change its ownership to your own username. Change the owner of
the file (the default pi user is assumed here) using sudo chown pi: index.html.
You can now try editing this file and then refreshing the browser to see the web
page change. If you know HTML you can put your own HTML files and other assets in
this directory and serve them as a website on your local network.
sudo rm index.html
and create the file index.php:
You can set up a DHCP/TFTP server which will allow you to boot a Raspberry Pi 3 or
4 from the network.
The instructions assume that you have an existing home network, and that you want
to use a Raspberry Pi for the server. You will also need an additional Raspberry Pi
3 or 4 as a client to be booted. Only one SD Card is needed because the client will
be booted from the server after the initial client configuration.
NOTE
Due to the huge range of networking devices and routers available, we can’t
guarantee that network booting will work with any device. We have had reports that,
if you cannot get network booting to work, disabling STP frames on your network may
help.
Client Configuration
Raspberry Pi 3 Model B
NOTE
This section only applies to the Raspberry Pi 3 Model B, as network boot is enabled
on the Raspberry Pi 3 Model B+ at the factory.
Before the Raspberry Pi 3 Model B will network boot it needs to be booted from an
SD Card with a config option to enable USB boot mode. This will set a bit in the
OTP (One Time Programmable) memory in the Raspberry Pi SoC that enables network
booting. Once this is done, the Raspberry Pi 3B will attempt to boot from USB, and
from the network, if it cannot boot from the SD card.
The client configuration is almost done. The final thing to do is to remove the
program_usb_boot_mode line from config.txt. You can do this with sudo nano
/boot/config.txt, for example. Finally, shut the client Raspberry Pi down with sudo
poweroff.
Raspberry Pi 4 Model B
Network boot can be enabled on the Raspberry Pi 4 using the raspi-config tool.
First, run raspi-config as follows:
sudo raspi-config
Within raspi-config, choose Advanced Options, then Boot Order, then Network Boot.
You must then reboot the device for the change to the boot order to be programmed
into the bootloader EEPROM. Once the Raspberry Pi has rebooted, check that the boot
order is now 0xf21:
vcgencmd bootloader_config
For further details of configuring the Raspberry Pi 4 bootloader, see Raspberry Pi
4 Bootloader Configuration.
ethtool -P eth0
To find the serial number:
cd /nfs/client1
sudo mount --bind /dev dev
sudo mount --bind /sys sys
sudo mount --bind /proc proc
sudo chroot .
rm /etc/ssh/ssh_host_*
dpkg-reconfigure openssh-server
exit
sudo umount dev sys proc
Find the settings of your local network. You need to find the address of your
router (or gateway), which can be done with:
Finally, note down the address of your DNS server, which is the same address as
your gateway. You can find this with:
cat /etc/resolv.conf
Configure a static network address on your server Raspberry Pi via the systemd
networking, which works as the network handler and DHCP server.
[Match]
Name=eth0
[Network]
DHCP=no
Then create a network file:
[Match]
Name=eth0
[Network]
Address=10.42.0.211/24
DNS=10.42.0.1
[Route]
Gateway=10.42.0.1
At this point, you will not have working DNS, so you will need to add the server
you noted down before to systemd/resolved.conf. In this example, the gateway
address is 10.42.0.1.
[Resolve]
DNS=10.42.0.1
#FallbackDNS=
Enable systemd-networkd and then reboot for the changes to take effect:
# Note: comment out port if you want DNS services for systems on the network.
port=0
dhcp-range=10.42.0.255,proxy
log-dhcp
enable-tftp
tftp-root=/tftpboot
pxe-service=0,"Raspberry Pi Boot"
Where the first address of the dhcp-range line is, use the broadcast address you
noted down earlier.
tail -F /var/log/daemon.log
You should see something like this:
First, press CTRL + C to exit the monitoring state. Then type the following:
cp -r /boot/* /tftpboot
Since the tftp location has changed, restart dnsmasq:
At this point, export the /nfs/client1 file system created earlier, and the TFTP
boot folder.
Using pxetools
We have created a Python script that is used internally to quickly set up Raspberry
Pis that will network boot.
The script takes a serial number, which you can find in cat /proc/cpuinfo, an owner
name and the name of the Raspberry Pi. It then creates a root filesystem for that
Raspberry Pi from a Raspberry Pi OS image. There is also a --list option which will
print out the IP address of the Raspberry Pi, and a --remove option.
NOTE
The following instructions describe how to set up the environment required by the
script starting from a fresh Raspberry Pi OS lite image. It might be a good idea to
mount a hard disk or flash drive on /nfs so that your SD card isn’t providing
filesystems to multiple Raspberry Pis. This is left as an exercise for the reader.
sudo apt update
sudo apt full-upgrade -y
sudo reboot
wget https://datasheets.raspberrypi.com/soft/prepare_pxetools.sh
bash prepare_pxetools
When prompted about saving iptables rules, say no.
The prepare_pxetools script should prepare everything you need to use pxetools.
We found that we needed to restart the nfs server after using pxetools for the
first time. Do this with:
The bootloader negotiates to get an IP address and the details of a TFTP server
using DHCP.
The bootloader loads the firmware via TFTP and hands over the boot process to the
firmware, passing it the details of the network.
The firmware loads the kernel and command line via TFTP.
The kernel boots the rest of the system, loading the root filesystem (rootfs) via
NFS or some other mechanism.
The bootloader and firmware (stages 1 to 3) have been enhanced to support booting
over IPv6.
IMPORTANT
IPv6 netboot is an experimental alpha feature and depending on feedback, we may
need to change how it works in future. This only works on Raspberry Pi 4 and
Compute Module 4.
How it works
To boot via IPv6 you need an updated version of the firmware (e.g. start4.elf) and
the bootloader. Using the Bullseye release of Raspberry Pi OS and the latest stable
bootloader should be sufficient.
NOTE
The commonly used dnsmasq DHCP server doesn’t currently support the network boot
parameters required for IPv6 network boot, so for the time being you will have to
use a different DHCP server such as ISC DHCP.
To mount rootfs over the network the IPv4 netboot tutorial suggests using nfsroot.
This doesn’t support IPv6, so another method is needed to mount rootfs over the
network.
If your ISP and router don’t support IPv6 you will be limited in what you can do.
Network addresses
The first thing the bootloader does is send a router solicitation to get the
details of the network. The router responds with an advertisement packet
identifying its ethernet address, which the bootloader might need if the TFTP
server is on a different network.
The router advertisement includes a flag which tells it whether to use stateful
(managed) or stateless (unmanaged) configuration for its IP address. Stateless
configuration means that the device configures its own IP address. Currently the
bootloader generates an address derived from its ethernet MAC address and a network
prefix supplied by the router.
DHCP Servers and clients identify themselves with variable length DUID (Device
Unique ID). On the Raspberry Pi this is derived from the MAC address (DUID_LL).
TFTP address
Whether using stateless or stateful configuration, the DHCP server is used to
obtain the TFTP server address. This is encoded in the BOOTFILE-URL parameter. We
send the client architecture type value 0x29 to identify a device.
See RFC 5970 and the IANA Dynamic Host Configuration Protocol for IPv6
documentation.
Boot process
The device should now have an IP address and TFTP details. It downloads the
firmware binary start4.elf from the TFTP server and continues running with this.
The firmware is passed the IP address and TFTP server details so it can download
the kernel and boot the rest of the system.
Kernel Boot
With IPv4 netboot, nfsroot is used to mount rootfs over the network. This doesn’t
support IPv6 so another solution is required. It might involve a small RAM file
system that can mount the appropriate network location before switching to the
proper rootfs contents.
NOTE
A mechanism to boot the Linux kernel with NFS via IPv6 is still to be demonstrated.
Test Setup
If you want to try this out you will need another Raspberry Pi to act as the TFTP
and DHCP server.
The TFTP server can in theory be on any routable network but the DHCP server has to
be on the same network as the devices it will serve.
TFTP Server
If you have a working IPv4 network boot setup you can reuse the TFTP server in
dnsmasq to supply the files (it can talk to both IPv4 and IPv6).
DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf
INTERFACESv6="eth0"
In /etc/dhcp/dhcpd6.conf you need to specify the TFTP server address and setup a
subnet. Here the DHCP server is configured to supply some made up unique local
addresses (ULA). The host test-rpi4 line tells DHCP to give a test device a fixed
address.
not authoritative;
subnet6 fd49:869:6f93::/64 {
host test-rpi4 {
host-identifier option dhcp6.client-id
00:03:00:01:e4:5f:01:20:24:0b;
fixed-address6 fd49:869:6f93::1000;
}
}
Your server has to be assigned the IPv6 address in /etc/dhcpcd.conf
interface eth0
static ip6_address=fd49:869:6f93::1/64
Now start the DHCP server.
Router
To use IPv6 you really need a router and ISP that supports IPv6. There are sites on
the internet that can check this for you or alternatively run the following
command.
Here dc:a6:32:6f:73:f4 is the MAC address of the TFTP server and it has an IPv6
address of fd49:869:6f93::1. The device itself has a MAC address e4:5f:01:20:24:0b
and an IPv6 address of fd49:869:6f93::1000
Stateful configuration
You can examine network activity with tcpdump.
================================================================================
Come rendere Raspberry Pi 3 Boot da USB
================================================================================
È meglio iniziare questo progetto con una nuova copia di Raspbian, quindi scaricare
l'ultima
versione (stiamo usando Raspbian Jessi in seguito il rilascio di Debian Jessie a
luglio,
la comunità Raspberry Pi è stata benedetta con una nuova versione della variante
Raspbian,
basata sulla distro "madre" Leggi di più) e installarlo nel solito modo
Ecco come ottenere un nuovo sistema operativo installato e funzionante sul tuo Pi -
e come
clonare la tua configurazione perfetta per un rapido disaster recovery.
Leggi di più . Appena fatto, rimuovi la scheda dal PC in modo sicuro, inseriscila
nel Raspberry Pi
inattivo e avvia la connessione remota tramite SSH
Configurazione del tuo Raspberry Pi per l'uso senza testa Con SSH
Il Raspberry Pi può accettare comandi SSH quando è connesso a una rete locale
(tramite Ethernet o Wi-Fi), consentendo di configurarlo facilmente.
Il passo successivo è verificare che l'OTP - una memoria programmabile una sola
volta -
sia stata cambiata. Controlla questo con:
nano /boot/config.txt
Quindi, collega una chiavetta USB formattata (o pronta per essere eliminata) in una
porta di
riserva sul tuo Raspberry Pi 3. Con questo inserito, procederemo a copiare il
sistema operativo.
umount /dev/sda
parted /dev/sda
# parted /dev/sda
GNU Parted 3.4
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print all
Model: Generic Flash Disk (scsi)
Disk /dev/sda: 8053MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:
fdisk -l /dev/sda
Disk /dev/sda: 7,5 GiB, 8053063680 bytes, 15728640 sectors
Disk model: Flash Disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x00000000
mktable msdos
e conferma che il disco è smontato, prima di entrare nel comando mdtable msdos in
un comando
con finestra linea.
mkdir /mnt/target
mount /dev/sda2 /mnt/target/
mkdir /mnt/target/boot
mount /dev/sda1 /mnt/target/boot/
apt-get update;
apt-get install rsync
rsync -ax --progress /boot /mnt/target
cd /mnt/target
mount --bind /dev dev
mount --bind /sys sys
mount --bind /proc proc
chroot /mnt/target
rm /etc/ssh/ssh_host*
dpkg-reconfigure openssh-server
exit
umount dev
umount sys
umount proc
Si noti che dopo sudo chroot (il quinto comando sopra) si passa a root, quindi
l'utente passerà da pi @ raspberrypi a root @ raspberrypi finché non si entra exit
on line 8.
Hai provato questo? Incuriosito dalle possibilità di un avvio USB piuttosto che
dalla scheda SD? Stai pianificando di provarlo? Diteci nei commenti!