Archive for the NodeMCU Category

Short cuts

Posted in ESP8266, MQTT, NodeMCU, OpenSprinklette on December 18, 2016 by asteriondaedalus

The chappy doing OpenSprinkler gave me the best idea yet for the 24VAC to 5VDC to power the OpenSprinklette stack (Wemos D1 R2, fiddly bits including VAC2VDC and pullups, relay board).

Rather involves using a LM2596S-5.

I have in my bits drawers 10 LM2596S-ADJ based modules that go for US$2 a pop in packs of 10 so I will start with that for the prototype.

lm2596-psu-01-a-450x450

For the VAC2VDC the secret is to add a 3A diode (cathode to +ve volts input) of the PSU board.  It then likely passes for the circuit at the OpenSprinklette blog.

In fact, if you solder the pullups onto the two naughty GPIO pins you need to, either on WEMOS D1 R2 or the relay board, you could get by without an intermediate board.  There is still the conditioning circuits for the flow meters, but again, since we are using mqtt there is the option of a separate system for that.  I think we are already convinced that the rain gauge can twerp to an mqtt topic for example.  Although, there may be traction in a shield board for people who want no more than four zones and one unit – at least with the rain gauge input and 24VAC to 5VDC … oh and those pesky pullups.

Note we still need do something like string all the relay commons together now don’t we.

I guess the more interesting thing going on with the rain input of the OpenSprinkler is the use of a surge protection across the rain gauge input that has a Transient Voltage Suppression diode.  The selected value appears to be 48V which seems a lot but the gadget is used for ESD threats to the board (aka lightning – not strike likely but nearby EM field, up to a point).

This is actually necessary especially when there is  likely a long “antenna” from the rain gauge to the unit.

Might be less need if an ESP8266 is connected at the gauge and the solar panel and charger (we’ll need a battery to run at night time) are similarly “close by”.  Already solved in any event.  

Hmmm.  Lightning detection

Ah ha! Digital rain gauge spare parts!

Posted in ESP8266, MQTT, NodeMCU, Wifi on December 17, 2016 by asteriondaedalus
rain-gauge

Rock it to me baby!

So, get this, for US$15 you can get a rain gauge that does naught but yep, still yep and yep, then maybe nope.

That is, the cover has a funnel and water drips in and cycles the rocker!

 

simple

Simple tich?!

 

That likely needs nothing more than one of the ESP littlins …

esp8266

… to chirp tich/toch onto a mqtt topic.

Connecting NodeMCU to a NTP server

Posted in Embedded, Lua, NodeMCU on July 4, 2016 by asteriondaedalus

Ignore the IP suggested in example.

Search google for “NTP server”.

Being Australian I am using one from the pool listed at:

http://www.pool.ntp.org/zone/au

Code therefore becomes:

sntp.sync("0.au.pool.ntp.org",

 function(sec,usec,server)
   print('setting time to:', sec, usec, "from: " .. server)
   rtctime.set(sec, usec)
   sec, usec = rtctime.get()
   print('time set to: ', sec, usec)
 end,

 function()
   print('failed!')
 end
)

The difference between times that you will see, when running this gem, is in and around 7 milliseconds which is the cost from function calls is all.

The idea would be to use a timer, set to max time and auto mode to run this occasionally to keep the time on the node synced with your local world.  That is:

tmr.register(6, 6870947, tmr.ALARM_AUTO, sntp.sync(...)) -- see above code

You might like to set a flag if the sync fails, or publish a mqtt alarm, or something more useful as the print will be lost on the world since we are deploying nodes in the real-world sans terminals.  Although consider loss of sync might also be loss of wifi access and so likely loss of communications with your mqtt server – so devilishly complicated this will all be.