CategoryDevelopment

Subsonic for OSX Update

I was finally able to find time to update Subsonic-Fluid with support for Subsonic 6. You can find the new script in the existing repo.

https://github.com/rossbates/subsonic-fluid

Please make sure to use the subsonic6.js version. I’m leaving the old version in the project just in case someone still needs it.

Now if we could only get the last.fm bug in the v6 HTML player fixed all would be well in the universe once again. Please let me know if you have any questions or run into any issues.

Subsonic desktop client for Mac OSX

I’m a fan of streaming music services for simplicity and convenience. subsonic-icns-sourceOn the other hand when I really want to sit down and listen to my favorite albums I prefer high quality .flac streaming from a Subsonic server. The mobile apps for Subsonic are outstanding, with my personal favorite being DSub for Android.

The one thing I’ve been searching for high and low is a solid desktop client for OSX to listen while I’m on my laptop. I’ve tried them all Clementine, Submariner, Subair and Thumper. All of these clients are either broken and no longer supported, or they are unable to stream .flac files. Inevitably I end up back using the official web client – which I dont’t mind using but the problem is I hate running my media player in a browser tab. You can’t quickly alt-tab to it, use keyboard shortcuts, or easily swap windows in a desktop manager.

I decided to sit down this weekend and work on turning the web client into a Mac OSX desktop client using Fluid. While the solution is not a perfect replacement for a native client, sub-fluid-screenit’s providing me the best Subsonic desktop experience I’ve had since I started using the platform two years ago. The app runs in a standalone container with a sharp looking dock icon along with shortcuts for the essentials; Next, Previous, and Play/Pause. To help any others out there searching for a similar solution I’ve shared the scripts and assets on GitHub.

Hope you find it useful. Let me know if you want to see any additions or changes.

Getting Started with the ESP8266 on OSX

Intro

Lately I’ve been spending time hacking on a couple different ESP8266 boards for use as home automation controllers. If you aren’t familiar, the ESP8266 is a microcontroller that runs both microprocessor and Wi-Fi stack all in a tiny little package. They are Arduino compatible, inexpensive, and using the GPIOs you can connect sensors with minimal development effort. In a nutshell, these are perfect for DIY connected home projects.

Getting everything configured just right took a long weekend and a ton of trial and error. My development environment is a MacBook Pro running OSX 10.10.5. Hopefully these notes will help others get a jumpstart towards developing their own solutions.

Boards

There are a number of ESP8266 boards you can find online at various price points. Here are two I would recommend for you to get started.

Adafruit Huzzah

This is a nice little board and comes with great documentation and support from Adafruit. Heads up for beginners, you are going to need to buy a USB to TTL Serial cable to use instead of a standard USB mini cable. huzzah This can present some problems on it’s own (more on that later). Also, if you plan on connecting a sensor to it you need to have experience soldering components – or have a willingness to learn. The board does not ship assembled like the picture displayed on the left. I had never used a soldering iron before and it wasn’t too bad. Honestly it’s probably best just to dive in head first and figure it out from the beginning because it’s a skill you’ll rely on going forward. Remember you can always hit up YouTube for how-to videos.

ESP12-E by DOIT

The other board I recommend comes out of the Chinese manufacturing ecosystem. What this means is a high quality board for less money, with the tradeoff being almost no documentation or support. esp12e-1 I ordered my units from AliExpress so it took a couple of weeks for them to arrive, but the boards are really great. The product links seem to change frequently on AliExpress so just do a search for the following: “ESP-12E from ESP8266 esp 12E Lua” and look for the image on the right. It’s a specific board you should be looking for from doit.am

Mac OSX Drivers

Before you can connect to the board using a serial terminal you’ll need to install the proper USB drivers for your Mac. These are commonly known as USB to UART drivers. The USB to TTL serial cable from Adafruit used to connect to the Huzzah uses this Silicon Labs driver for OSX.

Installation of the drivers should be very straightforward. The main problem I was running into was that the Huzzah does not have any indicator lights when it’s running. Further, the USB to TTL serial cable from Adafruit doesn’t always sit flush on the pins, so if & when you end up unable to connect to board from a console it’s hard to figure out if it’s a hardware/power issue or a software issue.

