raspberry-pi , How to control light bulbs with Raspberry Pi - Requirements


How to control light bulbs with Raspberry Pi - Requirements

Question:

Tag: raspberry-pi

I can control LED using the raspberry pi. I was wondering how to control house light bulbs with raspberry pi. I mean what are requirements?


Answer:

The code would be the same as for an LED, but you would need to switch a relay instead of the light itself.
Solid State Relay
http://www.newark.com/productimages/standard/en_US/4634348.jpg

Since the Raspberry Pi is not equipped to handle that much power, the relay is used because it can be switched on and off by 5v or 3.3v on one side, but actually handle your 220v on the side with the light.


The Voltage on the high side of this circuit is dangerous, and can cause severe injury or death I strongly suggest you take all possible precautions and use Personal Protective Equipment.

If you are not comfortable working so directly with electricity, there are ready made options which are much safer, but generally cost more. You could check out products similar to this one: http://www.powerswitchtail.com/Pages/PowerSwitchTail240vackit.aspx


Related:


Replace character in string with multiple characters Shell Script


bash,shell,raspberry-pi,raspberry-pi2
I want to replace "." in this result: "172.16.0.25" with " dot ". Here is my code: #!/bin/bash connection=`netstat -tn | grep :1337 | awk '{print $5}' | cut -d: -f1` #this returns "172.16.0.25" replace=" dot " final=${connection/./$replace} echo "$final" Which returns: test.sh: 4: test.sh: Bad substitution I tried using...

Java read bytes from Socket on Linux


linux,windows,sockets,network-programming,raspberry-pi
I'm trying to send a file from my Windows machine to my Raspberry-Pi 2, and I have a client and a server. The client should be able to send a zip file over the network to my server on my linux machine. I know my client and server work on...

Access GPIO (/sys/class/gpio) as non-root


