JST XH connector crimp contacts have a 3A
current rating per contact (with 0.33mm² cables).
Source: JST website
JST XH connector crimp contacts have a 3A
current rating per contact (with 0.33mm² cables).
Source: JST website
JST XH connector crimp contacts have the following part numbers:
One source to buy them from is LCSC. They have high base shipping costs so if you just want to buy a couple of contacts, you should rather buy a crimp set on Aliexpress or Amazon, but in larger quantities it’s hard to beat LCSC.
Source: JST website
When trying compile your ESP32 project, you see an error message such as
.pio/libdeps/esp32dev/HumanESPHTTP/src/QueryURLParser.cpp:29:9: error: 'ESP_LOGE' was not declared in this scope ESP_LOGE("Query URL parser", "parsing URL"); ^~~~~~~~
At the top of the file where the error occurs (QueryURLParser.cpp
in this example), add the following line:
#include <esp_log.h>
Typically, one DALI control gear is just a lamp that can be controlled using DALI.
More generally, a control gear can also be a DALI device controlling more than one physical lamp or some similar device. However, if you’re a DALI beginner, it’s much easier to think of control gear as individual lamps controllable by DALI.
In order to directly set the power level for a given control gear (lamp) using DALI, you have to send the following two bytes:
2
0...255
).In order to distinguish between command messages (frames) and DAPC (direct arc power control) messages, remember that the 1st bit must always be 0
for DAPC messages.
For example, if you want to set half brightness level for the lamp with short address 3, send the following bytes:
In order to convert the address byte for a single DALI control gear to an address byte to send over the wire, multiply the short address by 2
and add 1
. The following C macro can be used to compute the address byte:
#define DALI_SHORT_ADDR_TO_ADDR_BYTE(short_addr) (1 + (short_addr << 1))
Since the 1st bit is set (by adding 1), this will activate command mode, i.e. the control gear expects a command byte as data byte for the DALI message.
While trying to use TLS such as MQTTS or HTTPS on the ESP32, you see an error message like
E (333183) MQTT_CLIENT: mqtt_message_receive: transport_read() error: errno=119 [328153][E][MyMQTT.cpp:80] log_error_if_nonzero(): [MQTT] Last error reported from esp-tls: 0x8008 E (333191) MQTT_CLIENT: mqtt_process_receive: mqtt_message_receive() returned -1
0x8008
means ESP_ERR_ESP_TLS_TCP_CLOSED_FIN
. In other words, a TCP connection had been established successfully but unexpectedly, the connection has been closed by the server.
This is often caused by the server software crashing, or restarting in some way. When a server process is terminated, the operating system will cleanup after it and close all connections.
In order to debug the issue, start by checking the log of your server message and/or system log to check for unintended crashes. If that doesn’t help, it’s sometimes helpful to packet capture the communication between the ESP32 and the server. You can also write a software script doing the same communication with the server as the ESP32. This will often allow you to try out changes much more easily than on the microcontroller and observe what’s happening using a debugger.
Your ESP32 running a MQTT client is printing the following error messages:
E (285025) TRANSPORT_WS: Sec-WebSocket-Accept not found E (285025) MQTT_CLIENT: Error transport connect
You’re using MQTT over websockets (ws://
or wss://
) but on the given MQTT URL, no MQTT-over-websocket server is running.
This is often caused by using a wrong URL (possibly the URL is missing the path), but it might also be caused by a misconfiguraton of the server or the reverse proxy.
It’s often best to try using a software websocket client to test the correct settings.
While trying to use TLS such as MQTTS or HTTPS on the ESP32, you see an error message like
[MQTT] Last error reported from esp-tls: 0x8001
0x8001 means ESP_ERR_ESP_TLS_CANNOT_RESOLVE_HOSTNAME
. In other words, the ESP32 is unable to resolve the hostname of the host you’re trying to connect to using DNS.
Typically, this is a DNS problem, so check the DNS settings of your network. Also check if the ESP32 has a correct DNS server set – for example, if the ESP32 has 0.0.0.0
as a DNS server, this explains why it isn’t able to resolve the hostname.
Sometimes this issue is also caused by the hostname not existing at all (i.e. there is no DNS entry for that hostname). You can easily check this by resolving the hostname you’re trying to connect
You can use the UliEngineering library to compute the output voltage of a voltage divider by its top resistor, bottom resistor and its input voltage:
from UliEngineering.Electronics.VoltageDivider import * # Voltage divider with 1MΩ and 150kΩ resistors & 24V input voltage print(voltage_divider_voltage("1MΩ", "150kΩ", "24V")) # Print 3.1304347826086953
You can also directly format this voltage using auto_format()
:
from UliEngineering.EngineerIO import auto_format # Print formatted as volts print(auto_format(voltage_divider_voltage, "1MΩ", "150kΩ", "24V")) # Prints "3.13 V"
As for most components, LCSC has the best prices if you want to order more than just a few MOSFETs (due to the high shipping fees)
These are mostly SOT23-3, so the don’t provide good power dissipation. These are mostly used for switching voltages on and off and not for linear applications.
As for most parts, if you order more than just a few, LCSC is the cheapest source of these components (however, you need to consider the rather expensive shipping costs).
The prices given are for budgetary purposes only.
This example shows you how to make a selectable output voltage (3.3V / 5V / 12V) switching voltage regulator using the AP63200WU (2A current capability – but the approach works with any adjustable voltage regulator). The voltage can be selected using a three-way jumper.
The main trick here is to change the feedback network when selecting the output voltage.
One major mistake is to design the regulator so it doesn’t operate safely when the jumper is removed (for example, the output voltage goes to 12V or even up to the input voltage when no jumper is connected). In our circuit, when no jumper is used, the output voltage is 3.3V. We achieve this by using selectable (& optional) resistors in parallel to the bottom feedback resistor. The 3.3V feedback resistor is fixed.
Using a selectable-in-parallel-to-bottom-FB-resistor topology will always guarantee that the lowest output voltage will be selected when none of the optional parallel resistors are active.
You can use the UliEngineering library to compute the larmor frequency for a given magnetic field in Tesla using Python.
from UliEngineering.Physics.MagneticResonance import * # Default is to compute the Larmor frequency for hydrogen (H1 nucleus) # Print frequency [Hz] for a 1.0 T magnetic field print(larmor_frequency(1.0)) # Prints 42576384.74 # Compute for another nucleus like He3 print(larmor_frequency(1.0, nucleus_larmor_frequency=NucleusLarmorFrequency.He3)) # Prints 32434099.42
You can also directly format this frequency using auto_format()
:
# Format frequency from UliEngineering.EngineerIO import auto_format print(auto_format(larmor_frequency, 1.0)) # Prints "42.6 MHz"
The base excitation frequency (for hydrogen) is:
63.87 MHz
for 1.5 Tesla MRI scanners127.74 MHz
for 3 Tesla MRI scannersNote that the excitation frequency is not exactly one frequency but varies spatially based on the gradient field strength.
You can calculate the excitation frequency using
Excitation frequency [MHz] = 42.58 MHz/T * [magnetic field strength in Tesla]
For more info, see mriquestions.com
Only two pins on the ESP32-S2 are capable of being DAC outputs:
GPIO23
is DAC_1
GPIO24
is DAC_2
Source: ESP32-S2 datasheet
You can use the LEDC timer (typically used for PWM) to output a 50% duty cycle clock with 3.3V P-P amplitude on any output-capable GPIO pin.
First,
#include <driver/ledc.h>
then setup the timer. You only need to do this once on startup, no code in your loop function is required.
/** * Setup 2.048MHz clock output on GPIO33 */ ledc_timer_config_t ledc_timer = { .speed_mode = LEDC_HIGH_SPEED_MODE, .bit_num = LEDC_TIMER_2_BIT, .timer_num = LEDC_TIMER_0, .freq_hz = 2048000 }; ledc_channel_config_t ledc_channel = { .gpio_num = GPIO_NUM_33, .speed_mode = LEDC_HIGH_SPEED_MODE, .channel = LEDC_CHANNEL_0, .timer_sel = LEDC_TIMER_0, .duty = 2 }; ledc_timer_config(&ledc_timer); ledc_channel_config(&ledc_channel);
The ESP32 DAC has a built-in cosine waveform generator. Even though it’s an 8-bit DAC, the waveform looks pretty clean.
For an example on how to generate this wavefrm in firmware, see How to use the ESP32 DAC sine/cosine waveform generator using Arduino / PlatformIO
The ESP32 and its derivatives such as the ESP32-S2 have a built-in sine/cosine waveform generator for the built-in 8-bit DAC.
Using it requires ESP-IDF v5.1+ (see the official example). Using it with Arduino is slightly harder, since the stable version of the arduino-esp32
framework at the time of writing this post is based on ESP-IDF v4.4 which does not provide the DAC cosine generator API.
Therefore, we have to explicitly specify the arduino-espressif32
version (git commit) in platformio.ini
:
[env:esp32dev] platform = espressif32 # Commit f9cddfde697b659b9e818ec514f1505d2bd4a8ae is branch esp-idf-v5.1-libs @2022-02-01 platform_packages = framework-arduinoespressif32 @ https://github.com/espressif/arduino-esp32.git#f9cddfde697b659b9e818ec514f1505d2bd4a8ae board = esp32dev framework = arduino
The example main source code is pretty simple:
#include <Arduino.h> #include <driver/dac_cosine.h> void setup() { dac_cosine_handle_t chan0_handle; dac_cosine_config_t cos0_cfg = { .chan_id = DAC_CHAN_1, // GPIO26 .freq_hz = 1000, .clk_src = DAC_COSINE_CLK_SRC_DEFAULT, .atten = DAC_COSINE_ATTEN_DEFAULT, .phase = DAC_COSINE_PHASE_0, .offset = 0, //.flags.force_set_freq = false, }; ESP_ERROR_CHECK(dac_cosine_new_channel(&cos0_cfg, &chan0_handle)); ESP_ERROR_CHECK(dac_cosine_start(chan0_handle)); } void loop() { // put your main code here, to run repeatedly: delay(1000); }
If you want to see how the generated waveform looks on an oscilloscope, see How does the ESP32 DAC cosine generator waveform look on an Oscilloscope?
On the MAX11200EEE+
and the MAX112100EEE+
, bit 3 of the command byte is named IMPD
but this bit is never described in detail in the datasheet.
The meaning of this bit is Immediate power-down
. When you set it to 1
, the IC will switch to power-down mode. This is evidenced by the power-down example in Table 8
in the datasheet.