Archive for August, 2017

That was close (retraction)

Posted in Windoze10 on August 17, 2017 by asteriondaedalus

I went to start my PC yesterday to find the dopey thing had fallen into an auto-update.

I had turned off auto-update and refused to update my Windoze 10 because three times in a row the update froze.

I spoke the Windoze help desk, you know the ones in the balloon.

They hinted I had to deinstall my virus software – or at least disable it to allow the update to work.

I was planning to do just that, I just never got around to it.

Sigh!

So I sat there watching the dopey thing tick its status over.

Then it dawned on me it had gotten past the infamous 33% where it would get stuck – literally for days at a time – previously.

Happy to say the PC finally survived a Windoze update after 6 months of hiding from the process.

Not happy the machine fell into the update against my settings.

RETRACTION

So. For whatever reason my machine updated despite my settings. Fine because it finally made it through. Except another update come through this morning. Yep. It hung my machine.

Niggly

Posted in Embedded, MQTT, NodeMCU, OpenSprinklette, Orange Pi on August 16, 2017 by asteriondaedalus

I may have some more design work for the opensprinklette node-red implementation.

The nuance is that the google calendar node will happily trigger on event edges but the triggered response seems to be a dump of the calendar event parameters but not the edge that triggered the node.

It might be as simple as another parameter on the configurator to tell it whether it is for sprinklers on or off

The other might be using the before event.

Have two outputs then to act as start and stop.  Feed the stop into a timed node.

Either lapsed or absolute is another question.

Much of this is trying to think in a dataflow rather than an imperative idiom.

I want to think also about ACK from the WeMOS sectors. That might want a watchdog timer.

The lwt from the WeMOS sector will need a response. Although any sector/zone on, while WeMOS is down, falls on deaf ears.  Stil, it needs to be logged and reported.

Ta da!

Posted in Javascript, node-red, OpenSprinklette on August 12, 2017 by asteriondaedalus

Ah ha!

I had some trouble importing my pegjs parser function into the node console until I worked out node and/or javascript treats directories as “/” whereas windows uses “\”.

So finally the import is simply:

var parser=require('./parser.js');

I also hand modified the parse function signature which is now:

function peg$parse(input,zones, options) {};

I worked out that zones needed to go ahead of options as calling “parse(input,,zones)” wasn’t a popular choice with the javascript.

The input variable “zones” will come from the configuration node.  That way the parser will take the configuration object [{sector1:chipid()}] and return the mqtt topic fragment “chipid()/zone[0..4]”.

So, the modified parser tested using node console shows it working:

final zone parser test

Now all is needed is the use the zone “grammered” string in the google event title and snip it out, when the event starts/stops.  This is achieved with msg.payload.title as the first parameter in the call made by the node reacting to the calendar event.

The array returned can either be iterated over using a for-loop OR be returned by a node-red function to be treated as a stream of messages (aka msg).

I have a sneaking suspicion that, in fact (and having read the code and how it uses “options”), I [could|should] have injected the zones via options.

Something to play with I think, as it doesn’t seem clean to hand mod the parser code.

Sizzzzle!

Posted in Javascript, node-red, OpenSprinklette on August 10, 2017 by asteriondaedalus

Pop!

A parcel turned up with RaspingbreathburryDoodlePi heatsink kits.

They are the recommended source for a heatsink for the OPiZ.

Although I can certainly find the same on Aliexpress, I bought locally to get them within a week instead of 10 weeks.

Still, gotta say brrrrrrrrrrrrrr, freezy!

At least 5degreeC cooler running with heat sink.

Still not convinced that was source of ethernet dropouts on my new board.   No problems for a couple of weeks now so I will put concerns aside.

I did notice 15mmx15mmx5mm 5V fans on Aliexpress though.  Tempting.

Still tempted at getting a small peltier cooling gadget to go the whole hog – mostly for the fun of it.

But, at the moment, I am focusing on finishing the opensprinklette configurator node for in node-red.   I have a basic configurator to map sectors to WeMOS chipid(), now I will integrate the pegjs defined parser.

Parse the salt please, or at least the sector declarations

Posted in MQTT, OpenSprinklette on August 10, 2017 by asteriondaedalus

So, I spent some time on how to parse zone commands for the sprinklers in the form “sector1=1,sector3=4,sector2=0,sector3=1”, from the google calendar event titles, into mqtt commands for the WeMOS nodes.

Regex have never been a favourite of mine, being a clunky solution from hackers for hackers.

While it is a small problem to solve I still wanted to do something smart so I looked around for a parser generator for javascript.

I came across pegjs.

Brilliant!

Though, as usual, bugger all help.

However, I started with the JSON example and parred it back to get a solution that returns an array of zones (sector/zone) to act as a fragment of an MQTT topic.

Small steps

Posted in Embedded, ESP8266, IOT, MQTT, node-red, NodeMCU, OpenSprinklette, WEMOS D1 R2 on August 7, 2017 by asteriondaedalus

I have roughed a node-red config node and it’s visible counterpart.  I decided to call wemos nodes “sectors” – since the usual rort is to call a single channel on an irrigation controller, controlling a single solenoid, a zone.

I have set up for 4 sectors each using a WeMOS D1R2 with a quad relay shield.  That provides up to 16 zones (4 per WeMOS).

You need to mod the relay shield with a couple of pullup resisters.  This is to get around a design shortfall on the WeMOD D1R2.

