Why a Raspicam isn’t better than a USB webcam.

[Print This] By mjhammel ~ September 11th, 2016. Filed under: General, Linux, Software Development, Hardware, PiBox, Raspicam.

So here’s my use case:  I need a camera that is easily positioned away from the Raspberry Pi and can stream via mjpeg-streamer.  Not huge requirements.  Here is why the Raspicam doesn’t fit that use case.

I’ve received a camera with the wrong cable from a Chinese distributor via Amazon.  I discovered the cable was not reversed on the ends like it should be (the blue strip was on the same side on both ends).  So I ordered a new cable from Adafruit.com.  The new cable arrived on Friday and I installed it.  I built a new mjpeg-streamer with raspicamera support and installed it.  I updated my config.txt as required to enable the camera.

It still doesn’t work.  After a bit of research I can see no reason to want to use this camera unless you were trying to embed a camera in a box with the Pi.  I’m not trying to do that.  Let’s look at the reasons why you won’t want this camera vs a USB webcam.

  1. The cable:  It’s a ribbon cable that is stiff enough that the weight of the camera module isn’t enough to counter the cables desire to flip it out of position.  A USB cable is more forgiving and the USB cameras weight generally overrides the stiffness of the cable.  Bending the cable into submission is an option, but dangerous with ribbon cables.
  2. The connectors:  The ribbon cable connector is tricky to plug into the board compared to a USB camera.  The same connector has the same problem on the camera board.  Worse, the Sunny connector on the camera module (re: board) is so loose the camera pops out of it on the lightest touch – and you will touch it because the camera module is just a board.  It doesn’t have an enclosure by default.  I bought a tiny camera mount to set it up on my table but the camera had popped out of the Sunny connector while screwing the board to the mount and I didn’t notice it.
  3. The setup:  You have to enable the camera by changing the bootloader config.txt and rebooting.  To turn it on: change and reboot.  To disable it: change and reboot.   This matters because of the next issue.
  4. The power requirements:  the camera is power hungry, up to 300mA.  So you don’t want to leave it running (apparenty).  Not sure how this compares to a webcam. I do notice that starting the raspicam (even though it doesn’t work) causes the rainbow box (upper right in newer firmware) to show up, which says I have a voltage drop below 4.8V (so I’ve read). That doesn’t happen with a USB camera plugged into an external hub. And if disabling it is required to avoid power drain that would be a serious problem since it requires changes to the bootloader config and a reboot.  And you need to set aside at least 128M in the GPU.
  5. The sensitive nature:  According to forum posts, the board is finicky about shorting out.  Lots of talk about people frying the cameras.  I handle the Pi quite a bit and none have fried.  Why does a camera that costs about as much have more problems?  It shouldn’t.

I never got the camera working so couldn’t compare it’s quality against a USB web cam.  But I did get a USB webcam streaming 30fps on the pi TO the pi using mjpeg-streamer and omxplayer.   Given my work on PiBox infrastructure for adding apps, the USB camera was up and running in a couple of hours.  Works great.  Nearly no delay in playback.  Slight delay only if you stream to a remote player, and that can be attributed to network lag.  I haven’t even got the basic Raspicamera working much less integrated into PiBox after the same amount of time, though to be honest all I have to do is edit a config file to integrate it once it works.

Yes, this was an external USB hub with its own power supply.  Irrelevant.  The ease of setup and use of the web cam considering I already need the external hub (for USB media sticks for PiBox) means I’m better off with the USB webcam.

So I can see no reason to use the Raspicam.  At least not for my use case.

Related posts

ESP8266: its’ all about power

[Print This] By mjhammel ~ February 25th, 2016. Filed under: General, Software Development, Arduino.
Strangely, Amazon delivered the board on Sunday. But I'm not complaining.

Strangely, Amazon delivered the board on Sunday. But I’m not complaining.

Programming the ESP8266 is rather easy.  I’m using the Arduino libraries and the makeEspArduino build system because I like to use the command line, not IDEs.  Stock libraries provide everything you’d expect: Wifi setup, web servers, DNS support, etc.  There’s even a library that allows you to boot into the board as a WiFi access point with a web server to configure it to connect to your local network.  It’s a bit surprising what you can fit into 512k memory.