The first thing to check is the USB panel under System Information.usb-ttl-prolific. If the driver is installed correctly you will see “USB-Serial” controller with the manufacturer name Prolific Technologies when the cable is plugged in. If you see this and still can’t connect to the board, wiggle the power cable and watch for the lights to flash. Then hit the reset button and see if the blue LED flashes.

Drivers for the ESP-12E are a little more complicated. If you dig around the Doctors of Intelligence and Technology site long enough you’ll find the driver for the board is listed under the “NodeMCU” with a a link to this driver. You can download and install this file without any issues or warnings, yet nothing will work. The problem is that these drivers aren’t signed properly for OSX. You will not be able to connect to the board using these drivers unless you disable kext signing. Here’s a Stack Exchange thread with more info on how to do this.

I didn’t want to take that route and thankfully the folks from Codebender have published a properly signed version of the ESP-12E drivers. You have to sign up for an account and go through their on-boarding process. If you don’t want to do that however I’ve mirrored the package here.

Connecting

Once you are connected it’s time to start playing around. Both boards ship with the NodeMCU firmware already on board. NodeMCU is an open source IoT platform which gives developers an interactive Lua shell to control the hardware. This is handy to quickly get your feet wet. There are some simple examples you can run interactively to flash LEDs, connect to wifi, and run a tiny webserver.

It’s a great way to get started, but for real world projects you quickly realize you are going to need to be able to deploy your own firmware using the Arduino IDE.

Flashing Firmware

Setting up the Arudino IDE to work with the ESP8266 is not too difficult. I followed this tutorial from Adafruit which I found very helpful.

Once I had the Arudino IDE setup and verified that it was able to see my hardware I copied the sample blink code into my sketch and prepared to flash the board. This is where things started to go totally sideways.

The first error I encountered when attempting to flash the board looked like this: warning: espcomm_sync failed
error: espcomm_open failed

The only reference I could find on the internet was in a GitHub ticket. There were not specific solutions in the comments which worked, but there were references to the fact that this happens when there is not enough power to the board.

After banging my head against the keyboard trying to decipher all these potential solutions I tried one simple thing, I switched from the USB port on the left side of my MacBook to the one on the right. Good news, the error went away. Bad news, I ran into another even bigger issue.

ESPTOOL to the Rescue

Switching ports made the espcomm_sync error go away, but now when flashing the board I started getting this error:
warning: espcomm_send_command: cant receive slip payload data
warning: espcomm_send_command (FLASH_DOWNLOAD_BEGIN) failed

It took a while to get this all figured out, but long story short the utility (esptool) which the Arduino IDE uses to upload firmware (.bin files) to the ESP8266 does not play well with OSX.

Thanks to the author of this article here I learned of a replacement written in Python which you can drop in as a replacement for the IDE.

A couple of additional notes based on some things I ran into. When modifying the Arudino platform.txt file to point to the esptool.py file, this is what worked for me:
tools.esptool.upload.pattern=”/Users/ross/Projects/esptool.py” –port “{serial.port}” write_flash 0x00000 “{build.path}/{build.project_name}.bin”
Once I had the Arduino using the Python version of esptool I started getting another error about the .bin file not being found. For whatever reason on my system the path the the compiled .bin files were not being picked up. Updating esptool.py with the following change to line 631 fixed my issue.
image = file(‘/private’ + filename, ‘rb’).read()
After that I was finally able to successfully flash firmware sketches from the Arduino IDE to both of my ESP8266 boards. Victory!

Conclusions

If you made it this far hopefully you are at a point where you are flashing your own custom firmware onto your ESP8266. Make sure you check out the ESP8266 example sketches available in the Arduino IDE under File > Examples. You’ll find lots of helpful snippets for setting up the board as an access point and webserver.

If you have any questions please feel free to leave them here in the comments. Also, if there are any other examples you would like for to post just let me know and I’d be happy to do so.

© 2009 - 2017 Ross Bates