Sunday, 31 January 2016

Build a better web server – Part 2

Build a file server

File servers are very useful for both home and business environments. For home, it’s a good way to have a more low-power, dedicated solution to storing your media and backing up your systems, without needing to specifically turn on your desktop machine to get the files – a desktop machine that may use more power idling than a dedicated file server.

For enterprise, it can not only be useful for backups, but also provides for off-machine networked storage for individual users that can be accessed from within and outside the network. So, let’s set a server up.

For a simple server type such as this, we’re going to go ahead and use Ubuntu Server to set up the system. This means that if you have any experience with Linux, it should be easy to maintain and install more software on if
you need to.

If you’re doing the initial setup for a home server then installing it with a monitor attached will be much easier. Burn the ISO to an installable medium or boot it over the network if you have the facilities set up, then hit return on ‘Install Ubuntu Server’ to continue.

Installation

The installation for the server edition is different from the usual graphical installer of Ubuntu – it’s a command line one, albeit with fairly straightforward options. After setting up your location, language and keyboard settings, it will try and detect your hardware for you. Give your server a name, set up your username and password, and then continue with the installation as directed.

Like the graphical Ubuntu, the server edition comes with options to automatically set up the partitions – by default, using the whole disc will create an install partition and a swap. If you want it to use a specific set of partitions, we recommend sorting them out with GParted before trying to install, and then assigning the partitions manually yourself.

Build a better web server - Part 2

During installation you’ll get some extra questions about whether you need a proxy or not; set that up as you wish and then it will ask about other services to install. As we’re using this as a file server, make sure OpenSSH is installed so you can dial in from another machine on the network and ensure that a Samba server is installed, to make sharing files and such over the network easier and compatible with any Windows machines.

Finally, it will prompt you to install GRUB. Assuming this is a dedicated file server, you can let it overwrite the master boot record. Once that’s done you will restart the system, so make sure you remove the live boot medium. After it loads up, you will be dumped into the command line to log in – as this is a server distro, there is
no desktop environment.

First steps

Now you’re into Ubuntu, we’ll first get set up to SSH into the machine. For something like a home server it’s best to set a static IP, and we can do that in /etc/network/interfaces. Open it up with:

$ sudo nano /etc/network/interfaces

… and change the primary network interface to be something like:

auto eth0

    iface eth0 inet static

        address [Desired IP]

        netmask 255.255.255.0

        gateway [Router address]

If you are using a wireless connection, make sure you switch it to wlan0 and then add in details for the SSID and password.

With the IP you’ve set, or using ifconfig to find out what the IP has been automatically set as, you can now SSH into your machine using the username and password that you set up. From a machine on the same network, type:

$ ssh [username]@[IP address of server]

Entering the password will grant you access to the same command line interface.

Shared folders

Now we can create a shared folder that the rest of the network can see and modify. First, let’s create the folder that we want to use and put it in the normal home directory, with a usual:

$ mkdir ~/networkshare

It’s best if you don’t use any spaces, to make the sharing simpler. Once done, you’ll need to create a password for Samba. Do this by entering:

$ sudo smbpasswd -a [username]

It will ask you to enter and then confirm the password. Once that’s done, and with the folder created, we can add it to the Samba server. Access the config file using:

$ sudo nano /etc/samba/smb.conf

It’s best if you don’t use any spaces, to make the sharing simpler. Once done, you’ll need to create a password for Samba. Do this by entering:

$ sudo smbpasswd -a [username]

It will ask you to enter and then confirm the password. Once that’s done, and with the folder created, we can add it to the Samba server. Access the config file using:

$ sudo nano /etc/samba/smb.conf

Go to the very end of the file and add something like the following to get the shared folder recognised by Samba:

[NetworkShare]

path = /home/[username]/networkshare

available = yes

valid users = [username]

read only = no

browseable = yes

public = yes

writable = yes

Save the file and exit, then restart Samba:

$ sudo service smbd restart

And finish by testing the setup with testparm to ensure everything runs okay.



Build a web server

Your own web server can be a useful addition to any system. If you don’t have massive loads to worry about you can install it to your own custom-built server, or if you have a lot of scalable server space then you can build it on there with a very similar software setup.

We are going to use Ubuntu Server again for this, so follow our advice on the previous pages on how to get it set up and get to a point where we can start adding Apache services. Feasibly, you could have the server be both a file and web server in this way.

1. Install Apache

Once you’ve got your server set up and can SSH in, it’s time to install the Apache web server . Do that using the following:

$ sudo apt-get install apache2

It will automatically set the domain address to the following: 127.0.0.1

2. Test server

If you have to install a GUI onto your server, you can test out that Apache is working by going to a browser in it and navigating to 127.0.0.1. Otherwise, from an external system, navigate to the IP address of your system in your browser and it should show the Apache confirmation page on-screen.

Build a better web server - Part 2

3. Install FTP

With a web server you can now use it to host a website or to access storage from the server remotely over the Internet. We can set up the latter using FTP, or in our case the secure VSFTP. Install it to the system using:

$ sudo apt-get install vsftpd

4. Configure FTP

We can access the configuration file for FTP by using nano to open /etc/vsftpd.conf (sudo nano /etc/vsftpd.conf). From here we can configure it to match our uses, but first it is necessary that we increase the security just slightly before using it properly as an FTP server, just to be on the safe side.

Build a better web server - Part 2

5. Secure your FTP

The main change to make the FTP secure is to turn off anonymous users. In the config file, look for the line with ‘anonymous_enable’. We want to change this to NO if it’s not already there, just to make sure that there is a bit more security for the FTP server and that all of your content is kept private.

