Wlan / Wifi Beaglebone Black TP-Link TL-WN722N

After quite some struggeling getting this to work (including problem with internet over usb following this guide Sharing internet using Network-Over-USB in BeagleBone Black ), I got also a working solution for the Wifi.

I followed the guide at TP-Link TL-WN722N USB wireless adapter Beagle Bone Black with one minor typo (it is /etc/network/interfaces) and added three lines to my /etc/rc.local (as root, in front of exit 0 line).

connmanctl disable wifi
connmanctl enable wifi
ifup wlan0

The reason for this is because my adapter always started in master mode and not in managed mode.

Remark: This is most probably not the proper way of doing things, but it worked for me. Weiterlesen

pHAT DAC on OSMC

Our new media center (after some blue smoke on the TV side and resulting that the TV doesn’t send any information over the HDMI i²c-bus) is a RaspberryPi 2 with a [pHAT DAC] running [OSMC].

It is a little bit different than the [guide] on the Pimonori side and also the ones from the [HifiBerry]site [2](same chip on HifiBerryDAC) itself didn’t work.

So here is what I did by using all aforementioned guides:
sudo nano /boot/config.txt

Uncomment the dtoverlay=lirc-rpi:gpio_out_pin=17,gpio_in_pin=18' and add dtoverlay=hifiberry-dac.

Uncomment and change dtparam=audio=on.

Download the correct device tree overlay to  /boot/overlays/ from [ osmc-forum ] (it seems the overlay is broken).
Then reboot with sudo reboot

Within Settings > System > Audio output > Audio output device select ALSA: Default (snd_rpi_dac Analog) and you should hear the acquainted clicking noise.

One remark: This is what I did to get working audio output, not sure if it is the most simple way, but hey it works.

Weiterlesen

PDF-Schnittmuster zusammenfügen

vintage sewing patterns

Manchmal is es nötig aus vielen einzelnen PDF-Seiten eine große ganze zusammenzufügen. Das ist z.B. nötig wenn man ein Schnittmuser auf vielen Seiten verteilt ist, aber man den ganzen Plan ausdrucken will.

Dafür gibt es einige Methoden z.B. ein shell script mit Hilfe von [pdftk CLI] und [imagemagick], jedoch nur unter Linux / OSX. Beide Programme gäbe es auch als Windows Versionen jedoch mit GUI und daher eine anstrengende „Klickerei“ auf Dauer, also alles andere als einfach und deshalb hier eine einfachere Methode um PDFs zusammenzufügen.

LaTeX Variante

Für diese Methode benötigt man das Ausgangs-PDF (mit den einzelnen Schnittmuster-Seiten) und Zugang zu LaTeX. Dafür benötigt man jedoch keine Installation man kann dies online sehr einfach machen.

Weiterlesen

Save all Temporary PDF-Files from Chromium

Sometimes a file – and in that case always an important one – is not reachable anymore with your browser (paywall, internet access, etc.) in this case it is always nice to know how to recover temporary files.

After some stack overflow / exchange searching and piping everything together here a simple solution to find the temp files from chromium:

cd Downloads
mkdir tmp
cd tmp
find ~/.cache/chromium -type f -exec file {} + | grep PDF | sed 's/ *:.*//' | xargs -I{} cp "{}" ~/Downloads/tmp
ls -a

This creates a folder tmp inside the download directory searches the cache of chromium, checks if it is a pdf [source], removes any unnecessary things from the grep output with sed [source] and finally copies everything in the created folder with cp [source].

Note: alle files have a file name without extension and are continuous numbered. Hence, the name has no relation to the content.

Raspberry Pi + TI Sensortag + Plotly

In the last post (Raspberry Pi 2 TI Sensortag) I recapped the possibility to use Raspberry Pi to connect with BLE to a TI Sensortag using the bluepy-library.

A logical next step is to push the data to the „cloud“.

First register under https://plot.ly/ go to settings and note your API Key and your tokens (create two).

To use it with the Raspberry Pi ssh into it (or use a terminal) and install the prerequistes:
sudo apt-get install python-dev
sudo apt-get install python-pip
sudo pip install rpi.gpio
sudo pip install plotly

The next step is to create a script which uploads the streaming data plot.ly, it is heaviliy based on this intructable from plotlygraphs:

import plotly.plotly as py
from plotly.graph_objs import Scatter, Layout, Figure, Data
import time
import datetime
import sensortag

