Saturday, 12 March 2016

One Man’s Quest To Spend Less TIme In The Basement

[Lars] has a second floor apartment, and the washing machines and clothes dryers are in the basement. This means [Lars] has spent too much time walking down to the basement to collect his laundry, only to find out there is 15 minutes left in on the cycle. There are a few solutions to this: leave your load in the washer like an inconsiderate animal, buy a new, fancy washer and dryer with proprietary Internet of Things™ software, or hack together a washer and dryer monitoring solution. We all know what option [Lars] chose.

Connecting a Pi to the Internet and serving up a few bits of data is a solved problem. The hard part is deciding which bits to serve. Washers and dryers all have a few things in common: they both use power, they both move and shake, they make noise, and their interfaces change during the wash cycle. [Lars] wanted a device that could be used with washers and dryers, and could be used with other machines in the future. He first experimented with a microphone, capturing the low rumble of a washer sloshing about and a dryer tumbling a load of laundry. It turns out an accelerometer works just as well, and with a sensor securely fastened to a washer or dryer, [Lars] can get a pretty good idea if it’s running or not.

With a reliable way to tell if a washer or dryer is still running, [Lars] only had to put this information on his smartphone. He ended up using PushBullet, and quickly had an app on his phone that told him if his laundry was done.


Raspberry_Pi_LogoSmall

The Raspberry Pi Zero contest is presented by Hackaday and Adafruit. Prizes include Raspberry Pi Zeros from Adafruit and gift cards to The Hackaday Store!
See All the Entries || Enter Your Project Now!


Filed under: home hacks, Raspberry Pi

from raspberry pi – Hackaday http://ift.tt/1peznYO
via Hack a Day

Friday, 11 March 2016

Digital Zoetrope Powered By Pi

A zoetrope is a charming piece of Victoriana, a device that gives the sensation of a moving image by exposing its successive frames through slits in a rotating drum. [Brian Corteil] however is not content with a mere 19th century parlour amusement, he’s connected twelve OLED displays to a Raspberry Pi and mounted them on a circular platform with a rotary encoder to make a fully digital zoetrope.

Connecting 12 SPI devices to the Pi was always going to be something of a challenge, because only two CS lines are provided. [Brian] has a rather elegant solution to this problem, he’s daisy-chained his displays to form a shift register in which each image is passed to the next display on a rotational increment.

His resulting zoetrope sits on a laser-cut frame which rotates over an encoder disc which looks to be made from printed paper. It is still something of a work in progress, but he has plans to record video on the Pi camera for immediate playback on his creation. You can take a look at his code for the zoetrope on GitHub.

This isn’t the first zoetrope we’ve covered here at Hackaday, or even the first digital one. We’ve seen a couple of 3d-printed ones, and one featuring laser-cut images captured with a Kinect. But it’s a good piece of work, and has the promise of more to come if his camera plans come to fruition.

Here follows a video of [Brian]’s zoetrope in action, at the Raspberry Pi 4th birthday party. With apologies for the quality of a roving Hackaday writer’s camera phone, we hope it gives a flavour of what the device can do.


Filed under: Raspberry Pi

from raspberry pi – Hackaday http://ift.tt/1LXiWdW
via Hack a Day

Get your total guide to networks in LU&D #163

001_LUD_163The latest issue of Linux User & Developer is now available to buy. You can get your copy digitally through our online shop, or through Android, iOS or Zinio. Also keep an eye out for it in most print retailers.

This issue we’re giving you the complete guide to networks – covering everything from configuring your own, performing network administration and even setting up remote access. We’ve also got a nifty project for all you budding gamers out there, as we show you how to make a MAME machine using an old Xbox pad and a Pi Zero.

As ever, there’s also a selection of the best tutorials from our resident experts. In this issue you’ll be able to find guides to:

  • Securing your web server with Let’s Encrypt
  • Creating and using binary trees
  • Hacking the Atom editor
  • Adding textures in MonoGame
  • Setting up a Hadoop cluster

Don’t forget to head across to our FileSilo page, where you can download all the assets you could possibly need to complete all of our tutorials.

output_Lba81F



from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/1QRa1Y9
via IFTTT

Home automation with your Pi – Part 1

We regularly talk about how the Raspberry Pi is the perfect little computer to have around the house doing work that requires just enough computing power to keep it running. It’s not the purpose of the device, but it is just really good at it. File servers, media centres, etc – its size and flexibility make it an often surprisingly powerful tool.