There are a lot of possibilities with this little board, especially the versions with more GPIO pins but even with just 1 available pin on the ESP-01 you could do some interesting things.  The key point is that is requires very little power to control some other device via wireless communications.

But power is exactly where I ran into a little problem.  Seems that the FTDI Basic board I’m using to program and power the ESP-01 has a weak voltage regulator.  It works fine for uploading new firmware.  You can see it working because both the ESP board and the FTDI board flash their LEDs while data is being trasferred.  The ESP has a bright blue LED that flashes during programming.  It also has a RED LED that shows power to the board. Both are brightly lit when I’m flashing new firmware to the ESP.

But after the program has been flashed to the board the board needs to be rebooted to run the new program.  On reboot the ESP power LED would go dim and the firmware wouldn’t work.  Subsequent boots behaved erratically.  The dim power LED was curious and my only clue.  A few queries on SparkFun’s IRC channel led me to an issue with the FTDI’s regulator.  Apparently the ESP is very picky about the 3.3V it needs to run.  So I needed to find a separate power supply.

ESP's power light goes dim if the power supply is too weak.

ESP’s power light goes dim if the power supply is too weak.

There a lot of ways to handle this problem.  One is to throw together a few discreet components.   A simpler solution is to find a ready made board.  It needs to accept 9v-12v, so that it can be used with the tons of wall wart plugs I have laying around.  Ideally it should plug right into the breadboard I’m using for this project.

I dug around and found the one shown here on Amazon.  It’s perfect for this project because it spans the bread board providing power and ground to both sides.  And it supports either 3.3.V (which the ESP board requires) or 5V based on a switch.  It has a power button so I can turn power on and off easily without pulling wires.  More importantly, I only had to move 1 wire from my previous setup in order to use it.  And it’s cheap.  Well, I mean inexpensive.  It’s actually a nice board.  I ordered two.

Amazon managed to ship this to me on a Sunday so I had it just a few days after placing the order.  Once I plugged the power board into the breadboard I was able to test new firmware uploads without issue.

In the future I plan to power the board with a battery.  But for development, this little power board will do just fine.

Related posts

udev rule for FTDIBasic from SparkFun

[Print This] By mjhammel ~ February 15th, 2016. Filed under: General, Linux, Fedora, Arduino.
The ESP8266 came with pins already soldered, so I needed to use a breadboard to connect it to the FTDI. It's ugly but it's just an experiment.

The ESP8266 came with pins already soldered, so I needed to use a breadboard to connect it to the FTDI. It’s ugly but it’s just an experiment.

I’ve been fiddling with an ESP8266 this week that is being powered by an FTDIBasic board from SparkFun.  The setup is simple enough and it’s easy enough to get a simple web server running on it but I don’t have a power switch so the whole thing is powered through the FTDI board.  When I unplug the FTDI from the USB hub and plug it back in I get a different ttyUSBx port under Linux.  That means whatever serial terminal I’m using (Arduino’s or Minicom, for example) has to change after I connect the power.  But I want to see whatever the ESP8266 prints immediately at boot.  There is no way to manually switch ports in the terminal fast enough for this.  The solution is to use the same ttyUSBx port every time.  The way to do that is with a simple udev rule.

First, let’s look at the rule:

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001",
   GROUP="mjhammel", MODE="0660", SYMLINK+="ttyUSBFTDI"

This line (and that’s a single line, it’s just broken to make it readable on the web) is placed in a new file called /etc/udev/rules.d/99-usb-serial.rules.  You need root permission to do this.   With the file saved, I plug in the USB connector on the FTDI board to a USB port on a hub of my Linux (Fedora, in my case) computer.  Then I can check that it worked by listing out the ttyUSB ports.

$ ls -l /dev/ttyUSB*
crw-rw---- 1 root mjhammel 188, 0 Feb 15 14:26 /dev/ttyUSB0
lrwxrwxrwx 1 root root 7 Feb 15 14:26 /dev/ttyUSBFTDI -> ttyUSB0

