Sep 222016
 

I like my switch/routers from Mikrotik. While not flawless, they are working well, have a descent command line interface and a usable web (and Windows) GUI. They got all features I need and are stable.

One missing feature however was that DHCP leses did not get a DNS entry. The simple workaround was that stuff which should get DNS gets a static IP. Anything else doesn’t and thus is not reachable by DNS. Was not a big deal until I used Vagrant which can build VMs (via VirtualBox). Now I got plenty VMs which I simply bridge on the normal LAN. But in order to connect to them outside of “vagrant ssh nodeX”, I needed to have their IP. Vagrant can tell me, as can the VM itself when I connect via “vagrant ssh”, but all this is way more complex than simply using DNS. dnsmasq does that automatically, but not the DHCP/DNS combo on RouterOS.

Scripts to the rescue!

https://www.tolaris.com/2014/09/27/synchronising-dhcp-and-dns-on-mikrotik-routers/ has a nice one which does what it’s supposed to do. Relying on the TTL to be different from static DNS entries, it’ll create or delete DNS records which according to DHCP leases should or should not exist.

screenshot_20160922_163849

One important hint: you need to allow the script to read/write “things”. And the scheduler when running the script.

screenshot_20160922_164130

TTL for DHCP is set to 15min. TTL for static enteries is 1d. The script runs every 5min.

Sep 222016
 

I bought a small waterproof DS18B20 based temperature probe. Finally I had a reason to use it: to measure the temperature drop in the joeveo mug which I received 2 days ago. While the theory is sound, it’s one thing to just believe in it or to measure yourself. I pick the latter, especially if it it involves some programming!

Temperature over time for various things

x: time in seconds, y: temperature in degrees Celsius

Using flot (for now) to make a quick graph, I got a sense of temperature drop in my normal ceramic mug as well as an idea of the drop in an insulation mug. The first graph (ice melting in glass) was using integers for the temperature.  The DS18B20 can clearly do better, so the next measurements I did with the floating point NodeMCU firmware.

Here the trivial code:

ds18b20 = require("ds18b20")
gpio0 = 3
ds18b20.setup(gpio0)

# plot temp over time

mytime0 = tmr.time()
n = 0

function plot_temp()
 uart.write(0, "["..tmr.time()-mytime0..","..ds18b20.read().."],")
 n = n > 4 and 0 or n+1
 if n == 0 then
  print()
 end
end

tmr.alarm(0, 10000, tmr.ALARM_AUTO, plot_temp)

Integrate the output into a HTML et voilà: a simple yet good looking graph.

Step 2 is to actually measure the temperature in the joeveo mug.