Vadim Tabakman

Static IP on Raspberry PI 

Static IP on Raspberry PI

As I've been doing a bunch around cameras, streams, security, I wanted to make sure I can move my Raspberry Pi around with out worrying about the IP address changing.  That's really because my house has a pretty decent router that protects from incoming traffic.

But I've added some redirects and port forward, to allow certain things through, but securely :).  Well, setting the IP address on the Pi wasn't obvious, at least not to me.  So here's a few steps:

sudo nano /etc/dhcpcd.conf

Then to change the wifi connection to a static IP, add this (or modify that file)

interface wlan0

static ip_address=192.168.0.200/24
static routers=192.168.0.1
static domain_name_servers=192.168.0.1

Posted by Vadim Tabakman Saturday, October 14, 2017 10:10:00 PM Categories: Raspberry PI static ip

Streaming Video with the Raspberry Pi 

Streaming Video with the Raspberry Pi

I bought one of those cheapy camera boards for the Raspberry Pi, and I thought it'd be good to have it watching outside my office all the time.

The thing is, I didn't want to just take pictures, I wanted to stream video from it.

RPi-Cam-Web-Interface to the rescue. Thanks to all the people that put that together, because it was super easy to configure.

https://elinux.org/RPi-Cam-Web-Interface 

Posted by Vadim Tabakman Saturday, October 14, 2017 10:02:00 PM Categories: camera Raspberry PI stream video

Audio issues on Raspberry Pi 

I had a lot of audio issues using Analog option.

The following helped:

sudo -iE

cd /boot

nano config.txt

-- add the following line:
audio_pwm_mode=2

reboot

Posted by Vadim Tabakman Saturday, October 14, 2017 9:01:00 PM Categories: audio Raspberry PI

Simple Website on a Raspberry PI 

Simple Website on a Raspberry PI

Install a few important components

sudo apt-get install apache2 php5 libapache2-mod-php5

Start the apache service

sudo service apache2 restart

Modify the default page:

cd /var/www/html/
sudo nano index.html

sfd

 

Posted by Vadim Tabakman Monday, October 9, 2017 10:10:00 AM Categories: apache Raspberry PI website

apt-get died unexpectedly segmentation fault 

apt-get died unexpectedly segmentation fault

What an exciting title for a post :)

This is purely for me.  After starting my Raspberry PI 3, I went to do an update and the "sudo apt-get update" failed with an error that contained "has died unexpectedly" and "segmentation fault".

After many minutes googling and binging I found that this worked :

cd /tmp

wget http://mirrordirector.raspbian.org/raspbian/pool/main/a/apt/apt_0.9.7.7+rpi1_armhf.deb

dpkg -i apt_0.9.7.7+rpi1_armhf.deb

 

But, I ended up going to "http://mirrordirector.raspbian.org/raspbian/pool/main/a/apt/" to find a package that existed and that I could actually install without an error.

It is meant to update your "apt-get', but it actually downgraded it.  I'm hoping after the update/upgrade, it will update that also.

Hope this helps someone.

Posted by Vadim Tabakman Monday, October 2, 2017 6:02:00 PM Categories: apt-get Raspberry PI

FTP "command not found" 

FTP "command not found"

If you're looking at using the FTP command tool on a Raspberry Pi (raspbian), you might find that it's not available when you start up.

To install it :

 

sudo apt-get install ftp

 

Pretty easy ha?

Only took me 20 mins to figure that out ha!!

Posted by Vadim Tabakman Tuesday, July 18, 2017 6:53:00 AM Categories: ftp Raspberry PI

HC-SR501 Motion Detection Sensor 

HC-SR501 Motion Detection Sensor

Yet another sensor to play with.  This time a Motion Detection sensor.  This has actually taken to me a different stage of my learning.  So far, I've been using Python code that polls the sensors to get data from.  But I realized that there must be a better way, because by polling, there's a change I'm missing out on events.  The thing I found was Triggers.

The sensor looks like this :

Kind of reminds of the room sensors you see in shops you walk into or even ones you might have at home with an alarm system.

Polling

#!/usr/bin/env python

import os
import RPi.GPIO as GPIO
import time

pin = 6

GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN)

print "Press Ctrl+c to exit"
time.sleep(2)
print "Ready"

try:
   while True: 
      if (GPIO.input(pin)==1): 
         print "Motion Detected"
      time.sleep(1)
except KeyboardInterrupt: 
   print "Program Cancelled..." 
   GPIO.cleanup()

Trigger

#!/usr/bin/env python

 

import os
import RPi.GPIO as GPIO
import time

pin = 6

GPIO.setmode(GPIO.BCM)
GPIO.setup(pin, GPIO.IN)

print "Press Ctrl+c to exit"
time.sleep(2)
print "Ready"

def MOTION(pin):
   print "Motion Detected!"

try:
   GPIO.add_event_detect(pin, GPIO.RISING, callback=MOTION)
   while True: 
      time.sleep(100)
except KeyboardInterrupt: 
   print "Program Cancelled..." 
   GPIO.cleanup()

There's not a huge difference.  But it's all about the Callback function called MOTION.  It's registered by using the GPIO.add_event_detection function.  We are telling it that on that pin that the sensor is connected, when we get a Rising edge event, you need to call MOTION.