What this rule did was tell udev to create the ttyUSBx port – in this case ttyUSB0 – with a group of mjhammel that has read and write permissions on it.  That group is the group I’m using for my user id.  The other thing it did was to create a symbolic link from it to a device called /dev/ttyUSBFTDI.  That means that no matter what real device is created when I plug in the FTDI board I’ll always have a link to it with the ttyUSBFTDI filename.  Now I don’t have to worry about which port is actually in use.  I can always use the symbolic link.

If this doesn’t work out of the box for you then you probably just need to find the right vendor and product IDs.  List out the devices on the USB hub.

$ lsusb
Bus 008 Device 011: ID 0403:6001 Future Technology Devices International, Ltd FT232 Serial (UART) IC


Look for the Future Technology Devices International (re: FTDI) entry.  The two 4-digit hex numbers next to ID are the vendor ID and the product ID, respectively.  Replace idVendor and idProduct in the rules file to match your setup.  Then save the file, unplug and replug the FTDI into the USB port and you’re done.

Note that this didn’t really solve my problem, since unplugging the FTDI will drop the port and minicom and the Arduino monitor drop connection to it and do not automatically reconnect.  But at least you don’t have change your settings to figure out which port to connect to the next time you open the serial console to the ESP8266.

Related posts

Streaming just got easier, with DLNA and Roku

[Print This] By mjhammel ~ January 9th, 2016. Filed under: General, Linux, Video, Movies, PiBox, Raspberry Pi.

PiBox was built as a proof of concept for a variety of purposes. One of those was to serve media in my trailer when we go camping.  I use omxplayer to play videos that are provided over SMB between a server and a player system.  That works okay but the front end is not particularly user friendly.  At least it’s not easy to browse videos – they’re currently in one long list.  It’s on my list to fix but who knows when I’ll get to tit.

Most of my Roku's are older models, but they support DLNA just fine.

Most of my Roku’s are older models, but they support DLNA just fine.

The other day I was reading some tech headlines for Linux and ran across mention of running minidlna on a Raspberry Pi.  I wasn’t familiar with minidlna, or ReadyMedia as it’s now known.  A little digging uncovered that it’s an open source version of a NetGear product for streaming media: movies, music and pictures.  It works by implementing DLNA compliant protocols, a specification designed just for media sharing.  I decided I’d try it out at home first.  To see how well it worked.

The project doesn’t have Fedora or CentOS packages but it does provide a statically linked binary.  I downloaded that and found it only required install of two files: the binary daemon and a configuration file.  The configuration file is short and well commented making it easy to setup.  It helped that I had a large collection of music and videos ripped.  So I installed the files and ran the daemon as my own user (not root).

Now I just needed some software player that could handle DLNA.  Fortunatley, I have a house full of Rokus.  There is a simple player app that supports DLNA.  I clicked on it and there was my server.  I drilled down a few folders and found my music and video.  Just like that.  In my many years of trying to stream media, that has got to be the simplest tool setup I’ve ever come across.

The bad news is that most of my 600+  movies are ripped as ISO images.  That was done to get the DVD navigation, jumping to chapters, etc.  Now I’ll have to re-rip them as MP4 or MKV since the Roku doesn’t play ISO images.

I also need to see how I can add movies posters.  While MP3’s have album art, the MP4’s appear to just have filenames.  Something tells me I can fix that.  I just need to find a way to use poster art where it currently exists.

What’s interesting with this is the possibility of streaming from PiBox using ReadyMedia to a Roku in my trailer.  The Roku has an HDMI output, which will support the pico projector we use to play movies on the side of the trailer.  The PiBox provides the wifi access point, so the Roku should work fine, I think.  I haven’t tried this, but it’s something now added to my todo list.  Since omxplayer doesn’t do dlna (that I know of), this may be an alternative to using PiBox with omxplayer for the player.

Related posts


[Print This] By mjhammel ~ December 27th, 2015. Filed under: Linux, Hardware, PiBox, Raspberry Pi, Arduino.

Front side of the PCB. The back side has labels for the components as well.

My first PCBs arrived in early December, but due to the holidays I haven’t done anything with them yet.  I just wanted to show what they look like.

