Wednesday, 19 April 2017

Installing Visual Studio Code for ESP8266

Visual Studio Code is Microsoft's very light weight editor. Available for Windows, Mac and Linux.


To get it to work with the Arduino and the ESP8266 you need to add two extensions. The whole design of Visual Studio Code is so that it can easily be configured for any development language using these extensions.

Before you do that install the Arduino IDE.
Like most of the IDE's I have tried, they rely on the Arduino IDE for all the libraries.
I also made sure it was fully configured with the add-on for ESP8266 before I continued.

With that installed it's time to install the extensions.

The first extension is for C++ and it is by Microsoft:
https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools

The other extension is for the ARduino and for this there are several choices. I've used the Microsoft one:
https://marketplace.visualstudio.com/items?itemName=vsciot-vscode.vscode-arduino

I have not tried them but here are some others for the Arduino:
https://marketplace.visualstudio.com/items?itemName=steveyin.arduino-vscode
https://github.com/fabienroyer/VisualStudioCodeArduino
https://marketplace.visualstudio.com/items?itemName=moozzyk.Arduino

They are actually very easy to install.
There is a short code you can copy in and that displays the appropriate list of extensions:
Go to file (Ctrl-P): ext install cpptools
Go to file (Ctrl-P): ext install arduino-vscode

My initial install did not go to plan. I ended up spending more time than I expected but that was down to issues with my machine setup not as a fault with the application!

Important: You must be able to run JSON files. I had problems because my firewall was blocking them for some reason! I had to bypass that.


Important: Windows 10 security, Developer Mode might be restricting installs, On my machine it was restricting me to only install store apps. I had to change mine to Developer mode to get the extensions to install.

Extensions appear in a side bar. Select the appropriate one and press install.



Once installed, either restart or simply press the reload button that appears. Only then do the extensions get downloaded and installed.


Now it should be ready to go.

All projects need to be in their own folder. You can open individual files but without a corresponding folder there is nowhere for the application to save it's settings.

Once you have a new .ino file or project open, the status bar displays Arduino specific content.


There is a tiny selection at the bottom on the status bar to select C++ and the board etc.
You can change the settings and more from the Command Palette menu that appears when pressing F1.

At this point Intellisense worked up to a point. Where the classes are internal to the code, it worked fine but it could not find the external libraries and dependencies.

To get the rest of the Intellisense and probably the ability to compile you MUST select the board AND the COM port on the status bar. That appears to be the trigger to read the appropriate libraries.


This can be a pain if you do not have the Arduino or ESP8266 connected to the PC because you might not have any COM ports. Also, try selecting the COM port first. That's what I did.

That got things working for the main Arduino classes but I was still missing the ESP8266 classes.

That appears to be caused by a slight error in the install. It automatically includes a path that is too specific.

It can be fixed by following the light bulb link from within the code file.


That opened the file c_cpp.properties.json file.


I moved the path lower down the tree, to this:
"C:\\Users\\jcb\\AppData\\Local\\Arduino15\\packages\\esp8266\\hardware\\esp8266\\2.3.0"

The application searches all sub-folders unless you tell it otherwise, so that picked up all the class files needed.

It is necessary to restart Visual Studio Code for the change to take effect.



Once that was all working nicely it was time for a compile and upload.

That option can be found from the F1 Command Palette list. Not the most convenient place but it's OK.

It didn't work first time because I had trouble with using a USB hub. I had to swap to a physical USB port directly on the machine but after that it worked at 115,200 baud.


Not an extensive test so far but it's working. I like the Intellisense in Visual Studio Code and the style of the app. I'll try this for longer to see if it makes coding that much easier.

==

Tuesday, 18 April 2017

Improved Arduino Development Environments for ESP8266

I was going to call this 'alternative' Arduino IDEs but as the Arduino IDE works so well but just lacks a couple of features, I didn't want to rule out an improved Arduino IDE from my list.

Having tried out the Eclipse for Arduino IDE and been hampered by some limitations and known issues, I've decided to quickly try out a few others.

