10. August 2020

How to increase font size in Konsole

Konsole is a great terminal emulator that you can find in many Linux distributions. The problem with some Linux distributions is that font is too small.

To change the font open menu Settings and select Edit Current Profile…

Select Preview tab and change Text size value in the middle of the screen. Click Ok to confirm the new font..

Another option to change the font size is to press CTRL and Scroll Up/Down with mouse wheel.

The same result could be also achieved by keys CTRL and +/- keys.

Facebook Comments

18. July 2020

How to connect ESP8266 Wemos D1 to motor shield over I2C with MicroPython

ESP8266 Wemos D1 board has extension shield TB6612FNG which provides a connection to two motors.

The simplest way to get motors running is to connect the shield to ESP8266 and provide instructions to MicroPython repl so that ESP8266 can send instructions over I2C to TB6612FNG.

The first requirement to get the motor running is to have d1motor library.

You can download ZIP with patched d1motor library and sample code from here.

Original d1motor is available here: https://bitbucket.org/thesheep/micropython-d1motor/src/default/d1motor.py

Use rshell to copy the library on ESP8266 board.

unzip d1motor.zip
cd d1motor
rshell -p /dev/ttyUSB0
cp d1motor.py /pyboard/

Then start repl so that it’s possible to communicate with motor shield. You can exit repl by CTRL+X:

cd /pyboard/
repl

Insert following code:

import d1motor
from machine import I2C, Pin
i2c = I2C(-1, Pin(5), Pin(4), freq=100000)
m0 = d1motor.Motor(0, i2c)
m1 = d1motor.Motor(1, i2c)
m0.speed(5000)

By this moment motor should start roaring and rotating. Well, that would be the happy day scenario. There are several gotchas which you may encounter.

Gotcha #1 OSError: [Errno 19] ENODEV

The code might throw ENODEV error without further explanation of what went wrong. The error means that ESP8266 was not able to find motor board via I2C. You can verify the problem by entering code:

from machine import I2C, Pin
i2c = I2C(-1, Pin(5), Pin(4), freq=100000)
i2c.scan()

The correct result should be array with 48 which is 0x30.

[48]

If you get just empty array then the boards are not able to talk over I2C:

 [ ]

The most common reason for the problem is buggy version firmware in STM32F030. You must flash it according to instructions from hackday.io.

You will need UBS2TTL module to perform flashing.

Download patched firmware: motor_shield.bin

Connect by single wire RTS with 3V3 PIN – they’re next to each other.

Connect folling wires on main part of board (not part with RTS):

GND - GND
3V3 - 3V3 VCC on USB2TTL
D2 - TX
D1 - RX

Install stm32flash:

sudo apt-get install stm32flash

Unlock and flash the shield:

stm32flash /dev/ttyUSB0 -k
stm32flash /dev/ttyUSB0 -u
stm32flash /dev/ttyUSB0 -v -w motor_shield.bin

After flashing unplug wires and connect the shield back to ESP8266. Run I2C scan again and you should get the correct result:

from machine import I2C, Pin
i2c = I2C(-1, Pin(5), Pin(4), freq=100000)
i2c.scan()

[48]

Gotcha #2 Standby mode not controlled by I2C

Even after the first correction, the motors might not move and there is no voltage on A1-2 or B1-2. The problem is most likely caused by Standby mode.

Check your board and you should see STBY with 3 pins and with marking I2C and IO. You need to solder top and middle pin to enable I2C control of Standby mode. Solder them and plug the board again. Now motors should start to move.

Does it work? Congratulations.

Big thanks to community Radomir Dopieralski for d1motor.py, aarn_a and Matrix User for hints about Standby mode.

Facebook Comments

16. July 2020

systemctl Failed to list units: Access denied

During the upgrade of Debian or Ubuntu server you may encounter strange failing of scripts which are restarting services.

For some reason it’s not possible to call systemcl and any operation fails with Access denied even for root.

Here is example:

systemctl list-units
Failed to list units: Access denied

The fix to this problem it is sufficient to send TERM signal to process with PID #1:

kill -TERM 1
Facebook Comments

27. June 2020

ESP32 erase_flash failed with “Invalid head of packet”

The first step before installing MicroPython to ESP32 is to erase the flash.

I’ve installed all necessary software like esptool, but the flashing was failing with error:

esptool.py --chip esp32 --port /dev/ttyUSB0 erase_flash                                                                                                         ──(Sat,Jun27)─┘
esptool.py v2.8
Serial port /dev/ttyUSB0
Connecting........_____....._____....._____....._____....._____....._____....._____

A fatal error occurred: Failed to connect to ESP32: Invalid head of packet (0x1B)

The solution to the problem is to pres and hold BOOT button. Then start erase command mentioned above.

After the initial erase I was able to flash there MicroPython:

esptool.py --chip esp32 --port /dev/ttyUSB0 --baud 460800 write_flash -z 0x1000 esp32-idf4-20200627-unstable-v1.12-590-g9f911d822.bin

Then it was possible to connect via rshell:

rshell -p /dev/ttyUSB0                                                                                                                                          ──(Sat,Jun27)─┘
Using buffer-size of 32
Connecting to /dev/ttyUSB0 (buffer-size 32)...
Trying to connect to REPL  connected
Testing if ubinascii.unhexlify exists ... Y
Retrieving root directories ... /boot.py/
Setting time ... Jun 27, 2020 20:46:47
Evaluating board_name ... pyboard
Retrieving time epoch ... Jan 01, 2000
Welcome to rshell. Use Control-D (or the exit command) to exit rshell.

/home/georgik/projects/esp32> cd /pyboard/
/pyboard> ls
boot.py
Facebook Comments

21. June 2020

Learn to draw with tablet online app

Learning to draw takes time. Here you can find simple online app which can help you with the task.

The current version contains line drawing exercises: vertical line, horizontal line, diagonal line /, diagonal line \, X, Y, circle, half of circle.

It’s possible to draw by mouse, tablet or by touch (e.g. mobile device screen).

Suggestions for improvement are welcome. Feel free to post them to comment section.

Facebook Comments