Not as easy is IoT

I wanted to start playing with IoT and connecting it up to Azure after being inspired by some previous guests on my podcast (Bryn Lewis and Lars Klint). I did a search for something like ‘Azure IoT starter kit’ and the following popped up:

Microsoft Azure IoT Starter Kit w/ Adafruit Feather HUZZAH

Microsoft Azure IoT Starter Kit w/ Adafruit Feather HUZZAH

So I ordered it. I was looking forward to getting back to my Electrical Engineering roots with this IoT stuff.

A few weeks later (it did take quite a while to arrive) I opened the kit to see what was inside. To my dismay, there wasn’t very much in the ways of instructions. Yes, all the parts where there, but nothing to tell me how to make it all work.

The kit provider did have the following tutorial available:

https://learn.adafruit.com/adafruit-feather-huzzah-esp8266/overview

but it didn’t show me how to actually get my code into the device. That then lead me to the

Arduino IDE

but there wasn’t a lot of positive feedback on it and really wanted to use something I was more familiar with. Luckily, I had a contact who had done some basic IoT and told me I could user Visual Studio Code! Yes please. I like that because I use with with PowerShell nearly everyday.

What I needed to do after firing up Visual Studio code was to search and install an extension called Platformio IDE:

https://docs.platformio.org/en/latest/integration/ide/vscode.html#quick-start

image

It popped right up so I pressed the install button.

Unfortunately, the installation came up with some errors, but I was kind of expecting that because I was installing on a machine that was connected to my Azure AD and locked down with things like Windows ASR. Thus, after many, many attempts at trying to get the installation working and then create a project I moved to using a machine that was NOT connected to my Azure AD and locked down to the hilt. The installation then went smoothly unsurprisingly.

image

With PlatformIO IDE installed I went to create a Project.

image

I used the above settings. Warning, the platform supports a huge range of boards (1400+) so ensure you know the exact model of your board and be prepared to scroll.

With the project created I now needed to write some code to get the built in light on the board to flash. I used the following:

#include <Arduino.h>

int LED_Pin = 0;

int status = 1;

void setup(){

pinMode(LED_Pin, OUTPUT);

}

void loop() {

  // put your main code here, to run repeatedly:

if (status) {

digitalWrite(LED_Pin, HIGH);

  } else {

digitalWrite(LED_Pin, LOW);

  }

status = 1-status;

delay (1000);

}

Which I found after some searching. I have put the code up on GitHub if you want it:

https://github.com/directorcia/Azure/blob/master/Iot/huzzah-flash-led.c

I managed to get that code to compile but it would then not ‘upload’ to the device.

After more searching I discovered that PlatformIO wasn’t showing me any devices like so:

image

If PlatformIO can’t see my device, then it can’t upload to it.

After more searching around I found the following Windows drivers for the board here:

https://learn.adafruit.com/adafruit-arduino-ide-setup/windows-driver-installation

Typically, it seems you shouldn’t really need to manually install drivers on Windows 10/11, but in my case, I did.

With the drivers now installed I could see the board listed as a device in PlatformIO like so:

image

With the drivers now sorted, I could finally upload my code to the device successfully.

The code I found that would flash the light on the device on and off as the most basic test didn’t seem to do anything after it was uploaded. The trick was that the code I found had the LED_Pin = 13 and luckily, after that didn’t work I guessed correctly setting it to LED_Pin = 0 would as you can see from the code above that I actually used.

image

After, uploading the updated code to the device I was then rewarded with a flashing light at the base of the device near the USB connection as shown above. I know it doesn’t look like much but to me it was a huge step after all the time I had invested getting things set up (many hours).

Now that I have the basics working, my next project is to get the WIFI connectivity on device working so I can connect it up to the Internet and then hopefully Azure eventually.

I do have to say that getting this far has been far harder than I imagined it would be. I didn’t find a lot of information out there to help solve my problems. That’s why I’m documenting my results here so that others can find it and hopefully not have to go through the same pain I did.

I’m sure there’ll be more pain coming as I try and do more advanced things with the device but at least getting the light flashing gives me the encouragement to continue with this endeavour and not feel that I wasted my money. I’ll share more in time as I continue my IoT journey, but for now, I need a lie down.

One thought on “Not as easy is IoT

Leave a comment