HackADay https://tech.feedyourhead.at/tags/hackaday en HackADay: Let's make a Nukestation https://tech.feedyourhead.at/content/hackaday-lets-make-a-nukestation <span class="field field--name-title field--type-string field--label-hidden">HackADay: Let&#039;s make a Nukestation</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>Every time I replace an old hard disk by a newer or bigger one I think that I'll wipe it later. Now I have a big amount of hard disks to wipe. Since wiping takes ages, I don't want to use my personal computer for that. I would prefer a small device with low energy consumption just for wiping. That's why I am going to build a "Nukestation". Basically it's just a Raspberry Pi with nwipe on it and a udev-rule for automatically wipe attached hard disks. But some extras would be nice...</p> <h3>Hardware</h3> <p>My setup is quite basic: a Raspberry Pi 3b+, a Disk-Docking-Station(USB), and a LED for signalling that the drive can safely removed/attached. I know, It would be much better to use a red LED for signalling when the Nukestation is wiping disks, but I had just green LED's at home. That's why I am gonna do that the way around.</p> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/nukestation.mp4" type="video/mp4" /></video> </p> <p>This video shows my setup. As soon as I plugg in the harddisk, the green led turns dark for signalling that it is not safe to remove the disk now, and on the screen we can see that nwipe starts it's job.</p> <h3>Little Extras</h3> <p>I wrote a bash-script called "nukestation.sh". This script is a wrapper for nwipe and allows us to:</p> <ul> <li>Create Pre-run-hooks(like turn off the LED)</li> <li>Run nwipe with configurable settings</li> <li>Create Post-run-hoocks(like turn on the LED)</li> <li>Send a notification including the nwipe-log via email</li> </ul> <h3>Installation</h3> <p>I won't use this Raspberry Pi only for wiping disks. That's why I need a very easy to use installation routine for the nukestation. I used the configuration management sytem <a href="https://www.ansible.com/">ansible</a> for that. The sources of my nukestation ansible-role can be downloaded on <a href="https://github.com/whotwagner/ansible-role-nukestation">Github</a>&nbsp; and the role is available on ansible-galaxy too. On a freshly installed <a href="https://www.raspberrypi.org/downloads/raspbian/">Raspbian</a>&nbsp; the Nukestation can be installed using the follwing commands:</p> <pre> <code> $ sudo apt-get install ansible $ sudo ansible-galaxy install whotwagner.nukestation $ cat > playbook.yml << EOF --- - hosts: localhost roles: - whotwagner.nukestation EOF $ sudo ansible-playbook playbook.yml </code></pre> <p>The playbook above will just install Nukestation without mailsupport. If we want to install a mailsystem with a smarthost using authentication to automatically send notifications we can use another playbook:</p> <pre> <code> $ sudo apt-get install ansible $ sudo ansible-galaxy install whotwagner.nukestation $ cat > playbook.yml << EOF - hosts: localhost roles: - whotwagner.nukestation vars: nukestation_mailconf: server: mail.example.conf:587 user: username@example.conf pass: super-secret-password from: from@example.com to: to@example.com EOF $ sudo ansible-playbook playbook.yml </code></pre> <p>A detailed documentation about the playbook and the nukestation.sh-script can be found at <a href="https://github.com/whotwagner/ansible-role-nukestation">Github</a>.</p> <h3>Conclusio</h3> <p>Nukestation allows me to wipe disks easily and I'll recieve notifications as soon as the wipejob is finished. <em>"I love it when a plan comes together"</em></p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Apr 15 2018</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hardware" hreflang="en">Hardware</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ansible" hreflang="en">Ansible</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=262&amp;2=comment&amp;3=comment" token="mXNkYhJywlpehAmSRx0Jlb3KcW68vS026m820TmEpE8"></drupal-render-placeholder> </section> Sun, 15 Apr 2018 16:45:24 +0000 Hoti 262 at https://tech.feedyourhead.at HackADay: Listening to Spotify on my Pi using A2DP https://tech.feedyourhead.at/content/HackADay-Listening-to-Spotify-on-my-Pi-using-A2DP <span class="field field--name-title field--type-string field--label-hidden">HackADay: Listening to Spotify on my Pi using A2DP</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p><img alt="Raspberry Pi Logo" data-entity-type="file" data-entity-uuid="2aa4f80c-e0f3-4a34-8bce-f27689f8d5f5" height="504" src="/sites/default/files/inline-images/raspberry-pi-logo.png" width="401" /></p> <p>I installed  <a href="http://raspbian.org/">Raspbian(Debian Jessie)</a> with <a href="https://kodi.tv/">Kodi</a> on my <a href="https://www.raspberrypi.org/">Raspberry Pi</a> and I use my Pi as a Meda Center. This Media Center plays music, mostly radio stations, all day long. I can easily control this media-center using the <a href="http://yatse.tv/redmine/projects/yatse">Yatse-App</a> on my phone. The Setup is almost perfect, but just almost. Sometimes I prefer to listen to my <a href="https://www.spotify.com">Spotify</a>-Playlists. At the moment there are no really good music addons for that. So I came to the idea to pair my phone via bluetooth with my Pi and use the audio output of my phone to play the Spotify-playlists.</p> <h3>Requirements</h3> <ul><li>Raspberry Pi Model 3(All the others don't have a builtin bluetooth)</li> <li>Headset/Speaker</li> <li>Pulseaudio (Sound-Daemon)</li> <li>Bluez(Bluetooth-Stack)</li> </ul><h3>Installing the needed packages</h3> <pre> <code>apt-get update apt-get install bluez pulseaudio-module-bluetooth python-gobject python-gobject-2 bluez-tools </code></pre> <h3>Configuring Bluetooth</h3> <p>To enable all the bluetooth audio commands we have to add the following lines in the [General]-section of /etc/bluetooth/main.conf:</p> <pre> <code>Enable=Source,Sink,Media </code></pre> <p>Next we have to change the bluetooth-class:</p> <pre> <code>Class = 0x00041C </code></pre> <p>Now we have all the audio-functions we need for our bluetooth-stack. So let's pair the phone with our raspberry. Just call bluetoothctl and use the following commands:</p> <pre> <code> scan on trust xx:xx:xx:xx:xx:xx(phone bluetooth mac) connect xx:xx:xx:xx:xx:xx(phone bluetooth mac) </code></pre> <p>To exit bluetoothctl we can hit CTRL+D. Now our phone is paired and ready to rock.</p> <h3>Setup the Audio-Connection</h3> <p>When the phone connects via bluetooth, a few commands are necessary to rock the house. One of those commands are connecting the right bluetooth-audio-source to the right audio-output-device. Fist we start as user pi the pulseaudio-daemon:</p> <pre> <code>pi@raspberrypi:~ $ pulseaudio --start </code></pre> <p>Next we can check the audio-devices:</p> <pre> <code>pi@raspberrypi:~ $ pactl list sources short 0 alsa_output.0.analog-stereo.monitor module-alsa-card.c s16le 2ch 48000Hz IDLE 1 bluez_source.84_CF_BF_89_47_01 module-bluez5-device.c s16le 2ch 48000Hz RUNNING </code></pre> <p>The output might differ, since in this example my phone is already playing music via the raspberry pi ;) To list only all the sinks we can use this command:</p> <pre> <code>pi@raspberrypi:~ $ pactl list sinks short 0 alsa_output.0.analog-stereo module-alsa-card.c s16le 2ch 48000Hz RUNNING </code></pre> <p>So now we know the input-device, and the output device and can connect it properly. When we do that, we also have to make sure that the audio volume is set correctly. We can do all this automatically as soon as we connect our phone to the pi. We will use a udev-rule to achieve this. So let's create the file /etc/udev/rules.d/99-input.rules with the following content:</p> <pre> <code>KERNEL=="input[0-9]*", RUN+="/home/pi/a2dp-autoconnect" </code></pre> <p>The file /home/pi/a2dp-autoconnect looks like that:</p> <pre> <code> #!/bin/bash # The original script: http://blog.mrverrall.co.uk/2013/01/raspberry-pi-a2dp-bluetooth-audio.html. # Find the right sink with `pactl list sources short`. PA_SINK="alsa_output.0.analog-stereo" BT_MAC=$(echo "$NAME" | sed 's/:/_/g' | sed 's/\"//g') BT_USER=pi sudo su - "$BT_USER" -c "pulseaudio -D" function log { echo "[$(date)]: $*" &gt;&gt; /var/log/a2dp-autoconnect } function checkSource { # Get the current sources local _sources=$(sudo su - "$BT_USER" -c "pactl list sources short") # Check if any sources are currently running and that our new device is valid. if [[ "$_sources" =~ RUNIING ]]; then log "Source is already RUNNING. Available sources:" log "$_sources" return fi if [[ ! "$_sources" =~ "$1" ]] ; then log "Unrecognized source. Available sources:" log "\n$_sources" return fi log "Validated new source: $1." echo "$1" } function setVolume { log "Setting volume levels." # Set our volume to max sudo su - "$BT_USER" -c "pacmd set-sink-volume 0 65537" sudo su - "$BT_USER" -c "amixer set Master 100%" } function connect { log "Connecting $1." # Connect source to sink sudo su - "$BT_USER" -c 'pactl load-module module-loopback source="$1" sink="$PA_SINK" rate=44100 adjust_time=0' } log "Change for device $BT_MAC detected, running $ACTION." if [ "$ACTION" = "add" ] then incoming=bluez_source."$BT_MAC" if [ ! -z $(checkSource "$incoming") ] ; then connect "$incoming" setVolume fi fi </code></pre> <p>I borrowed this file from <a href="https://gist.github.com/oleq/24e09112b07464acbda1">here</a> but I modified it so that it automatically starts pulseaudio. Next we have to change the permissions:</p> <pre> <code> pi@raspberrypi:~ $ chmod +x a2dp-autoconnect </code></pre> <h3>Let's Rock The House</h3> <p>So finally we can rock the house. As soon as I start Spotify on the phone I can listen to it but I can also easily stop the music and play all my favourite radio stations using Kodi.</p> <p> </p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Oct 28 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/multimedia" hreflang="en">Multimedia</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/tricks" hreflang="en">Tricks</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <div class="node__links"> <ul class="links inline"><li class="comment-add"><a href="/content/HackADay-Listening-to-Spotify-on-my-Pi-using-A2DP#comment-form" title="Share your thoughts and opinions." hreflang="en">Add new comment</a></li></ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <article data-comment-user-id="0" id="comment-87" about="/comment/87" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1525519458"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">ofus (not verified)</span> on May 02 2018</span> <span property="schema:dateCreated" content="2018-05-01T22:23:10+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/87#comment-87" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/87#comment-87" class="permalink" rel="bookmark" hreflang="en">non-SBC codecs</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Is it possible to use a higher quality audio codec than SBC, or enable maximum quality SBC (375 kbit/s)?</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=87&amp;1=default&amp;2=en&amp;3=" token="Hic7uc9cyGcu8Emgc0pmLRpfxlu285eDB1WO9UqzIwY"></drupal-render-placeholder> </div> </article> <article data-comment-user-id="1" id="comment-88" about="/comment/88" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1525521093"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on May 05 2018</span> <span property="schema:dateCreated" content="2018-05-05T11:51:33+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/88#comment-88" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/88#comment-88" class="permalink" rel="bookmark" hreflang="en">I found the following codecs…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">I found the following codecs in the sources of bluez: #define A2DP_CODEC_SBC 0x00 #define A2DP_CODEC_MPEG12 0x01 #define A2DP_CODEC_MPEG24 0x02 #define A2DP_CODEC_ATRAC 0x03 but I am not sure if pulseaudio supports any other codec than sbc. If you really wanna know, ask at the pulseaudio-mailinglist</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=88&amp;1=default&amp;2=en&amp;3=" token="yNROpDxHetycA7X96bZ0aaei_TH6OlLk12xsiZxQxwI"></drupal-render-placeholder> </div> </article> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=212&amp;2=comment&amp;3=comment" token="21QyDjuz5iPBmhAfIRELqPXyoUz65_ZOQhGaaKlrOes"></drupal-render-placeholder> </section> Fri, 28 Oct 2016 12:52:36 +0000 Hoti 212 at https://tech.feedyourhead.at HackADay: Controlling computers and stuff with the mind https://tech.feedyourhead.at/content/hack-a-day-controlling-computers-and-stuff-with-my-mind <span class="field field--name-title field--type-string field--label-hidden">HackADay: Controlling computers and stuff with the mind</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I am very slothful.  I let computers do my work. That's why I became a sysadmin. In this article I am going to describe how I lifted up my lazyness to the next level by triggering a command with my mind to install a new virtual machine with: MariaDB, Nginx and Wordpress.</p> <h2>Intro</h2> <p>When I first read about the <a href="http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0111332">human-to-human-brain-interface</a> I was fascinated. It's like a science-fiction-x-men-story: controlling another human with the mind. But this is a little bit creepy too. Controlling a computer with the mind instead sounds for me more comfortable. In that way I could do all my work just by thinking of it while I am lying in my bed. That's awesome.</p> <h2>Hardware</h2> <p><img alt="Mindwave Equipment" data-entity-type="file" data-entity-uuid="516f6e07-edbb-4697-9daf-652540c07fd7" src="/sites/default/files/inline-images/mindwave_equippment.jpg" /></p> <h3>Headset</h3> <p>I did a little research and it seems the best option for an affordable EEG-headset would be the <a href="http://openbci.com/">OpenBCI-Project</a>. For my proof of concept it is still too expensive, that's why I took the <a href="http://store.neurosky.com/">Neurosky Mindwave Headset</a>. It's has just a few electrodes but it is cheap and might be good enough for my experiment. I ordered a Mindwave-Headset and not a Mindwave-Mobile-headset. The Mindwave-headset ships with a USB-dongle.</p> <p>Neurosky-Devices have a nice feature built-in: <a href="http://developer.neurosky.com/docs/doku.php?id=thinkgear_communications_protocol#thinkgear_data_values">eSense</a>. eSense  calculates the "attention"(are you focused?) and "meditation"(do you have many thoughts?) of a person. I will use this feature for triggering a command-execution.  I could also use the EEG-Data(16bin wave-format), but for this proof-of-concept I am fine with the eSense-meters.</p> <h3>Microcontroller</h3> <p>I have an old Raspberry Pi (Model B) and I installed <a href="https://www.debian.org/releases/jessie/">Debian Jessie</a> on it. A LED on a Gpio-Pin will indicate if I am concentrated or not.</p> <h2>Software</h2> <h3>Reading out EEG-Data</h3> <p>I wrote a <a href="https://github.com/whotwagner/mindwave">ruby gem</a> for interfacing the Mindwave Headset. It simply reads out all the data via serial line and parses it. There are several callback methods to overwrite.  In the following example I will override a method to read out the "attention"-value:</p> <pre> <div class="geshifilter"><pre class="ruby geshifilter-ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>   <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mindwave'</span>   <span style="color:#9966CC; font-weight:bold;">class</span> EEG <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">Mindwave::Headset</span> <span style="color:#008000; font-style:italic;"># override Attention-Callback-Method</span> <span style="color:#9966CC; font-weight:bold;">def</span> attentionCall<span style="color:#006600; font-weight:bold;">(</span>attention<span style="color:#006600; font-weight:bold;">)</span> str = eSenseStr<span style="color:#006600; font-weight:bold;">(</span>attention<span style="color:#006600; font-weight:bold;">)</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"this is an attention #{attention} #{str}<span style="color:#000099;">\n</span>"</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#008000; font-style:italic;"># create a new instance</span> mw = EEG.<span style="color:#9900CC;">new</span> <span style="color:#008000; font-style:italic;"># mw.log.level = Logger::DEBUG</span>   <span style="color:#008000; font-style:italic;"># if we hit ctrl+c then just stop the run()-method</span> <span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"INT"</span><span style="color:#006600; font-weight:bold;">)</span> <span style="color:#9966CC; font-weight:bold;">do</span> mw.<span style="color:#9900CC;">stop</span> <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#008000; font-style:italic;"># Create a new Thread</span> thread = <span style="color:#CC00FF; font-weight:bold;">Thread</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">{</span> mw.<span style="color:#9900CC;">run</span> <span style="color:#006600; font-weight:bold;">}</span> <span style="color:#008000; font-style:italic;"># ..and run it</span> thread.<span style="color:#9900CC;">join</span>   mw.<span style="color:#9900CC;">close</span></pre></div></pre> <h3>Manipulating the Raspberry-GPIO-Pins</h3> <p>I found a nice ruby gem for manipulating the GPIO-Pins of my raspberry at <a href="https://rubygems.org/gems/rpi_gpio">rubygems.org.</a> This code will switch the GPIO_Pin 22 on every key-stroke:</p> <pre> <div class="geshifilter"><pre class="ruby geshifilter-ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>   <span style="color:#008000; font-style:italic;"># gem install rpi_gpio</span> <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rpi_gpio'</span> <span style="color:#008000; font-style:italic;"># gem install io-console</span> <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'io/console'</span>   <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_numbering</span> <span style="color:#ff3333; font-weight:bold;">:bcm</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">clean_up</span> <span style="color:#006666;">22</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">setup</span> <span style="color:#006666;">22</span>, <span style="color:#ff3333; font-weight:bold;">:as</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:output</span>   GPIO_NUM=<span style="color:#006666;">22</span>   <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_high</span> GPIO_NUM   sohigh = <span style="color:#0000FF; font-weight:bold;">true</span>   input = <span style="color:#996600;">'c'</span>   <span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"INT"</span><span style="color:#006600; font-weight:bold;">)</span> <span style="color:#9966CC; font-weight:bold;">do</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"SiGINT Cleaning up.."</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">clean_up</span> GPIO_NUM <span style="color:#CC0066; font-weight:bold;">exit</span> <span style="color:#006666;">1</span> <span style="color:#9966CC; font-weight:bold;">end</span>     <span style="color:#9966CC; font-weight:bold;">while</span> input != <span style="color:#996600;">"q"</span> input = STDIN.<span style="color:#9900CC;">getch</span>   <span style="color:#9966CC; font-weight:bold;">if</span> sohigh <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_low</span> GPIO_NUM <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_high</span> GPIO_NUM <span style="color:#9966CC; font-weight:bold;">end</span>   sohigh = !sohigh <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Cleaning up.."</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">clean_up</span> GPIO_NUM</pre></div></pre> <h2>Controlling a LED</h2> <p>So let's put all parts together. Here is some code which toggles a LED if the attention value is bigger than 79:</p> <pre> <div class="geshifilter"><pre class="ruby geshifilter-ruby" style="font-family:monospace;"><span style="color:#008000; font-style:italic;">#!/usr/bin/env ruby</span>   <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'mindwave'</span>   <span style="color:#CC0066; font-weight:bold;">require</span> <span style="color:#996600;">'rpi_gpio'</span>   <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_numbering</span> <span style="color:#ff3333; font-weight:bold;">:bcm</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">clean_up</span> <span style="color:#006666;">22</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">setup</span> <span style="color:#006666;">22</span>, <span style="color:#ff3333; font-weight:bold;">:as</span> =<span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#ff3333; font-weight:bold;">:output</span>   <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_low</span> <span style="color:#006666;">22</span>   <span style="color:#9966CC; font-weight:bold;">class</span> EEG <span style="color:#006600; font-weight:bold;">&amp;</span>lt; <span style="color:#6666ff; font-weight:bold;">Mindwave::Headset</span> <span style="color:#0066ff; font-weight:bold;">@ishigh</span> = <span style="color:#0000FF; font-weight:bold;">false</span> attr_accessor <span style="color:#ff3333; font-weight:bold;">:update</span>     <span style="color:#9966CC; font-weight:bold;">def</span> meditationCall<span style="color:#006600; font-weight:bold;">(</span>meditation<span style="color:#006600; font-weight:bold;">)</span> str = eSenseStr<span style="color:#006600; font-weight:bold;">(</span>meditation<span style="color:#006600; font-weight:bold;">)</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Meditation #{meditation} #{str}<span style="color:#000099;">\n</span>"</span> <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#008000; font-style:italic;"># override Attention-Callback-Method</span> <span style="color:#9966CC; font-weight:bold;">def</span> attentionCall<span style="color:#006600; font-weight:bold;">(</span>attention<span style="color:#006600; font-weight:bold;">)</span> str = eSenseStr<span style="color:#006600; font-weight:bold;">(</span>attention<span style="color:#006600; font-weight:bold;">)</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"-&amp;gt; Attention #{attention} #{str}<span style="color:#000099;">\n</span>"</span>   <span style="color:#9966CC; font-weight:bold;">if</span> attention <span style="color:#006600; font-weight:bold;">&amp;</span>gt; <span style="color:#006666;">79</span> <span style="color:#9966CC; font-weight:bold;">and</span> <span style="color:#0066ff; font-weight:bold;">@update</span> == <span style="color:#0000FF; font-weight:bold;">true</span> <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"FIRE IT UP"</span> <span style="color:#9966CC; font-weight:bold;">if</span> <span style="color:#0066ff; font-weight:bold;">@ishigh</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_low</span> <span style="color:#006666;">22</span> <span style="color:#0066ff; font-weight:bold;">@ishigh</span> = <span style="color:#0000FF; font-weight:bold;">false</span> <span style="color:#9966CC; font-weight:bold;">else</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">set_high</span> <span style="color:#006666;">22</span>   <span style="color:#0066ff; font-weight:bold;">@ishigh</span> = <span style="color:#0000FF; font-weight:bold;">true</span> stop <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#0066ff; font-weight:bold;">@update</span> = <span style="color:#0000FF; font-weight:bold;">false</span>   <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#9966CC; font-weight:bold;">end</span> <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#008000; font-style:italic;"># create a new instance</span> mw = EEG.<span style="color:#9900CC;">new</span> mw.<span style="color:#9900CC;">update</span> = <span style="color:#0000FF; font-weight:bold;">true</span>   <span style="color:#008000; font-style:italic;"># mw.log.level = Logger::INFO</span>   <span style="color:#008000; font-style:italic;"># if we hit ctrl+c then just stop the run()-method</span> <span style="color:#CC00FF; font-weight:bold;">Signal</span>.<span style="color:#CC0066; font-weight:bold;">trap</span><span style="color:#006600; font-weight:bold;">(</span><span style="color:#996600;">"INT"</span><span style="color:#006600; font-weight:bold;">)</span> <span style="color:#9966CC; font-weight:bold;">do</span> mw.<span style="color:#9900CC;">stop</span> <span style="color:#9966CC; font-weight:bold;">end</span>   <span style="color:#008000; font-style:italic;"># Create a new Thread</span> thread = <span style="color:#CC00FF; font-weight:bold;">Thread</span>.<span style="color:#9900CC;">new</span> <span style="color:#006600; font-weight:bold;">{</span> mw.<span style="color:#9900CC;">run</span> <span style="color:#006600; font-weight:bold;">}</span> <span style="color:#008000; font-style:italic;"># ..and run it</span>   <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Starting..."</span> thread.<span style="color:#9900CC;">join</span>   <span style="color:#CC0066; font-weight:bold;">puts</span> <span style="color:#996600;">"Cleaning up.."</span> mw.<span style="color:#9900CC;">close</span> <span style="color:#6666ff; font-weight:bold;">RPi::GPIO</span>.<span style="color:#9900CC;">clean_up</span> <span style="color:#006666;">22</span></pre></div></pre> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/mindwave_led_lightup.mp4" type="video/mp4"></source></video></p> <h2>Automization</h2> <p>Automization is a very important part of our work at <a href="http://www.toscom.at/">Toscom</a>. I believe that sysadmins should automize as much as possible. Not only to be more efficient but also for quality management. So we do not configure servers manually but program the configuration and reuse this code as often as possible. This makes the next step very easy. I just install the configurations-management-system <a href="https://www.ansible.com/">Ansible</a> on the raspberry pi, download some (wordpress related) ansible-roles from <a href="https://galaxy.ansible.com/">ansible-galaxy </a>and call ansible-playbook within my script. Since Version 2 Ansible also includes modules for controlling <a href="https://aws.amazon.com/">Amazon AWS-Services</a>. So I will create my virtual machine in the Amazon-Cloud. Here is my playbook.yml:</p> <pre> <code> - hosts: localhost connection: local gather_facts: False tasks: - name: Provision Wordpress Instance ec2: aws_access_key: "MY-ACCESS-KEY" aws_secret_key: "MY-SUPER-SECRET-ACCESS-KEY" key_name: pi_key instance_type: t2.micro image: ami-ed82e39e wait: true wait_timeout: 500 assign_public_ip: yes vpc_subnet_id: subnet-de3b5da8 region: eu-west-1 group_id: sg-75d3c412 register: ec2 - name: Add new instance to host group add_host: hostname={{ item.public_ip }} groupname=launched ansible_user=ubuntu with_items: '{{ec2.instances}}' - name: Wait for SSH to come up wait_for: host={{item.public_dns_name}} port=22 delay=60 timeout=320 state=started with_items: '{{ec2.instances}}' - name: install wordpress hosts: launched become: True gather_facts: True vars: wp_mysql_host: 'localhost' session_post_max_size: '128M' session_upload_max_filesize: '128M' session_max_input_time: '70' session_max_execution_time: '90' roles: - valentinzberea.wordpress </code></pre> <p>I use the following roles (from <a href="https://galaxy.ansible.com/">ansible-galaxy</a>):</p> <ul><li>mats116.nginx        </li> <li>valentinzberea.wordpress</li> <li>mats116.mariadb-server    </li> <li>valentinzberea.hhvm</li> </ul><h2>Proof of Concept</h2> <p>In the next video clip, I recorded a proof of concept. First I got a connection with my headset (the light turns blue), then it took me a while to be focused. As soon as I have a focus level of 80, my program will turn on a LED and call ansible-playbook. In the clip we will see that in my Amazon AWS-Console a new virtual machine will start and install Wordpress, MariaDB and Nginx. At the end of the clip, I will copy the IP-address of the new host and connect to the Wordpress-Page on it.</p> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/mindcontrol_aws_wordpress.mp4" type="video/mp4"></source></video></p> <p>I did not use the Wave-Stream of the EEG-Data to detect the thoughts but only read out the attention-level of my mind. I also exited the script as soon as it fired up a command, otherwise I would have multiple command-executions on "long" thoughts aso.</p> <h2>Problems</h2> <ol><li>I cheated. I did not use the wave-data at all. I just used the attention-level I got from the Mindwave-Headset.</li> <li>This is difficult to use. How does one deliberately hold a focus with his mind? Some practice is needed...</li> <li>What if someone focuses longer? A timer is needed then, otherwise it toggles many times in a row</li> </ol><h2>Conclusion</h2> <p>I triggered a command with my mind which created a virtual machine (Amazon EC2-Instance), installed MariaDB, Nginx and Wordpress. That is one of my daily tasks and I was able to make it just by concentrating. If I combine this project with my <a href="https://tech.feedyourhead.at/content/controlling-power-outlets-using-the-rapberry-pi">power-outlets</a>, I could even make tea with my mind. It's not perfect. This technique is not very precise (neither is this headset). Even though I am very happy with the result. Maybe I will go deeper and compare signatures of EEG data to detect different states of mind.</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Sep 16 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/ruby" hreflang="en">Ruby</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Programming" hreflang="en">Programming</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hardware" hreflang="en">Hardware</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/taxonomy/term/97" hreflang="en">Toscom</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=200&amp;2=comment&amp;3=comment" token="2BmXclPgiIaQ8G9zkGASPYUrQx8quVImoHS9NOI2gYA"></drupal-render-placeholder> </section> Fri, 16 Sep 2016 07:06:56 +0000 Hoti 200 at https://tech.feedyourhead.at HackADay: Controlling power outlets using the Raspberry Pi https://tech.feedyourhead.at/content/controlling-power-outlets-using-the-rapberry-pi <span class="field field--name-title field--type-string field--label-hidden">HackADay: Controlling power outlets using the Raspberry Pi</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/steckdosen_aktion.webm" type="video/webm"></source></video></p> <p>My plan was to control some power outlets(16 ampere) using any browser(for example with a mobile phone). I wanted to use electronics only and tried to avoid relays.</p> <p> </p> <h3>Concept</h3> <p>I installed a Debian on my Raspberry Pi(including XBMC aka Kodi) on which a lighthttpd-daemon is running. This Webserver is calling a cgi-script(perl) which enables or disables the power sockets via it's GPIO-Pins. To make it as easy as possible I just call the gpio-command from the <a href="http://wiringpi.com/">WiringPi-Project.</a> I really love to make things work automagically. That's why I also included a function for enabling or disabling a socket at a specific time. Since I kept everything as simple as possible I just used a simple at-job for this.</p> <h3>GPIO</h3> <p><img alt="Raspberry Pi GPIO Pins" data-entity-type="file" data-entity-uuid="0fdfe731-f986-49af-9c1c-28bf3a1e0d59" src="/sites/default/files/inline-images/raspberry_gpio.jpg" /></p> <p>I am using the following Pins: GPIO23(socket 1), GPIO25(socket 2), P1-02 for 5volt power supply and P1-06 for ground.</p> <h3>Wiring</h3> <p>The most difficult thing was the wiring. As I already mentioned, I really wanted to avoid relays. Therefore I created this circuit: the GPIO-Pin controls an optocoppler(MOC3041) limited by a transistor(BC547). The optocoppler itself is switching a TRIAC(BT 139). The TRIAC enables or disables the power socket.</p> <p>That's the circuit:</p> <p><img alt="Circuit" data-entity-type="file" data-entity-uuid="a6fb9d6c-242a-4a7e-a200-ba88b8fcdfa6" src="/sites/default/files/inline-images/steckdosenschaltung_schaltplan.png" /></p> <p> </p> <p>...and that's how it looks like:</p> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/steckdosen_aufbau.webm" type="video/webm"></source></video></p> <h3>Programming</h3> <p>The Website is very very simple and looks like this:</p> <p><img alt="Website-Screenshot" data-entity-type="file" data-entity-uuid="02d16e00-a6aa-4ed2-981c-28baf11edae4" src="/sites/default/files/inline-images/steckdosenwebsite.jpg" /></p> <p>..very basic, isn't it?</p> <p>Don't forget to change the sudo-rights for www-data:</p> <p>/etc/sudoers:</p> <pre> <code> www-data ALL=NOPASSWD:/usr/local/bin/gpio </code></pre> <p>You can find all the sources of this project on <a href="https://github.com/whotwagner/power-outlets">my github</a>.</p> <h3><br /> Final Words</h3> <p>This project was a lot of fun. I got much support at the <a href="https://metalab.at/">Meta Lab(The very best hacker-space in vienna),</a> The project works very well. I also implemented some (green)diodes for indicating if the sockets are enabled or not. And don't forget that I really installed a full <a href="https://kodi.tv/">xbmc-system</a>. That's why my sockets are also a full multimedia center!!</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Mar 05 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hardware" hreflang="en">Hardware</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Programming" hreflang="en">Programming</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=164&amp;2=comment&amp;3=comment" token="-SY7lVx3Xoo2MZaTaovmasF1HkfkWgNMPbp_cxgoyzM"></drupal-render-placeholder> </section> Sat, 05 Mar 2016 15:57:26 +0000 Hoti 164 at https://tech.feedyourhead.at Space Invaders using 8x8 LED-Display on Tiva-Board TM4C1294XL https://tech.feedyourhead.at/node/145 <span class="field field--name-title field--type-string field--label-hidden">Space Invaders using 8x8 LED-Display on Tiva-Board TM4C1294XL</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I created 2 tasks in RTOS: one for reading from uart and one for the display(<a href="http://www.mikroe.com/click/8x8-r/">8x8 LED-Matrix</a>). Both tasks are communicating via queues. The space-invaders-programm gets started by pressing F1. If F2 is pressed, the programm will display all keyboard-input on the led-display.</p> <p> <video controls="" height="1280" width="720"><source src="/sites/default/files/DateiUploads/tiva.ogv" type="video/ogg" /></video> </p> <p><a href="/sites/default/files/DateiUploads/RTOS_8x8Click.tar.gz">Click here to download the sources</a></p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Jan 15 2016</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/downloads" hreflang="en">Downloads</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hardware" hreflang="en">Hardware</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <div class="node__links"> <ul class="links inline"><li class="comment-add"><a href="/node/145#comment-form" title="Share your thoughts and opinions." hreflang="en">Add new comment</a></li></ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <article data-comment-user-id="0" id="comment-103" about="/comment/103" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1543927016"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">TheDap (not verified)</span> on Nov 30 2018</span> <span property="schema:dateCreated" content="2018-11-30T08:37:33+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/103#comment-103" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/103#comment-103" class="permalink" rel="bookmark" hreflang="en">uwielbiam was</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>hello. i am from poland. i uwielbiam was!</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=103&amp;1=default&amp;2=en&amp;3=" token="8IxLol-RCK2QfmlXRvmS1Zp3_qGocngfdI12BVy7jd0"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-104" about="/comment/104" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1543927047"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Dec 04 2018</span> <span property="schema:dateCreated" content="2018-12-04T12:37:27+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/103#comment-103" class="permalink" rel="bookmark" hreflang="en">uwielbiam was</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">TheDap (not verified)</span></p> <a href="/comment/104#comment-104" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/104#comment-104" class="permalink" rel="bookmark" hreflang="en">haha allways happy to help</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">haha allways happy to help</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=104&amp;1=default&amp;2=en&amp;3=" token="Hi0vDbW9YLQBsq24HB9m3StO776yQ05F1sYedZo5310"></drupal-render-placeholder> </div> </article> </div> <article data-comment-user-id="0" id="comment-107" about="/comment/107" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1546279262"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">ltonropit (not verified)</span> on Dec 25 2018</span> <span property="schema:dateCreated" content="2018-12-25T16:51:48+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/107#comment-107" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/107#comment-107" class="permalink" rel="bookmark" hreflang="en">Hi everyone. I need to help</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>I am ltonser. I need help. What can i do it?</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=107&amp;1=default&amp;2=en&amp;3=" token="pc58SuPlL1cyFmEt5f6veN6PvB2IkTk_FO1GhL2Yo3Y"></drupal-render-placeholder> </div> </article> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=145&amp;2=comment&amp;3=comment" token="a33qdQaTba_r0l1vv_FwBZIgC6oqt3O6UNjiRBrveEo"></drupal-render-placeholder> </section> Fri, 15 Jan 2016 20:42:16 +0000 Hoti 145 at https://tech.feedyourhead.at Hack A Day: LED-Cube https://tech.feedyourhead.at/content/hack-day-led-cube <span class="field field--name-title field--type-string field--label-hidden">Hack A Day: LED-Cube</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>I created a LED-Cube. It was a lot of fun to make it. I used very cheap LEDs, therefore it's not perfect. But it is good enough to programm some nice effects. I used an arduino to controll the cube. It was interesting to play with bit-shift-registers and it was cool to programm more with bit-operations.&nbsp; The soldering was hell, but it was worthy</p> <p>&nbsp;</p> <p> <video controls="" height="360" width="480"><source src="/sites/default/files/DateiUploads/cube.ogv" type="video/ogg" /></video> </p> <p>PS: yeah, I know..my cam makes lousy videos...</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">May 16 2015</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Fun" hreflang="en">Fun</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=86&amp;2=comment&amp;3=comment" token="CGmpPRhnlMXaFimtyH7eZb79-Tr-YnlGRCFI43XIPaE"></drupal-render-placeholder> </section> Sat, 16 May 2015 10:31:02 +0000 Hoti 86 at https://tech.feedyourhead.at Hack A Day: Let's make a Mail2SMS-Gateway using the Raspberry Pi https://tech.feedyourhead.at/content/hack-day-lets-make-mail2sms-gateway-using-raspberry-pi <span class="field field--name-title field--type-string field--label-hidden">Hack A Day: Let&#039;s make a Mail2SMS-Gateway using the Raspberry Pi</span> <div class="clearfix text-formatted field field--name-body field--type-text-with-summary field--label-hidden field__item"><p>If you are monitoring services, you also might want to get informed about critical states via sms. Almost everyone has an old mobile phone at home. Why not using one of those old mobile-phones? In this article I will describe how to transform your raspberry into a mail2sms-gateway. This gateway will be able to:</p> <ul> <li>receive emails and forward them via sms</li> <li>receive sms and forward them via email</li> <li>provide a webinterface for sending sms manually</li> </ul> <p>&nbsp;</p> <p><img alt="" height="473" src="http://tech.feedyourhead.at/sites/tech.feedyourhead.at/files/pictures/mail2smsgw1.jpg" width="841" /></p> <h2>&nbsp;</h2> <p><img alt="" height="473" src="http://tech.feedyourhead.at/sites/tech.feedyourhead.at/files/pictures/mail2smsgw2.jpg" width="842" /></p> <h2>&nbsp;</h2> <h2>What is Mail2SMS?</h2> <p>Mail2SMS is a service which receives emails and forwards them via sms. In that way we are able to send sms via email. The "Email Body" is the "sms message", but where do we place the phone-number? Until now i used a commercial mail2sms-service. They placed the phone-number at the first part of the "Email TO Header", like: &lt;phonenumber&gt;@mail2sms-service.com. I will handle it the same, because in that way i haven't to change the notification-scripts for my monitoring-system.</p> <p>We used a commercial mail2sms-gateway until now but it was very expensive. Now we have our own sim-card with 1000 free sms/month.</p> <h2>How do we realize it?</h2> <ol> <li>Postfix(SMTP-Daemon) at our raspberry is waiting for emails</li> <li>Postfix passes the emails to my smsgw.pl-script</li> <li>smsgw.pl reads phone-number and message-text and calls "gammu-smsd-inject"</li> <li>gammu-smsd is a daemon which communicates with our phone(which is connected via USB) and sends our sms</li> </ol> <h2>Other features?</h2> <p>Beside forwarding emails via sms we will provide the following features:</p> <ul> <li>receiving sms and forwarding them via email( gammu-&gt;sms2mail.pl-&gt;postfix )</li> <li>sending sms manually via webgui ( lighttpd -&gt; sms.pl(cgi) -&gt; gammud )</li> </ul> <h2><br /> Lets start with the postfix-config</h2> <p>Our domain for sms will be: <strong>sms.example.com</strong></p> <p>Let's install postfix and set our mailname first:</p> <pre> <code> apt-get install postfix </code></pre> <p>/etc/mailname:</p> <pre> <code> sms.example.com </code></pre> <p>This is our /etc/postfix/main.cf:</p> <pre> <code> # See /usr/share/postfix/main.cf.dist for a commented, more complete version # Debian specific: Specifying a file name will cause the first # line of that file to be used as the name. The Debian default # is /etc/mailname. #myorigin = /etc/mailname smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU) biff = no # appending .domain is the MUA's job. append_dot_mydomain = no # Uncomment the next line to generate "delayed mail" warnings #delay_warning_time = 4h readme_directory = no # TLS parameters smtpd_tls_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem smtpd_tls_key_file=/etc/ssl/private/ssl-cert-snakeoil.key smtpd_use_tls=yes smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for # information on enabling SSL in the smtp client. transport_maps = hash:/etc/postfix/transport myhostname = sms.example.com alias_maps = hash:/etc/aliases alias_database = hash:/etc/aliases myorigin = /etc/mailname mydestination = sms.example.com, localhost.localdomain, localhost relayhost = mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 mailbox_size_limit = 0 recipient_delimiter = + inet_interfaces = all local_recipient_maps = </code></pre> <p>This we have to append to our /etc/postfix/master.cf:</p> <pre> <code> sms unix - n n - - pipe flags=Rq user=pi argv=/usr/local/bin/smsgw.pl -f ${sender} -r ${recipient} </code></pre> <p>And finally we just need this in our /etc/postfix/transport:</p> <pre> <code> sms.example.com sms </code></pre> <p>(Be aware that you have to do a "<em>postmap /etc/postfix/transport</em>" after you changed or created this file)</p> <p>After all just restart postfix: <em>/etc/init.d/postfix restart</em></p> <h2>smsgw.pl</h2> <p>/usr/local/bin/smsgw.pl is our small little script which recieves emails from postfix, parses all the necessary informations and calls "gammu gammu-smsd-inject". We need to install log4perl and touch the logfile:</p> <pre> <code> apt-get install liblog-log4perl-perl </code></pre> <pre> <code> root@sms:~# touch /var/log/smsgw.log root@sms:~# chown pi /var/log/smsgw.log root@sms:~# ls -l /var/log/smsgw.log -rw-r--r-- 1 pi root 29150592 Feb 6 13:20 /var/log/smsgw.log </code></pre> <p>/usr/local/bin/smsgw.pl:</p> <pre> <code> #!/usr/bin/perl use Log::Log4perl; use Getopt::Std; my %options=(); getopts("r:f:h", \%options); my $logconf = q( log4perl.rootLogger = DEBUG,Logfile log4perl.appender.Logfile = Log::Log4perl::Appender::File log4perl.appender.Logfile.filename = /var/log/smsgw.log log4perl.appender.Logfile.layout = Log::Log4perl::Layout::PatternLayout log4perl.appender.Logfile.layout.ConversionPattern = [%r] %F %L %m%n log4perl.appender.Screen = Log::Log4perl::Appender::Screen log4perl.appender.Screen.stderr = 0 log4perl.appender.Screen.layout = Log::Log4perl::Layout::SimpleLayout ); my $line = undef; my $mailstring = undef; my $from = undef; my $to = undef; my $subject = undef; my $out = 0; Log::Log4perl::init( \$logconf); my $log = Log::Log4perl::get_logger("smsgw"); if($options{h}) { $log-&gt;logdie("usage: smsgw.pl -f <sender> -r <recipient>"); } $log-&gt;logdie("-f option is missing use -h for help") if not defined($options{f}); $log-&gt;logdie("-r option is missing use -h for help") if not defined($options{r}); $from = $options{f}; $to = $options{r}; $log-&gt;info("Mail kommt rein.."); while(defined($line = <stdin>)) { $log-&gt;debug("LINE: \"$line\""); if($line =~ m/^subject: (.*)\n/i) { $subject = $1; } if( ($line eq "\n") &amp;&amp; ($out != 1) ) { $log-&gt;info("NOW IT MESSAGE-PART"); $log-&gt;info("BECAUSE: ..$line.."); $out = 1; } else { $mailstring .= $line if($out == 1); } } $log-&gt;info("FROM: $from"); $log-&gt;info("TO: $to"); $log-&gt;info("SUBJECT: $subject"); $log-&gt;info("MAIL: $mailstring"); my $telnumber = 0; if($to =~ m/^(\d+)@/) { $telnumber = $1; } if($telnumber == 0) { $log-&gt;logdie("not a number-format!"); } $log-&gt;info("NUMBER: $telnumber"); my $smsstring = "sudo -u gammu gammu-smsd-inject TEXT $telnumber -text \"$mailstring\""; $log-&gt;info("$smsstring"); my $output = `$smsstring`; $log-&gt;warn("$output"); </stdin></recipient></sender></code></pre> <pre> <code> root@smsgateway:~# chmod o+rx /usr/local/bin/smsgw.pl </code></pre> <h2>Gammu</h2> <p>For communications with our USB-connected mobile-phone, we use the gammu-smsd. This daemon is able to send and receive sms using a queue. So sms don't get lost even if we power off the raspberry during a transfer. This our gammurc:</p> <pre> <code> # Configuration file for Gammu SMS Daemon # Gammu library configuration, see gammurc(5) [gammu] port=/dev/ttyACM0 connection=at name=Sony Ericsson S500i/S500c logformat = textall # Please configure this! #port = /dev/null #connection = at # Debugging #logformat = textall # SMSD configuration, see gammu-smsdrc(5) [smsd] service = files logfile = /var/log/gammu-smsd # Increase for debugging information debuglevel = 0 ReceiveFrequency = 300 # Paths where messages are stored inboxpath = /var/spool/gammu/inbox/ outboxpath = /var/spool/gammu/outbox/ sentsmspath = /var/spool/gammu/sent/ errorsmspath = /var/spool/gammu/error/ </code></pre> <p>Restart the daemon after you connected the phone with /etc/init.d/gammu-smsd restart</p> <h2>Connecting the phone</h2> <p>At this point our mail2sms-service should work. We can connect our phone now with our raspberry. On some phones it is important to use it in "phone modus".</p> <p>&nbsp;</p> <p>Now we can test via telnet:</p> <pre> <code> dr@tardis:/# telnet sms.example.com 25 Trying 172.30.50.31... Connected to sms.example.com. Escape character is '^]'. 220 sms.example.com ESMTP Postfix (Debian/GNU) helo sms.example.com 250 sms.example.com mail from: dr@tardis 250 2.1.0 Ok rcpt to: 0190222222@sms.example.com 250 2.1.5 Ok data 354 End data with <cr><lf>.<cr><lf> allons-y allonso . 250 2.0.0 Ok: queued as 58F7C146B1 quit 221 2.0.0 Bye Connection closed by foreign host. </lf></cr></lf></cr></code></pre> <h2>Sms2mail</h2> <p>We also want to forward all received sms via email to a specific email-address. For this we will simply start a cron-job which calls a script called sms2mail.pl. This script simply checks the inbox-queue of gammu-smsd and forwards all sms via email to a pre-defined email-address.</p> <p>/usr/local/bin/sms2mail.pl:</p> <pre> <code> #!/usr/bin/perl # IN20130307_171617_00_+43190222222_00.txt my $spooldir = '/var/spool/gammu/inbox/'; my $file = undef; my $date = undef; my $tel = undef; my $subject = undef; # CHANGE THIS EMAIL-ADDRESS my $recipient = 'dr@tardis'; opendir(D,$spooldir) || die "Can't open dir: $!\n"; while($file = readdir(D)) { if($file =~ m/IN(\d\d\d\d)(\d\d)(\d\d)_(\d\d)(\d\d)\d\d_\d{1,2}_(.*)_\d{1,2}.txt/g) { $date = "$1-$2-$3 $4:$5"; $tel = $6; $subject = "SMS from $tel at $date"; `cat $spooldir/$file | mutt -s "$subject" -- $recipient`; unlink "$spooldir/$file"; } } closedir(D); </code></pre> <pre> <code> root@sms:~# chmod 700 /usr/local/bin/sms2mail.pl root@sms:~# apt-get install cron root@sms:~# echo "*/2 * * * * /usr/local/bin/sms2mail.pl" &gt;&gt; /var/spool/cron/crontabs/root </code></pre> <h2>Webservice</h2> <p>Last but not least we also want to create a website for sending sms manually. We will install lighttpd which calls a simple cgi-script.</p> <pre> <code> root@smsgateway:~# apt-get install lighttpd spawn-fcgi sudo </code></pre> <p>/etc/lighttpd/lighttpd.conf:</p> <pre> <code> server.modules = ( "mod_access", "mod_alias", "mod_compress", "mod_redirect", # "mod_rewrite", ) server.document-root = "/var/www" server.upload-dirs = ( "/var/cache/lighttpd/uploads" ) server.errorlog = "/var/log/lighttpd/error.log" server.pid-file = "/var/run/lighttpd.pid" server.username = "www-data" server.groupname = "www-data" server.port = 80 index-file.names = ( "index.php", "index.html", "index.lighttpd.html" ) url.access-deny = ( "~", ".inc" ) static-file.exclude-extensions = ( ".php", ".pl", ".fcgi" ) compress.cache-dir = "/var/cache/lighttpd/compress/" compress.filetype = ( "application/javascript", "text/css", "text/html", "text/plain" ) # default listening port for IPv6 falls back to the IPv4 port include_shell "/usr/share/lighttpd/use-ipv6.pl " + server.port include_shell "/usr/share/lighttpd/create-mime.assign.pl" include_shell "/usr/share/lighttpd/include-conf-enabled.pl" </code></pre> <p>/etc/lighttpd/conf-available/10-cgi.conf:</p> <pre> <code> # /usr/share/doc/lighttpd/cgi.txt server.modules += ( "mod_cgi" ) $HTTP["url"] =~ "^/cgi-bin/" { cgi.assign = ( "" =&gt; "" ) } ## Warning this represents a security risk, as it allow to execute any file ## with a .pl/.py even outside of /usr/lib/cgi-bin. # cgi.assign = ( ".pl" =&gt; "/usr/bin/perl", # ".py" =&gt; "/usr/bin/python", ) </code></pre> <pre> <code> root@sms:/etc/lighttpd# ln -s /etc/lighttpd/conf-available/10-cgi.conf /etc/lighttpd/conf-enabled/10-cgi.conf root@sms:/etc/lighttpd# /etc/init.d/lighttpd restart </code></pre> <p>Add the following line to /etc/sudoers:</p> <pre> <code> www-data ALL=(ALL) NOPASSWD:/usr/bin/gammu-smsd-inject </code></pre> <p>Place this script to /var/www/sms.pl:</p> <pre> <code> #!/usr/bin/perl print "Content-type: text/html\n\n"; print '', "\n"; print '</code></pre> <p><br /> <code>'; exit 0; </code></p> <p>..and change the permissions:</p> <pre> <code> root@sms:/var/www# chmod 755 /var/www/sms.pl </code></pre> <h2>Where to go from here?</h2> <p>Our index.html is still missing. You can <a href="http://tech.feedyourhead.at/content/mail2sms">all sources and configs in the download-area</a> <a href="https://github.com/whotwagner/mail2sms">https://github.com/whotwagner/mail2sms</a>. Beside this, I would recommend to make some monitoring so that you can be sure that the gateway is working. I created some nagios-scripts for this, but that's another story...</p> </div> <span class="field field--name-uid field--type-entity-reference field--label-hidden"><span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span></span> <span class="field field--name-created field--type-created field--label-hidden">Feb 06 2015</span> <div class="field field--name-field-tagies field--type-entity-reference field--label-above"> <div class="field__label">Tags</div> <div class='field__items'> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/sysadmin" hreflang="en">Sysadmin</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/hackaday" hreflang="en">HackADay</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/Linux" hreflang="en">Linux</a></div> <div class="field__item"><i class="fa fa-tags"></i> <a href="/tags/raspberry" hreflang="en">Raspberry</a></div> </div> </div> <section class="field field--name-comment-node-blog field--type-comment field--label-hidden comment-wrapper"> </section> <div class="node__links"> <ul class="links inline"><li class="comment-add"><a href="/content/hack-day-lets-make-mail2sms-gateway-using-raspberry-pi#comment-form" title="Share your thoughts and opinions." hreflang="und">Add new comment</a></li></ul> </div> <section class="field field--name-comment field--type-comment field--label-above comment-wrapper"> <h2 class="title">Comments</h2> <article data-comment-user-id="0" id="comment-77" about="/comment/77" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1498169024"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Anonymous (not verified)</span> on Jun 20 2017</span> <span property="schema:dateCreated" content="2017-06-20T09:12:44+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/77#comment-77" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/77#comment-77" class="permalink" rel="bookmark" hreflang="en">Hey, …</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Hey, </p> <p>very nice script. But I get the following Error: </p> <p>syntax error at ./smsgw.pl line 43, near &quot;= )&quot;<br /> syntax error at ./smsgw.pl line 59, near &quot;}&quot;</p> <p>I´ve tried it with copy &amp; paste from browser and your download files</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=77&amp;1=default&amp;2=en&amp;3=" token="fBZeHvMTZ-hMcEU-2GyaXcKJQN-wkiJ1-4A0Y2WoWH0"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-78" about="/comment/78" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1498170378"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Jun 23 2017</span> <span property="schema:dateCreated" content="2017-06-22T22:24:56+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/77#comment-77" class="permalink" rel="bookmark" hreflang="en">Hey, …</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Anonymous (not verified)</span></p> <a href="/comment/78#comment-78" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/78#comment-78" class="permalink" rel="bookmark" hreflang="en">Hi,…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">Hi, Something went wrong with the sources. I uploaded a (hopefully)correct version of smsgw.pl on my github: <a href="https://github.com/whotwagner/mail2sms">mail2sms-gitrepo</a> Let me know if it works.</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=78&amp;1=default&amp;2=en&amp;3=" token="9l7g6CyOGuRBsFPhhKNZzBSfw43mBAcNDdGPYBPfJms"></drupal-render-placeholder> </div> </article> </div> <article data-comment-user-id="0" id="comment-79" about="/comment/79" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1498511950"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Alex (not verified)</span> on Jun 26 2017</span> <span property="schema:dateCreated" content="2017-06-26T15:10:09+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/79#comment-79" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/79#comment-79" class="permalink" rel="bookmark" hreflang="en">Gammu not processing SMS</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Thanks for you script.<br /> I can confirm, that the smsgw.pl from github is working<br /> Difference github &lt;--&gt; web : Line: 43<br /> Github: while(defined($line = &lt;STDIN&gt; ))<br /> Web: while(defined($line = ))</p> <p>I have another problem. It seems, that the outgoing gammu folder ist not processed.<br /> I have now a file called OUTC20170626_144019_00_%MYNUMBER%_sms0.smsbackup in that folder.<br /> I can manually send SMS via &gt;gammu sendsms TEXT %MYNUMBER% -text &quot;Hallo&quot;<br /> What am I missing? Thanks<br /> Regards,<br /> Alex</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=79&amp;1=default&amp;2=en&amp;3=" token="W7_GwAhjvTHA6STRmXlDlO1SBwxHCX-_m7Nz5-SagxE"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-80" about="/comment/80" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1498512266"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Jun 26 2017</span> <span property="schema:dateCreated" content="2017-06-26T21:24:26+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/79#comment-79" class="permalink" rel="bookmark" hreflang="en">Gammu not processing SMS</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Alex (not verified)</span></p> <a href="/comment/80#comment-80" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/80#comment-80" class="permalink" rel="bookmark" hreflang="en">Do you have anything in the…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">Do you have anything in the logs(/var/log/gammu-smsd)? Are you sure that you configured /etc/gammu-smsdrc correctly? I could solve a similar problem once by restarting the phone</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=80&amp;1=default&amp;2=en&amp;3=" token="2v68fLSD0DXSi4Zqnq5y1yYWZzsIsLbz4Xzv7-_QUpg"></drupal-render-placeholder> </div> </article> </div> <article data-comment-user-id="0" id="comment-81" about="/comment/81" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1499351497"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Alex (not verified)</span> on Jun 27 2017</span> <span property="schema:dateCreated" content="2017-06-27T11:08:14+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/81#comment-81" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/81#comment-81" class="permalink" rel="bookmark" hreflang="en">Sorry, my bad…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Sorry, my bad.<br /> I thought i have to edit the file /root/.gammurc<br /> Just edit the correct file /etc/gammu-smsdrc. mail2sms is now working with my huawei E169 data stick<br /> Thank you so much for you help and sharing your howto + script.<br /> Regards Alex</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=81&amp;1=default&amp;2=en&amp;3=" token="rrN7lMAkQy2iykR8ueUsza2vFqpnO_Y10nrdKoMhEe4"></drupal-render-placeholder> </div> </article> <article data-comment-user-id="0" id="comment-82" about="/comment/82" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1501187124"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Mark (not verified)</span> on Jul 21 2017</span> <span property="schema:dateCreated" content="2017-07-21T14:03:41+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/82#comment-82" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/82#comment-82" class="permalink" rel="bookmark" hreflang="en">base64 encoding</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>many thanks for this great article!<br /> the issue i have is that postfix receives the email (from our Exchange server) in base64 so the message is garbage! don&#039;t suppose you have a workaround?</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=82&amp;1=default&amp;2=en&amp;3=" token="nVxxf7kfK3o9WWmH-jfoo0nGSrMi8Gxsp_WjifaM6w8"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-83" about="/comment/83" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1501187484"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Jul 27 2017</span> <span property="schema:dateCreated" content="2017-07-27T20:31:24+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/82#comment-82" class="permalink" rel="bookmark" hreflang="en">base64 encoding</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Mark (not verified)</span></p> <a href="/comment/83#comment-83" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/83#comment-83" class="permalink" rel="bookmark" hreflang="en">if it is possible, change…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">if it is possible, change the encoding(https://technet.microsoft.com/en-us/library/gg144562%28v=exchg.150%29.aspx) If it isn't possible for you, modifying the code to decode the base64-message might not be difficult..</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=83&amp;1=default&amp;2=en&amp;3=" token="ZsuyuJv6DMaNiqJc4LZhlyRo-RkwH9gmqO7z8qeUv3k"></drupal-render-placeholder> </div> </article> </div> <article data-comment-user-id="0" id="comment-84" about="/comment/84" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1510955092"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">WtG (not verified)</span> on Nov 17 2017</span> <span property="schema:dateCreated" content="2017-11-17T13:55:21+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/84#comment-84" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/84#comment-84" class="permalink" rel="bookmark" hreflang="en">Other transport syntax</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Hi there,<br /> Thanks for this elaborate howto!<br /> I had some trouble getting it to work, but smooth sailing after I used:<br /> &lt;phone number&gt;&lt;at&gt;sms.example.com sms<br /> in /etc/postfix/transport</p> <p>WtG</p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=84&amp;1=default&amp;2=en&amp;3=" token="-txB2sA_sjMw6RzmUufBVmJQlcNCE0a1ATMbCF7Blvs"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-85" about="/comment/85" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1510955757"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Nov 17 2017</span> <span property="schema:dateCreated" content="2017-11-17T21:55:57+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/84#comment-84" class="permalink" rel="bookmark" hreflang="en">Other transport syntax</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">WtG (not verified)</span></p> <a href="/comment/85#comment-85" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/85#comment-85" class="permalink" rel="bookmark" hreflang="en">This shouldn&#039;t be necessary…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">This shouldn't be necessary. if you define sms.example.com sms then emails to this specific email-address is routed to "sms". if you define sms.example.com sms then all emails to the domain sms.example.com is routed to "sms".</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=85&amp;1=default&amp;2=en&amp;3=" token="8mbyhWdAEhNiyr2naE1e8GX3FIzdgJsXIpkzA-5e5MQ"></drupal-render-placeholder> </div> </article> </div> <article data-comment-user-id="0" id="comment-99" about="/comment/99" typeof="schema:Comment" class="comment js-comment by-anonymous"> <mark class="hidden" data-comment-timestamp="1531682611"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/user/0" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Felix (not verified)</span> on Jul 15 2018</span> <span property="schema:dateCreated" content="2018-07-15T12:46:27+00:00" class="rdf-meta hidden"></span> </p> <a href="/comment/99#comment-99" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/99#comment-99" class="permalink" rel="bookmark" hreflang="en">sms4you</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item"><p>Hey, thank you a lot for this great write up! I used this setup for a couple of years. Recently, I rewrote it in Python and instead of dealing with emails directly, it relies simply on an email account to which it connects (imap and smtp) for sending emails. This means you don&#039;t have to setup any sms.example.com subdomain anymore, neither expose the computer directly to the internet. Maybe you find it useful: <a href="https://github.com/xamanu/sms4you">https://github.com/xamanu/sms4you</a></p> </div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=99&amp;1=default&amp;2=en&amp;3=" token="tu6wLhZ-Ma8EjJoR_ZfinWjwqLpCtBg3_WasaLL7trc"></drupal-render-placeholder> </div> </article> <div class="indented"> <article data-comment-user-id="1" id="comment-100" about="/comment/100" typeof="schema:Comment" class="comment js-comment by-node-author"> <mark class="hidden" data-comment-timestamp="1531682857"></mark> <footer class="comment__meta"> <article typeof="schema:Person" about="/users/hoti" class="profile"> </article> <p class="comment__submitted"><span rel="schema:author">Submitted by <span lang="" about="/users/hoti" typeof="schema:Person" property="schema:name" datatype="">Hoti</span> on Jul 15 2018</span> <span property="schema:dateCreated" content="2018-07-15T19:27:37+00:00" class="rdf-meta hidden"></span> </p> <p class="parent visually-hidden">In reply to <a href="/comment/99#comment-99" class="permalink" rel="bookmark" hreflang="en">sms4you</a> by <span lang="" typeof="schema:Person" property="schema:name" datatype="">Felix (not verified)</span></p> <a href="/comment/100#comment-100" hreflang="en">Permalink</a> </footer> <div class="content"> <h3 property="schema:name" datatype=""><a href="/comment/100#comment-100" class="permalink" rel="bookmark" hreflang="en">Thanks for sharing, I…</a></h3> <div property="schema:text" class="clearfix text-formatted field field--name-comment-body field--type-text-long field--label-hidden field__item">Thanks for sharing, I appreciate it.</div> <drupal-render-placeholder callback="comment.lazy_builders:renderLinks" arguments="0=100&amp;1=default&amp;2=en&amp;3=" token="OKuJvzWViMtDf3QSFFVn9OD3Hay6CR_ATONG1v-4IRw"></drupal-render-placeholder> </div> </article> </div> <h2 class='title comment-form__title'> <i class="fa fa-comments-o"></i> Add new comment</h2> <drupal-render-placeholder callback="comment.lazy_builders:renderForm" arguments="0=node&amp;1=45&amp;2=comment&amp;3=comment" token="B1_Y0roA_7jD8iCNklaU9NpZi7ThOtVhERxcNfdOEeQ"></drupal-render-placeholder> </section> Fri, 06 Feb 2015 10:40:19 +0000 Hoti 45 at https://tech.feedyourhead.at