Showing posts with label how to. Show all posts
Showing posts with label how to. Show all posts

Friday, October 29, 2021

Arduino IDE, open two independent Serial Monitor

To open two Arduino IDEs, with independent board and Serial Monitor. Tested on Arduino IDE 1.8 in Raspberry Pi OS, Windows 10 and Ubuntu 21.10.

- Open new Arduino IDE from system, or
- from File Explorer.


Wednesday, June 9, 2021

Arduino Nano RP2040 Connect

Just receive Arduino Nano RP2040 Connect:





Install Nano RP2040 Connect to Arduino IDE and fix "An error occurred while uploading the sketch":
 

Install Arduino Nano RP2040 Connect board to Arduino IDE.

- Open Board Manager in Arduino IDE.
- Search and install Arduino Mbed OS Nano Boards by Arduino. It's version 2.1.0 currently.


- Once installed, Arduino Mbed OS Nano Boards > Arduino Nano RP2040 Connect will available in board selection list.

If you have XIAO BLE Sense also, check Remark on "Arduino Nano RP2040 Connect" of "Arduino Mbed OS Boards" vs "Arduino Mbed OS Nano Boards".


Fix "An error occurred while uploading the sketch".

In my case on Raspberry Pi, sketch cannot be uploaded; with "An error occurred while uploading the sketch".

To fix it:
- Switch to mbed_rp2040 installed folder:
/home/pi/.arduino15/packages/arduino/hardware/mbed_rp2040/2.1.0
- Run post_install.sh:
$ sudo ./post_install.sh

- Then, you can upload the sketch again.


More exercise:
read onboard LSM6DSOX IMU module (accelerometer and gyroscope)

Wednesday, March 3, 2021

Install Arduino IDE 2.0 beta on Linux Mint 20.1, include ESP32/ESP8266 support.

Arduino IDE 2.0 (beta) is now available (refer to announcement in Arduino blog). It,s my first try to install Arduino IDE 2.0 beta (2.0.0-beta3) on Linux Mint 20.1, tested with VirtualBox 6.1/Windows 10.

Download Arduino IDE 2.0 beta

Visit https://www.arduino.cc/en/software, scroll download to download Arduino IDE 2.0 beta for Linux 64 bits (X86-64).

Run arduino-ide

Extract the downloaded file to a any folder you want. Run arduino-ide in Terminal
$ ./arduino-ide

Install board

In a fresh new installed Arduino IDE 2.0, no board is installed, you will be report with error:

Compilation error: Error: 2 UNKNOWN: platform not installed

Click Boards Manager on left, search to install Arduino AVR Boards by Arduino.

Add permission to user, to access USB

In a new Linux, you (as a regular user) have no permission to access USB port, and report with error:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

Open Terminal, enter the command to add permission:
$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw <port>

Done.



Install board support for ESP32/ESP8266



Then you can add board of ESP32/ESP8266 in Boards Manager.

Setup Python

By default Linux Mint 20.1 pre-install Python3, but no Python2. Currently, esptool for ESPs call python. You can create a symlinks /usr/bin/python to python3 by installing python-is-python3.

$ sudo apt install python-is-python3

Optionally, you can prevent Python 2 from being installed as a dependency of something in the future:

$ sudo apt-mark hold python2 python2-minimal python2.7 python2.7-minimal libpython2-stdlib libpython2.7-minimal libpython2.7-stdlib

And you have to install pyserial with pip:

$ sudo apt install python3-pip
$ pip3 install pyserial

Add permission to your user (if not do in above steps):

Additionally, if you cannot download your code to board caused by:
avrdude: ser_open(): can't open device "/dev/xxx": Permission denied

$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw <port>











Saturday, July 11, 2020

BasicOTA: Program ESP32 (or ESP8266) via ArduinoOTA, on Windows 10/Arduino IDE

One of the very useful feature of ESP32/ESP8266 is OTA (Over-The-Air) programming; such that you can update the firmware without physically connect to the device.

With ESP32/ESP8266 core for Arduino installed to your Arduino IDE, you can find ArduinoOTA examples of BasicaOTA and OTAWebUpdater under Examples for ESP32 Dev Module.