There is no point if the IDE's take too long to install or slow me down in any way.

I'm only after one main extra feature. Call-tips or Intellisense, so I don't have to have the library documentation open in another window, all the time I am coding. Something that displays the available methods and their parameters, as I type, is all I need.

Once you get the call-tips, other features like auto-complete and variable definition checking as I type, so I don't spell variable names incorrectly, usually come along with it.

I like open source, so I'm going to start with free products but I won't rule out low cost paid for ones. I've found a small fee is often worth paying to get a more reliable, less hassle, solution.

I will also rule out products that are not up to date enough to allow new boards to be added easily. It does not matter if the code is a few years old, as long as it was complete and had a feature to easily add boards and libraries.

There are several other sites with lists of things for me to try:
https://www.arduinostarterkits.com/resources/arduino-ide-windows-mac/
https://www.intorobotics.com/alternatives-standard-arduino-ide-one-choose/

In all the examples I have read so far, the IDE relies on the Arduino IDE and any add on libraries being installed on the same machine. This would apply to other language libraries, so is not unexpected.

I will add to this list as I try them.
My testing will be very brief. If it takes time too long to get going it fails the test of saving me time.
My other criterion is that it must work with ESP8266 boards.

//

In no particular order:

Eclipse for Arduino (Sloeber)
Date installed: 17 April 2017
See my more detailed page on this.

Plus:

  • Fully featured IDE
  • Syntax highlighting
  • Call-tips
  • ESP8266 boards included (with v4)
  • Good example code included

Minus:

  • Projects are not portable (my biggest issue.)
  • Pain to install
  • Does not cope with spaces in path names
  • Does not fully support Windows redirected folders (mainly a nuisance for me.)

The projects not being portable make it difficult to backup work and in my case, difficult to work from different computers.

//

UECIDE
Date installed: 17 April 2017

Plus:
  • Syntax highlighting
Minus:
  • No call-tips that I could find!
  • Failed to compile my example.
I don't think UECIDE deals with nested duplicated #include statements. It probably could be fixed with #include guard statements but that means it is not fully compatible with readily available code examples!

//

Visual Studio Code with Arduino Extension
Date installed: 19 April 2017
See my more detailed page on this.
There are several Arduino extensions available from different authors. So far I have only tried the one from Microsoft.

Plus:

  • Intellisence for call tips and more works very well.
  • Syntax highlighting.
  • ESP8266 included in the board list.
  • Simple, clean interface, fairly easy to use.

Minus:

  • Manual change to a config file to get the ESP8266 libraries working properly.
  • Some of the Arduino specific functions are on a list of add on commands rather than a button.


I will stop here with my installs for now as Visual Studio Code appears to work well and has the features I was looking for.

==

Things I would have tried next...
Visual Studio Community edition with the Visual Micro add-on.

==



Monday, 17 April 2017

Installing Eclipse for Arduino

Eclipse is a more fully featured IDE (Integrated Development Environment.) There is a version available, called Sloeber, that includes support for the Arduino and some IoT (Internet of Things) boards, like the ESP8266.

This is likely to be an odd post because I am typed it as I went to remind myself what I have tried and what failed or worked.

The Arduino IDE is very easy to install, very easy to add the ESP8266 to it and it works reliably. I'm only looking for a couple of extra features. It already has some syntax highlighting but I want the full set of auto-complete and call-tips. The latter being where it shows the method parameters, as you type, so you don't have to keep looking up the library documentation on another screen!

I've used Eclipse before and know it has the features I want and more but I could not remember exactly what I thought about it. Having now tried it again, I remember it has lots of good ideas but, in my opinion, it is not as reliable or user friendly as Microsoft Visual Studio.

Now for the down side. Like many, if not most, of the IDE's I've tried to install, it is a pain. Why can't the people who are clever enough to write such a complex application, manage to sort out a reliable install process.