I am using a protoshield in between the WeMOS and the relay shield to allow for fidgeting with design changes. I added a four position dip to set the zone id BUT I dropped that in favour of the config node concept.

That gives me back 4 pins for GPIO. The problem is the out and out lie that the WeMOS is a Uno form factor. The ESP8266 has to cheat by using the same GPIO pins across a couple of Arduino socket pins.

I will add the rain gauge input later.

The idea is an input line such as the following as the title of the google calendar event:

sector1=1,sector3=4,sector2=0,sector3=1

The line above shows you some of the input features I will aim for, being:

  • You don’t need to nominate all four sectors or even all four individual zones of a sector.
  • You can order the sectors in any order.
  • The zones per sector are number 0..4 with 0 being the global all on/off id for all 4 zones on the addressed sector.

I did think about using JSON as input but the problem is that if you have two tokens the same then the object construction takes the later value in the line for the key.  Oh well.

For this to work you attach two google calendar event sniffers, one to flag the start of an event and one to flag the end.  Both feed into the opensprinklette-configurator to decode the events into MQTT calls to the 4 WeMOS D1 R2.

Of note, the configurator maps between chipid() and sector# (and back again) so planning the sprinkling can be in people-talk (relatively speaking).  At least you don’t have to remember which WeMOS chipid() was allocated to what sector.

Of course, there are quirks to do with the distributed system.  There will be a watchdog on the WeMOS to automatically turn off the water to a zone after 45min.  To plan out longer watering you will need back to back calendar events (shorter than 45min to avoid the watchdog).  If that is offensive please send money to help me pay the water bill of a runaway commercial setup ($3,000 in fact).

The other option I guess is send the duration to the WeMOS node and let it do the countdown.

I will play with a couple of timing approaches to see what is most robust – given you could have the ISP gateway drop out, the node-red crash, the emqttd crash, the OPiZ drop of the network.  Not to mention, google calendar hickups – I occasionally get a baulk around credentials lapsing that somehow comes good again.  Oh and of course, the WeMOS could also behave badly.

All in all needs a good bashing to help weed out nuisances.

Back to work

Posted in ESP8266, Lua, MQTT, node-red, OpenSprinklette, Orange Pi, WEMOS D1 R2 on August 5, 2017 by asteriondaedalus

So, at last, now that the OPiZ setup saga is over (fingers crossed) we begin over.

I built a new nodemcu firmware for the WeMOS to include:

  • bit
  • end user setup
  • file
  • GPIO
  • MQTT
  • net
  • node
  • RTC Time
  • SNTP
  • timer
  • UART
  • Wifi

A few coding snippets later and  the WeMOS can catch the mqtt topic running on the OPiZ feed by the node-red on the OPiZ.

wemos

So, I can now parcel up the OPiZ as the house server and tidy up the sprinkler system.

I did note that the WeMOS did not come up first time I bombed the firmware.  That was sorted (it seemed) by selection the 4MB Flash option on ESP8266Flasher.  The ESP-12E on the WeMOS has a 4MB flash and I noted that there is a branch of the nodemcu frozen in time now for the 512kB chips – so go with the master branch if you have the WeMOS D1 R2.

I did also manage to break a hoodoo now that nodemcu does away with autoconnect for the MQTT.  The timer callback scheme works a treat.  I can reboot the OPiZ and the WeMOS will reconnect once emqttd is up and running again.  Of course, I have a LWT setup so that the emqttd server will tell the node-red if the WeMOS drops off the channel.

This is getting exciting now.

So far so good

Posted in MQTT, node-red, Orange Pi, Python RULES! on August 2, 2017 by asteriondaedalus

OPiZ is still up.  So I have avoided the hiccup of ethernet dropping out somehow.  I am always queasy when the problem just “disappears” but small mercies right?

The only thing that I noted was that, when the system has dropped its ethernet, I have not had a console connected.  So I have shut down the TeraTerm session, that was watching the memory usage, and left the device running now with the node-red and python test harnesses running.

We may be good now.   I hope I have properly documented the steps I went through.

PEP Project kick off

Posted in MQTT, PEP Project, WEMOS D1 R2 on August 1, 2017 by asteriondaedalus

So, I downloaded and installed and then run Arduino IDE 1.8.3.

I included the ESP8266 core.

I grabbed the blink example for the ESP8266 and bombed the WEMOS D1 R2.

We are blinking.

I then disconnected power and installed the ITD 2.8 inch touch screen shield (V1 I suspect).

I added power and led blinked PLUS I have back lighting on the LCD.

So far so good.

Next is grab and install libraries for the LCD to see what needs to be done on the WEMOS to port them.

Looks like some work to set up for the ESP8266.  Should be fun.

Errr … no.

I should have looked at this sooner as the ESP8266 does not have enough GPIO.  When you look more closely the UNO compatibility is met by sending the same signal to a couple of the arduino pins but for the most part you cannot run the TFT board on the WEMOS after all.

So,  I dusted off an old MEGA1280 to play with the TFT library.  No biggy, a little messy but might then look at simply adding a ESP-01 module to provide the MQTT client over the serial buss from the MEGA.  Once I get the hang of this I might as well order a couple to three mega2560+3.2 inch TFT from Aliexpress.

I can then set them around the house and front/back yards to control various things – for when I don’t have my phone on me.

Mind you, I also had to back date to Arduino 1.0.5 to program the MEGA1280.  I keep it around as it has been used to play with avrFORTH and OCCAM (except Plumbing doesn’t appear to work on Windoze 10 grrrrr)