There are 5 small boards attached to my PCB:

  1. An FTDI Basic from Sparkfun for connecting a USB cable to my Linux box for programming the microcontroller
  2. An Arduino Mini-Pro board
  3. A RTC clock board
  4. A tiny color display board
  5. An ESP8266 board

There is also a small USB connector for power.  I don’t have to use a real USB connector for this.  I just needed the power and ground points from a USB part for Fritzing to not complain about unclosed loops in the PCB layout.  I’ll wire this directly to a power converter that takes 110V input and drops it to 5V output.  That way I can use the same power input used for the outlets in this project to power the PCB (and relays, for that matter).

Not all of these have to be connected.  I could just use the pinouts for them and wire them manually.  For example, I’ll probably just add L-shaped male headers to the board for the FTDI Basic.  It doesn’t have to be installed for the board to work.

Related posts

Learning about power

[Print This] By mjhammel ~ December 24th, 2015. Filed under: General, Hardware, Holiday lighting, PiBox, Raspberry Pi, Arduino.

What do you get when an old software geek tries to learn about electricity?  The same thing you get when you teach a 5 year old not to put their hands on the red coils on the stove.  Experience through interactivity.  Today’s lesson:  fat wires vs thin wires.

I’ve been using small gauge wire to connect relays to outlets in my power controller project. I did this because I thought I needed thick wire to handle potentially large loads through the outlets.  I expected to have multiple lights and possibly multiple water pumps attached to each outlet.  Fatter wires are used for larger loads (ever seen thin wires on power poles?).  So I chose fat wires to connect the relays and outlets.  Wire thickness is measured as a gauge.  Fat wires have a smaller gauge, which means thin wires have a higher gauge.  Why?  Beats me.  That’s just the way it is.


This looks safe, doesn’t it?

The smaller gauge wires don’t fit in the screw-down holes for the relays on the Sainsmart board. I had to trim off some of the wire to make them fit cleanly.  But the relays only handle 10A max and the distance between the relays and the outlets is less than 6 inches.  I’m running standard 110V from the wall through the relays to the outlets. So how thick do these wires need to be?

After looking at an online wire capacity chart I realized I didn’t need the smaller gauge. I could use the larger 22 gauge wire (remember that larger gauge means thinner wire) for the very short runs between the relays and outlets. This is because if I take an average load per outlet of 6 lights averaging about 75 watts per bulb (remember this is lighting for my aquaponics at the moment) I find I’m only using 450 watts over the 110V power input. Using an online calculator I can see I’m only pulling about 4.1 amps. That’s far below the max for the relays and well within the safe limits listed in the Capacity Chart for 22 gauge wire. And this gets better if the lights are switched from high wattage incandescent bulbs to LEDs and CFLs, which most of them are now anyway.

So now I’ll be able to use thinner wire inside the enclosure, leaving more room for the relays and my custom boards.  But more importantly, I won’t have a bunch of frayed wires hanging out of the tie-downs to short out the whole thing.  And remember:  short-out is Latin for frying myself, because software guys are a danger themselves, their pets, their families and essentially entire neighborhoods when handling hardware.

And yet, I’m still doing it.  Go figure.

Related posts

Adruino updates: APC w/ESP8266 and OLED LCD

[Print This] By mjhammel ~ November 20th, 2015. Filed under: Arduino.

So my little aeroponics project is growing beyond its real needs, but once you start assembling legos it’s hard to stop.  I’ve added an ESP8266 for wireless connectivity and a really small OLED LCD display.  The latter will let me monitor the system without either serial (FTDI Basic) or wireless connected.


The breadboard really isn’t necessary at this point. The only thing it holds are the LED and its resistor plus Vcc and GND busses.

Fritzing made it easy to layout the prototype on a breadboard, though after working through cleanup of the schematic and the PCB I found some problems.  First, I intended to use a USB breakout board from SparkFun connected to some headers on the PCB.  But if you try to wire this in Fritzing the circuits are not closed at the headers and Fritzing gets confused.  Instead, I found a USB part (from SparkFun) in the Fritzing parts libraries that had through holes.   Through holes are important because I need to place some traces on the PCB on the bottom side of the board.  The USB  part had connectors that were labeled Vcc and Ground which allowed Fritzing to close circuits and allowed me to create traces the way I needed them.