Build a better web server - Part 2

6. Local use

While it will be great to access these files externally, we might as well have it so you can access the FTP internally too, just in case you prefer that to a shared folder. Find the line ‘local_enable’ and change it to YES to make sure it’s accessible elsewhere.

Build a better web server - Part 2

7. Edit files

As we are only letting people we want onto the server, we can make it so anyone logged in has write access. To do this, go back into the config file, look for the line with ‘write_enable’ and change it to YES. You may also need to uncomment it by removing the hash.

8. FTP Folder

If you didn’t create a shared folder for the previous server tutorial, now is a good time to create a dedicated directory for this. In the home folder, use mkdir to create a directory called whatever you wish for the FTP server to be able to access it.

9. Restart server

Once the config file has been fully edited and the folder is created, it is now time to start using it. Restart the FTP server using sudo service vsftpd restart and you will start to be able to access the folder. Any changes that you make to the configuration will require this restart to become active.

Build a better web server - Part 2



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

Friday, 29 January 2016

Fingerprint Scanner for Laptop and Raspberry Pi (or Giving the Finger to Your Computer)

We’ve got two hacks in one from [Serge Rabyking] on fingerprint scanning. Just before leaving on a trip he bought a laptop on the cheap. He didn’t pay much attention to the features and was disappointed it didn’t have a fingerprint scanner. Working in Linux he uses sudo a lot and typing the password is a hassle. Previously he just swiped his finger on the scanner and execution continued.

IMG_4296He found a cheap replacement fingerprint scanner on hacker’s heaven, also known as eBay. It had four wires attached to a 16 pin connector. Investigation on the scanner end showed the outer pair were power and ground which made [Serge] suspect it was a USB device. Wiring up a USB connector and trying it the device was recognized but with a lot of errors. He swapped the signal lines and everything was perfect. He had sudo at his finger tip.

Next he wonder if it would work with a Raspberry Pi. He installed the necessary fingerprint scanning software, ran the enrollment for a finger, and it, not terribly surprisingly, worked.

On Linux the command fprintd-enroll reads and stores the fingerprint information. By default it scans and saves the right index finger but all ten fingers can be scanned and stored. Use libpam-fprintd to enable account login using a finger. Anyone know how you can trigger other events using a different finger? A quick search didn’t turn up any results.

In true hacker style, [Serge] created his own fingerprint reader from a replacement part. But you can jump start your finger usage by purchasing one of many inexpensive available readers.


Filed under: computer hacks, Raspberry Pi, security hacks

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

My Pi Project – RasPiViv

So, what do you keep in the vivarium?

Right now I have seven poison dart frogs – they’re frogs from South America that, in the wild, excrete poison alkaloids, but in captivity, because their diet is just fruit flies, they can’t produce any poison. They’re something I’ve been interested in for quite a long time. I think I saw them first when I was in grade school at a trip to the Denver zoo, and I just thought they were the coolest animals I’d ever seen in my life. I’ve wanted to keep them since then but the opportunity never came up – they’re kinda rare – until I found a breeder on Craigslist who has an incredible collection and he breeds them to support his hobby. So right now I have a total of seven: two blue poison dart frogs, which I think could be a breeding pair, and I recently obtained five yellow-banded poison dart frogs.

What kind of requirements do you have for the vivarium, then?

The temperature is really important, which a lot of people have trouble with because your house temperature is going to be about the same as an enclosed box, give or take, as lighting can heat things up. But you have to maintain specific temperatures between about 75 and 85 degrees, and the humidity is even more important because the frogs use the humidity to thermoregulate, kinda like how we sweat.

So basically, what I needed was a way to monitor and regulate the humidity. I looked around online for a couple of days trying to come up with a solution – a lot of people use little timers, and there are a couple of systems that are made for this but they don’t do very much.

Poison dart frog 2

What hardware did you use to make your own solution?

Well, the Raspberry Pi is set up as a LAMP server. I started playing around with the DHT22 temperature-humidity sensor – originally I just wanted to monitor that, the temperature and the humidity, but then I got into using relays to control the lighting and it just progressed further and further. I was just making this for myself and I posted on a forum. Then a lot of people seemed really interested, so I said I’d clean things up and throw together a guide (see www.raspiviv.com).

So the temperature and humidity sensors are read every 60 seconds and logged into a database. Using WiringPi and Adafruit’s DHT22 sensor (and the driver for it, which is brilliant and works really well), lighting is controlled by regular relays or relay modules, and the fan is just a basic transistor switch. The main idea behind the fan is that if the atmosphere is too saturated with water then the frogs can’t thermoregulate. So the database is read every five minutes, and when it reaches 95% humidity it then kicks on the fan to blow in some fresh air.

RPi vivarium controller 2

Do you SSH in to control all this or do you have a web interface?

Yeah, there’s a whole web interface where you can check out the current readings. Check out the Demo section on my website and the first thing that pops up is my blue poison dart frog vivarium. It gives you the current temperature and humidity, and then also the readings for the last hour. If you click on the icon that looks like a grid of buttons (manual controls), you can manually control your lighting, any misting system or fans you have – essentially, for any component that you want to control, it’s just a matter of getting a relay module and wiring it up.

Are you planning to upgrade the RasPiViv software at any point?

Yeah, I am hoping to. I started work on this in my downtime and got insanely busy, so  unfortunately I haven’t been able to do a lot with it. I’m hoping to get some RF power outlets soon so that, rather than wiring up a little power outlet box, you can just use these prebuilt outlets that you plug into your wall and they give you a little remote control. I am hoping to implement some wireless stuff and I’d definitely like to make it more user friendly, rather than people manually adding cron jobs to things. I’d like them to be able to do it through the browser interface, stuff like that.

