Saturday, 20 May 2023

Getting going with the Ubuntu, the Arduino Development Tools and an ESP8266 Wifi Board

Requirements

  • ESP8266 board with CH340 serial interface (allows USB connection without programmer)
ot
  • ESP8266 board without CH340 serial interface
  • Programming Cable / Jumpers
  • Linux Compatible Serial Interface Adaptor with 3.3V output - e.g. CP2102 compatible DSD TECH USB to TTL Converter

Step 1: Download

Download Arduino IDE 2 AppImage and launch - the version I ended up using was:

# wget https://downloads.arduino.cc/arduino-ide/arduino-ide_2.1.0_Linux_64bit.AppImage

Or download the previous 1.8.19 version:

Unpack as root in /opt/arduino-1.8.19

Run /opt/arduino-1.8.19/install.sh as root

Run /opt/arduino-1.8.19/linux-user-install.sh <username>


Step 2a: Launch IDE V2

Change the permissions so that the AppImage is executable, and launch it:

# chmod u+x arduino-ide_2.1.0_Linux_64bit.AppImage

# ./arduino-ide_2.1.0_Linux_64bit.AppImage


Step 2b: Launch IDE V1

Launch the IDE from the start menu

Step 3: Install ESP8266 Board Info

Select File/Preferences and add the following URL to the "Additional Board Manager URLS" and select OK.

http://arduino.esp8266.com/stable/package_esp8266com_index.json

Launch Board Manager and search for "Generic" and install the "esp8266" board.

When it appears in Board Manager, select the desired version (I'm using the latest 3.12) and Install

In the board select drop-down, pick "Generic ESP8266"


Step 4: Select the board

In a new design, select Tools/Board/ESP8266 Boards/NodeMCU (ESP 12E Module)


Step3b: Install ESP8266 Board Info from Git

https://arduino-esp8266.readthedocs.io/en/3.0.0/installing.html

mkdir ~/Arduino/hardware

cd ~/Arduino/hardware

git clone https://github.com/esp8266/Arduino.git esp8266

Step 4: Add some Code

Select some code (e.g. https://randomnerdtutorials.com/esp8266-web-server/) and paste into the main edit window


Step 5: Plug in the Device to the USB Port

I found that the brltty driver was taking over the serial device and needed disabling

# dmesg | tail

159425.909714] ch341 3-1:1.0: ch341-uart converter detected
[159425.910391] ch341-uart ttyUSB0: break control not supported, using simulated break
[159425.910515] usb 3-1: ch341-uart converter now attached to ttyUSB0
[159426.484288] input: BRLTTY 6.4 Linux Screen Driver Keyboard as /devices/virtual/input/input22
[159426.604333] usb 3-1: usbfs: interface 0 claimed by ch341 while 'brltty' sets config #1
[159426.604766] ch341-uart ttyUSB0: ch341-uart converter now disconnected from ttyUSB0
[159426.604796] ch341 3-1:1.0: device disconnected


# systemctl stop brltty-udev.service

# sudo systemctl mask brltty-udev.service

# systemctl stop brltty.service

# systemctl disable brltty.service

Following this, unplugging and re-plugging the board allows /dev/ttyUSB0 to be created.

# ls -la /dev/ttyUSB0

crw-rw---- 1 root dialout 188, 0 May 20 16:07 /dev/ttyUSB0

If the current user does not have the correct access rights, he won't be able to access the device - to fix this, the user needs to be added to the appropriate group (in this case 'dialout')

# usermod -a -G dialout username

Then the current user must logout and log back in again to ensure that the new group membership is established.

Step 6: Download the Code


Step 7: Add some Tools

Add the "Arduino ESP8266 filesystem uploader" tool from  https://github.com/esp8266/arduino-esp8266fs-plugin

Or the "ESP8266 LittleFS Data Upload" tool from https://github.com/earlephilhower/arduino-esp8266littlefs-plugin/releases

Unpack into ~/Arduino/hardware/esp8266/tools


Step 8: Check Dependencies





No comments:

Post a Comment