The layout is about 8″ x 5″ which could be a bit pricey, not to mention difficult to fit in a decent sized enclosure. It will have to be scaled down.

The next problem came after the PCB was fully routed.  The size of the PCB makes it prohibitive to get made.  OSH Park charges about $5 per square inch.  With my PCB at 8.8 x 5.3 inches that cost for a small production run (3 boards) would have been around $200.  Not horrible but really, this is such a simple project why waste the money?

So now the plan is this:

  1. Remove the FTDI Basic. The Pro Mini just needs headers to connect the FTDI Basic.
  2. The OLED LCD doesn’t need to be on the PCB. It can be connected with wires. This will allow the display to be freely placed in the most appropriate location without respect to the positioning of the PCB.
  3. With these changes I should be able to mount the ESP8266 on the back of the PCB and
  4. move the TinyRTC and USB power to a second PCB, mounted vertically with spacers. That will reduce the costs of the PCBs significantly. In fact, I should be able to do the whole thing with perfboard.

So my cost goes next to nothing.  In the end I should have two perfboards mounted together with spacers with the LCD mounted on a third perfboard (or without possibly) on some user-facing wall of the enclosure.

I still haven’t gotten to the enclosure but that will come after I find out how big this thing will be.  I still have to add in the 4 channel relay board too, plus the wires connecting all the boards and the power outlets together.


Just posted this, then went back to review the layout in Fritzing.  I realized that the ruler part I used to measure the PCB had two sides: inches and cm.  Guess what idiot was reading the cm side?  Yeah.  That’s the guy.  So it looks like the whole design may fit completely on the perfboards.  The PCB would only be 3.3″ x 2″.  Much more affordable.

Just goes to show:  there is always one more thing to review….

Related posts

Embedded project: 4 channel Arduino-based power controller

[Print This] By mjhammel ~ November 5th, 2015. Filed under: Hardware, Holiday lighting, Raspberry Pi, Arduino.

The Sainsmart 4 channel relay board. Digital inputs (lower right) control standard 110v through the four relays (large blue boxes).

One of the directions my PiBox project is headed is as a central hub for sensor management.  This implies the ability to communicate between the PiBox and the sensor node using BLE or Wifi.  PiBox can do that already over Wifi (and supports basic BLE communication though lacks a meaningful UI or automated registration) so I only need to start work on sensor nodes.

Now it’s hard for me to toss together a temperature sensor node without having a purpose for knowing the temperature.  So whatever node I created needed to have a purpose.  Enter:  my newly configured aeroponics systems.  This system uses a 5 gallon bucket with a water pump inside to spray nutrients on the roots of the plants.  Lamps are hung from a support structure (a wire frame shelving unit) .  Lamps and pump are plugged into a simple manually configured timer.  Nothing special there, except for a really leggy tomato plant that has yet to fruit.  But that’s a different project.

So I thought to myself:  what if I created a programmable timer for the lamps and pump?  I could use an Arduino for the brains, plus added components to make it clever.  That’s my sensors purpose:  handle power on and off of the lamps and pump for the aeroponics systems.  So was born apc:  the Aeroponics Power Controller.



The aeroponics tub and manual timers (lower left)

I’m sure the first comment will be:  but that’s not a sensor.  Yeah, it’s not.  But the concepts are the same:  embedded device controls some physical components based on input from a remote management interface.  For apc the physical components are power outlets.  APC’s initial implementation will use four controlled outlets, each capable of being programmed independently.  It needs to be able to run scheduled events (power enabled and disabled on each outlet).  There should be some way of knowing the status of the controller:  running or not.  And there should be some status indication of what’s happened, re: a display of some kind.


Based on the design I need the following components.


Pro Mini (center), RTC (lower left) and USB breakout plus LED. Only thing not shown here is the FTDI USB board, which connects to the pins on the left end of the Pro Mini.

These are the main off-the-shelf boards I need.  I also need a breadboard to hook them all up, an LED and associated resistor and a bunch of wires.  I discovered, after finishing the version of the project, that soldering is limited to adding headers to the boards and a few wires to the headers.

