Woof woof woof

Posted in Arduino, MQTT, Sensing on June 18, 2017 by asteriondaedalus

A neighbor complained that the dogs were barking all day.

Likely cause all the renovation work going on (late into the night as well).

I looked around for software so I could detect the barking and potentially turn sprinklers on for a minute – to distract them.

Options are also a buzzer, so they associate the buzzer with the sprinkler coming on.  Then later the sprinkler needn’t come on.

HE is funny.  Not liking to wet he has an aversion to the solar powered, IR triggered, sprinkler I use to at least keep them away from the side of the house.

The psychology is funny though, they stop short of going down the side of the house and bark anyway.

Much of the software is really noddy.  Level sensing.  So I looked for microphones and downloaded python scripts etc.  The software would also send you an email if the dogs barked.

Still, the problem running on the PC was obvious.  The problems setting up a microphone on a C.H.I.P. or Orange Pi were not insurmountable BUT still was that over kill.

My time in signal processing get get me excited about using correlations to discern dogs barking from loud noises but there are other tricks there.  The load noise would be of a fixed duration that repeated.  So, a window with say four loud noises could count as barking in a backyard otherwise quiet.

The thought of the signal processing didn’t daunt me, but the turn around time to get something running did.  So, the plan is a super duper system later, at the moment I just want to monitor their behaviour and sort something out that might curb it.

So I thought I would go with a arduino compatible microphone/sound sensor instead.  An ESP-01 would do it as the sensor has a tuneable level sensor and raises as signal if the level is at or over that set.

However, it also puts out an analogue signal, from the mic, so a WeMOS mini would be better since it has the ADC input.

arduino-compatible-microphone

The sound sensor takes 5v, as does one of the pins on the D1 mini.    This way I can pump out noise events by the level sensor early using mqtt.   And later, I can pump analogue samples out by wifi.

I am already using node-red to send emails from the OPiZ so I can pump out hourly “woof” stats.   This setup is also cheap enough to set a couple up so that different parts of the yard (and thereby irrigation sectors) can play their part.

I have a suspicion neighbors are not helping and banging the fence.  So I am looking for a vibration sensor to get stats on that as well.

GaaaaaaaaaaaaaaG!

Posted in Linux, Orange Pi, The downside of Opensource on June 18, 2017 by asteriondaedalus

So, various things on follow up to mqtt as a service.

You can have a /etc/init.d/mqtt file (works from console but doesn’t work as a service and therefore does not work at boot)

You can have a /etc/systemd/system/mqtt.service file (doesn’t work)

You can have a /usr/lib/systemd/system/mqtt.service file (doesn’t work)

Closest thing that appears to hint at what the problem might be is that emqttd starts with console but systemd baulks during service startup.  Noting that /etc/init.d/mqtt works from console but won’t work using either of “service x start” or “systemctl start x” then that appears to “behave” in a way that would suggest console interaction with systemd.

Changed /opt/emqttd/bin/emqttd to turn off console on startup (doesn’t work).  Or at least the example code I used does not work as advertised.  The change suggested is from:

-args_file $RUNNER_ETC_DIR/vm.args 

To:

-args_file $RUNNER_ETC_DIR/vm.args -detached -noinput -noshell -- ${1+"$@"}"

Not to mention that, for some reason, the mqtt.service options seem to “break” the node-red startup somehow.   When I log into the OPiZ, pm2 show tells me node-red is online but browser fails to connect.  If I delete the mqtt services and reboot I get node-red running on boot as expected.

The problem with the internet …

Posted in Linux, node-red, Orange Pi, The downside of Opensource on June 17, 2017 by asteriondaedalus

… and all you need is that one page you can get to from anywhere in the world, though it might be obfuscated by all the other pseudo pages on the same topic.

So, to get the node-red to run on boot I used the following (see “Starting Node-RED on boot”)(as root):

npm install -g pm2
whereis node-red
node-red: /usr/local/bin/node-red
pm2 start /usr/local/bin/node-red --node-args="--max-old-space-size=128" -- -v
pm2 save
pm2 startup
export PM2_HOME="/root/.pm2" # because I installed in root 
reboot #takes a while after rebooting but it should come up

The max-old-space-size=128 is based on suggestions for RaspingBreathBurryDoodle Pi and Beaglebone Black, which both have (as does the Orange Pi Zero) 512Mb of memory.

