Important Note:
The errata listed here applies only to revision 1 of the book.
Revision 2 was published on 29 December 2024 and has all of these errors corrected.
Errata
Page 157
change
Stepperbi stepper1=Stepperbi(); void loop() { stepper1.step(1); delay(10); }
to
Stepperbi stepper1=Stepperbi(16); void loop() { stepper1.step(1); delay(10); } void setup(){};
Page 254
Change
void setup() { Serial.begin(9600); Serial1.begin(9600, SERIAL_8N1, 2, 1); Serial1.setTimeout(30); } void loop() { char buffer[100]; Serial1.write("Hello World\n"); int len = Serial1.readBytes(buffer, 100); buffer[len] = NULL; Serial.printf("\nrecieved data: %s\n", buffer); while (true) {}; }
to
void setup() { Serial.begin(9600); Serial1.begin(9600, SERIAL_8N1, 2, 1); Serial1.setTimeout(30); } void loop() { char buffer[100]; Serial1.write("Hello World\n"); int len = Serial1.readBytes(buffer, 100); buffer[len] = NULL; Serial.printf("\nreceived data: %s\n", buffer); delay(1000); }
i.e. change the final loop for delay and correct spelling
Chapter 14
Use pins GPIO12 and GPIO13 for rx and tx rather than GPIO2 and GPIO3 thoughout - GPIO2 is a strapping pin
and sometimes changes the boot mode of the ESP32 on startup. Also connect GPIO12 to GPIO13 for loopback.
That is change:
Serial1.begin(9600, SERIAL_8N1, 2, 1);
to
Serial1.begin(9600, SERIAL_8N1, 12, 13);
Page 258, 259, 263, 274, 275, 281, 282, 284, 304, 307
Some ESP32 devices do not change baud rate from upload until loop is called.
This is a bug but a simple fix is to set the baud rate a second time and wait.
That is change
void setup() {
Serial.begin(9600);
to
void setup() {
Serial.begin(9600);
delay(2000);
Serial.begin(9600);
Page 283
Change
void wifiConnect(char* ssid, char* password) { WiFi.onEvent(WiFiEvent); status = WiFi.begin("ssid", "password"); }
to
void wifiConnect(char* ssid, char* password) { WiFi.onEvent(WiFiEvent); status = WiFi.begin(ssid, password); }
Remove quotes from ssid and password.
Page 347
Change
printf("%llX\n", count);
to
Serial.printf("%llX\n", count);
Page 351
Change
printf("%llX %d\n", data,uxQueueSpacesAvailable(q));
to
Serial.printf("%llX %d\n", data,uxQueueSpacesAvailable(q));
Important Note:
The errata listed here applies only to revision 2 of the book.
Revision 2 was published on 29 December 2024 and has all of these errors corrected.
Errata for Revision 1 can be found here.
Errata
Page 155
change
State GPIO lines
s0 {1, 0, 0, 0} s1 {1, 1, 0, 0} s2 {0, 1, 0, 0} s3 {0, 1, 1, 0} s4 {0, 0, 1, 0} s5 {0, 0, 1, 1} s6 {0, 0, 0, 1} s7 {1, 0, 0, 1}
to
A A- B B-
s0 {1, 0, 0, 0} s1 {1, 0, 1, 0} s2 {0, 0, 1, 0} s3 {0, 1, 1, 0} s4 {0, 1, 0, 0} s5 {0, 1, 0, 1} s6 {0, 0, 0, 1} s7 {1, 0, 0, 1}
Errata
Page 83
self.finished.set() the final line is superfluous
Page 114
Change
myCond = Condition()
.to
Co = Condition()
Errata
Page 19
change
There are also DevKitM variants which differ in a few pin positions. All of the diagrams in this book use the C3 so make sure the development board you use has the same pin arrangement.
to
There are also DevKitM variants which differ in a few pin positions. All of the diagrams in this book use the ESP32 and ESP32 S3 C development boards so make sure the development board you use has the same pin arrangement.
Page 205
change
GPIOn → A, GPIOn+1 → B, GPIOn+2 → A- and GPIOn+3 → B-
to
GPIOn → B-, GPIOn+1 → A-, GPIOn+2 → B and GPIOn+3 → A
Page 210
change
To try either version of the program you need an H‑bridge connected so that GPIO 15 is A, GPIO 16 is B, GPIO 17 is A- and GPIO 18 is B-.
To
To try either version of the program you need an H‑bridge connected so that GPIO 19 is A, GPIO 18 is B, GPIO 17 is A- and GPIO 16 is B- .
also correct the diagram so that the GPIO lines are (from the top) GP16, GP18, GP17 and GP19 , i.e. swap GP18 and GP17
Page 234
change
spi=SPI(1,sck=Pin(14),miso=Pin(12),mosi=Pin(13))
spi.init(baudrate=500_000, bits=8, polarity=0, phase=0,
firstbit=SPI.MSB)
CS = Pin(15, Pin.OUT)
CS.on()
To
spi_bus_config_t busConfig = {
.sclk_io_num = 14,
.mosi_io_num = 13,
.miso_io_num = 12,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
};
spi_bus_initialize(SPI2_HOST, &busConfig, SPI_DMA_DISABLED);
spi_device_interface_config_t masterConfig = {
.command_bits = 0,
.address_bits = 0,
.dummy_bits = 0,
.mode = 0,
.queue_size = 10,
.clock_speed_hz = 500000,
.spics_io_num = 15,
};
spi_device_handle_t SPI = NULL;
spi_bus_add_device(SPI2_HOST, &masterConfig, &SPI);
Page 272
Change
ESP32 |
HTU21 |
---|---|
SDA GPIO18 |
SDA/DA |
SCK GPIO17 |
SCL/CL |
3.3v |
VCC/VIN/+ |
GND |
GND/- |
To
ESP32 |
HTU21 |
---|---|
SDA GPIO16 |
SDA/DA |
SCK GPIO15 |
SCL/CL |
3.3v |
VCC/VIN/+ |
GND |
GND/- |
Ie change 18 and 17 to 16 and 15.
Page 334
middle of page
int n = 4252;
change to
int n = 252;
Page 340
replace
The biggest complication in using flow control with the ESP32 is that the RTS signal is linked to the Rx FIFO buffer and not the Rx ring buffer. What this means is that the ESP32 will send a signal to stop the transmission when its FIFO buffer is full, even though there might be lots of space in the ring buffer.
with
The biggest complication in using flow control with the ESP32 is that the RTS signal is linked to the Rx FIFO buffer and not the Rx ring buffer. What this means is that the ESP32 will send a signal to stop the transmission when its FIFO buffer is full, even though there might be lots of space in the ring buffer. Another complication is that data is transferred to the Rx Ring buffer, which has to be at least as big as the FIFO buffer, usually 128 bytes, and the FIFO buffer starts sending data at once. This means that the RX FIFO buffer is emptying as incoming data is trying to fill it. This means that the number of bytes it can receive before reaching the threshold is more than you might have guessed.
This is a clarification rather than an error.
Page 342
Change
nt = uart_read_bytes(UART_NUM_2, &RecData[nr],
sizeof(RecData - nr), 30 / portTICK_PERIOD_MS);
to
nt = uart_read_bytes(UART_NUM_2, &RecData[nr],
sizeof(RecData) - nr, 50 / portTICK_PERIOD_MS);
That is move the bracket.and change 30 to 50
Page 343
change
Also notice that the way that the FIFO and ring buffers interact complicates the picture. The data from the FIFO buffer is transferred to the ring buffer, which has to fill before the FIFO buffer fills and sets RTS low. The result is that the data is received in blocks of 354 bytes rather than 128 bytes. When the RX FIFO is full, defined by the 50-byte rx_flow_ctrl_thresh field, the transmission from the TX FIFO stops emptying, but it too is kept topped up from the TX ring buffer and so, as soon as the RTS line returns high, it starts sending data again. In this way all of the data is sent.
to
Also notice that the way that the FIFO and ring buffers interact complicates the picture. The data from the FIFO buffer is transferred to the ring buffer, which has to fill before the FIFO buffer fills and sets RTS low. The result is that the data is received in an initial block of 350 bytes rather than 128 bytes. When the RX FIFO is full, defined by the 50-byte rx_flow_ctrl_thresh field, the transmission from the TX FIFO stops emptying, but it too is kept topped up from the TX ring buffer and so, as soon as the RTS line returns high, it starts sending data again. In this way all of the data is sent.
That is change 354 to 350
Errata
Page 85 (Spotted by Federico Arismendi - thanks!)
The line
['harry', 'ian', 'lucy', 'mike', 'sue']
should be
['sue', 'ian', 'mike', 'lucy', 'harry']
A copy and paste error.
Page 1 of 2