Monday, July 30, 2018

40" Picture Frame For under $100

Yup, another version of my picture frame obsession (YAPF). I have turned several laptops into picture frames in the past. The Mark I, a ca'95 HP laptop is still running strong, 8 years non stop. The Mark II ca'99 HP laptops were not that strong. These died after few years...something changed in HP's quality about the new millenum...

So here we go again! This time I am spending real $$$ on it!

The ingredients:

  1.  A used HDTV from craigslist.org.  Best, a TV with LED back-light and 1080p resolution (a 720p works too but the picture quality is not that great unless they are small.). I got a 4yr old Emerson LC401EM3F.for $75
  2. Rapsberry Pi Zero $5 or better RPiZeroW $10 (much more fun to access remotely)
  3. miniSD card, greater than 4GB capacity $5
  4. 5V USB power supply (a charger better than 500mA), USB cable (to power RPi) $10
  5. High-Speed Mini-HDMI to HDMI Cable, such as this (Amazon Basic) $5
Total about $95.

Quick steps to the finish

Here are the steps to achive glory in less than an hour...that is if you know what you're doing. (Some skills required.)

Create Bootable Raspian Lite system. 

There are plenty tutorials online how to do it here.
  • Download Raspian Lite (at the time of writing it's STRETCH). Here
  • Image your microSD card (on linux I use dd)
  • Connect a keyboard (needs a microUSB to USB cable/adapter, OTG works) to USB port.
  • Connect monitor via you cable (you can use adapters but the connectors on RPIW are fragile and close together so cable work better).
  • Power it up by plugging the USB charger/power supply into PWR connector.
  • You should see RPI booting.
  • After booting, log in as pi, password raspberry

Configure the system, via raspi-config utility.

  • change password (if you want)
  • set hostname (if you want)
  • configure wifi (so you can log into it with ssh - applies only to RPIZ or if you plug inWiFi adaptor)
  • enable ssh
  • configure locale: US UTF-8, timezone
  • configure keyboard: Generic 104 PC, US than at the end there is option to set Ctrl-Alt-Backspace to kill X
  • configure boot to console (not graphical)
  • set to resize file system to full CD
  • reboot, check that wifi is connected (ping something), also check you can ssh to the system (handy later)

Add to the system, as Lite is a bit...lite.

  • first update  all
    • sudo apt-get update && sudo apt-get upgrade -y
  • reboot 
  • install graphical display (xorg) and other utils
    • sudo apt-get install --no-install-recommends xserver-xorg xinit x11-xserver-utils lightdm feh
    • note: the lightdm allows auto login to X; feh is the slide show application.

Configure scripts so things start automatically on every boot.

  • create ~/.xinitrc (this is what startx runs: disable x screen blanking and make it execute pf.sh at the end)
    xset s off
    xset -dpms
    xset s noblank
    /home/pi/bin/pf.sh
  • create ~/bin/pf.sh to start feh in desired mode - full screen, randomized slide show 60s, no mouse etc and make it look for pictures in ... Pictures directory)
    feh -xrzYZFD60 --no-pointer --auto-rotate ~/Pictures
  • in ~/.profile add the following at the end  (this runs startx on login from tty1 so autologin will use it)
    if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then
    startx
    fi

Enjoy the view

Put some pictures in Pictures directory (you can use the scp utility via network).
Connect da TV.
Reboot.
You should see RPI booting and then switching into graphical X and after a moment displaying the pictures.

DONE?


Ahh...No....not completely. I still want the YAPF.M3 to turn off when nobody is watching and back on when somebody is here (via a PIR sensor). More on this later  (hooking PIR sensor, using HDMI CEC TV control and wrapping it all in a script).

Here is how to add schedule to the YAPF.M3
http://minkbot.blogspot.com/2018/08/picture-frame-rpipf-on-schedule.html

Also, since it's already connected to wifi, perhaps it could suck in the pictures itself? The disadvantage is that I am still using Picassa and which do not modify my pictures (Picassa just remembers the operations) and the pictures would be the resolution unnecessary higher than 1080p (20MP anyone?).

Github Repository

All the files are in github. These can be copied to the home directory: ~/home/pi.
https://github.com/michkrom/pictureframe



Saturday, July 28, 2018