What you don’t see in the demo is that there’s also a login system – you can make an account and keep it secure – so I want to give people that and I’ll probably run a tutorial for setting it up. I’ve been playing around with the Raspberry Pi camera module and hoping to include it, so now  we have a Raspberry Pi 2 that is a lot more capable, it could potentially pull off some kind of live camera that you can watch as well as all the other stuff that it does. 



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

Build a better web server – Part 1

Hacking a coffee machine

The folks at Q42 write code, lots of it, and this implies the copious consumption of coffee. In more primitive times, an actual human person would measure how many cups were consumed and update a counter on their website once a day. That had to be fixed, obviously, so they hacked their coffee machine so it publishes the amount of coffee being consumed by itself. Their Jura coffee machine makes good coffee, but it wasn’t hacker friendly at all. No API, no documentation, non-standard serial port and encrypted EEPROM contents. It seems the manufacturer tried every trick to keep the hackers away — challenge accepted.

The folks at Q42 found details of the Jura encryption protocol from the internet, and then hooked up a Raspberry-Pi via serial UART to the Jura. Encryption consisted of taking each byte and breaking it up in to 4 bytes, with the data being loaded in bit positions 2 and 5 of each of the 4 bytes, which got OR’ed into 0x5B. To figure out where the counter data was stored by the machine in the EEPROM, they took a data dump of the contents, poured a shot of coffee, took another memory dump, and then compared the two.

Once they had this all figured out, the Raspberry-Pi was no longer required, and was replaced with the more appropriate Particle Photon. The Photon is put on a bread board and stuck with Velcro to the back of the coffee machine, with three wires connected to the serial port on the machine.

If you’d like to dig in to their code, checkout their GitHub repository. Seems the guys at Q42 love playing games too – check out 0h h1 and 0h n0.

Thanks [Max] for letting us know about this.


Filed under: cooking hacks

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

Thursday, 28 January 2016

Home theatre distros group test

We narrow down the very best home theatre distros out there to make your choice a little easier.

OSMC

Available from: https://osmc.tv/

Home theatre distros group test

Ease of use

While OSMC has a different look to the default (and probably best) Kodi theme, it’s essentially the same in terms of moving through the menus. There’s also a specific ‘My OSMC’ menu with extra settings and system information not found in the normal Kodi settings menu, although it could use more work on the UX.

Compatibility

It’s built on Kodi so has all of Kodi’s excellent playback and codecs. You can throw any type of media at it and it will most likely be able to play it and even access any other features it has, like subtitles or language tracks to name just a few. It also has a fine selection of PVR and web-content apps to use as well.

Speed

On the Raspberry Pi 2, OSMC runs extremely well with none of the small hitches and bits of lag that are common with Kodi on the original Raspberry Pi. It loads fairly quickly as well, although the update software can slow down the interface while it’s running, sometimes as far as not registering input for a few moments, which is annoying but
not really detrimental.

Updates

OSMC has its own updating software that you can set on a schedule and, with the speed section in mind, it is best to aim for a time when you won’t be using it. However, you can also do it manually if there is a new build that you absolutely need right now.

Overall

OSMC needs a little more work before it really becomes a proper alternative to the likes of OpenELEC – or even its predecessor Raspbmc. Keep an eye on it over the next year though, as there’s a lot of potential.

7/10

XBian

Available from: http://www.xbian.org/

Home theatre distros group test

Ease of use

One of the most noticeable things missing from Kodi is a decent setup wizard. Recent versions have added some quick screens to help you navigate the interface better, but when you have to go digging in menus to set up the Wi-Fi for the first time, it gets frustrating. XBian provides an excellent first-time setup wizard along with the rest of Kodi’s otherwise great UX.

Compatibility

Again, with a full Kodi base XBian runs absolutely everything, or at least everything that matters to the vast majority of media consumers. We briefly mentioned the web services in the OSMC part of this group test; this includes YouTube (albeit a little rough) and other video services, podcast apps, RSS feeds and more.

Speed

XBian is probably the slowest to load up out of the three Kodi implementations in this test – the difference is not much in the grand scheme of things, but when OpenELEC launches pretty instantly, it’s a much more noticeable lag. Otherwise, interface navigation is fine and playback is nicely optimised.

Updates

You can actually update XBian from the setup wizard, and when it’s updating, the interface works just fine. It also has a scheduling feature like the others and lets you choose which packages to update. It gives a verbose updating screen which is basically just apt’s output when you choose manual update, letting you know exactly what’s going on.

Overall

XBian is great, with a straightforward first-time setup that won’t have you digging around other menus. Though there is a slight delay in loading it up from boot, the otherwise great Kodi experience is worth it.

9/10

OpenELEC

Available from: http://openelec.tv/

Home theatre distros group test

Ease of use

OpenELEC is basically pure Kodi, meaning the same great Kodi UX is part of the package. It also has a small setup wizard that enables you to activate some extra options on first boot, although once again, you may have to dig through menus to get to wireless network settings. OpenELEC’s custom settings menu is also much more in-line with the rest of the interface.

Compatibility

When a core software feature is the same on three pieces of software, it’s difficult not to repeat ourselves. If you haven’t already gathered from the first two reviews in this group test, Kodi is great in this regard and we love it. We still love it even after having to write about it for the third time in two pages!

Speed

OpenELEC starts up probably the fastest of the lot, and otherwise has the excellent Kodi interface speed when used on the Raspberry Pi 2. The latest versions of OpenELEC are optimised for the new processor so you get none of the lag experienced on the old one, especially after scraping all of the assets for your shows.

