Wednesday, September 7, 2016

UPS on Linux

Install nut

The following example is for Tripp Lite UPS
Verify the Tripplite UPS:

# lsusb
Bus 002 Device 026: ID 09ae:2010 Tripp Lite 


Edit /lib/udev/rules.d/52-nut-usbups.rules and make sure the line below exists:

ATTR{idVendor}=="09ae", ATTR{idProduct}=="2010", MODE="664", GROUP="nut"

Reload the udev files:

udevadm control --reload-rules
My UPS definition in /etc/nut/ups.conf:

[tripplite_ups]
    driver = usbhid-ups
    port = auto
    vendorid= 09ae
    productid = 2010
    desc = "Tripp-Lite UPS"

(The library file is located in /lib/nut)

My /etc/nut/upsd.conf:
LISTEN 127.0.0.1        3493
LISTEN 192.168.25.168   3493
LISTEN 192.168.1.1      3493
LISTEN ::1              3493

Restart the driver:

$ sudo upsdrvctl start
Network UPS Tools - UPS driver controller 2.7.2
Network UPS Tools - Generic HID driver 0.38 (2.7.2)
USB communication driver 0.32
Using subdriver: TrippLite HID 0.81

If no error, that means everything is working fine.

My /etc/nut/upsd.users contains:

[upsmon]
    password = pass
    upsmon  master

My /etc/nut/upsmon.conf contains:

MONITOR tripplite_ups@localhost 1 upsmon pass master
SHUTDOWNCMD "/sbin/shutdown -h +0"
NOTIFYCMD /usr/local/bin/upsnotifyme
#NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD    SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG NOPARENT SYSLOG

Restart the nut-server and client:

sudo service nut-server restart
OptiPlex-9020:/lib/udev/rules.d$ sudo service nut-client restart
                          
                                                                     
If it works, your PC can now communicate with UPS.

Sunday, March 27, 2016

SBC IoT

Single Board Computer for Internet of Things now are getting more popular since Raspberry Pi.  Now we can see even 64-bit SBC with less than $40 price tag!

Following is the list of SBCs I can think of:


MakerModelCPUPriceWebsiteMisc.
Raspberry-PiRPI1 Model A+BCM2835$25https://www.raspberrypi.org
Raspberry-PiRPI1 B+$35https://www.raspberrypi.org
Raspberry-PiRPI2 Model BBCM2836$35https://www.raspberrypi.org
Raspberry-PiRPI 3 Model B$35https://www.raspberrypi.org
Raspberry-PiZero$5https://www.raspberrypi.org
CHIPAllWinner R8 (ARM)$9http://www.allwinnertech.com
Pine64Cortex-A53 AllWinner A64$15 - $29http://www.pine64.com
FriendlyARMNanoPi 2 (I/O ports compatible with RPi)Quadcore A9$24.99http://www.friendlyarm.com
Texas InstrumentsARM TIVA LaunchPADARM Cortex M4F$12.99Datasheet
STM MicroelectronicsNUCLEO-F103RBARM Cortex M3$10.33Product InfoDev. Board is compatible with Arduino


I personally like the FriendlyARM as it is more open system than Raspberry Pi. Broadcom is known for being paranoid to reveal the details of their products as we can see from their datasheets. FriendlyARM is more community-friendly and provides a lot of stuff already. With the damn-cheap price and the board is ready out of the box (unlike Rpi which still needs flash card), this kit is very exciting, even more interesting than Arduino.

Sunday, February 21, 2016

Arduino 828p Pro Mini