Why the Mini Pro?  Well, for one thing there were on sale at SparkFun back in March 2014 when I bought a bunch of similar boards without having a specific purpose for them.  So it’s been sitting around for awhile waiting for an inspiratio on my part.  But it also has a very small footprint without all the bells and whistles (re: bulky connectors) required for other beginner projects.  And it has plenty of computing horsepower for this kind of project.  It’s actually way overkill.  But I already had the board, so what the heck.

The TinyRTC is a real-time clock with a battery.  The battery isn’t really necessary but it’s nice to have if you lose power.  Though without power the apc won’t work.  Dealing with that problem is beyond the scope of this project.

The 4 channel relay is the board that converts the control signals from the Arduino into the enable/disable actions of the power outlets.  The relays are optically isolated so when each is enabled they make a loud click sound.  You know they’re working if the click is loud and distinct.  If it’s a quiet click you probably don’t have enough voltage on the control lines of the 4 channel relay.

The FTDI Basic breakout board is what you use to connect your Linux box to the Mini Pro.  It’s what you use to upload your programs to the Arduino.

The USB power from your computer is enough to handle programming the Arduino and running the program.  But it’s not enough to change the state of the relays.  So a USB breakout board is used to connect a wall-wart power supply with 5V output to the APC.  This powers the Arduino and the relay board.  Note that you can connect this power source AND the power from the FTDI Basic at the same time.  It won’t hurt the board (as far as I can tell).  That’s how you test your code.

Hook Up Guide

The nice thing about this project is how it can be done with a series of off-the-shelf breakout boards.  The Mini Pro has plenty of digital lines to connect to more than one board.  Strangely the pins I need from it for SDA/SCL to talk to the TinyRTC are not aligned to the breadboard.  That’s a trade-off when using a smaller microcontroller board like this, but it’s a minor inconvenience.  I just soldered two pins to the A4 and A5 holes in the Mini Pro, then used female connectors to wire them to the breadboard at the SDA/SCL lines on the RTC.

Fritzing diagram for first APC implementation.

Fritzing diagram for first APC implementation.

The 3.3V power from the Mini Pro is not strong enough to switch the relays (not shown in the Fritzing diagram) so a USB breakout is used to bring in power from a wall wart that provides 5V input.  In fact, that’s why I added two additional outlets to the original set of four outlets.  The two new outlets are not controlled and I can plug the wall wart into the USB breakout board.  Easy-peasy.  This is why IoT is so popular.   It’s a bit like Lego building, but with wires and pins.


All the code for this project is available from the git repository at gitlab.com.  The code utilizes two libraries for the RTC, the Wire library for serial communications and the Timer library for running scheduled events.  The Timer library provides for events to be run on short intervals like 100ms.  The RTC libraries allow checking the current date/time against the schedules to see if an event should be triggered.  Events are simply when the outlets are enabled and disabled.

As a side note to programming:  I’m not using the Arduino IDE.  I think IDE’s are a crutch that prevents you from learning WHY things work.  So I’m using Tim Marston’s arduino-mk to edit and build from the command line.   I added support for opening  serial monitor to it, which you can find in the source code under the docs directory.  I also use screen to create a bunch of virtual terminals in a single window.  This I do because I can then work from different systems (desktop or laptop in different rooms of the house, for example) without losing history or resetting my environment.  Lastly, I use cdtools with my project because I have a zillion projects and cdtools functions make it easy to bounce around them.  Config files for both screen and cdtools are in the docs directory.

Automated Registration and Web UI

The next phase of this project will add networking to the system.  An ESP8266 will be added to provide wifi connectivity.  The ESP8266 uses an AT command set to connect and send and receive data from remote servers.  The plan is to have the Pro Mini perform an initial registration with a remote server running on PiBox.  The registration is initiated with a multicast message from PiBox asking for new devices.  The device receives the message and sends a whoami packet with it’s IP address and a registration token (something akin to a secure key, I think).  Once registered the device can access the PiBox web server via a RESTful interface.  The interface will provide scheduling data for the device and the device can report status back.