Updates

There’s a special updating system that OpenELEC employs to keep your software up to date; similar to the others, it’s on a schedule and you can also perform a manual one if you wish. It’s not quite as verbose as XBian when doing it manually, but it does work very well and it’s useful to have both options available.

Overall

OpenELEC is still the best ‘default’ packaging of Kodi for embedded systems and other computers, but due to the extras XBian adds, it feels lacking in comparison now. Still, if you’re already using it there is little reason to change.

8/10

Raspbian

Available from: http://ift.tt/1FlZW23

Home theatre distros group test

Ease of use

Raspbian is great – it really is – but it’s not optimised for use on your TV particularly well. Sure, the newer menus have bigger icons and such, but it’s far better suited for a desktop environment. The best way to play video without installing Kodi is through the command line, which makes it even less user friendly.

Compatibility

Some more basic, open formats such as AVI and MP4 work just fine in both the command line video player (OMXPlayer) and the basic installation of Kodi that you can set up. However, you need to start hunting down other codec packs to play anything else on Kodi itself. OMX doesn’t work with normal remotes either.

Speed

The slowest to load and the slowest to set up, although navigating traditional web services is a lot faster than with some of the hacked-together apps available for Kodi. Still, it’s slow for its core media-playing purpose, even in an installation of Kodi, due to the rest of the bloat inherent with the unoptimised system.

Updates

All handled via the command line in the standard desktop, while it’s good and thorough and will probably have the most updated software of the bunch, it’s a little more tricky to access as it has to be via the command line and will also update software you probably don’t even want for the purposes of a HTPC.

Overall

Raspbian is really unsuited to your HTPC needs. It’s not designed to either, but it was interesting to see if the extra UX considerations that were added this year made it more suitable for the task. Unfortunately, they didn’t.

5/10



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

Get the new edition of The Python Book

The Second Edition of The Python Book is out now, with more projects and tutorials to help you get to grips with the versatile and simple-to-learn programming language.

038-039_TPB_02E 074-075_TPB_02E

You can get your copy now from the Imagine Shop for £14.99, as well as newsagents and supermarkets.



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

Old School Gauges Let You Know Which Way the Wind Blows

When your passion is a sport that depends on Mother Nature’s cooperation, you need to keep a close eye on weather conditions. With this in mind, and not one to let work distract him from an opportunity to play, [mechanicalsquid] decided to build a wind-monitoring gauge with an old-school look to let him know when the wind is right for kitesurfing.

old-school-meter-for-windBeing an aficionado of big engineering helped [mechanicalsquid] come up with a style for his gauge – big old dials and meters. We hesitate to apply the “steampunk” label to every project that retasks old technology, but it sure looks like a couple of the gauges he used could have been for steam, so the moniker probably fits here. Weather data for favorite kitesurfing and windsurfing locales is scraped from the web and applied to the gauges to indicates wind speed and direction. [mechanicalsquid] made a valiant effort to drive the voltmeter coil directly from the Raspberry Pi, but it was not to be. Servos proved inaccurate, so steppers do the job of moving the needles on both gauges. Check out the nicely detailed build log for this one, too.

For more weather station fun be sure to check out this meter-based weather station with a slightly more modern look. And for another build in the steampunk style, this vintage meter and Nixie power display is sure to impress.


Filed under: classic hacks, misc hacks

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

Sunday, 24 January 2016

Cricket Scoreboard is a Big Win for Novice Hackers

The game of cricket boggles most Americans in the same way our football perplexes the rest of the world. We won’t even pretend to understand what a “wicket” or an “over” is, but apparently it’s important enough to keep track of that so an English cricket club decided to build their own electronic scoreboard for their – pitch? Field? Help us out here.

This scoreboard build was undertaken by what team member [Ian] refers to as some “middle-aged blokes from Gloucestershire” with no previous electronics experience. That’s tough enough to deal with, but add to it virtually no budget, a huge physical size for the board, exposure to the elements, and a publicly visible project where failure would be embarrassingly obvious, and this was indeed an intimidating project to even consider. Yet despite the handicaps, they came up with a great rig, with a laser-cut acrylic cover for a professional look. A Raspberry Pi runs the LED segments and allows WiFi connections from a laptop or phone in the stands. They’ve even recently upgraded to solar power for the system.

And we’ll toot our own horn here, since this build was inspired at least in part by a Hackaday post. The builders have a long list of other links that inspired or instructed them, and we think that says something powerful about the hacker community that we’ve all been building – a group with no previous experience manages a major build with the guidance of seasoned hackers. That’s something to feel good about.


Filed under: misc hacks, Raspberry Pi

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

Saturday, 23 January 2016

Finally, a Power Meter Without Nixies

We’ve had quite a spate of home-brew energy meters on the tip line these days, and that probably reflects a deep inner desire that hackers seem to have to quantify their worlds. Functionally, these meters have all differed, but we’ve noticed a distinct stylistic trend toward the “Nixies and wood” look. Ironically, it is refreshing to see an energy meter with nothing but a spartan web interface for a change.

Clearly, [Tomasz Salwach] had raw data in mind as a design goal, and his Raspberry Pi-based meter delivers. After harvesting current sensing transformers from a bucket of defunct power meter PC boards, [Tomasz] calibrated them with a DIY oscilloscope and wired them and the voltage sensors up to an STM32 Nucleo development board. Data from the MCU goes to the Pi for processing and display as snazzy charts and GUI elements served internally. [Tomasz] was kind enough to include a link to his meter in his tip line post, but asked that we not share it publicly lest HaD readers love the Pi to death. But we can assure you that it works, and it’s kind of fun to peek in on the power usage of a house in Poland in real time.