This post show trying BasicOTA examples on ESP32-DevKitC using Arduino IDE running on Windows 10, and fix the problem I faced:  Network Ports no shown and No response from device.


Basically, the default DevKitC firmware have no OTA function. So you have to flash the first firmware with OTA function using serial port (USB). After then, you can update your firmware via OTA without physical connected serial port. Both the computer used to update the firmware and the ESP devices to be updated have to be in the same network.

The ESP device I used in this example is ESP32-DevKitC with ESP32-WROOM-32 module. It should be a relatively old and original version.


Somebody (include me) reported there are no Network Ports shown up. 


Somebody suggested to install Python, somebody suggested to reboot router, or install Bonjour... All of them not work for me. In order to eliminate the problem outside my computer, I decide to use Windows 10's Mobile hotspot.


Open BasicOTA example and change ssid and password according to my network setting. Upload the ESP32 device via serial port (USB, or COM5 in this example).

Turn on Windows 10's Mobile hotspot with matched ssid/password.

Now the Network ports shown, with attached device (the programmed ESP32 with OTA function) and its assigned ip.


Once Network port selected, the Arduino IDE's Serial Monitor not work on network. So I run Putty to monitor the output from ESP device via serial port.

Now, upload your second program via OTA. But still fail due to No response from device.


Now, open Windows Security and Allow espota.exe to communicate through Windows Defender Firewall.

Upload again, and Done uploading.
(In the various steps, the assigned ip of the ESP device may be changed. Double check the ip in Putty and select the Network port accordingly.)


Wednesday, June 24, 2020

Install Arduino IDE 1.8.13 on Ubuntu 20.04

To run Arduino IDE, you have to install Java on Ubuntu, refer last post Install JDK (OpenJDK) on Ubuntu 20.04.


Visit https://www.arduino.cc/ to download Linux 64 bits version.

Extract the downloaded file and more to where you want. Switch to the folder and run:
$ sudo ./install.sh

You will be reported with error of:

An error occurred while uploading the sketch
avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

You can add you (the user) to the group own permission of the upload port:

$sudo usermod -a -G dialout <username>
$sudo chmod a+rw /dev/ttyACM0

change username and ttyACM0 according to your setup.

logout and login.



Basically, the steps to install Arduino IDE on Ubuntu 20.04 are same as install on previous version of Ubuntu. But if you target to develop for ESP32/ESP8266, very likely you will be with error of:
exec: "python": executable file not found in $PATH
ModuleNotFoundError: No module named 'serial'

Check next post - Install ESP32/ESP8266 to Arduino IDE on Ubuntu 20.04, with setup Pythton & serial

Install JDK (OpenJDK) on Ubuntu 20.04


Install JDK 14.0.1 (from Oracle) on Ubuntu 20.04

- Visit https://jdk.java.net/ to download latest JDK of Linux/x64, currently openjdk-14.0.1_linux-x64_bin.tar.gz

- Extract the downloaded file:
$ tar -zxvf openjdk-14.0.1_linux-x64_bin.tar.gz

-  Create a folder in /opt/java where jdk will be stored.
$ sudo mkdir -p /opt/java

- Move the extracted folder to /opt/java
$ sudo mv jdk-14.0.1 /opt/java

- Set default java and javac using update-alternatives:
$ sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk-14.0.1/bin/javac 1
$ sudo update-alternatives --install /usr/bin/java java /opt/java/jdk-14.0.1/bin/java 1
$ sudo update-alternatives --config javac
$ sudo update-alternatives --config java


Wednesday, June 3, 2020

Fixed fatal error: Wire.h: No such file or directory - for platform IO/Arduino

When I tried exercise using Wire library, it's reported:

fatal error: Wire.h: No such file or directory


Solution, it work for me:

Open platformio.ini, add the line:

lib_deps = Wire

(or lib_deps = SPI for fatal error: SPI.h: No such file or directory)

Build again:






Friday, May 8, 2020

Install VS Code/PlatformIO IDE on Ubuntu 20.04, to program Arduino/ESP8266/STM32.

This video show how to install VS Code/PlatformIO IDE on Ubuntu 20.04 (run on Windows 10/VirtualBox), to program Arduino. And also set upload port in platformio.ini and add USB permission to user.


Visit Visual Studio Code download page to download .deb version for Ubuntu.