Of course this requires a web interface for setting schedules for all registered devices.  Fortunately PiBox already has a web UI with a RESTful API.  I just need to extend it to support IoT devices.  Then I need to create a UI, potentially using a self-defining UI format so devices can create their own configuration options without having to place the knowledge in the UI.   If done right this format won’t take up much space on the device because there will be little to configure in each IoT.  That’s the point:  IoT implies a device with a simple purpose that is remotely managed.

Beyond the ordinary

The ESP8266 will connect to the serial lines of the Pro Mini so that means the serial console won’t be available.  There is a neat little trick around that:  a color LCD display.  These devices are cheap, around $10-$20.  I’ve selected a four wire device that uses SDA/SCL lines for data plus a ground and Vcc.  Luckily the TinyRTC board has extra SDA/SCL pins to piggy-back another device like the LCD.  And Adafruit has libraries for these devices that make it very easy to use.

After all this is done there is only one thing left to do: extend scheduling for my holiday lights.  After all, wasn’t that really where this was headed?  I mean, do I really need brains in my outlet timer for a tomato plant?  I guess that depends on if that thing ever starts to fruit….


Related posts

PiBox: bluetooth for video means no omxplayer

[Print This] By mjhammel ~ July 27th, 2015. Filed under: Linux, Software Development, Hardware, Audio, Video, PiBox, Raspberry Pi.

One of the longterm goals for PiBox is to integrate it into the home.  I want to see the PiBox Server provide centralized communication for an array of IoT devices.  One way to do this is with Bluetooth Low-Energy, aka BLE, aka Bluetooth 4.0.  This specification allows very low power sensors to report information to services that can do something useful with the information:  close the shades when the temperature goes up, let the roomba loose when the dog’s sheddings are accumulating, turn off the stove when granny forgets to take her meds.

Before I can do this I needed to get bluetooth classic working on the server.  This turned out to be fairly easy.  The kernel supports it and there is the BlueZ userspace tools, plus the bluez-tools wrappers to make it even easier.  After much procrastination I finally got around to testing these on a server with a 4.0-compatible USB dongle.  After a little fiddling with the /etc/bluetooth/audio.conf and /etc/asound.conf files I was able to play a simple wav file to a bluetooth speaker.  Easy-peazy.

The next logical step was to get omxplayer, the hardware-accelerated video player for the Raspberry Pi that I use to play videos full screen, to switch from the analog output to ALSA.  Turns out this can’t be done, or at least it isn’t done yet.  omxplayer doesn’t support ALSA.  So you can’t play the audio stream from a video over bluetooth.  So much for my drive-in movie with wireless speakers.  I looked at what might be required for this (there were hints from the omxplayer developers) but it seems a bit over my head and would distract from the larger scale goals for the project.  I’m a one man team.  There’s only so much time in a year.

So I’ve started banging my head for alternatives.  The obvious one is to plug an analog-to-bluetooth transmitter into the analog output port of the Pi.  Too easy.  Though I have one on order for the short term (hey, we still use it when we go camping).  But that would also require a larger box to hide the transmitter.  And how do I switch between bluetooth and analog output?  I may not always want bluetooth.  Nah, I’m just kidding.  Everyone loves bluetooth.

Another alternative is to switch to a different video player, like mplayer.  That would get me a software switchable option for audio output.  I tried this on a Model B+ but the performance was terrible since the GPU isn’t used.  First, to get a nearly smooth playback the image had to be halved while being decoded on the CPU.  And there was no way to rescale it to the display size at display time.  So this was functionally unusable.

The next alternative (this is computing and there is ALWAYS another alternative) is to switch boards.  I looked at several competitors like BananaPi an Odroid.  The former looks like a possibility.  But then I took another look at the newest version of the Pi, the Raspberry Pi 2 Model B.  It’s a quad-core with each core spec’d at 1GHz, slightly more than the original Pi’s 900MHz.  Not to mention the possibility of overclocking and additional on-board memory.   So mplayer, which does work with ALSA but which requires the CPU to do the decoding, might just work on this board.