It’s a nice project that does exactly what it set out to do. But if you missed the recent spate of Nixie-based displays, check out this front hallway meter or this one for a solar-power company CEO’s desk.


Filed under: green hacks, home hacks

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

Friday, 22 January 2016

How to Use Lidar with the Raspberry Pi

The ability to inexpensively but accurately measure distance between an autonomous vehicle or robot and nearby objects is a challenging problem for hackers. Knowing the distance is key to obstacle avoidance. Running into something with a small robot may be a trivial problem but could be deadly with a big one like an autonomous vehicle.

My interest in distance measurement for obstacle avoidance stems from my entry in the 2013 NASA Sample Return Robot (SRR) Competition. I used a web camera for vision processing and attempted various visual techniques for making measurements, without a lot of success. At the competition, two entrants used scanning lidars which piqued my interest in them.

A lidar is a laser range measurement device. The name is a combination of the terms LIght and raDAR and not, as commonly suggested, an acronym derived in a manner similar to its forerunner, “RAdio Detection And Ranging”. The term was first used in 1963 according to Merriam-Webster. Some of the early use of lidar was measuring clouds and the surface of the moon by Apollo 13. As lasers were reduced in size, other uses were found, including as a rangefinder for military purposes.

Commercial Lidar Neato Lidar

A single laser beam can only provide the range to a single object. Just as aircraft control radar swings a beam through the sky, a scanning lidar sweeps the laser. The application of lidar for autonomous mobile devices requires scanning of a wide area both vertically and horizontally to provide a point cloud of distance measurements. Something similar might be done with an infra-red sensor, as we’ve seen previously but the accuracy is not as good as with a laser.

Distance measurement can be done in multiple ways but there are two principal ones used. One measures the time of flight of a laser pulse while the other uses the angle of deflection of the laser beam.

Time of Flight Measurement

You’re familiar with how basic radar and sonar works – send out a pulse and measure the time it takes to receive the return signal. The time divided by the speed of light or sound gives you the distance the signal traveled out and back. Divide that by two to get the distance to the object. That’s time of flight (ToF) measurement.

As you might suspect things get tricky given the speed of light. A pioneer in computers, Rear Admiral Grace “Amazing Grace” Hopper would hand out 11.80” pieces of wire to demonstrate the distance light travels in a nanosecond in vacuum. With robots that is the magnitude of the distance we’re interested in measuring. It’s difficult to measure less than a meter sending out just a pulse and timing the return signal because the signal returns in about 7 nanoseconds.

One technique around this is to continuously modulate the signal by amplitude or frequency. The phase difference between the transmitted and received signals is proportional to the distance to the object. A lidar using modulation can measure down to centimeters.

There are a number of commercial providers of ToF based scanning lidars but the price is a bit higher than the most hobbyist’s would spend. A relatively new entrant, PulsedLight, offered a single beam ToF lidar within the price range of hackers but their suppliers are all back ordered.

tof triangulation

 

Triangulation

The triangulation lidar uses the same technique as the Sharp infra-red distance measuring sensors which hackers have been using for years. The transmitter is a single source but the receiver is a 1 or 2 dimensional array of receivers. The offset of the receiver elements from the transmitter creates the baseline of a triangle. The outgoing and return signal are the other two sides of the triangle. Simple trigonometry provides the distance from the baseline to the object.

The Optical Society describes these and other techniques used for measuring distance.

Neato Robotics Vacuum Lidar

What I didn’t know when competing in the 2013 NASA SRR is that Neato Robotics released a vacuum cleaner in 2010 using a scanning lidar to sense the vacuum’s surroundings. This allows the robot to avoid obstacles instead of bumping into them as previous robot vacuum’s were doing.

XV-11_Lidar-400x240Sparkfun did a tear down of the vacuum and investigated the lidar. A long discussion starting in November of 2010 ensued on the Trossen Robotic forum as hackers dissected the vacuum with much attention to the lidar. There were even small prizes offered for hacking the lidar.

Unfortunately a number of the links in that thread no longer exist but it is still worth reading since many details are laid out in the messages. Some other threads on the forum have additional information. One especially interesting find is a research paper that preceded the Neato lidar but served as the basis for the final design. It outlined the details necessary for Neato to create an engineered product.

The good news is a wiki exists with a summary of information about the vacuum and the lidar. One of the active hacking participants, [Nicolas “Xevel” Saugnier] created a small USB interface board to power the lidar and connect to its serial interface. In the summer of 2014 I obtained a couple of the lidar units and the boards as I looked toward entering the 2015 NASA SRR. I got the lidar units working using [Xevel’s] Python software and packages available in the Robot Operating System.

The scanning lidar allowed Neato Robotics to implement Simultaneous Localization and Mapping (SLAM) using the distance measurement data. This allows the robot to plan the cleaning path rather than using the previous bump and random movements, a Drunkard’s Walk, of earlier vacuums. This allows the Neato to completely cover a room more quickly. Note in this video of a Neato demonstration how the robot builds a map of where it’s been and the obstacles it encounters. Especially note how it uses the lidar data to neatly circle the one obstacle.

Pi 2 and Lidar

I’m still very interested in robots although I’ve given up on the SRR contest. The lidars have been sitting on the shelf luring me like mythical Sirens. I finally succumbed to their call when I realized the lidar serial interface was a perfect match to a Raspberry Pi’s since both work at 3V3 levels. This would eliminate the USB interface. A similar effort is [Thomas Jesperson’s] in 2014 who used an STM32F429 board and produced a video of the lidar in action.

Lidar Physical