After downloaded, open Terminal and switch to the downloaded folder and run the command to install VS Code:

$ sudo apt install ./<file>.deb

(reference: Visual Studio Code on Linux)

After installed, search and run VSCode.

In VS Code, select Extensions tab, enter platformIo in the search box, and click to install platformIO IDE.


(This screen shot after PlatformIO IDE installed. Before install, you can see a Install button.)

If you report with error of ModuleNotFoundError: No module named 'distutils.***'

Enter the command to install python3-distutils:

$ sudo apt-get install python3-distutils

(reference: https://github.com/platformio/platformio-vscode-ide/issues/907)

Close and restart VS Code to complete installation.

Now you can select PlatformIO on the left, and create a New Project. For Arduino Uno, steps refer to the above video.

May be you have to specify the upload port in platformio.ini. Open platformio.ini and add the code:
upload_port = /dev/ttyACM0

where /dev/ttyACM0 is the USB port.

Also have to add permission of the USB port to user. Enter the command in Terminal:
$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw /dev/ttyACM0

more:
2.8" 320*240 TFT Touch Screen shield (ILI9341 8 bit I/F) on Uno, using MCUFRIEND_kbv and Adafruit GFX Libraries
TFT Touch Screen shield (ILI9341 8 bit) + Uno, calibration and simple touch drawing example.


Platform IO + ESP8266/ESP32

With PlatformIO IDE installed, you can also program ESP8266/ESP32 board of Arduino framework. This video show the steps.



The following video show how to install library in PlatformIO, for I2C SSD1306 OLED driver for ESP8266/ESP32.


This example run on ESP32 (WEMOS Lolin32 with integrated SSD1306/OLED driver).

#include <Wire.h>
#include <SSD1306Wire.h>

SSD1306Wire display(0x3C, 5, 4);

void setup() {
  // put your setup code here, to run once:

  display.init();
  display.flipScreenVertically();
  display.setTextAlignment(TEXT_ALIGN_LEFT);
  display.setFont(ArialMT_Plain_16);
}

void loop() {
  // put your main code here, to run repeatedly:

  display.clear();
  display.drawString(0, 0, "ESP32/OLED");
  display.drawString(0, 20, "Hello PlatformIO");
  display.display();

  delay(1000);
  
}


Reference:
~ My old post: ESP32 + OLED Module

Next:
ESP8266 (NodeMCU/ESP8266 DevKitC) + SSD1306 I2C OLED, Platform IO.


PlatformIO + STM32

PlatformIO also can program STM32, such as NUCLEO-F401RE Board.



KEY FEATURES of NUCLEO-F401RE Board:

- Common features
  • STM32 microcontroller in LQFP64 package
  • 1 user LED shared with Arduino™
  • 1 user and 1 reset push-buttons
  • 32.768 kHz crystal oscillator
  • Board connectors:Arduino™ Uno V3 expansion connectorST morpho extension pin headers for full access to all STM32 I/Os
  • Flexible power-supply options: ST-LINK, USB VBUS or external sources
  • On-board ST-LINK debugger/programmer with USB re-enumeration capability: mass storage, Virtual COM port and debug port
  • Comprehensive free software libraries and examples available with the STM32Cube MCU Package
  • Support of a wide choice of Integrated Development Environments (IDEs) including IAR™, Keil® and GCC-based IDEs

- NUCLEO-F401RE Board-specific features
  • External SMPS to generate Vcore logic supply
  • 24 MHz HSE
  • Board connectors:External SMPS experimentation dedicated connectorMicro-AB or Mini-AB USB connector for the ST-LINKMIPI® debug connector
  • Arm® Mbed Enabled™ compliant
Reference: NUCLEO-F401RE

Steps to create  a new project for NUCLEO-F401RE Board, using Arduino and Mbed framework.


Error: libusb_open() failed with LIBUSB_ERROR_ACCESS

To make PlatformIO run on Ubuntu, in addition to add USB permission to user as describe above, you have to install udev rules (99-platformio-udev.rules) also.

Enter the commands in Terminal:

$ curl -fsSL https://raw.githubusercontent.com/platformio/platformio-core/master/scripts/99-platformio-udev.rules | sudo tee /etc/udev/rules.d/99-platformio-udev.rules

$ sudo service udev restart

After this file is installed, physically unplug and reconnect your board.


Update VS Code for Ubuntu

If update of VS Code is available and you are asked to Download Update.


Just close VS Code and run the commands in Terminal:

$ sudo apt-get install apt-transport-https
$ sudo apt-get update
$ sudo apt-get install code # or code-insiders

reference: https://code.visualstudio.com/docs/setup/linux

Updated 1.46.0 currently@2020-06-11



Wednesday, April 10, 2019

Install Arduino IDE 1.8.9 on Ubuntu 18.10 and set permission for serial port

This video show how to install the latest Arduino IDE 1.8.9 on a fresh new Ubuntu 18.10 (on VirtualBox 6.0/Windows 10).



This installation is very straightforward:
- visit Arduino Software download page to download the Linux 32 bits or 64 bits version corresponding to your system.
- Extract the downloaded file to the where you want to install.
- Open Terminal to run the install.sh with sudo.
$ sudo ./install.sh

After finished, you can start Arduino IDE with arduino command or from Application launcher.

But...up to this step, you have no permission to access the serial port. When you download the code to Arduino devices, you will be reported with error:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied


To fix it, you have to add permission:
- Open Terminal, enter the command:
$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw /dev/ttyACM0


Thursday, June 15, 2017

Add Arduino core for ESP8266 to Arduino IDE (run on Raspberry Pi/Raspbian Jessie with PIXEL)

Last post show how to "Install and run Arduino IDE on Raspberry Pi/Raspbian Jessie with PIXEL". We can add Arduino core for ESP8266 to Boards Manager, such that we can develop ESP8266/NodeMCU program on Raspberry Pi directly, without using PC. For sure, the compiling time will be longer than on PC.

Add Additional Board Manager URL for ESP8266 board:
> File > Preference
> Add "http://arduino.esp8266.com/stable/package_esp8266com_index.json" in Additional Board Manager URLs.

Add ESP8266 board to Arduino IDE:
- Open Boards Manager in Arduino IDE
- Search "esp8266" or "NodeMCU", you will find "esp8266 by ESP8266 Community". Install it.

This video show how to, and run the Blink example on ESP8266/NodeMCU. The Raspberry Pi 3 connect to a 4" 800x480 HDMI IPS LCD Display, so it display in low resolution.

Next:
ESP8266/NodeMCU read Analog Input and send to Raspberry Pi via Serial/USB
A Python example run on Raspberry Pi 3/Raspbian Jessie with PIXEL, to plot the serial data graphically using matplotlib library.


Monday, April 3, 2017

Program the Siemens IOT2000 With Arduino IDE

The new Internet of Things gateway from Siemens (Simatic) has been released! It's based on the Intel Galileo Gen2 chipset.

This tutorial show how to "Program the New IOT2000 From Siemens With Arduino IDE!".

Thursday, October 1, 2015

Install Arduino driver on Windows 10


Due to any reason, you cannot install the Arduino driver on Windows, you can try to update the driver manually in your Device Manager.
  • Plug in your board and wait for Windows to begin it's driver installation process. After a few moments, the process will fail, despite its best efforts
  • Click on the Start Menu, and open up the Control Panel.
  • While in the Control Panel, navigate to System and Security. Next, click on System. Once the System window is up, open the Device Manager.
  • Look under Ports (COM & LPT). You should see an open port named "Arduino UNO (COMxx)". If there is no COM & LPT section, look under "Other Devices" for "Unknown Device".
  • Right click on the "Arduino UNO (COmxx)" port and choose the "Update Driver Software" option.
  • Next, choose the "Browse my computer for Driver software" option.
  • Finally, navigate to and select the driver file named "arduino.inf", located in the "Drivers" folder of the Arduino Software download (not the "FTDI USB Drivers" sub-directory). If you are using an old version of the IDE (1.0.3 or older), choose the Uno driver file named "Arduino UNO.inf"
  • Windows will finish up the driver installation from there.

reference: Getting Started with Arduino on Windows - Install the drivers


Friday, June 26, 2015

5 Mistakes to damage an Arduino, avoid them!



This episode discusses five ways you can easily damage an Arduino - so you can avoid them!
Mistake #1: Shorting I/O Pins to Ground
Mistake #2: Shorting I/O Pins to Each Other
Mistake #3: Apply Overvoltage to I/O Pins
Mistake #4: Apply External Vin Power Backwards
Mistake #5: Apply greater than 5V to the 5V Connector Pin

Also learn about an Arduino UNO derivate designed to protect against each potential mishap.

*Read More...*
https://opensourcehardwaregroup.com/5-ways-to-destroy-an-arduino

Friday, April 3, 2015

Get idVendor and idProduct of your Arduino/USB devices

To know the idVendor and idProduct of your Arduino/USB devices, in Linux system, we can use the dmesg command, to read messages from kernel ring buffer.


- with your Arduino/USB devices NOT connected, run the command to clear the buffer.
$ sudo dmesg -c

- Connect Arduino/USB devices, enter the command:
$ dmesg

- The latest connect device will be shown, include its idVendor and idProduct:

Thursday, January 15, 2015

How to identify pin 1 of 8x8 LED Matrix

This post show how to identify pin 1, and pin 16, of 8x8 LED Matrix.


Part I: Row Anode Column Cathode 8x8 LED Matrix, 1588BS as example. Current flow from pin 1 to pin 16 to make LED on row 5 col 8 ON.

Use the example of Row-Column Scanning an 8x8 LED matrix to show it work.

The connection between Arduino Uno and 8x8 LED Matrix is show here:

(It's recommended to add 220 ohm resisters to limit the current)

We need a test program to verify our connection, visit http://goo.gl/tXySxV, copy the example sketch of Walking bit on 8*8 LED Matrix, and download to Arduino Uno.


If your 8x8 LED Matrix have no marking for pin 1, we can use a multimeter to identify pin 1, and also pin 16.

This scheme diagram show when we apply +ve on pin 1 and -ve on pin 16, the LED on row 5 col 8 will be turn on.

Switch multimeter to diode test, the red lead will be +ve and black lead will be -ve.

Refer to the below video:
There are 4 possibility of pin 1 and 16, only one case will turn on a LED. When the LED (row 5 col 8) on, the pin connected to the RED lead of multimeter is pin 1.




Part II: Row Cathode Column Anode 8x8 LED Matrix, 1088AS as example. Current flow from pin 16 to pin 1 to make LED on row 5 col 8 ON.


Same procedure as in part I, with pin 1 on BLACK lead of multimeter.


Working example, refer to next post "Arduino Uno + SPI 8x8 LED Matrix, with MAX7219 LED driver".


Monday, December 8, 2014

Program Arduino Pro Mini with USB-to-Serial adapter

This is a good video tutorial for programming (or flash) Arduino Pro Mini with USB-to-Serial adapter. Using 3 different USB to Serial modules to program a clone Arduino Pro Mini. The chips are the FTDI FT232RL, the Silicon Labs CP2102 and the Prolific Technologies PL2032HX.



Tuesday, August 26, 2014

Arduino IDE error - avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied

If you run Arduino IDE on Ubuntu (Arduino 1.5.7 and Ubuntu 14.04 in my case), most possibly you cannot upload to Arduino board, caused by the error of:

avrdude: ser_open(): can't open device "/dev/ttyACM0": Permission denied
ioctl("TIOCMGET"): Inappropriate ioctl for device

To fix it, enter the command:
$ sudo usermod -a -G dialout <username>
$ sudo chmod a+rw /dev/ttyACM0

Where <username> is your user name in Ubuntu, /dev/ttyACM0 is the detected device of your Arduino board.

Check the video:

Tuesday, January 28, 2014

Install GTK+3 and compile with gcc in Linux

To install GTK+3 to develop GUI program on Linux (eg.Ubuntu), you have to install libgtk-3-dev, enter the command in Terminal:
$ sudo apt-get install libgtk-3-dev

To compile your souce code using gcc, with GTK+3:
$ gcc <your_code>.c -o <your_code> `pkg-config --cflags --libs gtk+-3.0`

where <your_code>.c is your c source code. <your_code> is the generated program.

Notice the symbol `, not ' or ".

Then run it with:
$ ./<your_code>

Check a example: Send data to Arduino from Linux PC, program in C with GUI of GTK+3, as ColorChooser