Temperature Sensor – Mk II

My first go at creating a simple battery powered temperature sensor was really interesting and fun to do, but, like any project, there are always way to make it better!

For my Mark II sensor, there were a few things I wanted to improve:

Mesh Networking

I’m interesting in exploring the concept of mesh networking. Within the Expressif family of devices, there are two flavors that I’m aware of; WiFi mesh and Bluetooth Low Energy Mesh. The ESP32 platform supports both of these. My current Temperature Sensor is built upon the ESP8266, but moving to the ESP32 should be straight forward.

In Progress – .

More Data

Mk I of my sensor was a simple temperature probe. I wanted to expand on this after I found the Bosch BME280 sensor. This little sensor can capture temperature, pressure and humidity. The boards I ordered work on the I2C protocol, so I’ll have to figure that out.

Not started.

MQTT Discovery

I use the Hass.io platform to manage my automation at home. It supports a simple MQTT interface for receiving data and sending commands. Typically, you would configure the devices within a config file, but it does support a discovery protocol, which allows devices to make themselves known to Hass and to provide all the information required for Hass to use them.

I would like my temperature sensors to support this mode, so that when they fire themselves up for the first time, they would register themselves automatically.

Not started.

Battery Life

Not started.

Housing

I’d like to enclose my sensor in a nice case, so that I can mount them on the wall in way that doesn’t look completely ugly!

Not started.

Low battery notifications

Not started.

Advertisements

Best laid plans, part 2

After my little boo-boo with measurements, I purchased a new Wiska junction box from RS, this time with a little more width and the Sonoff relay fit perfectly! I also picked up some IP66 glands to help secure the wire from the LED strip.

IMG_5011

This junction box had a membrane covering each hole, so I pierced a hole in it and fed the table through. The gland then screwed into the threaded hole (what makes these Wiska boxes so great).

IMG_5013

I tightened it all up.

Sadly, I didn’t take any pictures of my SWA cable gland process as I did it at lunch time. This was the tricky part of my installation since it required a hacksaw. I found a great YouTube (https://www.youtube.com/watch?v=epmxqFiD9JI)  video and followed that as best I could. I didn’t have the “glanding spanners” as recommended, but I made do with pliers. I do plan on using another armoured cable to connect to the other side of the garden, so I’ll take photos of that.

Anyway, with everything installed, I dropped the box in the garden.

IMG_5014

You can see the thick black SWA cable and the thin LED cable. I should point out that this is not the final resting place of this box!

IMG_5017

The lights look pretty nice in the snow and light the garden pretty well.

This weekend I plan on getting a few metres of SWA and using the small junction box to hook up the lights on the other side of the garden!

Best laid plans…

Wanted to work on my garden LED lighting project weekend. Unfortunately, I may have made a slight miscalculation with my measurements…

IMG_4996

I placed an other with RS for a replacement box, this time a little wider! If all else fails I can always take the circuit board out of the case and place it directly in the junction box, but I’d rather keep it housed.

I did manage to test it out though and the lighting is effective enough.

IMG_5002

Maybe next weekend?

 

Apple Bonjour for .Net Core

As part of my work on building a .Net implementation of Apple Homekit protocol, I want to have it run on a Raspberry Pi. My plan is to accomplish this using Windows 10 for IoT. This is basically a cut down version of Windows 10, designed to run .Net Core and UWP apps. I haven’t really explored it very much, but it seems to suit my needs. I can deploy my Homekit service and put the Raspberry Pi in the cupboard.

The first piece of functionality I need for my Homekit implementation is the broadcasting of the accessories using Bonjour. Bonjour is apple’s zero configuration protocol implementation. It is available on Windows, via Apple’s SDK, but unfortunately, it’s a COM component, so running it on Raspberry Pi is a non-starter. I searched around on the internet for a few hours and discovered, to my immense disappointment, that there are no Nuget packages for advertising services over Bonjour. Lots of ones for browsing and searching, but none for advertising.

These kind of situations, whilst annoying, do provide an opportunity to learn something new. What would it take to create a simple implementation of Bonjour that would run on .Net Core, on a Raspberry Pi. Let’s find out 🙂

To get the ball rolling, I created a .Net Core console application in Visual Studio. This doesn’t achieve anything in and of itself, but makes me feel like I’m making progress 🙂

A read through a few articles on Bonjour;

and I was ready to start. General searching around the web, led me to RFC-6762 (https://tools.ietf.org/html/rfc6762), which describes Multicast DNS or mDNS. This is used by Bonjour. I do love a good RFC.

After reading the first few pages, I established the following facts; mDNS, in essence, works by resolving .local addresses e.g. computer.local or hap.local. It does this by sending requests over multicast to the group 224.0.0.251 on the port 5353. I had come across the multicast technology (my router didn’t support it) a few years ago, so I was familiar with the main concepts.

Converting this into code, I came up with

public void Start()
{
 try
 {
 UdpClient udpClient = new UdpClient();

udpClient.ExclusiveAddressUse = false;
 IPEndPoint localEndpoint = new IPEndPoint(IPAddress.Any, 5353);

udpClient.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, true);
 udpClient.ExclusiveAddressUse = false;

udpClient.Client.Bind(localEndpoint);

IPAddress multicastaddress = IPAddress.Parse("224.0.0.251");
 udpClient.JoinMulticastGroup(multicastaddress);

while (true)
 {
 Byte[] data = udpClient.Receive(ref localEndpoint);
 string dataAsString = Encoding.UTF8.GetString(data);
 Console.WriteLine(dataAsString);
 }
 }
 catch (Exception exp)
 {
 Console.WriteLine(exp.Message);
 }
 }

This code essentially listens on port 5353 for broadcasts to the group 224.0.0.251.

When I fire up the console app, I just see this

Console

Not much to see. In order to generate some Bonjour traffic, I use an app called Bonjour Browser

I launch this and again, I don’t see much:

Bonjour

However, a few lines appear in my console app:

Console with data

Right now I don’t have a clue what these are, but I can see what might be dns requests.

More detail to follow!

 

IIS 0x80070020 when starting a website

As a developer, I run IIS on my PC so that I can test my websites using ForwardHQ. Sometimes, however, I will have an issue starting a particular website and IIS will throw up this dialog.image

“The process cannot access the file because it is being used by another process”. Totally cryptic and totally useless.

Most of the time, I can get around this by doing one simple thing:

Kill Skype.

image

When I return to IIS and try to start my website, it starts without issue.

Worth a try next time you run into this issue.

Git.exe crashing on Windows 10 Insider Build 14251

Yesterday, I upgraded my desktop to the latest Windows Insider build, 14251. I’ve successfully installed and worked on the previous Fast Ring insider builds over the past few months and I haven’t had any issues.

Unfortunately, this build was the exception. My first clue was Github for Windows telling me there was something wrong with my repository. It was unable to sync. I removed and cloned the repository again, but the error persisted. Running ‘git pull’ and ‘git push’ from the Powershell didn’t seem to do anything, which was odd. So I installed git.exe directly and the installer reported an error. Running git.exe just resulted in a “git has stopped working” message.

I decided not to waste any time on debugging this and I rolled back to the previous build, without issue. Thankfully I was back up and working within an hour.

This experience will temper me in the future and I might just drop back to the Slow Ring Smile