And we can always go a step further. Instead of handling idle computing tasks around the house, what if we had it control the house? Through modern home automation and a bit of fancy coding, you can easily make the Raspberry Pi do a little bit more and control many aspects of your home. In this feature, we’re going to run you through not only setting up the controllable lights and thermostats and such, but also how to go about controlling them. Snarky voice interface not required.

ledstrip_bb

Your smart home setup

Remote control sockets

Energy saving and green houses are a big thing right now, and you can buy power strips that will shut down every socket based on the draw from a single socket. This isn’t always accurate, though, and being able to manually control the socket is not always easy if it’s hidden away or part of a power strip. With the use of remote control sockets, you can control the power of anything from the Pi and a web interface, enabling better control and less use of device standby modes.

Lights

A classic home automation function is controlling the lights in the house depending on the time of day or how dark it is. There are many ways you can do this: the popular method right now is Wi-Fi enabled bulbs, allowing for direct control, but you can also use the remote control sockets or use strips of LEDs that can easily light a room and are much easier to manually interface with. With all of these methods separate from the automated control, you can also remotely control the lights to switch on and off as you please. It’s not a good idea to try and spook house guests, though.

Thermostat

Technologies like Nest are becoming extremely popular, but connected thermostats have been around for a long time – longer for those with a soldering iron. While we’re not going to be quite creating a thermostat that ‘learns’, using it for external control and monitoring is easy enough when you have the right equipment. We’ll be concentrating on the monitoring part in this tutorial, using a thermistor and a bit of calibration to figure out the temperature.

Security doorbell

It’s surprisingly easy to get one of these home security systems set up. Using technology created for security cameras and streaming, you can create a live feed using the Raspberry Pi that can be displayed wherever you want. This can be done quite simply on the Pi using a webcam or even the Pi camera itself, and you can even try and hook it into the doorbell if you want a really cool party trick.

LEDStripCircuit

Build your own automated system

Remote control sockets

We are going to use a 433MHz receiver and transmitter module (these can be found for a couple of pounds on eBay – simply search for ‘433MHz’ and you’ll find what you’re looking for) connected to an Arduino to switch a pack of remote control sockets. We used a pack of four remote control sockets from Energenie (£17 on Amazon). Remote control sockets are ideal for items such as floor-standing lamps, and anything else without an on/off switch. In our expert’s case, he has an audio mixer that doesn’t have an on/off switch.

Once you have the sockets set up to work with the remote, you can use the 433MHz receiver and a simple piece of Arduino software to capture the message sent by the remote so it can be sent later using the transmitter module. The modules have very simple wiring: 5V, Ground and Data. The receiver has two pins for the data line but you only need to connect the Arduino to one of them. The beauty of sniffing remote control codes is that it can be used for anything you like that works at 433MHz – remote control garage doors or light switches are likely to use 433MHz.

LED light strips

LED light strips are great. They are very easy to find on Amazon and cost about £15 for a length of five metres with a 12V power supply and remote. They have adhesive on the back so they can be stuck to a surface. Alternatively, you can just leave it on the reel as that will still give off a lot of light.

Each LED on the strip has an individual red, green and blue colour component. These colours can be set to any brightness level between 0 and 100% using pulse width modulation. This is where the signal for each colour is a square wave that is on a certain amount of the time. For example: if the Red signal had a 50% duty cycle then it would be on for 50% of the time, resulting in reduced brightness. The strip has four connectors on it: +12, Red, Green and Blue. The colour connectors are the ground pins for each colour. When the pin for a colour is connected to ground, the circuit is completed, allowing 12V to flow through the strip and to ground. We will use a high current transistor for each colour to control the connection. Note that the ground from the Arudino and power supply should be connected together on the breadboard. The 12V supply for the LEDs should not connect to the Arduino – only to the LED strip – or the Arduino will get damaged.

radiorx_bb

We used a TIP120 NPN transistor, which is capable of switching 5 amps – this is plenty for our application (the power supply that comes with the strip only supplies 2.5 amps, and we can switch 15 amps because there is a 5 amp transistor for each colour). This transistor would also be good for controlling the speed of a fan or other kinds of motors.

The pins of the TIP120 are Base, Collector and Emitter, from left to right. The base is connected to the PWM signal from the Arduino via a 220-ohm resistor. The collector is connected to one of the colour pins of the LED strip, and the emitter is connected to ground. Note that when passing high amounts of current, these chips get hot. Also, it is wise to use solid core wire from the emitter-to-ground and collector-to-LED strip wires because they can safely handle more current than breadboard jumper wires. You need to ensure that none of the wires connected to the strip can short, otherwise you could damage the LEDs in the strip. Our setup here is only temporary – it could be worth moving the circuit onto veroboard so that it is more stable once you have tested that it works on a breadboard.