First the easy bit you need to get the package:
http://eclipse.baeyens.it/stable.php?OS=Windows
You will need something like 7Zip to uncompress it from the Gzip format tar file!
I chose the 64bit version but with hind sight, perhaps the 32 bit version would have been easier.
Get the latest version. It includes support not only for the Arduino but also the ESP8266 boards.

You'll need Java for it to run and it must be the same as the Eclipse download 32 or 64 bit:
https://java.com/en/download/manual.jsp

Be careful where you plan to install Eclipse. Install is the wrong word. It just runs from wherever it is but on first run it sets up lots of things that then only work from that location.

I could not get it to work properly in C:\Program Files\. I believe it does not like the spaces! In fact it is listed as a known issue for version 4.
I found that out the hard way and had to unpack it a couple of times before I was happy with where it was.
I eventually extracted it and ran it from C:\Local\EclipseArduino\

Eclipse needs a working folder where it will store all your projects. Again, avoid spaces in the path names, just to be sure.
I used C:\Local\Eclipse\ for the working folder.

Once it starts you need to set a couple of folders. These are mainly for my particular setup because I have a server and my Documents folder is redirected. Something Eclipse also does not understand properly!

Windows -> Preferences -> Arduino
I used C:\Local\Arduino\libraries\ for the Arduino library folder.
I used C:\Local\Arduino\hardware\ for the Arduino hardware folder.

ESP8266 boards are listed by the latest version of Eclipse for Arduino. Like all of the board choices, they are not installed by default. You need to select them from a list and Apply the change.

Windows - Preferences
- Arduino -> Platforms and Boards
- - Expand the tree until you get to the ESP8266, version 2.3.0, tick that.
Add ESP8266 in the available boards
It will then install the files needed for the boards selected.


With my Internet connection they took a few minutes to download.

Hopefully at this stage you are ready for your first project.

It remembers your choices after the first project is created, so you only need to enter the following the first time or probably each time you change project type.

File - New - Project

When starting a new project, select the platform for ESP8266

The board has to be connected to be able to select the COM port

I could now code with tool tips to show the full syntax of the methods. I could compile separately from deploy and I could upload to the ESP8266.

SNAG
I was not able to move the project or the application after it has been run the first time. It hard codes some paths in to some of the \.settings\ files in to the project and got in a muddle if I moved anything on the disk. I tried to manually edit them to fix it but that did not work. Eventually I had to create a new project and copy back in the code!

This is going to be a problem for me because I work on multiple machines. I assume it would also be a problem for teams. The project files do not appear to be portable.

The resulting code is fine and can be opened by the Arduino IDE, so no work is lost but the benefit of an easier to use faster development tool, is lost!

I'm going to investigate alternative IDE's or see if anyone has added call-tips to the Arduino IDE.



Friday, 14 April 2017

Just starting with NodeMCU

I have just received a couple of NodeMCU's which I plan to use for some security devices.


These are tiny circuit boards about 50mm long x 25mm wide. The chip is a computer processor with WiFi built in attached to a board with pins on for easy development of a prototype. They are designed to be low cost for use as Internet of Things (IoT) processors. UK stock cost me a massive £8 each but from China they are less than £3 each, including shipping!

They are used by the same people that like to make small gadgets using the tiny Raspberry Pi computer and the Arduino processor boards.

Before the NodeMCU's arrived I'd been searching the Internet to find out how to get started. The trouble is that it gets confusing. There is lots of outdated information, the NodeMCU is also referred to as ESP8266, there are multiple development environments and so on.

This is a list of what has confused me and the conclusions I have made, so far.

NodeMCU or ESP8266
The ESP8266 is the processor which has built in Wifi. This is used as an add-on board for Arduino as well as a stand alone product called NodeMCU.

NodeMCU
This uses the ESP8266 wifi enabled processor and includes a serial to USB adapter on board.
It is that latter bit that is significant. You don't need any extra hardware to get going with the NodeMCU. Just power.
As far as I can tell the NodeMCU includes a firmware implementation of the LUA environment. Not just the hardware.
If you use one of the other development environments LUA will be replaced and so arguably it is no longer a NodeMCU board! Very confusing.
I will refer to NodeMCU meaning the hardware in the configuration expected by the NodeMCU implementation of the ESP8266.