username = 'your_username'
api_key = 'your_api_key'
stream_token1 = 'one_unique_token'
stream_token2 = 'another_unique_token'

py.sign_in(username, api_key)

trace1 = Scatter(
    x=[],
    y=[],
    name='Ambient Temp.',
    stream=dict(
        token=stream_token1,
        maxpoints=5000
    )
)
trace2 = Scatter(
    x=[],
    y=[],
    name='IR Temp.',
    stream=dict(
        token=stream_token2,
        maxpoints=5000
    )
)

layout = Layout(
    title='Raspberry Pi Streaming Sensor Data',
    showlegend=True,
    autosize=True
)

data = Data([trace1,trace2])
fig = Figure(data=data, layout=layout)

print(py.plot(fig, filename='Raspberry Pi Streaming Example Values'))

# activate sensortag
intervall = 20 # seconds
print "Push button on sensortag"
time.sleep(2.0)
tag = sensortag.SensorTag('BC:6A:29:AC:53:D1')

time.sleep(1.0)
tag.IRtemperature.enable()
print("Connected")

i = 0
stream1 = py.Stream(stream_token1)
stream1.open()

stream2 = py.Stream(stream_token2)
stream2.open()


#the main sensor reading loop
while True:
    sensor_data = tag.IRtemperature.read()
    now = datetime.datetime.now()
    stream1.write({'x': now, 'y': sensor_data[0]})
    stream2.write({'x': now, 'y': sensor_data[1]})
    i += 1
        # wait for new measurement
    tag.waitForNotifications(intervall)
    if i > 100:
        break

stream1.close()
stream2.close()
tag.disconnect()
print("Finished!")

The result looks somthing like this.

Raspberry Pi 2 BLE TI Sensor Tag

Install necessary packages:
sudo apt-get install bluez-utils libopenobex1 build-essential libglib2.0-dev libdbus-1-dev

Restart the bluetooth service
sudo service bluetooth restart

Scan for BLE enabled devices connected to the Raspberry Pi:
hciconfig --all

hci0: Type: BR/EDR Bus: USB
BD Address: 00:1A:7D:DA:71:0C ACL MTU: 310:10 SCO MTU: 64:8
UP RUNNING PSCAN
...

Scan for BLE devices:
sudo hcitool lescan

BC:6A:29:AC:53:D1 SensorTag
F4:F9:51:C7:4C:23 (unknown)
BC:6A:29:AC:53:D1 (unknown)
BC:6A:29:AC:53:D1 SensorTag
BC:6A:29:AC:53:D1 (unknown)
...

It shows two devices, but we are only interrested in the Sensor Tag. The adress is BC:6A:29:AC:53:D1 (this address may be different with each device).
So we know bluetooth is working and the mac address of the sensor tag.

Next step is to download/install the great bluepy library from Ian Harvey:
git clone https://github.com/IanHarvey/bluepy.git
cd bluepy/bluepy
make

To read now sensor data from the sensortag, use the example script sensortag.py:
usage: sensortag.py [-h] [-n COUNT] [-t T] [-T] [-A] [-H] [-M] [-B] [-G] [-K]
[--all]
host

positional arguments:
host MAC of BT device

optional arguments:
-h, --help show this help message and exit
-n COUNT Number of times to loop data
-t T time between polling
-T, --temperature
-A, --accelerometer
-H, --humidity
-M, --magnetometer
-B, --barometer
-G, --gyroscope
-K, --keypress
--all

I.e. to read the temperature five times in an interval of 0.5 seconds we use:
python sensortag.py BC:6A:29:AC:53:D1 -n 5 -t 0.5 -T
then press the button on the side of the sensortag
Connecting to BC:6A:29:AC:53:D1
('Temp: ', (31.71875, 30.4396374686782))
('Temp: ', (31.75, 28.29441505369789))
('Temp: ', (31.71875, 27.21886394070981))
('Temp: ', (31.71875, 27.21886394070981))
('Temp: ', (31.71875, 28.54570004702458))

It is also possible (without any changes to the sensortag.py-script) to use it as a python script:
import time
import sensortag

tag = sensortag.SensorTag('BC:6A:29:AC:53:D1')

time.sleep(1.0)
tag.IRtemperature.enable()
for i in range(5):
tag.waitForNotifications(1.0)
print tag.IRtemperature.read()
tag.disconnect()
del tag

One remark if you want to import the module from another folder I recommend adding to the __init__.py file the line:
from . import *
Than it is possible to import the package with realtive importing like:
from bluepy.bluepy import sensortag