How to home only ONE axis in Marlin

In the Marlin 3D printer firmware, you can home one axis without homing the other axes using G28[Axis].

In order to home the X axis:

G28X

In order to home the Y axis:

G28Y

In order to home the Z axis:

G28Z

Homing X & Y without homing Z

You can also home multiple axes using G28[Axis 1][Axis 2]. So in order to home the X and the Y axis (but not home the Z axis), run

G28XY

 

Posted by Uli Köhler in 3D printing

What is the correct supply voltage for DALI?

DALI operates at a supply voltage of 16V, current limited at 250mA.

Since the specified voltage range for a 1 bit is between 9.5V and 22.5V, the supply voltage can also be in this range (with 16V being right in the middle of this range. But even if you technically can use a 12V supply, this might not work for setups with longer cable lengths and/or setups with many DALI devices connected. If you have a 12V or 5V power supply, I recommend to use a boost converter to generate 16V.

Note that you always need to current-limit the DALI supply. Just connecting a power supply to the DALI line could destroy your equipment.

Posted by Uli Köhler in Electronics

How to install PlatformIO remote agent on Raspberry Pi

This is from the Super Quick installation procedure from the official PlatformIO documentation:

python3 -c "$(curl -fsSL https://raw.githubusercontent.com/platformio/platformio/master/scripts/get-platformio.py)"
sudo apt -y install rustc libffi-dev
echo "export PATH=\$PATH:/home/${USER}/.platformio/penv/bin" >> ~/.profile

Run it as user (whatever user you want to use PlatformIO as – by default, this is the pi user) and not as root!

After running these commands, log out and log back in again in order for the changes to the PATH environment variable to take effect.

After that, run

pio remote agent start

to complete the installation procedure. This will take quite some time.

After logging in, you can use pio from the shell:

$ pio

Usage: pio [OPTIONS] COMMAND [ARGS]...

Options:
  --version          Show the version and exit.
  -f, --force        DEPRECATE
  -c, --caller TEXT  Caller ID (service)
  --no-ansi          Do not print ANSI control characters
  -h, --help         Show this message and exit.

Commands:
  access    Manage resource access
  account   Manage PlatformIO account
  boards    Embedded board explorer
  check     Static code analysis
  ci        Continuous integration
  debug     Unified debugger
  device    Device manager & serial/socket monitor
  home      GUI to manage PlatformIO
  lib       Library manager
  org       Manage organizations
  package   Package manager
  platform  Platform manager
  project   Project manager
  remote    Remote development
  run       Run project targets (build, upload, clean, etc.)
  settings  Manage system settings
  system    Miscellaneous system commands
  team      Manage organization teams
  test      Unit testing
  update    Update installed platforms, packages and libraries
  upgrade   Upgrade PlatformIO to the latest version

 

Posted by Uli Köhler in PlatformIO, Raspberry Pi

How to flash Marlin on BigTreeTech Octopus V1 using debug adapter

In order to flash the Bigtreetech Octopus V1 using my STLinkv2 debug adapter, I needed. First we need to note that the first 32k of flash memory are occupied by the bootloader (0x08000000 to 0x08008000). So we need to flash the firmware at address 0x08008000. By default, this is not configured correctly in Marlin.

Open ini/stm32f4.ini and edit the [env:BIGTREE_OCTOPUS_V1]:

[env:BIGTREE_OCTOPUS_V1]
platform           = ${common_stm32.platform}
extends            = stm32_variant
board              = marlin_BigTree_Octopus_v1
board_build.offset = 0x8000
board_upload.offset_address = 0x08008000
build_flags        = ${stm32_variant.build_flags}
                     -DSTM32F446_5VX -DUSE_USB_HS_IN_FS
upload_protocol = stlink

Note that you absolutely need to re-flash the bootloader in case you accidentally flashed with the old configuration. Follow the official documentation in order to flash the bootloader. I flash usin STM32CubeProgrammer 2.7.0 (2.8.0 does not work) on both Linux and Windows.

The [env:BIGTREE_OCTOPUS_V1_USB] will be updated automatically as it includes [env:BIGTREE_OCTOPUS_V1]

Posted by Uli Köhler in 3D printing, Electronics, STM32

ESP32 JTAG pinout

The ESP32 uses the following pins for JTAG:

  • GPIO12: TDI
  • GPIO13: TCK
  • GPIO14: TMS
  • GPIO15: TDO

Source: ESP32 reference manual, section 4.10 IO_MUX Pad List

Posted by Uli Köhler in ESP8266/ESP32

Is your PD device 802.3bt PoE++ Type-3 or Type-4?

Note: Do NOT confuse Type-3 or Type-4 with PoE class 3 and class 4!

If your PD uses a maximum of 51W (class 1-6 – up to 60W at the PSE), your device is Type 3. If your device uses 62W or 71.3W (class 7 or 8 – 75W or 90W at the PSE), your device is Type 4.

In case your device uses more than 71.3W (or 90W at the PSE), your use-case is not covered by IEEE 802.3bt aka PoE++.

Note that “uses” does not refer to the actual power draw of your device but whatever class you present during the PoE classification process. Typically, this is configured using a resistor, depending on your PoE PD controller.

For reference, see this Ethernet Alliance Whitepaper

Posted by Uli Köhler in Electronics, Networking, PoE

Does 802.3bt PoE++ work with 2-pair power or does it require 4-pair power?

802.3bt always requires four pairs for power >= 40W (class 5+) and does not support powering over two pairs. Powering 2-pair devices using 802.3bt will only when powering devices with up to 30W (i.e. in “802.3at backwards-compatible” mode).

For reference see this whitepaper by the Ethernet Alliance.

Posted by Uli Köhler in Electronics, Networking, PoE

What does “PSE” mean in PoE / Power over Ethernet context?

PD means Power sourcing equipment. This refers to a device which injects power in a PoE port – in other words, it provides Power over Ethernet as opposed to a PD (powered device) that consumes power injected by a Power sourcing equipment device.

Also see: What does “PD” mean in PoE / Power over Ethernet context?

Posted by Uli Köhler in Electronics, Networking, PoE

What does “PD” mean in PoE / Power over Ethernet context?

PD means Powered device. This refers to a device which is powered by a PoE port – in other words, it consumes Power over Ethernet as opposed to a PSE (power sourcing equipment) that injects power that can be consumed by powered devices.

Also see: What does “PSE” mean in PoE / Power over Ethernet context?

Posted by Uli Köhler in Electronics, Networking, PoE

How to run HTTP request on call to extension using FreePBX

This post is based on our previous post How to add custom action on call to custom extension in FreePBX

In FreePBX, add the following config to /etc/asterisk/extensions_custom.conf in order to add a custom extension 999 that uses System() to run curlon a fixed URL.

[from-internal-additional-custom]
exten => 999,1,Answer()
exten => 999,n,Wait(1)
exten => 999,n,System(curl http://mydomain.com/myurl)
exten => 999,n,Wait(1)
exten => 999,n,Hangup()

Don’t forget to reload Asterisk e.g. using the core reload command from the Administrator menu => Asterisk CLI in order for the changes to take effect.

For details on how [from-internal-additional-custom] works, see our previous post How to add action on call to custom extension in FreePBX

Posted by Uli Köhler in FreePBX

How to add action on call to custom extension in FreePBX

In FreePBX, add the following config to /etc/asterisk/extensions_custom.conf in order to add a custom extension 999 that just plays Hello world when called:

[from-internal-additional-custom]
exten => 999,1,Answer()
exten => 999,n,Wait(1)
exten => 999,n,Playback(hello-world)
exten => 999,n,Wait(1)
exten => 999,n,Hangup()

Don’t forget to reload Asterisk e.g. using the core reload command from the Administrator menu => Asterisk CLI in order for the changes to take effect.

How the dialplan routing works

Note that we have added this in the [from-internal-additional-custom] context, which is included at the beginning of the [from-internal-additional] context by FreePBX in extensions_additional.conf:

[from-internal-additional]
include => from-internal-additional-custom

The [from-internal-additional] context in turn is included in [from-internal]In other words, our custom extension 999 will be active for all phones calling from the [from-internal] context – which is, by default, all internal extensions.

Posted by Uli Köhler in FreePBX

How to install NodeJS 18.x LTS on Ubuntu in 1 minute

Run these shell commands on your Ubuntu computer to install NodeJS 18.x:

sudo apt -y install curl
curl -sL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt-get install -y nodejs

Instead of setup_18.x you can also choose other versions like setup_16.x. However, using this method, you can’t install multiple versions of NodeJS in parallel.

Source: Official nodesource documentation

Posted by Uli Köhler in Linux, NodeJS

How to fix python ipaddress.IPv6Address AddressValueError: Unexpected ‘/’ in ‘…/64’

Problem:

When trying to parse an IPv6 network address in Python using code like

import ipaddress
ipaddress.IPv6Network("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64")

you see an error message like

---------------------------------------------------------------------------
AddressValueError                         Traceback (most recent call last)
/tmp/ipykernel_154945/2602627019.py in <module>
----> 1 ipaddress.IPv6Address("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64")

/usr/lib/python3.8/ipaddress.py in __init__(self, address)
   1836         addr_str = str(address)
   1837         if '/' in addr_str:
-> 1838             raise AddressValueError("Unexpected '/' in %r" % address)
   1839         self._ip = self._ip_int_from_string(addr_str)
   1840 

AddressValueError: Unexpected '/' in '2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64'

Solution 1: Remove the CIDR netmask (/64)

By just removing the slash and the part after it (the CIDR netmask).

Solution 1: Maybe you should use IPv6Network instead of IPv6Address

If you intend to parse the network, use ipaddress.IPv6Network but remember that this will discard all host bits. If you want to use IPv6Address or IPv6Network really depends on what you want to do with it – if you want to refer to a specific host, you almost always want to use IPv6Address.

import ipaddress
ipaddress.IPv6Network("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64", strict=False)

Note that strict=False is added in order to prevent an exception due to host bits being set – see How to fix Python ipaddress.IPv6Network ValueError: … has host bits set

Posted by Uli Köhler in Networking, Python

How to fix Python ipaddress.IPv6Network ValueError: … has host bits set

Problem:

When trying to parse an IPv6 network address in Python using code like

import ipaddress
ipaddress.IPv6Network("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64")

you see an error message like

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
/tmp/ipykernel_154945/1312927855.py in <module>
      1 import ipaddress
----> 2 ipaddress.IPv6Network("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64")

/usr/lib/python3.8/ipaddress.py in __init__(self, address, strict)
   2106         if packed & int(self.netmask) != packed:
   2107             if strict:
-> 2108                 raise ValueError('%s has host bits set' % self)
   2109             else:
   2110                 self.network_address = IPv6Address(packed &

ValueError: 2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64 has host bits set

Solution 1: Maybe you should use IPv6Address instead of IPv6Network

If you intend to parse the address and don’t care about the network, use ipaddress.IPv6Address but remember that the CIDR mask (e.g. /64)  needs to be removed. If you want to use IPv6Address or IPv6Network really depends on what you want to do with it – if you want to refer to a specific host, you almost always want to use IPv6Address.

import ipaddress
ipaddress.IPv6Address("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69")

Solution 2: Use strict=False to let IPv6Network discard the host bits:

strict=False basically ignores this error

import ipaddress
ipaddress.IPv6Network("2a01:c23:c0bb:d00:8ce6:2eff:fe60:cc69/64", strict=False)

Note that the result will be

IPv6Network('2a01:c23:c0bb:d00::/64')

so the information in the host bits will be lost!

Solution 2: Remove the host bits manually

Since the host bits will be discarded anyway, you can just specify the IPv6 network with the correct netmask:

import ipaddress
ipaddress.IPv6Network("2a01:c23:c0bb:d00::/64")

 

Posted by Uli Köhler in Networking, Python

What is the default PlatformIO / Arduino ESP32 TIMER_BASE_CLK?

On PlatformIO / Arduino, by default the TIMER_BASE_CLK is 80 MHz (the maximum frequency the ESP32 can run at).

If you want to verify this yourself, use this firmware:

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
    Serial.println(getCpuFrequencyMhz());
}

void loop() {
}

 

Posted by Uli Köhler in Arduino, Electronics, Embedded, ESP8266/ESP32, PlatformIO

What is the default PlatformIO / Arduino ESP32 CPU clock frequency?

On PlatformIO / Arduino, by default the ESP32 clock frequency is 80 MHz (the default 240 MHzCPU frequency divided by 4)

If you want to verify this yourself, use this firmware:

#include <Arduino.h>

void setup() {
    Serial.begin(115200);
    Serial.println(TIMER_BASE_CLK);
}

void loop() {
}

 

Posted by Uli Köhler in Arduino, Electronics, Embedded, ESP8266/ESP32, PlatformIO

How to fix PlatformIO serial monitor scrambled output

Problem:

When using the Monitor function of platformIO, you see strange characters instead of strings being printed, for example:

)�
�␜ܠ��J��1��1!y��!���!��

Solution:

This issue almost always appears due to the Monitor function using the wrong UART speed. You can see from the log in our screenshot above:

--- Miniterm on /dev/ttyUSB0  9600,8,N,1 ---

that PlatformIO is using 9600 baud in this case – but your microcontroller is sending data at a faster speed (or, rarely at a slower speed).

Most firmwares using serial IO use 115200 baud, so that’s what I’d recommend to try first, but if that doesn’t work, look out for config options named baud rate or similar, or for lines of code like

Serial.begin(57600);

in the firmware.

In order to change the Monitor UART speed, open platformio.ini and add

monitor_speed = 115200

Full platformio.ini example for ESP32:

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

After that, restart the Monitor function.

Posted by Uli Köhler in Arduino, Electronics, Embedded, ESP8266/ESP32, PlatformIO, STM32

How to fix ESP32 PlatformIO error: ‘LED_BUILTIN’ was not declared in this scope

Problem:

When trying to compile your ESP32 firmware using PlatformIO, you see this error message:

src/main.cpp: In function 'void setup()':
src/main.cpp:22:13: error: 'LED_BUILTIN' was not declared in this scope
     pinMode(LED_BUILTIN, OUTPUT);

Solution:

Important: Some ESP32 boards such as the ESP32-DevKitC have no builtin LED at all ! Either connect an external LED or find another method of doing whatever you are intending to do.

On most ESP32 boards that do have a builtin LED, the LED is connected to pin 2 – however, PlatformIO does not define LED_BUILTIN p. In order to fix the issue, define LED_BUILTIN yourself by using

#define LED_BUILTIN 2

at the top of every file where you see this error.

Posted by Uli Köhler in Electronics, Embedded, ESP8266/ESP32, PlatformIO
This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Cookie settingsACCEPTPrivacy &amp; Cookies Policy