Remote Controlled Cave

Petes Radio Controlled BoardsMy first attempts at remote control over here in Spain are coming together. Having had remote access to cameras for 3 or 4 years now with reasonable reliability, I’m ready to extend this to temperature and humidity monitoring and remote control of lighting. If you look at my previous articles on home control you’ll know that I’m using NETIO on Android phones, via WEBSOCKET drivers on Arduino-type boards using the WIZ Internet controller at the master end and low-cost RF24NETWORK-driven radio-controlled boards for remotes.

I recently had some boards made to comprise the Atmel 328 chip and associated components along with monitoring LEDS and the NRF24L01 low-cost radio boards as daughterboards. Here is the first of the units, in a case top – alongside a single RELAY board. This board needs USB power only (pretty standard low cost plug-in-the-wall power) and communicates with the master (and hence the remote Android or iPhone) to allow monitoring and control.

The board you see here also has a DHT11 unit attached to provide temperature and humidity readings. These are not stunningly accurate but I have calibration offsets available in EEPROM on the controller to compensate.

Skype as a webcam (and other Skype settings)

Skype remains a wonderful tool – but now that it’s owned by Microsoft they are DETERMINED to confuse everyone with a host of additional tick boxes….

Have you noticed when you upgrade, it wants you to use BING – probably the worst search engine on the planet? Just like drugs “just say no” – stick with Google – untick those boxes when you upgrade!!!

Anyway, the purpose of this blog is to tell you how to set up Skype as a webcam – and along the way ensure you un-tick some of those pesky boxes in Skype (this is of general use to anyone).

What I needed was a reliable webcam while I’m on holiday to keep an eye on the place – and in my case, to communicate with our cats who get very worried when we’re away. No, seriously – they do and if they get REALLY worried they clear off for weeks!

I set up a laptop with camera. What I needed was for it to auto-answer with camera…. and for as few things to be able to screw things up as possible. Here are my settings under TOOLS – OPTIONS in Skype.

Firstly  – ensure that Skype starts when you start Windows (most likely the laptop will reboot at some point due to pesky Windows updates so you want things to keep running).



Next, under audio settings, pick a mic setting that sounds fine and TURN OFF those pesky auto settings which make background sounds creep up when no-one is talking..



Under privacy, only allow people in your contacts list to call you.



Under notifications – do you REALLY need to know every time someone goes online? TURN IT OFF..



One would presume you DON’T want to be pestered by adverts?



Under CALL SETTINGS click advanced.. Turn on auto answer with video



Under ADVANCED near the end – untick “Use Skype to call callto: links on the web” – a particularly nasty trick that puts all sorts of stuff in web pages and can be harmful to web editing software



That’s it – make sure you SAVE (then go in again and check).. and you’re all set – create a new account – make sure YOU are a friend of that account… and you have yourself a webcam you can call from anywhere, it will auto answer with video and sound….   one cheap webcam.

MQTT on Arduino

MQTT is essentially a simple format for sending small data packages back and forth. It can be used with or without password and the passwords can be simple or encrypted. The information out there is not easy to understand for beginners.

Essentially you have a BROKER (some may think of it as a server). This program accepts messages and dishes out messages.  It handles them in the form of topics and messages.

Imagine you wanted to turn a relay on and off remotely with your Arduino.  Let’s pick a topic name out of thin air… “listentome”.

So – your Arduino needs an Ethernet client connected an MQTT broker and the client needs to be “subscribed” to topic “listentome”. In the simplest case with no passwords, if anyone sends a message such as “turnrelay1on” to the topic “listentome” on the broker – your Arduino will get that message.

Of course with a username and password, only those clients with that username and password will receive that message.

So let’s get a working example so you can see this. And this is where it gets painful unless you’re reading this – where do I find an MQTT “Broker” – what about clients?

Ok, so first things first – on Android there’s a simple server package called Servers Ultimate Pro. This does not YET have the passworded version of the broker but it does have a simple version.  Better – but more complicated – is Mosquitto.  Basically install this from here… open up a command line (yes, I know, how awful but hey, it’s free) and go to the Mosquitto directory and simply type “Mosquitto” in the command line – you’ll see the program is running but with no visible output. Actually it has installed a “service” and you could run it that way but lets stick with the simplest solution first.

Before we start messing with code that might or might not work first time you’ll want to make sure your Mosquitto or Android broker is working – and for that you might want to use an external test program… such as this… the only issue there being – how does it know what your internal IP address is?  Well, to test, I simply put a port redirect on my router.  The standard port used is 1883. Point that external port to the same port on your PC or WIFI-enabled phone or whatever is running the above.

tmp627CAssuming you know how to do that – and with Mosquitto running – you should be able to plug in your external IP address and connect using the tool at

Assuming that works – at the bottom – send a message to topic, oh…. “mytest”.


Won’t work – because no-one is listening. In the window called “subscribe to topics” – SUBSCRIBE to mytest and try again. You’ll see your message come in.

Ok, so how do we get from there to sending messages to and from your Arduino?


You will need your Arduino, the Ethernet shield (don’t use the cheaper ENC boards, they are just so much hard work and I’ve never managed to get them to run reliably – get proper Ethernet cards and if cost is an issue – try Ebay and China). You need to get this library and install it.  unzip the file and there’s a pubsubclient INSIDE the outer one – you need to copy that into your LIBRARY directory for Arduino. Clean start the Arduino IDE for this to take effect.

Examples out there put the setup in the setup routine – great – but what if you lose the connection – so I’ve taken a fairly standard example and moved that setup into the main loop – so that should for any reason you lose the connection – it will reconnect automatically.

Once you get this up and running and understand what you’re doing – moving to the password protected version should be easy enough (read the Mosquitto docs) and actually using this to control relays etc and return status results should be equally easy.

Basic MQTT example

– connects to an MQTT server
– publishes “hello world” to the topic “outTopic”
– subscribes to the topic “inTopic”
int sendit=0;
char msg[20];

#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h> // only non-standard library – the rest come with Arduino IDE

// Update these with values suitable for your network.
byte mac[]    = {  0xDE, 0xED, 0xBA, 0xFE, 0xFE, 0xED }; // make this unique
// internal address of your MQTT broker… or see examples forusing address lookup etc.
byte server[] = { 192,168, 0, 24 };
// internal IP your want this board to be
byte ip[]     = { 192,168, 0, 100 };//

byte mydns[] = { 192, 168, 0, 138 };       // your router
byte gateway[] = { 192, 168, 0, 138 };     // your router
byte subnet[] = { 255,255,255,0 };          // your IP address mask – usually this value

// this routine is called automatically when something comes in. I’ve used serial.print to let you see it. Also use this to prepare a response.
void callback(char* topic, byte* payload, unsigned int length) {*(payload+length)=0;
Serial.print((char *)topic); Serial.print(” : “); Serial.println((char *)payload);
strcpy(msg,”Sorted”); sendit=1;

EthernetClient ethClient;
PubSubClient client(server, 1883, callback, ethClient);

void setup()
Ethernet.begin(mac, ip, dns,gateway,subnet);
Serial.print(“Got IP… “);

void loop()

// this checks to see if you’re connected and connects – will retry forever if need be.
if (!client.connected())  {
Serial.print(“Connecting… “);
if (client.connect(“arduinoClient”)) {
client.publish(“outTopic”,”hello world”);

if (sendit) { sendit=0;   Serial.println(“Sending”); client.publish(“outTopic”,msg); }

I’ve not tried the link below out but it looks like there is some new code for Mosquitto here.