There are several different manufacturers but as far as I can tell there are only minor differences between them and the pin outs are the same. There is a smaller and larger board. I prefer the pin outs on the larger board.

The boards I received are branded 'Amica.'

How to power the NodeMCU
The simplest is to just use the USB port. Plug in a USB power adapter or a cable from the USB port of a PC.
The preferred method for a wired in power source is to use the Vin pin. This connects to a voltage regulator on the board so you can connect any DC power source between +5V and +10V. The regulator can handle up to 800mA which is enough for most small circuits.
There are also several 3.3V pins which, as far as I understand, are in and out so they provide 3.3V for external devices or can be used with a regulated power supply or to plug batteries in to. The ESP8266 chip will apparently work with anything between 2.8V and 3.5V, so 2x AA batteries should do it. I have not tested this yet.
There's some more detailed explanations on the following page:
http://henrysbench.capnfatz.com/henrys-bench/arduino-projects-tips-and-more/powering-the-esp-12e-nodemcu-development-board/

Development environments

This is where it gets even more confusing.

NodeMCU firmware
The firmware is the programme running on the ESP8266 processor. You can change that firmware. Exactly what that is and how you change it depends on what development environment you use:
- LUA comes as standard.
- Python needs to be built and deployed to the NodeMCU.
- Arduino IDE compiles the code and installs it as part of the upload process to the NodeMCU.


- The standard for a NodeMCU is LUA.
This is a high level language needing very few skills to get going with.
It's disadvantage is that it uses up a lot of the in-built memory for the interpreter!
Despite it being the original environment, I ruled this out fairly early on and have not tried it:
http://nodemcu.com/index_en.html
Documentation: https://github.com/nodemcu

- Python
There is a whole community developing this:
https://docs.micropython.org/en/v1.8.6/esp8266/esp8266_contents.html
I've not looked in great detail at this but it looks like a fully implemented solution with some good features. I've done some Python programming before but I'm not a fan of the lax structure of the Python language. Others however do like it and it is very popular.

- Arduino IDE
This is the one I have started to use. It uses C++ syntax and libraries and appears to be the most common choice. The code is complied before being uploaded to the ESP8266 so uses the least amount of memory.
You need the Arduino IDE:
https://www.arduino.cc/en/Main/Software
Then add the extension for the IDE to support ESP8266 based boards. This is available as a package that is easy to install. You just include this one line in the Arduino IDE preferences:
http://arduino.esp8266.com/stable/package_esp8266com_index.json

See the following tutorial:
http://www.instructables.com/id/Quick-Start-to-Nodemcu-ESP8266-on-Arduino-IDE/


The instruction imply that the ESP8266 boards install automatically. They do not. They get added to the Board Manager and you need to browse the list in Board Manager, select the ESP8266 based boards and hit install.


Once that is installed you need to select the NodeMCU board from the list of boards.

Finally before being able to upload your programme to the NodeMCU you need to find out what COM port your NodeMCU appears as on your computer. The COM port is assigned when you plug in the NodeMCU to the USB port.


Serial USB Connection
The back of my board says to use a CP2102 driver at only 9,600 baud. The default in the Arduino IDE is much faster at 115,200 baud which worked fine for me.


I had installed the Arduino IDE prior to connecting the NodeMCU. The Arduino IDE also installs some serial drivers. I don't know where the driver came from but when I plugged in the board to the PC USB port it installed a CP210x driver and displayed the COM port it was assigned to. In my case COM 4 but that will depending on which USB port it is connected to and what else uses COM ports on the machine.



You can lookup the COM ports used in Device Manager or watch the driver install, which shows the COM port.
I'm using Windows 10 but this was similar in Windows 7 and 8.1.