Temperature sensor

The TMP36 is a very simple IC. It has three pins: 5V supply, ground and a voltage out from 0-2V to represent temperature. This variable voltage can be read with the analogue in pins of an Arduino. The formula is: Temp in °C = [(Vout in mV) – 500] / 10, so a voltage of 0.7V would be 20°C.

Camera

You can either use a USB webcam or Raspberry Pi camera for the video stream. The Raspberry Pi camera should be connected with the blue plastic facing the Ethernet connector, and the exposed traces of the ribbon cable facing towards the HDMI connector.



from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/1RDp9s1
via IFTTT

Wednesday, 9 March 2016

Make a visual novel with Python

Videogames have come a significant way since their early days, and in recent years it’s become even easier to tell a gripping and compelling story through the medium. A great way to tell a pure story is through the genre of visual novels. These interactive novels are extremely popular in Japan, though they’re gaining traction in the rest of the world, and usually have the player click through a story and make decisions as they go to experience different plot points and endings.

In Python, this is a relatively easy project to create, but with the addition of the pygame module we can make it easier still and more expandable for the future. Pygame adds better support for positioning images and text, creating display windows, using mouse and keyboard inputs, and simplifying the coding process. We’ll be coding this in Python 2, so make sure to run it in IDLE 2 and not IDLE 3 while writing and testing and coding.

vn1

1. Get pygame dependencies

The best way to install pygame for your system is to compile it. To do this you need to first install the right dependencies. Open up the terminal and install the following packages, which in Ubuntu looks like:

  $ sudo apt-get install mercurial python-dev python-numpy libav-tools libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev libsmpeg-dev libsdl1.2-dev libportmidi-dev libswscale-dev libavformat-dev libavcodec-dev

2. Get the pygame code

Next we need to download the code for pygame direct from the source. Still in the terminal, you can do this by typing in:

  $ hg clone  http://ift.tt/1zmvGkX

… which will download it to the folder pygame. Move to it using cd pygame in the terminal so we can continue building it.

Make a visual novel with Python

3. Build the pygame module

To install it, we need to do it in two steps. First we need to prepare the code to install using the terminal with:

  $ python setup.py build

One that’s finished, you can then actually install it with:

  $ sudo python setup.py install

This won’t take too long.

4. Install in other ways

If the above steps don’t work for you (or if it seems a little bit daunting) you can check the pygame website for binary and executable files that will work on other operating systems and Linux distros. Head to http://ift.tt/1cbdQ9P to get the files you need for your specific system, including Windows and OS X. The rest of the tutorial will work in any OS.

5. Get the visual novel files

We’ve uploaded the code to FileSilo, and here we’re going to walk you through what we’ve done to make it work. Download the files for the visual novel and unzip them. The two files we care about for the moment are the visualnovel.py and script.py python files – this is where all the important code is.

vn6

6. Understand the script file

For the moment the script file is small and literally just holds the script for the game. It’s made up of events for the visual novel to move between, line by line, by splitting it up into scenes. This includes the location of each line, the character, the actual line itself and information on how the game flows. These are all matrices that store the relevant information, and are completely customisable.

7. How the script relates

In our game, the code pulls in elements from the script file as it goes. We’ll explain how that works later, but this also allows us to implement decisions later on to change where the game might take you in a later part of the game.

Make a visual novel with Python

8. Starting the main game

We don’t need many modules for the current state of our visual novel. Here we’ve imported the new pygame module, our script as a module and the time module for aesthetic reasons – we’re going to have the code pause in bits rather than just instantly change scenes to the next line. We also initialise pygame with a simple pygame.init().

9. Add variables and assets

We can now add the mixture of info that we need to run the novel. We define the size of the display screen to use (1000 pixels wide and 563 high), along with some RGB colours for the code to use. We’re also telling pygame which font to use, and how large for certain sections, and also loading images for the game.

10. Start the game

Create a display for the game. Pygame works by constantly updating the display with new information. To show how this works, the menu function adds elements to the display (which we’ve titled screen), such as filling it with colour, adding shapes and using blit to add images, or in this case text. Once you’ve created a buffer of changes to the screen, you update it with the flip() function.