So, now that fraking emqttd, which does not start as a service on boot, is the last hurdle.

Okay, so I have changed my mind …

Posted in Arduino, ESP8266, Open Source can be professional on June 17, 2017 by asteriondaedalus

… it was fun for a while but …

So, dabbling in Lua on the ESP8266 was interesting.

The event driven stuff is clever.

However, the whole thing stinks because you cannot use the REPL cycle to take advantage of the scripting environment and the superior debugging opportunity that affords.

Especially around the niggly aspects of event processing and state problems inherent therein.

So, now the Arduino has the ESP8266, but especially since it now has a mqtt library, and mostly because we are only reading GPIO ports or setting bits on/off, I relent.

If you want to knock up a simple IoT gadget quickly, then Arduino plus ESP8266 are gold.

Turing is dead, long live Turing!

Posted in Rant on June 17, 2017 by asteriondaedalus

God!  It had to happen.  Life becomes Science (as opposed to Art).

An Israeli mob is working with AI to provide a coding assistant that does more than complete function names – it is to scan Stack Overflow for code snippet suggestions!

I wonder if they are going to have it write sardonic blog entries as it discovers, over and over again, that the code examples at Stack Overflow do not work for the most part.  Or at least they are so narrow a “solution” they cannot be generalised.

What, by the way, does the AI do in my situation where perfectly good init.d script runs in console, does not run in service startup, and there is no solution provided (currently) on the Internet?

Sort of also reminds me of the AI goons who, at a party (and in a very Hitch Hikers Guide to the Galaxy kind of way), connected two AI conversation agents together.  The AI agents had been “trained” by hooking them into social websites (twitter, facebook et cetera) – to “train” them on human conversational style.  Within 5 minutes there was a tirade of abuse going both ways.  The AI scientists had “trained” Trolls.

Now, here comes the deep and philosophical.

The trend to “free” software has incurred a huge technical debt through the utter lack of software quality attributes.  I am, for example with the problems setting up my OPiZ for node-red and emqttd, suffering at the hands of lack of portability, usability and a smidgen of functionality.

What I am going through is old skool Through Life Blues.

The cost of Through Life aspects of software systems is about 80% of the full life cycle cost.  That is we spend 20% on development then a shit load more on keeping it going.

Much of that cost comes from un-codified knowledge.

So, the propensity to write code, comments are a “code smell”, produce no documentation, all of that increases the cost of Through Life Support.  Though the cost is in time an efficiency for me, it must be burning someone’s bottom line in the commercial sectors.

So, since there is no code comments, design documents or useful manuals the question begged is should there be?  The AI push for recovery of codified knowledge says yes since we are not denying its necessity.   However, we still feel the generation of the technical debt incurred by developers, but repaid by everyone downstream, is acceptable – somehow.

The problem is, of course, a quality attribute Adoptability (not in the ISO standard).  Adoptability is not to be confused with Attractiveness.  Adoptability might the decision point, based on the aggregation of all the facets of the software quality.

So, where is the benefit of AI trawling the coffers of sloppy code?

Where is the cost trade off against the waste going on versus the relatively small number of successes in the scheme of things?

So wearing …

Posted in Linux, Orange Pi, The downside of Opensource on June 16, 2017 by asteriondaedalus

… goddamm fracking frack!

So, again different versions of versions of linux.

So, apparently I can change the timeout of a service with:

systemctl set-property mqtt.service TimeoutStartSec=x

If and only if I have a TimeoutStartSec property that is, you guessed it.

Turns out, there is a TimeoutStartUSec … woop … er… already set to five minutes.

doh

So theres goes that theory.

Oh COME ON!

Posted in Linux, Orange Pi, The downside of Opensource on June 16, 2017 by asteriondaedalus

I know I said I sorted starting emqttd as a service. I rebooted and opened browser to the emqttd web console.

Got caught out with beginner blunder – the webpage is cached on my PC isn’t it. So the emqttd didn’t, afterall, start. However, the bonus is the error reported has changed (using the tidier init.d file of mine), and the inference I get from the new error is, I think, the service startup period is timing out.

No problem.

A couple of mechanisms appear to be there to change the default timeout.

Maybe.

Stay tuned as nothing has worked as advertised on my OPiZ now its fragged and running arbian.org distro.