So I placed an order for one Pi 2 which has a slightly different Broadcom chip.  I’ve already rebuilt the toolchain for this new chip.  That’s an adventure in itself, but fortunately doesn’t appear to require major changes to the toolchain.  I’m unclear if I have the toolchain optimized.  It doesn’t use the latest Linaro gcc releases so I’m doubting it.  But if my toolchain shows any possibility of running mplayer then I can always upgrade my Crosstool-NG release to get access to the latest Linaro bits.

Related posts

PiBox field trial results

[Print This] By mjhammel ~ July 2nd, 2015. Filed under: General, PiBox.

mediaserver01-largeThis past weekend I took PiBox out in the trailer for a field trial.  The box was mounted under a cabinet with power and HDMI wrapped around to a 7″ HDMI-input monitor.  Power on worked fine and the system came right up.  But not everything worked as expected.  Here is the summary.

SMB playback

The first issue was with shared files over SMB.  I first tried to watch a movie using my LG Volt phone, which runs Android 4.4.2.  I use ES File Explorer on Android to get to the video files.  The phone could access the files and start the playback but the network would drop out after a while.  I then tried it with a Galaxy Tab 2 tablet running Android 4.2.2.  This worked much better and I watched several movies without interruption.  The PiBox Media Player also worked perfectly.  So I think the problem was with the phone’s wifi.  That’s interesting since I often use the phone at the gym when I run on the treadmill to watch Netflix without problem.  Apparently it works better with 3G than it does with wifi.

One thing of interest here:  the tablet notified me at one point of “unusual magnetic activity” in the area.  I got this when I used an astronomy app (setting up to use my telescope – hey, it wasn’t all work on this field trial, we were camping).  I have no idea how it sensed this but wonder, if it was real, if it had any impact on local wifi network performance.


The media server was cabled to a 7″ display in the trailer.  This required an extra power cable.  Then we also had a digital TV box that added additional power and HDMI cables.  Finally I had a HDMI switch to go between the TV receiver and the Media Server.  That amounts to a boat load of cables that didn’t exist before with the old TV/DVD player.  Fortunately, the digital TV and HDMI switch will go away when I add a digital TV dongle to the Media Server.  But I’ll still have a TV cable.  Even so, I can see that there are still too many cables.  I need to power a display and connect to it with fewer exposed cables.  That would leave just the power and digital TV lines exposed, which is much better.  I’m not sure how I’ll solve that problem yet.

Wifi Setup

The wifi setup works well when connecting to the local router.  Using PiBox Media Server as a wireless access point had some minor problems.  First there was a problem with the way I set ccmp vs tkip.  There are two ways to configure the network:  bui-network-config (the GTK+ app run from the launcher) and the web interface.  I fixed the web interface to do the right thing, which is use tkip, in the web backend (piboxd).  But bui-network-config uses its own code for the same thing.

I’ve fixed bui-network-config but the long term solution is to have bui-network-config use the same backend.  The problem is that bui-network-config was designed as a standalone tool that can be used outside of PiBox.  So the question is how to maintain that capability.  I think the solution is going to be to have a shared library that both bui-network-config and piboxd can use for this purpose.

Multiple USB sticks

Something that kind of shocked me was a problem with multiple USB sticks.  With one stick plugged in videos were available.  With two or three they were not.  This may have been a problem with the USB ports.  I still need to check on that.  Another problem may be with how VideoFE handles the databases created by VideoLib on the sticks.  Or it might just be that the sticks were messed up.  This simply needs more research.

Video Browsing

Field trials are good to find out just how usable the device really is.  In this case I found that the simplistic alphabetical list of videos was slow to move through using the keyboard’s arrow keys.  I also found that, for some reason, the poster art was slow to load (or at least appeared that way).  This poster issue is new, as I’d not seen this problem at home.  Again, it may be due to networking issues at this site.

The important issue here is that I need a way to fine tune the list of videos.  Pressing a few keys should be sufficient to reduce the displayed list.  I would need a way to cancel that search (to get the full list back) and/or a way to timeout the current search.  If it does timeout, does the display go back to the full list?  How does the user know what the current search state is (as in timeout state, etc.)?

There’s a bit of work to do here.




Related posts