Not that hard right?  This is going to make for some interesting apps now that my app doesn't have to sit in a loop, constantly polling a sensor and when an event occurs, my code has to stop what it's doing to process it.  In this case, the Callback function MOTION would be called on another thread behind the scenes, and my app can continue on it's merry way.

If you want to check out the code, it's available in the download section.

Downloads

Download the HC-SR501Sensor scripts - this is zipped.  So unzip it when you want to run it.  To run it :

python HCSR501SensorPoll.py

or

python HCSR501SensorTrigger.py

Posted by Vadim Tabakman Tuesday, January 17, 2017 10:29:00 PM Categories: HC-SR501 Motion Detection Python Raspberry PI

KY017 Mercury Sensor 

KY017 Mercury Sensor

Starting to get the hang of plugging these sensors in.  I wanted to do a quick post about the KY017 Mercury Sensor.

I found that it wasn't documented well and even the sensor itself, I wasn't sure which was Gnd, which was data and power.  Given that one pin said '-', I assume that is ground (see I'm learning).  The right most pin said 'S'  But I plugged that into my GPIO13 pin.  Therefore the middle pin, is power so I plugged that into the '+' line.  

What confirmed that it worked, is that I actually plugged into my breadboard with the jumpers.  That means I can move the sensor around.  When the little ball of mercury hit the right side (closest to the board), a light light up on the sensor.

Sensor Pointing Under Horizontal

Sensor Pointing Over Horizontal

Jumpers Plugged In

Notice the Black jumper on the right and it's plugged into the '-' line.  That plugged into the '-' on the sensor.  The Yellow jumper is plugged in the middle pin on the sensor.

Python Code

#!/usr/bin/env python

import os
import RPi.GPIO as GPIO

GPIO.setmode(GPIO.BCM)
GPIO.setup(13, GPIO.IN)
GPIO.setup(27, GPIO.OUT)

try:
   while True: 
      if (GPIO.input(13)==0): 
         print "Tilt"
         GPIO.output(27, True)
      else: 
         print "Level" 
         GPIO.output(27, False)
except KeyboardInterrupt: 
   print "Program Cancelled..." 
   GPIO.cleanup()

The Python code, as you can see above has something plugged into GPIO27 for output.  That's a Piezo thing I plugged on.  So basically, when the mercury sensor points down, the Piezo makes a clicking sound,.

Downloads

Download the KY017Sensor.py script - this is zipped.  So unzip it when you want to run it.  To run it :

python KY017Sensor.py

Posted by Vadim Tabakman Tuesday, January 17, 2017 1:12:00 PM Categories: GPIO KY017 Mercury Sensor Python Raspberry PI

DHT11 Temperature and Humidity Sensor 

DHT11 Temperature and Humidity Sensor

I think after doing the Hello World example with a Raspberry Pi and getting an LED to light up, the next thing to do is work on an Input sensor.  The DHT11 Temperature and Humidity sensor was the obvious target.

It has 3 pins that I plugged into my breadboard.

1. Gnd - I connected that to the - line on the breadboard

2. Data - I connected that to GPIO026

3. VCC - I connected to the + line on the breadboard

As soon as I did that, a light lit up on the sensor.  That means I've connected it correctly.. Right?? haha.

Next step was to get some Python code that can talk to the sensor.  You are probably wondering why "get" and not just write it myself.  Firstly, I'm still learning about all this sensors/GPIO stuff and at the same time, I'm learning Python.

A huge thanks goes out to Darius Juodokas (netikras) from Lithuania.  I grabbed his code from GitHub.

I had to change it a little to display the temp in Fahrenheit, but I was pleasantly surprised at the fact that it just worked.

Results

When you run it, it goes and gets the data from the sensor around 1,000 times, then calculates averages.  This should get rid of any anomalous readings.

The output looks like this :

H: 18%

T: 69.8F

Now you know what I have my office set to.

note:  there is also some text "Hello World" that pops up.  That's just for me.. feel free to get rid of that.

Downloads

Download the DHT11Sensor.py script - this is zipped.  So unzip it when you want to run it.  To run it :

python DHT11Sensor.py

Posted by Vadim Tabakman Tuesday, January 17, 2017 12:07:00 PM Categories: DHT11 Humidity Python Raspberry PI Temperature

Raspberry Pi visible to Windows 

Raspberry Pi visible to Windows

I had a bunch of copy and pasting I wanted to do to my Pi from my Windows pc.  Obviously, by default, the Pi is locked down and isn't visible on the network.  To get it be visible, I had to install Samba and tweak the config and also set a password.

Here are the steps I took:

sudo apt-get install samba

sudo apt-get install samba-common-bin

sudo nano /etc/samba/smb.conf

Make some changes to this conf file.

workgroup = WORKGROUP

wins support = yes

add the following to the bottom of the conf file.

[PiShare]

   comment = Pi Home

   path=/home/pi

   browseable=Yes

   writeable=Yes

   only guest=no

   create mask=0777

   directory mask=0777

   public=no

Finally, run this command and enter the password.

sudo smbpasswd -a pi

Posted by Vadim Tabakman Tuesday, January 17, 2017 11:58:00 AM Categories: apt-get Raspberry PI Samba
Page 1 of 2 1 2 > >>