The lidar is a sealed unit with a motor hanging from one end. The motor drives a turret that rotates at around 300 rpm. The turret contains the laser and receive sensor and by spinning provides a 360 degree scan of the surrounding area. The laser and receive sensor have two optical ports out of the turret. There are two short cables with JST connectors coming from the lidar. A two pin connector provides power to the motor. A four pin connector provides 5V power to the control circuits and the 3V3 serial interface. The pinouts are:

Motor Cable
Red: 3V3 or PWM
Black: Ground
Interface Cable
Black: Ground
Red: 5V
Brown: RX
Orange: TX

In the vacuum, the motor is powered by a 12V source using PWM at around a 25% duty cycle. This means the motor needs around 3V to run at the right speed and subsequent testing by the hackers showed this is true. The USB interface board runs the lidar from the 5V input from the USB connector using PWM controlled by a a PID (Proportional Integral Differential) loop to maintain the motor’s speed. Why use PWM and PID? To maintain a constant RPM for the spinning turret as it wears and collects dirt, dust, and other detritus. In my testing I noted that the motor will turn the turret in either direction depending on the positive and negative connection. The interface still works fine but the sequence of the data points is going to be reversed. Normally the turret turns counter-clockwise.

A word of caution: in some early units the interface used 3V3 so connecting them to 5V may destroy the interface.

My original hook-up between the Pi and the lidar was quick and dirty. I connected the motor to the Pi’s 3V3 output and it worked. The output from the Pi 3V3 is limited to 50 mA by the specifications and the lidar Wiki says the motor would draw 64 mA. I measured mine and it drew considerably more. I also connected the interface’s TX pin to the Pi’s RX (pin 10). Using CuteCom under Raspbian Jessie I could read the data when the turret was manually spun. With those basic tests out of the way it was time to get a little more serious.

I elected to use a ULN2803A Darlington Transistor Array I found in my parts cabinet to drive the motor. This IC easily handles the current needed to drive the motor and includes the protective diodes required for driving an inductive load. I didn’t intended to do PWM of the motor but did want to turn it off and on. I connected the Pi’s 5V on pin 2 to the red wire on the motor connector. The black wired connected to the ULN2803A  through a 15 ohm resistor to drop the voltage. This setup low-side configuration for controlling the motor. The interface cable is connected to the 5V, ground, and RX pins on the Pi.

circuit layout 600 high pi2 lidar schmatic 600

To test the motor control I used the mapping of the GPIO pins to the file system directory /sys/class/gpio. Each GPIO can be controlled here once the pin is exported. Commands can then set pins the direction and turn the pin on and off. The commands I used controlled GPIO 18 (pin 12):

echo 18 > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio18/direction
echo 0 > /sys/class/gpio/gpio18/value
echo 1 > /sys/class/gpio/gpio18/value

The ‘0’ and ‘1’ when echoed turn the pin off and on, respectively. This worked and I could see the data using CuteCom.

One interesting result occurs if you are connected to the serial port and then apply power to the interface. The lidar generates a welcome message:

Piccolo Laser Distance Scanner
Copyright (c) 2009-2011 Neato Robotics, Inc.
All Rights Reserved
Loader\0x09V2.5.15295
CPU\0x09F2802x/c001
Serial\0x09KSH34313AA-0140854
LastCal\0x09[5371726C]
Runtime\0x09V2.6.15295

Also, if you manually spin the turret, a message saying “Spin” appears and advises there is a command capability available by sending a break or three esc characters. Information on the commands is available on the Wiki.

Lidar Software

Now to create some rough software to see how all this works. Of course I used C++ so I installed the tool chain for the Pi 2 and find that the compilation speed is sufficient for development. I started using the Geany programming editor and makefiles; a setup I learned about while working with the Python code for the lidar. It handles multiple programming languages and I’ve adopted it as a general purpose text editor on Ubuntu and Raspian. But I eventually abandoned Geany and installed Eclipse CDT on the Pi when it wouldn’t properly reformat the C++ code after editing. Eclipse works surprisingly well on the Pi. I was actually a little disappointed in the switch since with Geany I was re-learning how to work with makefiles, a skill I’ve lost working with Eclipse.

While looking for information on programming the GPIO with C++ I found the WiringPi library by [Gordon Henderson]. It not only supports raw GPIO programming but supports many Pi daughter boards. An additional appeal to me is it has a serial port interface so I didn’t have to get into the details of that on Linux, which would have been new to me. Eventually, I even used its simple thread capability to handle an absurdly minimal user interface. [Gordon] also has a utility you should check out for controlling pins from the command line more completely than writing to the directories as I showed above.

The final piece I found in WiringPi is the ability to do hardware PWM on the one GPIO pin capable of it on the Pi. That is GPIO 18. I’d originally used GPIO 4 (pin 7) to control the motor but switched when I found this capability. The code currently sets a constant value for the PWM but eventually I want to add (and write an article about) a PID (Proportional Integral Differential) control system loop to maintain constant speed. Setting up WiringPi, a thread and the the PWM on GPIO 18 is easy:

        wiringPiSetup();
        piHiPri(10);  // set program priority to run better
        piThreadCreate(key_read);

        pinMode(turret, PWM_OUTPUT);
        pwmWrite(turret, 950);

The thread is there simply to stop the program when any key is entered and return hit. When run is set to false, the main thread reading the serial input quits and the program exits after turning off the turret. The actual thread is dirt simple:

PI_THREAD(key_read) {
        cin.get();
        run = false;
        return 0;
}

