Tuesday, September 17, 2019

Referencing the PINs on the ESPDuino on the Arduino IDE

I bought the ESPDuino a while back to tinkle with, and finally got down to actually using it. It's a pretty nice piece of hardware considering the fact that you get an ESP8266 processor on an UNO R3 form factor for a USD7 - USD10 (RM20 - RM40) price point. You can purchase the the dev board from their website: -

http://www.smartarduino.com/view.php?id=94894 ;

or from Shopee / Lazada.


Although the company claims it's a drop-in replacement for the UNO with Wi-Fi, there are already 2 obvious differences. The first being a 3.3V device (ESP8266) and the second, the pins. It's the pins I'll be talking about here.

The ESPDuino from http://www.doit.am/


The Arduino UNO from http://www.arduino.cc/


The PINs : UNO vs ESPDuino

We'll kind of kick off with an example. Pin 13 on the UNO physically maps to a "NC" (no connection) on the ESPDuino and Pin 2 on the UNO physically maps to D0 on the ESPDuino.

So, if you had an existing UNO project that goes like ...

#define pinLED 13

you'll end up having to move your DuPont Wire to MOSI/D13 on the ESPDuino.

The ESPDuino comes with a set of #defines for their pinout. You can find them in a file named "pins_arduino.h". The location of the file is in

"C:\Users\<User>\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\<version>\variants\ESPDuino"

for Linux, that would be

"/home/<User>/.arduino15/packages/esp8266/hardware/esp8266/<version>/variants/ESPDuino"

N.B. : the location of the folder can be obtained from the boards.txt file.

From the pins_arduino.h file for ESPDuino, we have the following pins ...

#define PIN_WIRE_SDA (4)
#define PIN_WIRE_SCL (5)

static const uint8_t SDA = PIN_WIRE_SDA;
static const uint8_t SCL = PIN_WIRE_SCL;

// All digital pins are PWM capable
static const uint8_t D0   = 0;
static const uint8_t D1   = 1; //TX0
static const uint8_t D2   = 2;
static const uint8_t D3   = 3; //RX0
static const uint8_t D4   = 4;
static const uint8_t D5   = 5;
static const uint8_t D12   = 12; // MISO
static const uint8_t D13   = 13; // MOSI
static const uint8_t D14   = 14; // SCK
static const uint8_t D15   = 15; // SS(SDA)
static const uint8_t D16   = 16; // LED_BUILTIN
static const uint8_t RX0   = 3;
static const uint8_t TX0   = 1;

#define LED_BUILTIN 16

#include "../generic/common.h"

So it looks like you can't port your UNO project verbatim over to the ESPDuino.

You'll have to rewrite your code ...

#define pinLED D13

and that's the best way to go, since the labels match exactly the pins on the ESPDuino board.


References
How to Determine Which pins_arduino.h File is Used? - StackExchange
Communication Between the Arduino UNO and ESPDuino - Arduino Forums
ESPDuino Pinout - ESP8266 Community


Friday, July 26, 2019

Some Minor Glitches with the Latest Arduino 1.8.9

I've just installed the latest Arduino IDE 1.8.9 on Ubuntu 18.04 and found that the installation isn't quite as smooth as one would want it.

The install script install.sh had some glitches in it and needed some manual fixes. Refer #8779. So, the error messages ...

Adding desktop shortcut and menu item for Arduino IDE...
rm: cannot remove '/usr/local/bin/arduino': No such file or directory
Removing symlink failed. Hope that's OK. If not then rerun as root with sudo.

rm: cannot remove '/usr/local/bin/arduino': No such file or directory
Removing symlink failed. Hope that's OK. If not then rerun as root with sudo.

Done!

 

... for that you can't do much about it, unless you apply the fix c3675a8 to the install script. That's caused by the install script attempting to remove the symlinks of the previous install, which does not exist. This can be ignored.

Next up, we have the install script creating an icon on the Desktop that doesn't quite work : https://imgur.com/8BdHBbP. To fix this you have to issue the following command ...


sudo chown YourUserName /path/to/icon/arduino-arduinoide.desktop

Open a Terminal (Ctrl+Alt+T) and run the command. YourUserName is shown in the prompt. When your Terminal starts into your Home directory, /path/to/icon should just be "Desktop". My command will look like this ...

