Using The WeMos D1 Mini

Way back in the late 1970's I worked in a computer shop on Bridge Rd in Richmond, Melbourne called 'Silicon Valley' with a ham radio operator, Geoff Atkinson VK3AFA (at that time VK3YFA).

We ran one of the first retail outlets to sell computer and electronics parts. Motorola had the D2 development kit for sale at the time featuring the 6800 microprocessor. This monster had two A4 sized circuit boards connected by a ribbon cable. The Hexadecimal keyboard and the six x seven segment LED displays formed the user input and output. This was my first experience with microcomputers and the wonderful world of programming.

Go forward 40 years and I'm now trying out the WeMos D1 Mini computer that can be programmed using the fantastic Arduino platform.

The D1 Mini uses the ESP8266 processor that includes built-in Wifi and can run off 3 volts. The Micro-USB connector provides 5 volt power as well as the USB interface for uploading programs commonly known as a 'Sketch'.

I thought it might be fun to write an article on how to set up the Arduino software and configure it for the WeMos D1 Mini.

The D1 Mini is a tiny 34mm x 25mm circuit board with 16 power and Input/Output connection pads. The printed Wifi antenna at one end, the micro-USB and reset switch at the other end. Some configurations have the surface mounted parts visible, others have a metal shield.

To get started, if you haven't already, download and install the latest Arduino software on your computer. This is available for Windows, Linux and Apple machines. As of writing this, Version 1.8.7 is available at https://www.arduino.cc/en/Main/Software .

There is also an installation guide available for your particular computer HERE.

Once installed you should be able to start up your Arduino IDE software and get the default sketch page showing in the IDE window. Across the top of the IDE are menu options File Edit Sketch Tools Help. Your default sketch should be named 'sketch_(monthday) | Arduino 1.8.7

Now we need to set up your Arduino IDE to work with the ESP8266 processor on the WeMos board. To do this we need to add the location of the setup information for the D1 Mini. Click on the 'File' menu option and select 'Preferences'. In the box marked as 'Additional Boards Manager URLs' enter the following.
http://arduino.esp8266.com/versions/2.3.0/package_esp8266com_index.json
Close the 'Preferences' page by clicking on 'OK'.
Click on the 'Tools' menu and select 'Board' then across to 'Boards Manager'. This should open the 'Boards Manager' window showing all the different boards the Arduino IDE can program. In the search window type 'Wemos'. You should see the ESP8266 board. Click this and select 'Install'. You should then see the installation progress for the ESP8266.

When this is complete close the Boards Manager window and return to the Arduino IDE. Once again select 'Tools', 'Board' and scroll down and click on the Wemos D1 Mini. The Tools menu should now show the Wemos D1 Mini as your selected board.

Ok, time to try our first sketch. The IDE has a built-in library of simple sketches that we can try on our Wemos board. Click on 'File', 'Examples', 'Basics' and select 'Blink'. This simple sketch switches the on-board LED on and off once a second.

We now need to compile our 'Blink' sketch. Click on the 'Sketch' menu and select 'Verify/Compile'. The compiler should report a successful compile of the sketch after a few seconds.

If you look through the code for this sketch you'll notice the documentation section at the top. Good coding practice requires the programmer to write a short description of the software. Descriptive lines should start with a '//' whereas blocks of text should start with a '/*' and end with a '*/' to tell the compiler where the start and finish is.

The two main code blocks are the 'void setup()' and the 'void loop()'. The 'setup' code runs only once at the start and the 'loop' code runs continuously. You should now be able to plug in your WeMos D1 Mini using a USB to Mini-USB cable ready to upload your sketch. With the WeMos connected, select 'Sketch', 'Upload' and you should see the sketch code upload in the monitor window at the bottom of the screen.

Leave the D1 Mini connected, press the reset button on the board and the LED on the board should start blinking. Sketches can use the Micro-USB connection as a serial monitor if you want to get messages from the board. This is under the 'Tools', 'Serial Monitor' option.

Try some of the other sketches in 'File', 'Examples' and see how they compile. Some may have particular requirements depending on how they are written. Explore the other menu options and enjoy using the Arduino IDE.

Cheers, Rob.

13.09.2018. 08:44