bash,raspberry-pi,chmod,chown,raspberry-pi2
The /sys/class/gpio can only be access as root by default. So I like that a new group gpio can use the files and dirs under /sys/class/gpio. To achieve that I added the following lines to /etc/rc.local (I'm on Debian): sudo chown root:gpio /sys/class/gpio/unexport /sys/class/gpio/export sudo chmod 220 /sys/class/gpio/unexport /sys/class/gpio/export So...

My While True loop is getting stuck in python


python,while-loop,raspberry-pi,infinite-loop,raspbian
Hello I have been working on an infinite While True loop for the main file in my python code. I am working on a Raspberry Pi and my goal is that whenever one of the GPIO Pins senses an input it will print out a string. However When I push...

Is .pyc platform independent?


python,raspberry-pi
I recently started python development on raspberry pi. While reading about .pyc file to speed up the start up, I was wondering if I test a .pyc file on PC, given that same python modules are available on Rpi, will it work directly ? Please also include what happens if...

How to install RPi.GPIO to windows


python,module,install,raspberry-pi,gpio
I have looked and most of the tutorials are rasbian based. I would like it on windows so I can develop a python script on windows to which would later be put on the Raspberry pi. I have downloaded the module and have tried python setup.py install in command prompt...

QtDesigner for Raspberry Pi


qt4,raspberry-pi,qt-creator,qt-designer
I am building a UI with QT Designer. I need this UI to run on a Raspberry Pi. What do I need to do to make the UI for the Pi? Does it have to be written in a specific language like python or can I just write it in...

Raspberry pi kernel 3.2.27 no keyboard detected on boot


keyboard,kernel,raspberry-pi,cross-compiling,boot
I'm trying to cross-compile a driver for Raspberry Pi. The driver works in kernel 3.2 so I downloaded the 3.2.27 raspberry pi's kernel. I compiled the kernel as follows: make -j3 ARCH=arm CROSS_COMPILE=<dir>/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- make -j3 ARCH=arm CROSS_COMPILE=<dir>/rpi-tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf- modules make -j3 ARCH=arm...

Illegal instruction when running simple ELLCC-generated ELF binary on a Raspberry Pi


arm,raspberry-pi,cross-compiling,raspbian,ellcc
I have an empty program in LLVM IR: define i32 @main(i32 %argc, i8** %argv) nounwind { entry: ret i32 0 } I'm cross-compiling it on Intel x86-64 Windows for ARM Linux using ELLCC, with the following command: ecc++ hw.ll -o hw.o -target arm-linux-engeabihf It completes without errors and generates an...

GPS App compile errors


c++,linux,gps,raspberry-pi,gpsd
I am working on a GPS application on the Raspberry pi. I have just installed GPSD by running sudo apt-get install gpsd gpsd-clients. I do get data from my GPS module when I run sudo gpsd /dev/ttyAMA0 -F /var/run/gpsd.sock. My issue resides when I try to make my own GPS...

os.hostname() to return an IP


node.js,raspberry-pi,hostname
I have this raspberryPi with Node.JS running on top of it. By calling os.hostname(), the Pi returns "raspberry". I'm aware on how to modify this behaviour. What I don't know is how to do so in order to have it return an IP. The raspberry is connected in a distributed...

Logging python errors on raspberry pi


python,linux,pyqt,raspberry-pi
I'm having a helluva time debugging a python app I've written for an embedded raspberry pi project I'm working on because it's using a TFT screen instead of a full monitor and has no monitor/keyboard, so i'm having to launch the python app via an icon on the TFT desktop...

Use same Python variable in multiple if-statements


python,if-statement,raspberry-pi,global-variables,bottle
I am having issues with my current Python script. The purpose of the 'progress' variable is take a specific value when it goes through one of the if-loops. But, the program never goes further then the first if-statement. It looks as if every if-statement makes his own variable called 'progress'....

python class definition problrm


python,raspberry-pi
this my first python code i am trying to connect to a database , i defined a class called Database in a python file called mysqlConnection.py but when i run the code i get this error : Traceback (most recent call last): File "mysqlConnection.py", line 3, in <module> class Database:...

python error in main method defenetion


python,raspberry-pi
this my first python code , i am trying to connect to data base , i think the connection part was processed successfully import MySQLdb class Database: host = "localhost" user = "root" passwd = "root" db = "pitest" def __init__(self): self.connection = MySQLdb.connect( host = self.host, user = self.user,...

Raspberry Pi script boot order


raspberry-pi,crontab,raspbian,init.d,ppp
There're three forms about running a script on the boot of the Raspberry, that are modifying /etc/rc.local, modifying the cron daemon and making a script that automatically run on boot in /etc/init.d I want to know which of the methods listed about executed first. The point of the question is...

Ubuntu login on a Raspberry Pi 2


ubuntu,raspberry-pi,raspberry-pi2
I just got a Raspberry Pi 2 and put Ubuntu on a microSD card with Win32 Disk Imager. When starting up I get the following: Ubuntu 14.04.2 LTS ubuntu login: What should I type in there?...

Raspbian log files


raspberry-pi,raspbian
Where can I find all boot, driver or kernel related logs on a Raspbian? Could you please reply with a list as follows: Driver logs - /something/somethingelse.log Thanks!...

start file manager in terminal window wheezy


linux,debian,raspberry-pi
Is there an easy way to start my File Manager in GUI as root? All I want to do is temporarily create/update some files and I want to do it through the GUI. I am using a Raspberry Pi that is running Wheezy....

act on a single object


python,raspberry-pi
We have a timer and we want to stop one of the timer when one of the GPIO goes to 1 so far we have this code: #!/usr/bin/env python3 # -*- coding: utf-8 -*- from Tkinter import * import time from functools import partial import RPi.GPIO as GPIO class Chronometre(Frame):...

Receiv boolean result to see if crontab exists


python,bash,raspberry-pi
In Python or Bash, is there an easy way to receive a Boolean result on whether or not the crontab exists? crontab -e #shows me manually ...

setInterval doesn't get cleared, function keeps getting executed


javascript,node.js,socket.io,raspberry-pi
I have the following function: function monitorClimate() { var sensorReadingInterval; function startClimateMonitoring(interval) { sensorReadingInterval = setInterval(function() { io.emit('sensorReading', { temperature: sensor.getTemp() + 'C', humidity: sensor.getHumidity() + '%' }); }, interval); console.log('Climate control started!'); } function stopClimateMonitoring() { clearInterval(sensorReadingInterval); console.log('Climate control stopped!'); } return { start: startClimateMonitoring, stop: stopClimateMonitoring }; }...

Connect to wifi using Python on Raspberry Pi


python,python-2.7,raspberry-pi,wifi
I am using Python 2.7 and wifi library (https://wifi.readthedocs.org/en/latest/) on a Raspberry Pi. I have managed to install wifi library using: sudo pip install wifi on the terminal. The library seems to work but I can't figure out the way to connect to a wifi using a password. The documentation...

smtplib sending multiple messages instead of one


python,raspberry-pi
I am trying to run a python script at bootup which will take a ~10 second video on applying an external input (such as push button, IR sensor etc, and in our case an ultrasonic sensor), and then mail this video to specified email addresses using the SMTPlib library of...

Bad file descriptor error in Python (Error 9) on Raspberry


python,linux,raspberry-pi
I am working with Python for the first time, and encountered the following issue, while running it on a Raspberry Pi Version B+ rev 2: The code is supposed to set an interrupt on pin 22 (BCM), and when a button is pressed, halt the OS: # Import the modules...

Why doesn't “Set-Item” work on Windows 7 PowerShell?


windows,powershell,raspberry-pi
I am trying to install Windows 10 IoT on my Raspberry Pi 2. The PowerShell documentation tells me to put in this: Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> However, when I put it into my Windows 7 PowerShell, this comes out: At line:1 char:54 + Set-Item WSMan:\localhost\Client\TrustedHosts -Value <minwinpc> + ~ The...

Apache won't serve pages on my Raspberry Pi


php,apache,configuration,installation,raspberry-pi
I've installed PHP 5.6 on my Raspberry Pi (from the Jessie repo), as well as Apache2. When I access http://192.168.2.50/ (the Pi's IP-address) it's not serving the index.php or index.html file in ~/var/www/. Just an hour ago I was running PHP 5.4 from the Wheezy repo, this was working fine....

Python “shutdown / reboot raspberry pi” script, using a single button


python,linux,raspberry-pi,interrupt
I got a piece of code in Python from here: http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi And I wanted to improve on it. Since this is the first time I work with Python, I got stuck on understanding what actually happens. Here is the code: # Import the modules to send commands to the system...

How do I make a number of looping scripts execute at startup?


python-2.7,raspberry-pi
I have a few Python scripts, all of them involving while True: and a wait timer so they run at varying intervals. They do things like monitor a serial port and look for new versions of my code on a remote server. I haven't used cron because some require offsets...

subprocess call to setup crontab


python,cron,raspberry-pi,subprocess
I'm trying to use a subprocess call in python to add a cron job entry: from subprocess import call call(["(crontab -l; echo '* * * * * ls -l | tee tresults.txt') | sort - | uniq - | crontab - "]) And I don't know what I'm doing wrong!...

Arduino serial works fine with Debian but hangs with Raspbian


c,linux,arduino,raspberry-pi
I'm working on a personal home automation project. On the server side, I have an Arduino Pro Mini with: a 433 MHz TX module on pin 2 a 433 MHz RX module on pin 3 a DHT22 probe on pin 4 (with 10k pull-up) a DHT22 probe on pin 5...

Popen.kill() failing


python,raspberry-pi
Update 2: So I piped the output of stderr and it looks like when I include shell=True, i just get the help file for omx player (it lists all the command line switches and such). Is it possible that shell=True might not play nicely with omxplayer? Update: I came across...

Using camera shutter to trigger MPU6050 on raspberry pi


raspberry-pi,sampling,i2c,gpio,inertial-navigation
I've connected DSLR to RPi by GPIO; and MPU6050 to RPi using I2C. I'm trying to record the gyro and accelerometer data in a small time window (typically less than 50ms) when I press camera shutter button. My desired sampling rate is somewhere in between 500Hz to 1000Hz. And I...

ping one device after the other and check availability


bash,if-statement,for-loop,raspberry-pi,sendmail
I want to run a bash-script on my raspi. The script's purpose is to check one device in my network for availability (with ping). If this device is responding, script should end. If it's not responding it has to go further and check the availability of 3 specific devices: if...

Why can't I use python-mosquitto on the Raspberry Pi?


python,raspberry-pi,raspbian,mqtt,mosquitto
I'm using a Raspberry Pi with a Debian Wheezy image. I have installed Mosquitto (the broker of MQTT protocol), mosquitto client and python mosquitto to use mosquitto in my Python script, I have run a very simple example to test if all my packages work fine or not import mosquitto...

Raspberry Pi C++ Header Documentation


c++,linux,linux-kernel,raspberry-pi,embedded-linux
Is there some sort of documentation for what kind of headers you can include in c++ files when writing programs for Raspberry Pi or linux in general? For instance I found this great guide on how to access the SPI bus from the Pi using c++ (http://hertaville.com/2013/07/24/interfacing-an-spi-adc-mcp3008-chip-to-the-raspberry-pi-using-c/) I was able...

C++ chrono library on Raspberry Pi


c++,raspberry-pi,c++14,chrono
On a Raspberry Pi 2, I need to call a php file on a regular basis, typically every 100ms. I found this c++ code which looks like it does what I need and a test version of it compiles and runs fine using CodeBlock on Windows. I've updated the wheezy...

Connection refused to mosquitto service in Raspian


raspberry-pi,mqtt,gpio
I installed a fresh and clean new raspbian onto a raspberry pi A+ and added the 1.4.2 mosquitto package from mosquitto.org. With mqtt-gpio-Monitor from https://github.com/sumnerboy12/mqtt-gpio-monitor/issues/3 i try to connect but always get an error saying connection refused. Mosquitto_sub works without issues and connects correctly. The mosquitto service is listening on...

Using IPEGA bluetooth gamepad with Retropie


bluetooth,raspberry-pi,emulation,bluez
I'm trying to configure my Ipega PG-9025 with Retropie with no succeed. I made some progress following this link (http://askubuntu.com/questions/608386/using-ipega-bluetooth-gamepad-with-steam-linux) but it only works at Emulation Station menu... The gamepad stops working in every emulation system and also gives me some problems pairing and reconnecting my device. Has someone any...

How deploy an large number iBeacons


bluetooth,raspberry-pi,bluetooth-lowenergy,uuid,ibeacon
I want deploy a large number of iBeacons with the same UUID because we can't access dynamically to the UUID of the beacons detected. What is the limit number of the maximum Beacons with the same UUID ? I found some discussions with a number of 65000 approximately, is it...

Updating An Image on All instances of a website


php,jquery,html,ajax,raspberry-pi
So I have a Raspberry Pi controlling my Garage door. The Pi is running an apache webserver. I also have a camera connected to the raspberry pi and I want to be able to update the images from the camera. Currently I have the following code: garage.html: <html> <head> <meta...

How to install shared library and include files manually in linux?


linux,opencv,cmake,raspberry-pi
I am trying to build and install TBB library from source so that it can be used for OpenCV to take advantages of multiple cores on my raspberry pi. I was able to build TBB from source without any problems using this steps. (Source : How do I build OpenCV...

Python Flask persistent object between requests


python,rest,flask,raspberry-pi
I am creating a web interface for OMXPlayer on the Raspberry Pi. I'm trying to create a more REST like API for controlling the video while its playing. The issue I'm having is how to control the video while it is playing. Currently I can create a Player object which...

Raspberry Pi MicroSD Boot not working, MicroSD card unreadable on PC


raspberry-pi
I downloaded the necessary files for Raspberry Pi onto a MicroSD card, although the MicroSD card is no longer readable. When I put the card into the computer through a MicroSD to USB adapter nothing shows up in Windows Explorer. The card isn't present in Windows Disk Management either. How...

How to Read Files Stored in Raspberry Pi Directly to Window Using R


linux,r,windows,ssh,raspberry-pi
I'm attempting to read files stored in Raspberry Pi (Raspbian) directly to Windows 7 using R. To be specific, here are what I've done so far. 1. Install R 3.1.2 on Windows 7 2. Install Raspbian on Raspberry Pi, stored some text data files in Raspberry Pi. 3. Attempt to...

Using macbook pro as display for raspberry pi 2 [closed]


osx,raspberry-pi,raspberry-pi2
I just received a pi 2 with sd card preloaded with NOOBS. I also have an hdmi cable and wifi dongle for it. I wanted to begin using the pi 2 but do not have a spare monitor to connect it to. I was hoping to be able to connect...

Cross compiling for Raspberry pi 2 error


c,gcc,raspberry-pi,cross-compiling,raspberry-pi2
I wanted to start cross compiling for raspberry pi2 on Ubuntu 32bit (in virtual box), so I downloaded the toolchain on the github site (https://github.com/raspberrypi/tools) and tried to compile a simple hello world program with the command (I've included the path to the bin folder that contains arm-linux-gnueabihf-gcc-4.8.3 to the...

Raspberry PI USB to RS232 adapter Receiving Only Ctrl Chars


python,serial-port,raspberry-pi,pyserial
I'm using a USB to RS232 cable for get communication with a pure rs232 device. With pyserial lib a got this code running in loopback tx -> rx cable pins. Setting the port: def __init__ (self, baudrate,timeout,parity,stopbits,bytesize): try: #self.s = serial.Serial(port="'/dev/ttyUSB0'",baudrate=baudrate,timeout=timeout,parity=parity,stopbits=stopbits,bytesize=bytesize) #self.s = serial.Serial("/dev/ttyUSB0",9600) self.s=serial.Serial( "/dev/ttyUSB0", baudrate=9600, parity=serial.PARITY_NONE, stopbits=serial.STOPBITS_ONE,...

Raspberry Pi: printf() doesn't work with wiringPi


c,printf,raspberry-pi,gpio
I'm trying a simple code that using wiringPi as here: #include<wiringPi.h> #include<stdio.h> int main(void){ int i; wirintPiSetup(); pinMode(0,OUTPUT); //a single LED pinMode(8,INPUT); //tactile switch for(;;){ delay(500); //push tactile switch and LED is turning on if(digitalRead(8)) digitalWrite(0,0); else digitalWrite(0,1); printf("%d",digitalRead(8)); } } I expected a result of printf() is output to...

Jumbled out put of RFID Tags


python,raspberry-pi,raspbian
I am working on a project, in which I have to interface multiple RFID Readers (I'm Using EM 18, With Serial out) with Raspberry Pi. I'm using an USB to TTL Converter to connect EM 18 to Raspberry Pi. I've connected two RFID Readers using USB to TTL Adapter. This...