sudo chown kenneth Desktop/arduino-arduinoide.desktop

Run Arduino once from the desktop symlink and the Arduino icon "Arduino IDE" will appear nicely over the raw filename.

Starting off with the IDE, I was in for some further surprises. If you select a board other that the Genuino / Uno (Tools > Board), for example ...

Adafruit Feather HUZZAH ESP8266

... and you proceed with a test compile, you will get the followin error message ...

fork/exec /home/<user>/.arduino15/packages/esp8266/tools/python/3.7.2-post1/python: no such file or directory
Error compiling for board <board>.


After a little digging, I found that the symlink python inside
.arduino15/packages/esp8266/tools/python/3.7.2-post1 was an orphaned link pointing to the old Python2+ location /usr/bin/python. Since Ubuntu 18.04.2 LTS came default with Python 3.6.8, I had to redo the symlink (soft) to /usr/bin/python3 or you can straight point it to python3.6.

To do that, open a Terminal, move to your Home directory (to move to your Home directory you can do cd ~ or cd $HOME), then cd to .arduino15/packages/esp8266/tools/python/3.7.2-post1. Rename the file python to python_OLD (just in case you might want it back). To rename, use the command mv python python_OLD. Then create a new soft symlink pointing to python3.6 : ln -s /usr/bin/python3 python (you need to keep the filename python because the compiler uses that name to invoke python).

cd ~
cd .arduino15/packages/esp8266/tools/python/3.7.2-post1
mv python python_OLD
ln -s /usr/bin/python3 python

Note: If you have Python 3.7.x (latest as of 2019.07.27 is 3.7.4), you'll need to point the symlink to that version.


This resolves the 2 issues I've found so far with the new Arduino IDE 1.8.9. I'll post as further  problems are encountered along the way.

Other references ...
ESPOTA.py Passes Wrong .BIN File
 

Wednesday, January 30, 2019

Arrivals : Plenty of Development Boards & Components

Over the past week, I have received a variety of Components & some Development Kits. Here are some of them.

I'll first start off with the Buck and the Boost. A Buck is a DC-DC Step-Down Converter while a Boost is a DC-DC Step-Up Converter. Both these devices are Switching Mode Power Supplies (SMPS).

I ordered a couple of these two devices for testing and studying.

The Buck I received is based on the LM2596. The Datasheet for the LM2596 can be downloaded here.

From the above image, you can see that there are 2 sets of terminals on each of the ends of the board. Obviously, one terminal is input and the other, output. This device takes a range of input voltage from 2.5V to 40.0V and you can programmatically set the output voltage to anywhere between 1.25V to 37.0V with a maximum output current of 3.0A. The little tactile switch or pushbutton on right of the board allows you to set the output voltage.

The XL6009 DC-DC Step-Up Power Supply Module (BOOST)

Complementing the Buck is the Boost. This DC-DC Step-Up Converter that I received is based on the XL6009. The Datasheet for the XL6009 from XLSemi.

Just like the Buck, the Boost has two sets of terminals, input and output. Increasing the Voltage is a little more challenging, and therefore the Boost is a little more expensive than the Buck. The input voltage range is between 3.0V to 32.0V and the output voltage is between 5.0V to 35.0V. This device is rated to take an input current of 4.0A providing a maximum conversion efficiency of 94%.

A Boost device takes a lower voltage and provides a higher voltage by drawing more current at the input. Thus, a 5.0V 4.0A input can produce a 12.0V output voltage with a substantially lower output current. In essence, the Buck and the Boost are forms of SMPSs (Switching Mode Power Supply).

Just like the Buck, this Boost allows you to set the output voltage with a multiturn trimpot trimmer potentiometer (the blue rectangular box with a golden screw-head at the top right corner of the board).

The pushbutton (momentary tactile switch) at the bottom right of the board allows you to switch between the input- and output- voltage displays and also to turn off the display (power saving mode).

Both these boards are puny. They measure about 80mm x 40mm and feature 4 mounting holes at the corners.

Update 2019.08.11 : It is interesting to note that this board was designed by ICStation (http://www.icstation.com/). There are a few variations of the board out there in the market, some without the 7-segment LED display.

Can anyone think of uses for these 2 types of devices?