Reading the serial input is simple, just reading characters, but the data itself, while straightforward, requires a little bit banging. There are 360 samples per revolution of the turret so the amount of data at 5 revolutions per second is massive. There are 90 packets each containing four data points. Each point is represented by four bytes of data: distance, signal strength, invalid distance bit, and invalid strength bit. In addition, each packet begins with a start byte, an index byte which is the packet number, and two bytes for the turret rotation speed. The packet ends with two checksum bytes. Here’s how I mapped that data into structures:

        struct DataPoint {
                bool invalid_data;
                bool bad_strength;
                float distance;
                unsigned int strength;
        };

        struct Block {
                unsigned int index;
                unsigned int speed;
        };

I didn’t get into storing the data packets, just reporting them to verify I was seeing good data and my calculations looked good. The distance data is an integer reported in millimeters which I converted to inches. The code for the checksum is on the Wiki but I haven’t implemented it yet.

Wrap Up

This is just the start of working with the Neato lidar but a good one. The hardware works well and the basics of the software are in hand. I can get the data and see that it is valid. The WiringPi library is a good find for continuing in my efforts with the Pi.

Next steps are to get the checksum routine working, expand the so-called user interface to allow controlling operation of the turret and adding a PID loop to maintain a constant speed of rotation. Since the UNL2803A chip is there I’ll use it to control the power to the interface. I also want to look at cross-compiling the code from my desktop and doing remote debugging. As I make those changes I’ll organize the code into classes and see how I can use it on a robot.


Filed under: Hackaday Columns, how-to, Raspberry Pi, robots hacks

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

Monday, 18 January 2016

Custom Siri Automation with HomeKit and ESP8266

Knowing where to start when adding a device to your home automation is always a tough thing. Most likely, you are already working on the device end of things (whatever you’re trying to automate) so it would be nice if the user end is already figured out. This is one such case. [Aditya Tannu] is using Siri to control ESP8266 connected devices by leveraging the functionality of Apple’s HomeKit protocols.

HomeKit is a framework from Apple that uses Siri as the voice activation on the user end of the system. Just like Amazon’s voice-control automation, this is ripe for exploration. [Aditya] is building upon the HAP-NodeJS package which implements a HomeKit Accessory Server using anything that will run Node.

Once the server is up and running (in this case, on a raspberry Pi) each connected device simply needs to communicate via MQTT. The Arduino IDE is used to program an ESP8266, and there are plenty of MQTT sketches out there that may be used for this purpose. The most recent example build from [Aditya] is a retrofit for a fiber optic lamp. He added an ESP8266 board and replaced the stock LEDs with WS2812 modules. The current version, demonstrated below, has on/off and color control for the device.

[via reddit]


Filed under: home hacks, Network Hacks

from raspberry pi – Hackaday http://ift.tt/208PWmm
via Hack a Day

Friday, 15 January 2016

The Stork Looks Different Than We Thought

What the Internet of Things really needs is more things, and the more ridiculous the better. At least, that’s the opinion of [Eric] who has created a tongue-in-cheek gadget to add to the growing list of connected devices. It’s a Bluetooth-enabled pregnancy test that automatically releases the results to the world. Feeling lucky?

The theory of operation is fairly straightforward. A Bluetooth low-energy module is integrated into the end of a digital pregnancy test. These tests have a set of photo detectors to read the chemical strip after the test is conducted. If the test is positive, the module sends a signal to a Raspberry Pi which tweets the results out for the world to see. It also has an option to send a text message to your mom right away!

[Eric]’s project to live-tweet a pregnancy test also resulted in a detailed teardown of a digital pregnancy test, so if you need any technical specifications for pregnancy tests (for whatever reason) his project site has a wealth of information. He does note that his device can be used on other similar devices with directly driven LCD screens, too. The fun doesn’t end there, though! Once the pregnancy is a little further along you’ll be able to get the baby on Twitter, too.


Filed under: lifehacks

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

Thursday, 14 January 2016

My Payphone Runs Linux

For the 20th anniversary of the Movie “Hackers” [Jamie Zawinski], owner of DNA Lounge in San Francisco, threw an epic party – screening the movie, setting up skating ramps and all that jazz. One of the props he put up was an old payphone, but he didn’t have time to bring it alive. The one thing he didn’t want this phone to do was to be able to make calls. A couple of weeks later, he threw another party, this time screening “Tank Girl” instead. For this gathering he had enough time to put a Linux computer inside the old payphone. When the handset is picked up, it “dials” a number which brings up a voice mail system that announces the schedule of events and other interactive stuff. As usual, this project looked simple enough to start with, but turned out way more complicated than he anticipated. Thankfully for us, he broke down his build in to bite sized chunks to make it easy for us to follow what he did.

This build is a thing of beauty, so let’s drill down into what the project involved:

sewing-needles-making-connectionsKeypad

His plan was to connect wires from the payphone keypad to a USB numeric keyboard. These wires were soldered to the through hole via’s on the old payphone keypad PCB. Hooking up these wires to the USB keypad required drilling 0.5mm holes spaced 1mm apart using his Dremel on a piece of acrylic, lots of sewing needles, super glue, Sugru and a couple of days to track down dodgy connections.

Handset

Working late at night, and without a TRRS jack handy, he chopped off an old cable and somehow managed to solder its ultra-thin wires to a pin header. A corresponding socket was soldered to the four wires from the headset for the speaker and the microphone. And lots of epoxy goop to hold it all together.

Computer

The Raspberry Pi 2 B doesn’t have an audio input, so he needed a Cirrus Logic audio hat for the Pi. He had trouble getting ALSA to tango with the Audio hat, so he eventually wrote some of his own code to detect keyboard buttons and play or record messages.

Hook switch