Google Assistant Marine Weatherman

Once upon a time, I decided that checking  the weather on the phone while driving is not conducive to safety.  But then I learnt about Google Assistant AI thingy that is changing the world...sorry Alexa!
And here is a story of trying to build a Google Assistant skill for accessing marine weather information.

WHY

Soo...what marine whether data am I interested in? Wind, tides, fog, swell....I am a kite-surfer and my day-to-day ability to kite depends on catching the windy days. I need to know! Since I am on north California coast I depend on NOAA and NWS.

WHAT

So here are some web weather resources I want to access via a speach-based application:

Coastal Forecasts
http://tgftp.nws.noaa.gov/data/forecasts/marine/coastal/
Tide Predictions
https://tidesandcurrents.noaa.gov/tide_predictions.html
Noaa Buoys:
https://www.ndbc.noaa.gov/mini_station_page.php?station=44017

HOW

Google Assistant AI. Well...really the AI?...That depends on your definition of 'I'.  IMHO, it is not AI - it is a speech-to-text (a very good one, mind you) then a text pattern matching filter with ability to invoke external web servers when matched a pre-canned pattern.  It can't think by itself (the 'I' in AI is rather weak).

LINGO


Here is the lingo, which took me quite a time to decipher:

Google Assistant

A user facing system that can accept user input and provide, by some magic means, relevant output. Google Assistant (GA) has a plethora of 'native skill' and ability to invoke 3rd party applications (via 'talk to XYX'). There is also notion of Actions on google..I think it's just a fancy name for an Google Asistant application?

Google Assistant Application

(aka skill...aka Action?) It is what I have created. GA apps are invoked by 'talk to XYZ', in my case it is 'talk to marine weather'. I tried to be funny but GA app name must be 2 or more words so Neptune or Poseidon did not work.

DialogFlow

Is a text pattern matching system - my application (my Google Action) is a set of text patterns, aka Intentions (read: 'user intentions', 'user statements').
(I suspect there is a close relation between defined patterns and a speech recognition as each time I update the pattern it says it's 'training...', likely speech recognition is much better if the correlator knows what to expect). DF also contain a system of describing parameters (ie the variables in intentions) via Entities and also linking intention to external web-based services (aka Fulfilment).

DialogFlow Intentions

I have mentioned the intentions. These are the patterns that constitute one user desire (intention) and DF app may have many intentions. In intention, the same thing may be expressed many different ways:
tides for bodega
give me tides for bodega 
what are the tides for bodega
bodega tides
give me bodega tides
etc..
Intentions can have parameters here a 'location' would be a parameter. One can select a part of the example sentence and make it a parameter. So:
tides for 'LOCATION'
where location is a parameter. Which brings us to entities.

DialogFlow Entity

Entity is a ... type (specification) of a parameter.  You can use predefined entity (such as 'city' 'time' 'color' etc) or define your own or ... use @sys.any which is ...well anything.

DialogFlow Fulfilment

Simple intention can have canned responses. You define them right in the dialog flow. But if you need to go to get some real time data, the fulfillment is where things get more interested. Fulfillment is essentially the GA/DF reaching to some other place in the WWW and getting a reply. So fulfillment is a www server accepting a https request returning a response. The request and response are GA-specific, JSON formatted collection of parameters. You can host this service yourself or you can use google services. The google services are called Firebase. Note, the Google Firebase is more generic than focused on GA/DF but there is a good support to make things easy.

It's all pretty convoluted and overwhelming on the first date...

Monday, July 9, 2018

It's been a while

Yup, I got busy/lazy/having too much fun. This post is just to unplug the pipes, move the joints and warm up my fingers...

Thing I have been toying with:
  • Picture Frame Mark2
  • Ghost-busters backpack (Halloween Outfit)
  • Fulling around with MSP430
  • Fulling around with rPIs (3,zero,zerow)
  • Fulling around with MSP8266
  • Lego robotics help training
  • Odyssey of the Mind training
  • Hacking Ikea ANSLUTA remote
  • Building and flying quads and fix wings RC
  • Flying man-lifting kites in the waves.
  • Sailing sailing boats
  • Remodeling
  • Life
My current toyject (short for toy-project): Google Assistant app for Marine Weather.

Stay put, some of these will find it's way here.