I bought this small board Arduino Mini (the right board, not the left board which is just a power regulator) from eBay from China for less than $2 plus S/H.  The bareboard has SMD version of Atmel AVR 828p, a RESET switch (left), and bunch of I/O ports.  The board seems a clone of what Sparkfun has (see https://www.sparkfun.com/products/11113)

Specifications:
  • 20 Digital input / output ports:TX, RX, D2..D13, A0 .. A5
  • 8 analog inputs ports:A0 ~ A7
  • 1 pairs of TTL level serial transceiver ports RX / TX
  • 6 PWM ports: D3, D5, D6, D9, D10, D11
  • Main Chip: Atmel Atmega328P-AU
  • Support Serial Download
  • Support external power supply 3.8-12V DC
  • Support 12V or less than 12V battery power supply
  • 16MHz clock frequency
  • Size: 33.8mm x 18mm
  • Supports auto-reset
  • Max 150mA output
  • Over current protected
  • Weighs less than 2 grams

When supplying unregulated power to the board, we should connect to the “RAW” pin and not VCC.
I/O pins are labeled "D0", "D1", ... "D13" for digital I/Os, and "A0" to "A7" for analog inputs.  There are two TRO and RXI pins.


Label on BoardFunction(s)
A0ADC0
A1ADC1
A2ADC2
A3ADC3
A4ADC4/SDA
A5ADC5/SCL
A6ADC6
A7ADC7
RXID0/RXD
TXOD1/TXD
D2D2/INT0
D3D3/INT1
D4D4/T0
D5D5
D6D6/OC0B
D7D7/IN1
D8D8/ICP1
D9D9/PCINT1
D10D10/PCINT2
D11D11/PCINT3
D12D12/MISO
D13D13/SCK/LED

Sunday, January 31, 2016

Raspberry Pi vs. Next-Big-Thing's CHIP SoC Computer


Feature
RPI 1 Model A
RPI 1 Model B
RPI 1 Model A+
RPI 1 Model B+
RPI 2ModelB
NBT CHIP

SoC
BRCM 2835
BRCM 2835
BRCM 2835
BRCM 2835

AllWinner's R8
Standard SoC Speed (MHz)
700
700
700
700
900
1000

RAM (MB)
256
512
256
512

512
Ethernet (Mbps)
N/A
100
100
100
1000
N/A

HDMI output
N/A
Yes
Yes
Yes
Yes
With extra module

Composite Video out
Yes
Yes
via 3.5 mm jack
via 3.5 mm jack
via 3.5 mm jackYes

Number of USB2.0
2
2
1
4
4
1

CPU Cores111141
StorageSD CardSD Cardmicro SDmicro SDMicroSDBuilt-in Flash
Internal Storage CapacityN/AN/AN/AN/AN/A4 MB
Camera Interface (CSI)
yesyesyesyesyes
Display Interface (DSI)
yesyesyesyesyes
Video/Graphic CoprocessorVideoCore IVVideoCore IVVideoCore IVVideoCore IVVideoCore IVPowerVR SGX544
ArchitectureARM11v6ARM11v6ARM11v6ARM11v6ARMv7ARMv7
GPIO Pins2640404040

Thursday, September 10, 2015

OpenFrameworks: Another cool Multi-platform Framework for Graphics

Steps to download and build OpenFrameWorks:
  • git clone https://github.com/openframeworks/openFrameworks.git
  • goto the OF root.  This is usually the folder openFrameworks.  Change directory to ./scripts/linux/ubuntu (e.g: cd openFrameworks/scripts/linux/ubuntu)
  • Execute the scripts in the folder as root:
sudo ./install_dependencies.sh
sudo ./install_codecs.sh

Go to ./scripts/linux and execute:

./compileOF.sh
./compilePG.sh

To generate projects (Makefile etc.)  for all the examples, goto OF root, then type:

projectGenerator -v -r examples/

wxWidgets 3.0

To add the repository, first import the key:
sudo apt-key adv --fetch-keys http://repos.codelite.org/CodeLite.asc
 
Then add the source:


sudo tee /etc/apt/sources.list.d/wxwidgets.list
deb http://repos.codelite.org/wx3.0.2/ubuntu/  $(lsb_release -sc) universe
sudo apt-get update

Install wxWidgets modules:

sudo apt-get install libwxbase3.0-0-unofficial libwxbase3.0-dbg libwxbase3.0-dev libwxgtk3.0-0-unofficial libwxgtk3.0-dbg wx3.0-doc wx3.0-examples 

Create soft-link:
sudo ln -s /usr/include/wx-3.0-unofficial/wx /usr/include/wx 
To compile a single file, create a script named wxcompile and edit it with the content as below (assume with have subdirectory obj/Debug and bin/Debug:

#!/bin/bash

if [ -z "${1}" ]
then
    echo "$0 "
    exit 1
fi

FILE=`basename $1`
CPPF=$FILE
OBJF=`basename -s .cpp $CPPF`
OBJF=${OBJF}.o
g++ -g -c -Wall -DWX_PRECOMP -Winvalid-pch `wx-config --cppflags` -o obj/Debug/${OBJF} ${CPPF}


To link, create a script file name 'wxlink' and its content as below:



#!/bin/bash

if [ -z "${1}" ]
then
    echo "$0 "
    exit 1
fi

FOUT=$1
OBJF=obj/Debug/*.o

g++ -v obj/Debug/*.o `wx-config --libs` -o obj/Debug/$FOUT

For a bigger project which requires more complicated and conditional compilation, use Makefile.