vn11

11. See the mouse

As we’ve created the button as a rectangle and now an image on the menu, we need to know that the mouse is hovering over it to know when it’s clicked the button. First we have to use event.get() to see the mouse in general, then we look for the position with get_pos(). After that, we wait for it to click, see where it clicked (using the co-ordinates of the rectangle) and then make a decision after that.

Make a visual novel with Python

12. Start the story

Our start_game function is called when the mouse clicks the right position and we prepare the game, getting the characters, locations and progression through the game script. The rest of this function uses this info to pull in data from the script to make the game flow properly.

vn13

13. First screen

The first screen is handled differently to the rest, and acts to get every element up on the interface before we start continuing – it makes the code take up a little less time to process as we begin. The getattr allows us to use the string/integer associated with our place in the story and call upon the relevant scene function from the script file. We then use an if statement with an iterative function to successively add screen elements, to give the illusion that it’s building up the first screen. We finish it by advancing the progression value.

14. Go to the next line

Similar to how our original startup code works, our next if statement and iteration checks to see what is different on the next line, and if it moves to a different scene function, and changes anything that is different without filling up the buffer any more than is needed. We’ve made it so no change is labelled with a 0 in the scripts.

15. The starting function

We finish our code bit with a simple function that starts off the entire game. This is just to encapsulate the entire code and allows us to add different ways of turning it off in the future. When running the file, IDLE will load everything up and then run the game() function at the end – this is similar to how you can add a __main__ function at the end that will start the code in the command line.

vnanno2

16. Expand your code

The code we’ve written is very expandable, enabling you to add decisions that are logged to take you to different scenes – or ‘routes’, in visual novel terminology – and make your game feel more interactive. This doesn’t require much more code to the if statements, and is also a good way to look into adding graphical buttons to click in order to use the collide function.

17. Move the assets

Currently, the code has the script-specific assets in the main visualnovel file. These can be moved to the script, allowing you to make the visualnovel file much more modular so that can you have multiple scripts with different assets to load at startup. 



from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/1R6ZYnm
via IFTTT

Tuesday, 8 March 2016

Wall-E Goes Corporate, Offering Telepresence Service

I guess if you are going to build a robot to do something boring like telepresence, you might as well make it cute. That’s obviously what [Andrew Maurer] was thinking when he built a telepresence robot using a Wall-E toy. The result is kind of adorable: Wall-E is holding the 5-inch HDMI screen that shows the video, and can scoot around in true Pixar fashion under remote control.

It’s also a neat build on the inside, using a Raspberry Pi for the brains and an Adafruit MotorHat to control the motors. The original toy didn’t have motors, so he added a new RC gearbox and motors to drive the little fella around. Installed behind Wall-Es eye is a USB webcam. Running behind the scenes is a mumble server that does the audio, a copy of Chromium that shows the video, and an Apache server that feeds the captured video to the other end of the conversation. The whole thing is tied together by a few scripts that kick things off appropriately and allow the user to remotely control Wall-E. It’s a cute build, and hopefully Wall-E can still find his EVE while performing his new corporate duties.

[via reddit]


Filed under: Raspberry Pi, Virtual Reality

from raspberry pi – Hackaday http://ift.tt/1nt7mLL
via Hack a Day

Monday, 7 March 2016

ownCloud 9.0 officially announced; innovative collaboration leads new features

ownCloud is a self-hosted sync and share server, which is about to release its latest update. The 9.0 update brings with it a host of new and innovative features to make storing and distributing files easier than ever before.

Innovative collaboration

Users now have more options available to them when it comes to working and accessing files on other accounts. Comments can be left on specific files, while tags have been added to keep your account neatly organised. There’s also a revamped notifications system, so you can expect to be notified when someone accesses a file and interacts with it in some capacity.

Ultimate scalability

Behind the scenes, ownCloud has been deployed in larger installations, allowing for better scalability and a dramatic increase in file transfer speeds. A new storage API has also been included to enable complete control of previously troublesome file types.

Full federation

If a colleague didn’t have an ownCloud server, you’d have previously been fairly restricted to the files you could share with them, until now. Links to files can now be shared, with a non-ownCloud user requiring the password for said file.

Keep an eye out on your ownCloud account for the 9.0 update later this week.



from Linux User & Developer – the Linux and FOSS mag for a GNU generation http://ift.tt/1TZy3G0
via IFTTT

Amazon

Donate

Donate Towards More Raspberry PI's for Projects