Don't get misled by the references to an FTDI cable or serial adapter that you might come across in other articles. That adapter cable is not necessary for a NodeMCU. The serial to USB is built in, that is what the CP2102 chip does. The adapter cable is only needed for the add-on shield type boards typically used with Arduino's that do not include that extra chip.

Hello World
When learning a programming language the first thing you typically do is to display 'Hello World' on the screen. Something easy to do that checks that all the basics are working. The electronics equivalent of that, in this context, is to blink an LED.


I copied in the sketch, as the code is referred to, pressed the button in the Arduino IDE to upload it to the NodeMCU and waited for a minute or two as it compiled and uploaded. It worked perfectly.

==

Useful sites:

ESP8266 using Arduino IDE, code library documentation:
https://github.com/esp8266/Arduino/blob/master/doc/esp8266wifi/readme.md

Arduino language reference:
https://www.arduino.cc/en/Reference/HomePage
Arduino standard and add-on libraries. Not directly useful for ESP8266 but might be handy:
https://www.arduino.cc/en/reference/libraries


==

Update:
I found out by accident that the Vin pin will also supply the output voltage from the USB port. I don't know how reliable this is but it powered the 5V ultrasonic sensor I was using.

==

Sunday, 9 April 2017

Sharpening block

Just a quick project.

With all the pruning that Shelley now does I'm expecting to be doing more sharpening. I'll probably be using a diamond sharpening file for the secateurs but regardless of that it made me think about my oil stones (whetstones.)



I should have made this years ago. It's just a simple block to hold them in place. It fits in a vice and my leather honing strop can hang next to that.



Made from odds and ends of timber, glued, screwed and wax coated. This fits two of the 203mm (8") whetstones so I can have the coarse and the fine side by side.

Saturday, 8 April 2017

Finished the drain

A further 2m trench dug in the gravel. This is to finish the run we did a couple of weekends ago.




A lot of stones to dig through but this section did have one bonus. There was no concrete to break up.

The job was made easier because I had bought a couple of more suitable shovels (I would have called them spades) based on those Steve had used for digging the previous bit of the trench. I could not find the exact same type online but the Polyfibre cable layer and trenching shovels from Caldwell's have been a good choice. Yet again, the right tools save a lot of time and effort.





To finish the job off, I moved the down pipe of the guttering to match.

Friday, 7 April 2017

MultCloud review

Following on from my post the other day about AmazonDrive I have been using MultCloud to help me transfer from OneDrive to AmazonDrive.

I started off doing it the hard way. Setting my NAS to sync to AmazonDrive and in conjunction using a different Internet connection to manually upload photos. One of those methods is slow due to the amount of data involved and the other is time consuming doing a few folders at a time.


I hunted around for a cloud storage aggregator service. There are a few, like Mover.io and Otixio that are often mentioned in reviews but for some reason MultCloud is less commonly mentioned. From my experience it should be number one on people's lists. Hence this review.

The advantage of using an online service is that it is not constrained by the speed of my own Internet connection. The files transfer via the aggregators servers. From my perspective, direct from one storage location to another. I can log off or shutdown and the transfer carries on behind the scenes, day and night.


The other providers I looked at had very limited or no free offering and worked out very expensive for the near terabyte of photos I need to transfer. MultCloud is very generous with its limits and supported all the storage providers I needed plus lots more and it gets better...

MultCloud's free tier offers up to 2TB of data transfer. I thought the two terabytes was a typing mistake. I had to check several times and found it repeated in their documentation. Good for them.

I'm using it now and I can say it works very well.



Configuring the cloud end points and adding transfer tasks was easy. It even supported creating the target folder as it went. I now just sit back and wait.


The free service uses only 2 threads and is in no particular hurry but it is still more than twice as fast as I could do it any other way. In addition it is far simpler, just sitting there in the cloud while I get on with other things.

I think a lot of cloud companies might be missing a trick. I'd be prepared to pay a small one off fee for a week or months' use but I don't want to get stuck paying recurring fees for a service I only need once every few years.


I'm happy, the job is getting done at no cost to me. Thank you MultCloud.