A key element of using a Raspberry Pi for a moteino gateway is how to talk to /dev/ttyUSBX for the serial communication.
Problems
Fork/exec management from JRuby seems to be best done with spoon
JavaWorld - fork and exec on the JVM? JRuby to the Rescue!
JavaWorld | May 13, 2009 11:01 PM |
As you should know by now, JRuby ships with FFI, a library that allows you to bind any arbitrary C function in Ruby code. So getting fork+exec to work was a simple matter of writing a little Ruby code:
require 'ffi'
module Exec
extend FFI::Library
attach_function :my_exec, :execl, [:string, :string, :varargs], :int
attach_function :fork, [], :int
end
vim1 = '/usr/bin/vim'
vim2 = 'vim'
if Exec.fork == 0
Exec.my_exec vim1, vim2, :pointer, nil
end
Process.waitall
Update: The biggest problem with using fork+exec in this way is that you can’t guarantee nothing happens between the fork call and the exec call. If, for example, the JVM decides to GC or move memory around, you can have a fatal crash at the JVM process level. Because of that, I don’t recommend using fork + exec via FFI in JRuby, even though it’s pretty cool.
However, since this post I’ve learned of the “posix_spawn” function available on most Unix variants. It’s basically fork + exec in a single function, plus most of the typical security and IO tweaks you might do after forking and before execing. It’s definitely my recommended alternative to fork+exec for JRuby, and to make that easier I’ve bundled it up as the “spoon” gem (gem install spoon) which provides spawn and spawnp to JRuby users directly. Here’s an example session using Spoon to launch JRuby as a daemon. If you just need fork+exec on the JVM, posix_spawn or the Spoon gem are the best way to do it.
require 'rubygems'
require 'spoon'
Spoon.spawnp 'jruby', *ARGV
~/projects/jruby ➔ jruby daemonize.rb -e "puts 'starting'; while true; sleep 1; puts 'still going'; end"
~/projects/jruby ➔ starting
still going
still going
still going
still going
~/projects/jruby ➔ still going
still going
still going
ps
PID TTY TIME CMD
342 ttys000 0:00.06 -bash
421 ttys000 0:00.49 /usr/bin/java -d32 -client -Djruby.memory.max=500m -Djruby.stack.max=1024k
363 ttys001 0:00.02 -bash
still going
~/projects/jruby ➔
kistill going
llstill going
still going
421still going
~/projects/jruby ➔
A fork/exec replacement for FFI-capable implementations
Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot.
Gem::Specification.new do |s|
s.name = "spoon"
s.version = "0.0.4"
s.authors = ["Charles Oliver Nutter"]
s.date = "2013-03-29"
s.description = s.summary = "Spoon is an FFI binding of the posix_spawn function (and Windows equivalent), providing fork+exec functionality in a single shot."
s.files = `git ls-files`.lines.map(&:chomp)
s.require_paths = ["lib"]
s.add_dependency('ffi')
s.license = "Apache-2.0"
end
/usr/bin/socat http://linux.die.net/man/3/posix_spawn http://ruby-doc.org/core-1.9.3/Signal.html
def self.posix_spawn(path, file_actions, spawn_attr, argv, env = ENV) int posix_spawn( pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict]);
int posix_spawnp( pid_t *restrict pid, const char *restrict file, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char * const envp[restrict]);
http://ruby-doc.org/core-1.9.3/Process.html#method-c-waitpid2
https://github.com/headius/spoon/blob/master/examples/ls.rb
require ‘spoon’
# # Do a recursive ls on the current directory, redirecting output to /tmp/ls.out #
file_actions = Spoon::FileActions.new file_actions.close(1) file_actions.open(1, “/tmp/ls.out”, File::WRONLY | File::TRUNC | File::CREAT, 0600) spawn_attr = Spoon::SpawnAttributes.new pid = Spoon.posix_spawn(‘/usr/bin/env’, file_actions, spawn_attr, %w(env ls -R))
Process.waitpid(pid)
https://github.com/ffi/ffi/issues/336 «««««««««««< wrong, should be issue on JRuby Fail on Raspberry Pi ARM linux JRuby. FFI not available
https://github.com/jruby/jruby/issues/1561 Fail on Raspberry Pi ARM linux JRuby. FFI not available
A Raspberry Pi based gateway to distributed Moteino radio connected Arduinos.
After the Debian Wheezy armel image I made a new one based on Raspbian armhf. This one is compiled with hard float support, so basically floating point operations are MUCH faster because they are done in hardware instead of software emulation :)
The most interesting on here is the raspbian-ua-netinst. There is Github repo for it:
Github repo with raspbian-ua-netinst
I had previously used the Raspbian net installer here: RaspbianInstaller
But the notes now say: Currently we reccomend using hifi’s raspbian-ua-netinst instead if you want to use an installer rather than a pre-installed image.
Dark Basic Raspbian SDHC Boot image
You will have to extract the image with p7zip:
7za x raspbian_wheezy_20130923.img.7z
Then flash it to your SD with dd:
$ sudo dd bs=1M if=raspbian_wheezy_20130923.img of=/dev/sdc
Finally, if you have an sd larger than 1GB, grow the partition with gparted (first move the swap partition at the end).
$ sudo gparted /dev/sdc
At this point install the SDHC card on the RPI, plug in the ethernet cable, plug in the USB terminal cable which will power up the RPI.
Now use screen to watch the boot up messages.
Able to use screen to connect on laptop:
$ sudo screen /dev/ttyUSB0 115200
When connected check the stty values.
$ stty -a
Attempts to use socat instead of screen
$ sudo socat - /dev/ttyUSB0,b115200
$ sudo socat - /dev/ttyUSB0,b115200,raw # no
$ sudo socat - /dev/ttyUSB0,b115200,cs7 # no
$ sudo socat - /dev/ttyUSB0,b115200,parenb,cs7 # no
$ sudo socat - /dev/ttyUSB0,b115200,parenb,cs8 # no
$ sudo socat - /dev/ttyUSB0,b115200,raw,cs7 # no
$ sudo socat - /dev/ttyusb0,b115200,raw,cs8,start=1,stop=1 # no
$ sudo socat - /dev/ttyusb0,b115200,parenb=false,raw,cs8,start=1,stop=1 # no
$ sudo socat - /dev/ttyUSB0,b115200,raw,cs8 # no
$ sudo socat - /dev/ttyUSB0,b115200,raw,cs7 # no
$ sudo socat - /dev/ttyUSB0,b115200,raw,cs8 # no
$ sudo socat - /dev/ttyUSB0,b115200,cs8,parenb=0 # close, but not exact
$ sudo socat - /dev/ttyUSB0,b115200,cs8,parenb=0,stop=0 # close
$ sudo socat - /dev/ttyUSB0,cs8,parenb=0,stop=0,ixon=1,ixoff=1 # close
$ sudo socat - /dev/ttyUSB0,cs8,parenb=0,stop=0,ixon=1,ixoff=1,echo=0
$ sudo screen /dev/ttyUSB0 115200
$ sudo socat /dev/ttyUSB0,raw,echo=0,crlf
$ socat -d -d -d -d -x TCP:localhost:7758 FILE:/dev/ttyUSB0,b9600,raw
Found the IP address on the router: 192.168.88.223
ssh into the RPI and have a go. The root password is raspberry.
$ ssh root@192.168.88.223
Change the root password
passwd
You will have to reconfigure your timezone after the first boot:
# dpkg-reconfigure tzdata
The keyboard layout:
# dpkg-reconfigure console-data
And the localization:
# dpkg-reconfigure locales
Edit /etc/hostname to have the hostname.
$ cat /etc/hostname
pika
Edit /etc/hosts and a line with the new hostname.
$ cat /etc/hosts
127.0.0.1 localhost
127.0.0.1 pika <<< added this line with hostname
...
# adduser craig
Note that from now on:
# prompt means run as root.
$ prompt means run as user craig
# su - craig
Generate a key pair for the new user
$ ssh-keygen
Check the Debian version
$ cat /etc/debian_version
7.2
Update the system
# apt-get update
# apt-get dist-upgrade
Install python, vim, tmux, git
# apt-get install python
# apt-get install vim tmux git
Personalize git
# git config --global user.name "Your Name Here"
Sets the default name for git to use when you commit
# git config --global user.email "your_email@example.com"
Sets the default email for git to use when you commit
Set up the vim dotfiles and vundle.
$ git clone git@github.com:CootCraig/dotfiles_again.git
$ cd dotfiles_again/linux
$ bash ./install.sh
cd ~/dotfiles_again/windows/vimfiles/bundle
git clone https://github.com/gmarik/vundle.git
There are some notes on using vundle in the file ~/.vim/bundle/Readme.txt The Raspbian vim does not have python support, so disable UltiSnips vim script. Comment out the following line in ~/.vimrc
Bundle 'vim-scripts/UltiSnips'
to
"Bundle 'vim-scripts/UltiSnips'
And then run BundleInstall.
in vim. :BundleInstall
These instructions worked fine.
How to set up ssh so you aren’t asked for a password
Add the contents of the public key file into ~/.ssh/authorized_keys on the remote site (the file should be mode 600).
# apt-get install sudo
# adduser craig sudo
On the Ubuntu host.
$ sudo dd bs=1M if=/dev/sdc of=pika_20140220_1441.img
7519+0 records in
7519+0 records out
7884242944 bytes (7.9 GB) copied, 446.404 s, 17.7 MB/s
$ 7za a -t7z pika_20140220_1441.img.7z pika_20140220_1441.img
$ ls -l pika_2014*
-rw-r--r-- 1 craig craig 7884242944 Feb 20 14:49 pika_20140220_1441.img
-rw-r--r-- 1 craig craig 254215741 Feb 20 15:09 pika_20140220_1441.img.7z
# apt-get install build-essential checkinstall libtool automake uuid-dev
The following extra packages will be installed:
autoconf autotools-dev binutils bzip2 cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl libfile-fcntllock-perl libgmp10 libgomp1 libltdl-dev
libltdl7 libmpc2 libmpfr4 libstdc++6-4.6-dev libtimedate-perl m4 make
Suggested packages:
autoconf2.13 autoconf-archive gnu-standards autoconf-doc gettext binutils-doc bzip2-doc cpp-doc gcc-4.6-locales debian-keyring gcc-4.6-doc libstdc++6-4.6-dbg gcc-multilib manpages-dev automake1.9 flex bison gdb gcc-doc
libmudflap0-4.6-dev libgcc1-dbg libgomp1-dbg libquadmath-dbg libmudflap0-dbg binutils-gold libtool-doc libstdc++6-4.6-doc automaken gfortran fortran95-compiler gcj make-doc
The following NEW packages will be installed:
autoconf automake autotools-dev binutils build-essential bzip2 checkinstall cpp cpp-4.6 dpkg-dev fakeroot g++ g++-4.6 gcc gcc-4.6 libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libdpkg-perl
libfile-fcntllock-perl libgmp10 libgomp1 libltdl-dev libltdl7 libmpc2 libmpfr4 libstdc++6-4.6-dev libtimedate-perl libtool m4 make uuid-dev
0 upgraded, 32 newly installed, 0 to remove and 0 not upgraded.
Need to get 26.8 MB of archives.
After this operation, 69.2 MB of additional disk space will be used.
Source for stable release 3.2.4
This is supported by ffi-rzmq, the JRuby librar I plan to use. I unpacked for build at:
# cd /opt/zeromq/zeromq-3.2.4
The installation will be to /usr/local/
# ./configure --help
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
Build and install.
# ./configure
# make
# checkinstall
A debian package was left here:
/opt/zeromq/zeromq-3.2.4/zeromq_3.2.4-1_armhf.deb
From /etc/inittab
...
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
...
However, this is the device file we see:
$ ls -l /dev/ttyAMA0
crw-rw---T 1 root dialout 204, 64 Dec 31 1969 /dev/ttyAMA0
So let’s add this line to /etc/inittab
...
# Example how to put a getty on a serial line (for a terminal)
#
#T0:23:respawn:/sbin/getty -L ttyS0 9600 vt100
T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100
#T1:23:respawn:/sbin/getty -L ttyS1 9600 vt100
...
I have failed to get Wifi working and would like some help. I’m not sure how how to troubleshoot from here. Here are some details on my setup.
Using this OS image. I want a minimal install with no X.
Dark Basic Raspbian SDHC Boot image
With this USB wifi plug: Edimax EW-7811UN
Boot time messages include these related to the Edimax plug.
[ 3.232011] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[ 3.364155] usb 1-1.2: New USB device found, idVendor=7392, idProduct=7811
[ 3.380505] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[ 3.399033] usb 1-1.2: Product: 802.11n WLAN Adapter
[ 3.411807] usb 1-1.2: Manufacturer: Realtek
[ 3.417625] usb 1-1.2: SerialNumber: 00e04c000001
...
[ 15.826605] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
System reports as.
root@pika:~# uname -a
Linux pika 3.6.11+ #545 PREEMPT Fri Sep 20 23:57:55 BST 2013 armv6l GNU/Linux
More evidence the Edimax Wifi is seen
root@pika:~# lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp.
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp.
Bus 001 Device 004: ID 7392:7811 Edimax Technology Co., Ltd EW-7811Un 802.11n Wireless Adapter [Realtek RTL8188CUS]
The wifi driver module is loaded
root@pika:~# lsmod
Module Size Used by
...
8192cu 490361 0
...
Output of iwconfig
root@pika:~# iwconfig
wlan0 unassociated Nickname:"<WIFI@REALTEK>"
Mode:Auto Frequency=2.412 GHz Access Point: Not-Associated
Sensitivity:0/0
Retry:off RTS thr:off Fragment thr:off
Encryption key:off
Power Management:off
Link Quality:0 Signal level:0 Noise level:0
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:0 Missed beacon:0
The MicroTik Router is seen.
root@pika:~# iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 - Address: D4:CA:6D:56:86:59
ESSID:"Pirates"
Protocol:IEEE 802.11bgn
Mode:Master
Frequency:2.412 GHz (Channel 1)
Encryption key:on
Bit Rates:300 Mb/s
Extra:wpa_ie=dd160050f20101000050f20401000050f20401000050f202
IE: WPA Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Extra:rsn_ie=30120100000fac040100000fac040100000fac02
IE: IEEE 802.11i/WPA2 Version 1
Group Cipher : CCMP
Pairwise Ciphers (1) : CCMP
Authentication Suites (1) : PSK
Quality=100/100 Signal level=100/100
Contents of /etc/network/interfaces.
root@pika:/etc/network# cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
allow-hotplug eth0
iface eth0 inet dhcp
allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-ssid Pirates
wpa-psk thepassword
But I have not been able to enable the Wifi.
root@pika:~# ifup wlan0
Internet Systems Consortium DHCP Client 4.2.2
Copyright 2004-2011 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
[ 1389.028246] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
Listening on LPF/wlan0/80:1f:02:a2:df:94
Sending on LPF/wlan0/80:1f:02:a2:df:94
Sending on Socket/fallback
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 11
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 18
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
No DHCPOFFERS received.
No working leases in persistent database - sleeping.
Note, the MicroTik router Wifi is in use by all the laptops we have tried.
$11.95
The Pololu adjustable boost regulator is a very flexible switching regulator (also called a switched-mode power supply, SMPS, or DC-to-DC converter) that can generate voltages higher than its input voltage. We offer two adjustable ranges: approximately 2.5 V to 9.5 V and 4 V to 25 V. The output voltage can be set using the trimmer potentiometer in the upper-right corner of the board. The input voltage range is 1.5 V to 16 V (the input voltage should be kept below the output voltage). The integrated 2 A switch allows for output currents high enough to drive small motors, as in our 3pi robot, and allows large voltage gains, such as obtaining 24 V from two NiMH or NiCd cells.
The boost regulator has just three connections: the input voltage, ground, and the output voltage. These three connections are labeled on the back side of the PCB, and they are arranged with a 0.1″ spacing along the edge of the board for compatibility with standard solderless breadboards and perfboards and connectors that use a 0.1″ grid. You can solder wires directly to the board or solder in either the 3×1 straight male header strip or the 3×1 right-angle male header strip that is included.
The output voltage can be adjusted using a meter and a light load (e.g. a 10 kΩ resistor). Turning the potentiometer clockwise increases the output voltage. The output voltage can be affected by a screwdriver touching the potentiometer, so the output measurement should be done with nothing touching the potentiometer.
$4.95
This compact (0.45″×0.6″) U1V11F5 switching step-up (or boost) voltage regulator efficiently generates 5 V from input voltages as low as 0.5 V. Unlike most boost regulators, the U1V11F5 offers a true shutdown option that turns off power to the load, and it automatically switches to a linear down-regulation mode when the input voltage exceeds the output. The pins have a 0.1″ spacing, making this board compatible with standard solderless breadboards and perfboards.
This 5 V boost (step-up) voltage regulator generates higher output voltages from input voltages as low as 0.5 V, and it also automatically switches to a linear down-regulation mode when the input voltage exceeds the output. This makes it great for powering 5 V electronics projects from 1 to 3 NiMH, NiCd, or alkaline cells or from a single lithium-ion cell. Additionally, unlike most boost regulators, this unit offers a true shutdown option that turns off power to the load (with typical boost regulators, the input voltage will pass directly through to the output when they are disabled).
When boosting, this module acts as a switching regulator (also called switched-mode power supplies (SMPS) or DC-to-DC converters) and has a typical efficiency between 70% to 90%. The available output current is a function of the input voltage, output voltage, and efficiency (see Typical Efficiency and Output Current section below), but the input current can typically be as high as 1.2 A.
The boost regulator has four connections: shutdown (SHDN), input voltage (VIN), ground (GND), and output voltage (VOUT).
The SHDN can be driven low (typically under 0.4 V) to power down the regulator and turn off power to the load (unlike most boost regulators, the input power does not pass through to the output when the board is disabled). This pin is internally pulled up to VIN through an 100 kΩ resistor, so it can be left disconnected or connected directly to VIN if you do not need to use the disable feature. The disable threshold is a function of the input voltage as follows:
Called when data is available. Use Serial.read() to capture this data.
Demonstrates use of the SerialEvent() function. SerialEvent() is called after a loop(), if there is serial data in the buffer.
Data Structures and Algorithms
It is created to help adding FIFO (First In - First Out) Abstract Data Structure to a program for any use.
alexanderbrevig - Simple templated FIFO class
forum.arduino.cc - Demonstration code for several things at the same time
Robin2 - March 04, 2014, 07:28:03 am
My sketch uses the concept in “blink without delay” to cause three LEDs to blink at different intervals, a fourth LED is controlled by a button and a servo sweeps back and forth at two different speeds. The idea is to demonstrate how different processes can be accommodated in the same general framework.
It also uses the “state machine” concept to manage the various activities and enable the different functions to determine what to do.
I have deliberately designed the sketch as a series of short functions. Short pieces of code are much easier to understand and debug and it will be an easy matter for a user to delete functions that they don’t need or to duplicate and modify functions if they need more of the same (for example to flash 5 LEDS at different intervals).
There is a case for saying there is too much in the sketch but I concluded that the larger number of activities is a better demonstration of the capabilities of this approach.
SeveralThingsAtTheSameTimeRev1.ino
arduino.cc tutorial - Blink Without Delay
Sometimes you need to do two things at once. For example you might want to blink an LED (or some other time-sensitive function) while reading a button press or other input. In this case, you can’t use delay(), or you’d stop everything else the program while the LED blinked. The program might miss the button press if it happens during the delay(). This sketch demonstrates how to blink the LED without using delay(). It keeps track of the last time the Arduino turned the LED on or off. Then, each time through loop(), it checks if a long enough interval has passed. If it has, it toggles the LED on or off.
SimpleTimer Library for Arduino
This is (yet another) simple library to launch timed actions.
It’s based on millis(), thus it has 1 ms resolution.
It uses polling, so no guarantee can be made about the exact time when a callback is fired. For example, if you setup the library so that it calls a function every 2ms, but this function requires 5ms to complete, then you’ll have an invocation every 5ms.
For applications where non-strict timing is enough, not using interrupts avoids potential problems with global variables shared between the interrupt service routine and the main program, and doesn’t consune a hardware timer.
Nick Gammon - How to do multiple things at once … like cook bacon and eggs
I am goint to try out the Github Makefile project for Arduino from Sudar Muthu
This is a very simple Makefile which knows how to build Arduino sketches. It defines entire workflows for compiling code, flashing it to Arduino and even communicating through Serial monitor. You don’t need to change anything in the Arduino sketches.
If you’re using FreeBSD, Debian or Ubuntu, you can find this in the arduino-mk package and can be installed using apt-get or aptitude.
Download the latest release
Or clone it from Github using the command git clone Github Repo
Night Dreaming (by Sudar) WordPress, JavaScript, Android, Arduino and some random stuff
Hello and Welcome
I am Sudar and this is my personal site. It serves as a starting point for most of the information I have put on the web. I started this site as a hobby so that I can return back what I can to this online world from where I have learned and still learning so many things. Have a nice sta
One of the main reasons why Arduino is very popular with beginners is that it is completely self-contained which makes it very easy to use. Once you have an Arduino board, all you have to do is to download the software and within minutes you can make your first led blink. The software has everything you need right from the IDE, to the compiler and even serial monitor to communicate with Arduino, all within one single package.
While the Arduino IDE is very good for beginners, you might start to feel its limitations, once you start working with it regularly. I use vim for everything and always wished writing Arduino sketches in vim.
I configured Arduino IDE, to use an external editor and started using vim to write code and then Arduino IDE to compile and upload. While this worked for sometime, I started to feel the need for a proper makefile so that I can do everything from vim itself.
lug$ cd /opt/Arduino
log$ wget http://arduino.googlecode.com/files/arduino-1.0.5-linux64.tgz
lug$ tar xzf arduino-1.0.5-linux64.tgz
lug$ ln -s arduino-1.0.5 arduino
lug$ ls -l
lrwxrwxrwx 1 craig craig 13 Mar 23 14:45 arduino -> arduino-1.0.5
drwxr-xr-x 8 craig craig 4096 May 17 2013 arduino-1.0.5
The Makefile delegates resetting the board to a short Perl program. You’ll need to install Device::SerialPort and YAML library.
On Debian or Ubuntu:
apt-get install libdevice-serialport-perl
apt-get install libyaml-perl
I forked Arduino-Makefile from sudar.
$ mkdir /opt/sudar; cd /opt/sudar
$ git clone git@github.com:CootCraig/Arduino-Makefile.git
$ cd /opt/sudar/Arduino-Makefile
Pull in upstream changes
$ git remote add upstream https://github.com/sudar/Arduino-Makefile.git
$ git fetch upstream
$ git merge upstream/master
Set up git branches for craig local working changes. Leave master as copy of upsteam.
$ git checkout -b craig
Switched to a new branch 'craig'
craig@lug:/opt/sudar/Arduino-Makefile$ git branch
* craig
master
$ git checkout -b craig-develop
Switched to a new branch 'craig-develop'
$ git branch
craig
* craig-develop
master
What are the avr packages.
$ dpkg --get-selections |grep avr
avr-libc install
avrdude install
binutils-avr install
gcc-avr install
Where are the avr files.
/usr/bin/avr-g++
/usr/bin/avrdude
/usr/lib/avr/lib/libc.a
/usr/lib/avr/bin/ar
/usr/lib/gcc/avr/4.7.2/
~/.profile
export ARDUINO_DIR=/opt/arduino/arduino
export ARDMK_DIR=/opt/sudar/Arduino-Makefile
export AVR_TOOLS_DIR=/usr
/opt/sudar/Arduino-Makefile/Arduino.mk
Per sketch variables
After the global settings, you will need to specify the following variables for each sketch
BOARD_TAG – The Arduino board that you are using. By default Uno is used ARDUINO_PORT – The serial port where Arduino is connected ARDUINO_LIBS – Space separated set of libraries that are used by your sketch
I just received from Sparkfun a few RFM12B wireless modules to experiment with. They’re great little things – you get a FIFO in, a FIFO out, all the RF stuff is taken care of, and you have super flexibility with all the network layers above that. The best part is, the relatively low complexity compared to something like a ZigBee means both that there’s no extraneous fluff when your application doesn’t need it, and the cost is just right at $7/module in low quantities. But annoyingly, they can be had in a SMD module with 2mm pin pitch – not very 100mil breadboard friendly. Not wanting to deal with that. I whipped up a basic passive breakout board to have on hand. Inevitably, this will see updates as I do things like add regulators and level shifters for particular projects. For now, it just makes breadboarding easy. To get the files, head over to the Github repository at https://github.com/alexwhittemore/RFM12B-Breakout. I’ve ordered 6 from OSHPark, I’ll report back in a couple weeks how they turned out.
This board is the perfect way to interface traditional Arduinos (or other microcontrollers) to JeeNodes. While we like our JeeLink modules a lot, as an easy way to get going with wireless, this board is a quick and easy add-on to Arduinos, to leverage your current technology. The RFM12B Board is a compact breakout board for HopeRF’s RFM12B radio module, as featured on all JeeNode and JeeLink boards. If you are looking for an affordable way to add wireless communication to your Arduino (compatible) board, this is the board to get.
Now looking at Modeino instead of JeeNodes
Radios are available in 433 MHz & 915 MHz in the US, all unlicensed ISM (Industrial, Scientific, Medical) bands.
The JeeNode Kit contains all the parts needed to build a JeeNode v6 – including an ATmega328p processor and an RFM12B radio module. The processor chip is pre-flashed with the Arduino boot loader and the RF12demo sketch, so it works to talk to another JeeNode right out of the box.
Here is an introduction of my first attempt at an Arduino project.
I have installed
260 inches of this 12v LED strip into my front steps.
My estimate of maximum power consumed is 32W as shown here. Their rating is 24W for a 16.4 foot reel. So my power estimate is
260 in. X (24w / 197in) ~= 32W.
The strip is too bright by itself so I use a PWM dimmer from LEDWholesalers set about as low as it will go.
What I would like to do is use a JeeNode and LEDnode pair to make a remote controller for the lights.
I’m hoping to get some help and encouragement here and to end up with a sweet controller for our LED step lighting.
This module switches a high current load using a high power transistor. Unlike a mechanical relay, this is capable of high speed switching for use with PWM.
Output: This module lets you control devices operating at a maximun of 24VDC with an Arduino pin. To wire the module, connect the power supply for your device (max 24 V) to the V+ and GND terminals. Connect the device to M+ and M-. Be aware of your circuit’s polarity, you could damage your components if it is not wired correctly.
Module Description: This module features an IRF520 power MOSFET transistor, a kick-back diode, a standard TinkerKit 3pin connector,a signal amplifier, a green LED that signals that the module is correctly powered and one yellow LED whose brightness depends on the input signal received by the module.
Description: This is a 12-step rotary encoder with a nice ‘clicking’ feel. It’s breadboard friendly, and has a pretty handy select switch (by pushing in on the knob). The encoder is different from a potentiometer in that an encoder has full rotation without limits. The unit outputs gray code so that you can tell how much and in which direction the encoder has been turned.
The Input Plug is a small board containing a CD4067 16-channel analog multiplexer plus a dedicated ATtiny microcontroller to take care of channel selection. It allows you to connect up to 16 analog inputs to a single AIO pin on any port. There is an “InputPlug” class in the Ports library to interface with this board and perform the channel selection.
This board can also be used as 16-channel digital input multiplexer, and even for digital outputs or PWM – with the restriction than a channel goes into high-impedance mode when not selected (there is no latching or buffering).
Description: This is a standard 12mm square momentary button. What we really like is the large button head and good tactile feel (it ‘clicks’ really well). This button is great for user input on a PCB or a good, big reset button on a breadboard. Breadboard friendly!
The TSL2561 Luminosity Sensor Breakout is a sophisticated light sensor which has a flat response across most of the visible spectrum. Unlike simpler sensors, the TSL2561 measures both infrared and visible light to better approximate the response of the human eye. And because the TSL2561 is an integrating sensor (it soaks up light for a predetermined amount of time), it is capable of measuring both small and large amounts of light by changing the integration time.
The TSL2561 is capable of direct I2C communication and is able to conduct specific light ranges from 0.1 - 40k+ Lux easily. Additionally, the TSL12561 contains two integrating analog-to-digital converters (ADC) that integrate currents from two photodiodes, simultaneously. Each breakout requires a supply voltage of 3V and a low supply current max of 0.6mA.
TSL2561 Luminosity Sensor Hookup Guide
TSL2561 label | Pin function | Arduino connection |
---|---|---|
SDA | I2C data | pin labeled A4/SDA |
SCL | I2C clock | pin labeled A5/SCL |
GND | Ground | GND |
3V3 | 3.3V power supply | 3.3V (NOT 5V) |
INT | Interrupt | Optional, leave disconnected unless you're using interrupts. |
Adafruit tsl2561 Breakout - wiring Tsl2561 and RTC
Notes on using the Tsl2561 and the RTC both on I2c.
You may be wondering, how is it OK to connect a 3.3V chip like the TSL2561 to 5.0V data pins like the Arduino? Isn’t that bad? Well, in this specific case its OK. I2c uses pullup lines to the 3.3V power pin, so the data is actually being sent at 3.3V. As long as all the sensors/device on the i2c bus are running on 3.3V power, we’re fine. However, don’t use a 5.0v powered i2c device (like the DS1307) with pullups at the same time as a 3.3V device like the TSL2561! If you want to use this sensor with a datalogger that uses the DS1307, remove any/all of the pullup resistors from the DS1307 SDA/SCL pins. The pullups built into the TSL2561 will then be active and keep the voltage at 3.3V which is safe for both the RTC and the sensor.
You don’t need to connect the ADDR (i2c address change) or INT (interrupt output) pins.
The ADDR pin can be used if you have an i2c address conflict, to change the address. Connect it to ground to set the address to 0x29, connect it to 3.3V (vcc) to set the address to 0x49 or leave it floating (unconnected) to use address 0x39.
The INT pin is an ouput from the sensor used when you have the sensor configured to signal when the light level has changed. We don’t have that code written in this tutorial so you don’t have to use it. If you do end up using it, use a 10K-100K pullup from INT to 3.3V (vcc)
Every component attached to an I2C bus has a fixed address from 0 to 127. You can theoretically have a maximum of 128 devices on a single bus, but in practice you are limited to the options available for each part.
The TSL2561 supports three possible addresses: 0x29, 0x39, or 0x49. Practically speaking, this means you can have up to three TSL2561s attached to a single I2C bus.
Which address the part uses is controlled by the solder jumper labeled “ADDR”. When there is no solder on this jumper, the TSL2561 will used the default address of 0x39.
To use one of the other addresses, add solder to bridge the center pad to ONE of the two side pads. If you bridge to the “0” side, the address will be 0x29. If you bridge to the “1” side, the address will be 0x49. Don’t bridge both sides.
#define DS1307_ADDRESS 0x68
##
BPS AN0002 Introducing Solderable PC BreadBoard
Here are some suggestions for connecting power and other off-board signal connections to a solderable PC breadboard:
Jumptuck - Voltage regulation with our friend the 7805
Electrolytic smoothing caps
output - 0.1uF
Digikey - JST Sales America Inc B2B-PH-K-S(LF)(SN) CONN HEADER PH TOP 2POS 2MM
FTDI Basic Breakout - 5V $15.00
USB cables replace the huge variety of connectors that used to be standard for computer peripherals: Parallel ports, DB9 Serial, keyboard and mouse ports, joystick and midi ports… Really, it was getting out of hand. USB simplifies the process of installing and replacing hardware by making all communications adhere to a serial standard which takes place on a twisted pair data cable and identifies the device that’s connected. When you add the power and ground connections, you’re left with a simple 4-conductor cable that’s inexpensive to make and easy to stow.
99% of host controllers will have a USB-A receptacle, so when you’re looking for a USB cable, you’ll usually be looking for a “USB A-to-something” cable. A lot of the time the USB-A end is assumed, since that’s the connector on most PCs, and cables will be named after the connector on the opposite end. Some smaller hosts use a Mini or Micro receptacle but they usually supply a pigtail adapter to USB-A.