Finally, he needed to detect the hook switch status. Sounds simple, but it took him a few more days to get it to work. Turns out the audio hat was causing all unused GPIO pins to act “floating” no matter which way he tried. Finally, after trial and error, he bent one pin on the Pi so it wouldn’t connect to the audio hat, and wired the hook switch to it directly.

Software

His main code was in Perl. In the version of Raspbian he was using, reading pin states worked in Python, but not in Perl – they would always appear floating. Since the underlying BCM2835 library is written in C, he tried writing his code in C, and that didn’t work either. As usual, python was doing its magic under the hood. So he called the Python script from his Perl code to do that, but not before running everything under “root” since that was the only way he could read the status of the pins. Take a closer look by reading section 3 of his blog post, which includes a link to the code.

He had thoughts on adding more features, but having got this much working, he decided to wrap it all up before things headed south. We think there’s more than enough accomplished here for him to be proud of. If you need some introduction to [jwz] as he is known, he’s the guy who worked on emacs, Netscape and Mozilla and has been hacking away since 1985.

Thanks [dr Memals] for sending in this tip.


Filed under: phone hacks, Raspberry Pi

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

PS/2 Keyboard for Raspberry Pi

A lot of people can bake a cake. Sort of. Most of us can bake a cake if we have a cake mix. Making a cake from scratch is a different proposition. Sure, you know it is possible, but in real life, most of us just get a box of cake mix. The Raspberry Pi isn’t a cake (or even a pie), but you could make the same observation about it. You know the Raspberry Pi is just an ARM computer, you could program it without running an available operating system, but realistically you won’t. This is what makes it fun to watch those that are taking on this challenge.

[Deater] is writing his own Pi operating system and he faced a daunting problem: keyboard input. Usually, you plug a USB keyboard into the Pi (or a hub connected to the Pi). But this only works because of the Linux USB stack and drivers exist. That’s a lot of code to get working just to get simple keyboard input working for testing and debugging. That’s why [Deater] created a PS/2 keyboard interface for the Pi.

Even if you aren’t writing your own OS, you might find it useful to use a PS/2 keyboard to free up a USB port, or maybe you want to connect that beautiful Model-M keyboard without a USB adapter. The PS/2 keyboard uses a relatively simple clock and data protocol that is well-understood. The only real issue is converting the 5V PS/2 signals to 3.3V for the Pi (and vice versa, of course).

The code bit bangs the PS/2 clock and data, unlike some other projects that tie up the UART (disallowing use of the serial console for development). [Deater] says the code might work with a mouse with a little work. The challenge is handling the data rate in the face of unknown interrupt latencies. The USB port on [Deater’s] PCB, by the way, allows you to connect some USB keyboards that fall back to PS/2 mode with an adapter. You can’t just plug any USB keyboard into it.

We’ve covered PS/2 interfacing to different platforms before and even saw a keyboard converted to a drum machine. You can see a video about the construction of the Raspberry Pi interface below.


Filed under: ARM, peripherals hacks, Raspberry Pi

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

Monday, 11 January 2016

PiNoculars – A Farseeing Pi Camera

The Raspberry Pi camera provides a 5 megapixel resolution with still images of up to 2592 x 1944 and multiple video modes including 2592 x 1944 at 15 frames per second. With it being mounted on a small board it is ideal for using in hacks. [Josh Williams] mounted the camera on the lens of binoculars to capture some startling images, including this squirrel.

FTWLOS5IHLVN3TO.MEDIUM FVRY2O0IHLVN4RE.SMALL

The camera is installed on a custom, laser cut mount that fastens to one eyepiece of the binoculars. The Pi itself is mounted above the binoculars. An LCD touch screen from Adafruit allows [Josh] to select the image and adjust the focus. Snapping pictures is done using either the touch screen or switches that come with the screen.

The Instructable [Josh] wrote is extremely detailed and includes two different ways of mounting the Pi on the binoculars. The quick and dirty method just straps on with tape. The highly engineered method delves into Inkscape to design a plywood mount that is laser cut. For portable operation, [Josh] uses one of the ubiquitous battery packs meant for USB charging.

Basic setup of the Pi and camera are in a video after the break.

 


Filed under: digital cameras hacks, Raspberry Pi, video hacks

from Hackaday » raspberry pi http://ift.tt/1P24xrN
via Hack a Day

Sunday, 10 January 2016

Nixie Tubes Adorn Steampunk Solar Power Meter

The appeal of adding Nixie tube displays to a project seems to know no end. First it was Nixie clocks, now it’s Nixie power meters, with the latest addition being this Nixie-Steampunk hybrid solar power monitor.

We’re suckers for a project with a vintage look, and this one pushes all the buttons. Built on commission for a solar power company CEO’s office, [Paul Parry]’s build is based on a Depression-era Metropolitan-Vickers combined voltmeter and ammeter. The huge meters with mirrored scales and the rich wood of the case – our guess is that it’s mahogany – made a great starting point, and after some careful hole drilling, nine IN-18 Nixies were sprouting from the case. A strip of RGB LEDs below decks added the requisite backlighting of the envelopes, and a Raspberry Pi was enlisted to interpret data from the company’s solar farm and drive the tubes and the meters. The project was capped off with a new finish on the case and a couple of fancy brass plaques.

[Paul] sent us the tip for his build after seeing the last power meter we covered, and we have to say they’re both great looking and functional projects. Keep the Nixie projects coming!


Filed under: green hacks, Raspberry Pi

from Hackaday » raspberry pi http://ift.tt/1N1of5u
via Hack a Day

Amazon

Donate

Donate Towards More Raspberry PI's for Projects