Saturday, March 14, 2015
Happy Pi Day
Happy Pi day on 3 / 14 / 15 at 9 : 26 am 535897932... ns
Pi to 100 places:
3 . 141 592 653 589 793 238 462 643 383 279 502 884 197 169 399 375 105 820 974 944 592 307 816 406 286 208 998 628 034 825 342 117 067 9
Sunday, March 8, 2015
Arduino is a Guy
"Arduino will then stop talking about himself in the third person."
Apperently Arduino is a guy and illeistic too.
Friday, March 6, 2015
Electronics Merit Badge
This last Saturday I had the opportunity to volunteer to teach a few Boy Scouts the Electronics merit badge.
We had a good time talking about various electronics components, building and soldering an electronic kit.
The kit we put together was a noisy little police siren kit. Amazingly all of the boys were able to complete their kits without frying any transistors or IC chips.
We also got to play with a Metcal station which did a consistent and amazing job with the soldering tasks.
Electronics merit badge requirements | |
|
Saturday, February 28, 2015
RadioShack Store Closures
Our local RadioShack closed, along with many other RadioShacks across the country in a massive Chapter 11 bankruptcy protection move.
Although RadioShack is significantly more expensive than buying parts online, they have saved my bacon more than once on various weekend electronic projects, when shipping time would have ruined my weekend.
References:
Sunday, February 8, 2015
Installing Ubuntu Server on Mac Xserve Server
Apple Xserve Server |
I had an old Xserve server laying around and wanted to put it to good use. My current Plex server is going away, so this will serve as the replacement. The Xserve line has long since been discontinued by apple and is no longer supported. What is the best solution to bring any old server back to life? Install Linux on it, of course!
Specs
Xserve3,1
Model: Intel Xserve3,1 (2009) Processor: 2.26 GHz Quad-Core Intel Xeon Memory: 12 GB 1066 MHz RAM Network: 2x Intel 82574L Gigabit Network Storage: (3 high speed SAS drives, but not important as controller is not supported) Graphics: NVIDIA GeForce GT 120 with 256 MB of GDDR3 SDRAM Expansion: * 2x PCIe 2.0 ×16 * 3x USB 2.0 * 2x Firewire 800 * 1x RS-232 serial
additional details
Display Port
Unless you are a Apple enthusiast, you probably don't have a Mini DisplayPort adapter laying around. I picked up a Mini DisplayPort to DVI adapter on amazon for about $10.
Ubuntu Server ISO
After downloading the Ubunut Server 14.04.1 LTS ISO (ubuntu-14.04.1-server-amd64.iso), I burned it to a CD-ROm with ImgBurn.
Install to USB Drive
To keep the server from booting from the local hard drives, I pulled them slightly out.
The server only has USB 2.0 ports (could always install a USB 3.0 controller into one of the two free PCIe slots), but as USB 3.0 drives are pretty much all you can find now I used a USB 3.0 flash drive. I would recommend a SanDisk drive, but I am completely biased. :-)
Installing Ubuntu
To boot from the install CD, hold down the "Alt" key as the system boots.
You will see a white screen ("White Screen of WaitingTM"), and it won't seem like anything is happening for a long time (60+ seconds), but continue to hold down the alt key until the boot menu comes up.
You will see a white screen ("White Screen of WaitingTM"), and it won't seem like anything is happening for a long time (60+ seconds), but continue to hold down the alt key until the boot menu comes up.
After what seems like a really long time, an error will appear. Ignore it and wait some more time, and the Ubuntu installer GRUB menu will appear.
Finally the "purple" Ubuntu installer will appear. The default options on the installer will be sufficient, but you can make any desired changes as well.
Luckily the Intel 82574L Gigabit Network is well supported by Linux. The two connections are labeled on the back of the server.
Eventually you will be asked to choose a storage location for the install. If your USB drive has existing partitions, you will get a warning about unmounting partitions on /dev/sda, do so.
For the partitioning scheme, I am not a fan of LVM (had to many bad experiences trying to recover from issues), so I chose the "Guided - use entire disk" option.
Eventually the installation will complete, and the system will reboot.
Expect another 60 seconds of waiting at the "White Screen of Waiting", before the system actually boots and you get your expected login prompt.
Congratulations on completing the installation.
Saturday, February 7, 2015
The Zen of Python
The Zen of Python, by Tim Peters, is guiding principles for Python's design.
Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!
This list can also be generated within python by executing:
>>> import this
The Mozilla Manifesto
The Mozilla Manifesto are the principles that guide Mozilla's mission to promote openness, innovation & opportunity on the Web.
- The Internet is an integral part of modern life—a key component in education, communication, collaboration, business, entertainment and society as a whole.
- The Internet is a global public resource that must remain open and accessible.
- The Internet must enrich the lives of individual human beings.
- Individuals’ security and privacy on the Internet are fundamental and must not be treated as optional.
- Individuals must have the ability to shape the Internet and their own experiences on the Internet.
- The effectiveness of the Internet as a public resource depends upon interoperability (protocols, data formats, content), innovation and decentralized participation worldwide.
- Free and open source software promotes the development of the Internet as a public resource.
- Transparent community-based processes promote participation, accountability and trust.
- Commercial involvement in the development of the Internet brings many benefits; a balance between commercial profit and public benefit is critical.
- Magnifying the public benefit aspects of the Internet is an important goal, worthy of time, attention and commitment.
Tuesday, January 27, 2015
Dilbert RSS
Dilbert.com used to have an RSS feed, but has since removed this feature. Luckily, dilbert-rss was created by fredley, which allows anyone to create their own Dilbert RSS feed.
"dilbert-rss - Scrapes dilbert.com and generates an RSS feed.
Since dilbert.com nerfed their own RSS feed, I created a tool to replicate the old functionality. This is designed to be used on your own server, using cron to update it."
Usage
To use the dilbert-rss (assuming you want to store the RSS feed in /www/):git clone https://github.com/fredley/dilbert-rss.git cd dilbert-rss python dilbert.py /www/dilbert.xml
Dependencies
Before you can use dilbert-rss, you will need to install two Python dependencies: BeautifulSoup and PyRSS2Genpip install BeautifulSoup PyRSS2Gen
BeautifulSoup and PyRss2Gen
On this topic, learning about the BeautifulSoup and PyRSS2Gen Python libraries were a benefit of using the dilbert-rss project. Both libraries can be used for a number of other useful projects. BeautifulSoup will parse an HTML page turning it into a usable Python object and PyRSS2Gen can be used to easily generate RSS feeds.Oeey.com Dilbert Feed
An example of the output can be found here: http://dilbert.oeey.com/
Open the URL within an RSS viewer. If you don't have one handy, use Firefox to see the feed as a "Live Bookmarks" view. The content will be rendered. Most other browsers will just show the XML content.
With the above I created the following cronjob:
Open the URL within an RSS viewer. If you don't have one handy, use Firefox to see the feed as a "Live Bookmarks" view. The content will be rendered. Most other browsers will just show the XML content.
With the above I created the following cronjob:
0 18 * * * python /usr/local/bin/dilbert.py /www/dilbert/dilbert.xmlAnd the matching Apache configuration, with a default DirectoryIndex pointing to the XML feed:
<virtualhost> ServerName dilbert.oeey.com DirectoryIndex dilbert.xml DocumentRoot /www/dilbert ErrorLog logs/dilbert-error_log CustomLog logs/dilbert-access_log common </virtualhost>
Update: Recently the Dilbert HTML layout changed. I had forked dilbert-rss and posted a suggested fix, to which fredley accepted the pull request.
Wednesday, January 21, 2015
Agile Manifesto
Individuals and interactions over processes and tools
Working software over comprehensive documentation
Customer collaboration over contract negotiation
Responding to change over following a plan
That is, while there is value in the items on
the right, we value the items on the left more.
Friday, January 2, 2015
Hacking Kankun Smart Wifi Plug
Kankun Smart Wifi Plug |
The Kankun "Small K" (KK-SP3) Smart Wifi Plug Socket is an inexpensive device (~$20) that lets you switch an outlet on and off over Wi-Fi.
Smart Plug is a Controllable OpenWRT Linux BusyBox
Designed to be controlled by a smart phone, some engineering minds posted on Hackaday a way to control the device from any web browser or SSH client. It turns out the Smart Plug is running a version of OpenWRT, which is basically a minimal BusyBox Linux environment (BusyBox: The Swiss Army Knife of Embedded Linux). It also has SSH access turned on by default, and was just a matter of determining the default password (admin, 1234, or p9z34c). Once you have SSH access you can either control the relay directly, or add a CGI script to control from a web browser.root@koven:~# cat /etc/openwrt_release DISTRIB_ID="OpenWrt" DISTRIB_RELEASE="Bleeding Edge" DISTRIB_REVISION="r39365" DISTRIB_CODENAME="barrier_breaker" DISTRIB_TARGET="ar71xx/generic" DISTRIB_DESCRIPTION="OpenWrt Barrier Breaker r39365"
AliExpress
The Kunkun Smart Plug can be picked up on AliExpress for about $20."AliExpress is like eBay worldwide, but a lot bigger." (src)
Smart Plug package |
There are a lot of options for purchase, just make sure you pick the US connector version (example), or you will need to buy an adapter (a mistake I made with the first one I ordered).
Smart Plug - US Connector Version
If you do get the wrong one, the front "female" receptacle connector was a universal connector, but the back "male" plug connector is the problem and you have to buy an adapter, so your device will end up looking like this:
Smart Plug - Chinese Connectors with US adapter |
Factory Reset
As we make changes to the wireless settings, we can recover to the original factory settings by pressing and holding an almost-invisible white button on the surface of the plug for 4 seconds.Configuring to SmartPlug Wireless Network
To get access and control to the Smart Plug, we first need to configure it.Out of the box the Smart Plug is set as a Wireless Access Point, with an SSID of OK_SP3 (no password). To be useful, we will need to connect to this temporary access point and configure the device to connect to our home wireless network.
To configure the wireless, we can either:
1. Connect to the SSH service (default ip: 192.168.10.253) and modify the wireless files manually
or
2. We can use the Smart Phone Android/iOS app to configure the Smart Plug
I think the initial setup is easier with the app, so...
Configuring to SmartPlug Wireless Network - Android App Method
1. Download and install the Android Kankun "SmartPlug" app. (I assume the app on iOS is the same, but I haven't verified this)
For reference, I installed the app from the Google Play Store, but the instructions also provide a URL to download the app file: http://kk.huafeng.com:8081/android/Smartwifi.apk
2. Connect your Android Smart phone to the OK_SP3 network.
3. Start the SmartPlug app and click the "Config" button. Note: the "Device" page will be empty, unless you have already configured devices.
4. This is where we will change the Smart Plug's wireless network settings to our home network. Change the "Wifi" item to your home SSID (sorry no discovery option here). Change the Password to your home's wireless password. Ignore the "Encryption" option. Finally click the Configuring button to save the changes.
5. The Smart Plug should now be on your home's wireless network, and your Smart Phone will have been auto disconnected from the OK_SP3 network and also back on your home network. Check the status of the blue LED on the Smart Plug. If the LED is off, everything is good. If the light is blinking, it was unable to connect to your home wireless network.
6. Now check the "Device" list. Your Smart Plug should now be in the device list. Select the device.
Note: The device's Ethernet address (MAC) is also listed. Take note of the MAC, as you will want to check your DHCP server's logs to determine the IP address of your Smart Plug.
7. From here, we can quickly test the Smart Plug. We will be presented with a visual "on/off" button. Click the "on/off" a few times until you are satisfied. You will hear the relay switch on and off, or if you have something plugged into the Smart Plug, you will see it turn on and off.
7. Check your home's DHCP logs to find out what the new IP address of your Smart Plug is. Next we will connect to the Smart Plug over SSH.
Example:
dnsmasq-dhcp: DHCPDISCOVER(eth0) 00:15:61:bc:42:af dnsmasq-dhcp: DHCPOFFER(eth0) 10.10.10.222 00:15:61:bc:42:af dnsmasq-dhcp: DHCPREQUEST(eth0) 10.10.10.222 00:15:61:bc:42:af dnsmasq-dhcp: DHCPACK(eth0) 10.10.10.222 00:15:61:bc:42:af
Configuring to SmartPlug Wireless Network - SSH Method
default /etc/config/wireless:
... config wifi-iface option device radio0 option network lan option mode ap option ssid OK_SP3 option encryption none
change /etc/config/wireless:
... config wifi-iface option device radio0 option network wwan option ssid 'YOURSSID' option mode sta option encryption psk option key 'YOUR_WPA_KEY'
append /etc/config/network: (thanks Michael Liddle)
config interface 'wwan' option proto 'dhcp'
After saving this file, reboot the Smart Plug and it should be connected to your home network. If the connection fails, perform the "factory reset" procedures to reset the network settings.
# reboot
SSH Password
Using your favorite SSH client, connect to the Smart Plug's IP address. Use "root" for the username, and "p9z34c" as the password (older models may have used "admin" or "1234").$ ssh root@10.10.10.222 root@10.10.10.222's password: BusyBox v1.19.4 (2014-03-27 17:39:06 CST) built-in shell (ash) Enter 'help' for a list of built-in commands. _ _ _ _ | | _-_| _____ _____ | | _-_| _____ ____ | -_- | || || -_- | || | | |-_ | - || | || |-_ | -__|| _| | _ -_ |_____||__|__|| _ -_ |_____||__| |_| -__| S M A L L |_| -__| S M A R T ----------------------------------------------------- KONKE Technology Co., Ltd. All rights reserved. ----------------------------------------------------- * www.konke.com All other products and * QQ:27412237 company names mentioned * 400-871-3766 may be the trademarks of * fae@konke.com their respective owners. ----------------------------------------------------- root@koven:~#
You can then change the default password with the 'passwd' command.
# cat /etc/shadow | grep root root:$1$4a45vajh$LVbmwoCs84PwyB.r2UdIN1:16185:0:99999:7:::
# passwd Changing password for root New password: Retype password: Password for root changed by root
Control Relay
Turning on and off the relay is really easy:# turn relay on echo 1 > /sys/class/leds/tp-link:blue:relay/brightness # turn relay off echo 0 > /sys/class/leds/tp-link:blue:relay/brightness
Web Interface
cnxsoft posted a simple CGI script (relay.cgi) to control the relay from a web interface:Simply create the directory /www/cgi-bin/ and create the relay.cgi script as follows and give execute permission (chmod +x /www/cgi-bin/relay.cgi).
#!/bin/sh echo "Content-Type: text/plain" echo "Cache-Control: no-cache, must-revalidate" echo "Expires: Sat, 26 Jul 1997 05:00:00 GMT" echo RELAY_CTRL=/sys/class/leds/tp-link:blue:relay/brightness case "$QUERY_STRING" in state) case "`cat $RELAY_CTRL`" in 0) echo "OFF" ;; 1) echo "ON" ;; esac ;; on) echo 1 > $RELAY_CTRL echo OK ;; off) echo 0 > $RELAY_CTRL echo OK ;; esac
Open a browser and use the following URLs to control the relay:
http://your_device_ip/cgi-bin/relay.cgi?on
http://your_device_ip/cgi-bin/relay.cgi?off
Power Limits
The Smart Plug has a max current of 10 A or 2,200 W. A fire may be caused by exceeding these limits.Google+ Group
Hacking the the Smart Plug now has a community group setup on Google+ Groups.
Subscribe to:
Posts (Atom)