Arduino V Machine Learning Steven Barrett PDF Download
Arduino V Machine Learning Steven Barrett PDF Download
download
https://ebookbell.com/product/arduino-v-machine-learning-steven-
barrett-47440834
https://ebookbell.com/product/tinyml-machine-learning-with-tensorflow-
on-arduino-and-ultralow-power-microcontrollers-daniel-
situnayake-10679310
https://ebookbell.com/product/iot-machine-learning-applications-in-
telecom-energy-and-agriculture-with-raspberry-pi-and-arduino-using-
python-1st-edition-puneet-mathur-50195440
https://ebookbell.com/product/arduino-i-getting-started-steven-f-
barrett-46867338
https://ebookbell.com/product/arduino-iv-diy-robots-3d-printing-
instrumentation-and-control-tyler-kerr-47229038
Arduino A Beginners Guide To Arduino Programming 1st Edition George
Gibson
https://ebookbell.com/product/arduino-a-beginners-guide-to-arduino-
programming-1st-edition-george-gibson-48621802
https://ebookbell.com/product/arduino-for-dummies-1st-edition-john-
nussey-48672310
https://ebookbell.com/product/arduino-sketches-tools-and-techniques-
for-programming-wizardry-1st-edition-james-a-langbridge-48672312
https://ebookbell.com/product/arduino-in-easy-steps-stuart-
yarnold-50317872
https://ebookbell.com/product/arduino-project-handbook-mark-
geddes-50317882
Synthesis Lectures on
Digital Circuits & Systems
Steven F. Barrett
Arduino V:
Machine Learning
Synthesis Lectures on Digital Circuits &
Systems
Series Editor
Mitchell A. Thornton, Southern Methodist University, Dallas, USA
This series includes titles of interest to students, professionals, and researchers in the
area of design and analysis of digital circuits and systems. Each Lecture is self-contained
and focuses on the background information required to understand the subject matter and
practical case studies that illustrate applications. The format of a Lecture is structured
such that each will be devoted to a specific topic in digital circuits and systems rather
than a larger overview of several topics such as that found in a comprehensive handbook.
The Lectures cover both well-established areas as well as newly developed or emerging
material in digital circuits and systems design and analysis.
Steven F. Barrett
Arduino V: Machine
Learning
Steven F. Barrett
Department of Electrical and Computer
Engineering
University of Wyoming
Laramie, WY, USA
© The Editor(s) (if applicable) and The Author(s), under exclusive license to Springer Nature Switzerland AG
2023
This work is subject to copyright. All rights are solely and exclusively licensed by the Publisher, whether the whole
or part of the material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information storage
and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or
hereafter developed.
The use of general descriptive names, registered names, trademarks, service marks, etc. in this publication does
not imply, even in the absence of a specific statement, that such names are exempt from the relevant protective
laws and regulations and therefore free for general use.
The publisher, the authors, and the editors are safe to assume that the advice and information in this book are
believed to be true and accurate at the date of publication. Neither the publisher nor the authors or the editors give
a warranty, expressed or implied, with respect to the material contained herein or for any errors or omissions that
may have been made. The publisher remains neutral with regard to jurisdictional claims in published maps and
institutional affiliations.
This Springer imprint is published by the registered company Springer Nature Switzerland AG
The registered company address is: Gewerbestrasse 11, 6330 Cham, Switzerland
Preface
This book is about the Arduino microcontroller and the Arduino concept. The visionary
Arduino team of Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and
David Mellis launched a new innovation in microcontroller hardware in 2005, the concept
of open-source hardware. Their approach was to openly share details of microcontroller-
based hardware design platforms to stimulate the sharing of ideas and promote innovation.
This concept has been popular in the software world for many years. In June 2019, Joel
Claypool and I met to plan the fourth edition of “Arduino Microcontroller Processing
for Everyone!” Our goal has been to provide an accessible book on the rapidly evolv-
ing world of Arduino for a wide variety of audiences including students of the fine arts,
middle and senior high school students, engineering design students, and practicing sci-
entists and engineers. To make the book even more accessible to better serve our readers,
we decided to change our approach and provide a series of smaller volumes. Each vol-
ume is written to a specific topic and audience. This book, “Arduino V: AI and Machine
Learning”, explores Arduino applications in the fascinating and rapidly evolving world
of small, local microcontroller-based AI and ML applications. The first three chapters
explore the Arduino IDE, the Arduino Nano 33 BLE Sense, and sensor and periph-
eral interface techniques. In the remaining three chapters, we take a tutorial approach to
Artificial Intelligence (AI) and Machine Learning (ML) concepts appropriate for imple-
mentation on a microcontroller including: K Nearest Neighbors (KNN), Decision Trees,
Fuzzy Logic, Perceptrons, and Artificial Neural Nets (ANN).
This book is part of a multi-volume introduction to the Arduino line of processors. The
book series also serves as the “fourth edition” of “Arduino Microcontroller Processing
for Everyone!” When discussing plans for a fourth edition, Joel Claypool and I (sfb)
decided to break the large volume up into a series of smaller volumes to better serve
the needs and interests of our readers. I have tried to strike a balance between each
volume being independent of one another while holding to a minimum of information
v
vi Preface
contained in other volumes. For completeness and independence, this volume contains
tutorial information on getting started, microcontroller interface information, and motor
control partially contained in some of the other volumes and related works completed
for Morgan and Claypool and Springer Nature. I have identified via chapter footnotes
the source of this information contained elsewhere in the series. The book series thus far
includes:
1 We emphasize throughout the book that this is a 3.3 VDC processor. Processor inputs and outputs
must not exceed 3.3 VDC!
viii Preface
the realm of AI, we explore Fuzzy Logic in Chap. 5. In Chap. 6, we explore the percep-
tron and Artificial Neural Networks (ANNs). Deep Learning involves the development
of algorithms using multi-layer Artificial Neural Networks (ANN). We conclude Chap. 6
with a brief introduction to advanced AI and ML deep learning tools and applications.
References
1. Arduino Team, Get started with machine learning on Arduino, blog.arduino.cc, October 15, 2019.
2. Arduino Nano 33 BLE Sense, ABX00031, January 5, 2022, www.arduino.cc
3. G. Lawton, Machine Learning on Microcontrollers Enables AI, targettech.com, November 17,
2021.
4. nRF52840 Advanced multi--protocol System--on--Chip, nRF52840 Product Brief Version 1.0,
Nordic Semiconductor.
5. J.P. Mueller and L. Massaron, Artificial Intelligence for Dummies, John Wiley and Sons, Inc,
2018.
6. C. Pickover, Artificial Intelligence an Illustrated History, Sterling, New York, 2019.
Acknowledgments
A number of people have made this book possible. I would like to thank Massimo Banzi
of the Arduino design team for his support and encouragement in writing the first edition
of this book: “Arduino Microcontroller: Processing for Everyone!”
I would also like to acknowledge Joel Claypool for his publishing expertise and support
to a number of writing projects. His vision and expertise in the publishing world has made
this book possible. Joel “retired” in September 2022 after 40 plus years of service to the
U.S. Navy and the publishing world. On behalf of the multitude of writers you have
provided a chance to become published authors, we thank you! The next adventurous
chapter in Joel’s life begins with an upcoming hurricane relief effort service trip. I dedicate
this book to you my friend.
I would also like to thank Dharaneeswaran Sundaramurthy of Total Service Books
Production for his expertise in converting the final draft into a finished product.
Finally, as most importantly, I would like to thank my wife and best friend of many
(almost 50) years, Cindy.
ix
Contents
1 Getting Started . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 The Big Picture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.3 Arduino Quickstart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.1 Quick Start Guide . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.3.2 Arduino Development Environment Overview . . . . . . . . . . . . . . . . 6
1.3.3 Sketchbook Concept . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.3.4 Arduino Software, Libraries, and Language References . . . . . . . . 7
1.3.5 Writing an Arduino Sketch . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1.4 Application: LED Strip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
1.5 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
1.6 Problems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
2 Arduino Nano 33 BLE Sense . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.1 Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
2.2 Arduino Nano 33 BLE Sense SoC Board . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.3 Arduino Nano 33 BLE Sense Features . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.4 NINA B306 Module Subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4.1 B306 Module Memory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5 NINA B306 Module Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
2.5.1 Pulse Width Modulation (PWM) Channels . . . . . . . . . . . . . . . . . . . 22
2.5.2 Serial Communications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
2.5.3 Bluetooth Low Energy (BLE) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35
2.6 Nano 33 BLE Sense Peripherals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43
2.6.1 Nine Axis IMU (LSM9DS1) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
2.6.2 Barometer and Temperature Sensor (LPS22HB) . . . . . . . . . . . . . . 46
2.6.3 Relative Humidity and Temperature Sensor (HTS221) . . . . . . . . . 47
2.6.4 Digital Proximity, Ambient Light, RGB, and Gesture
Sensor (APDS–9960) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
xi
xii Contents
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
About the Author
Steven F. Barrett, Ph.D., P.E., received the BS Electronic Engineering Technology from
the University of Nebraska at Omaha in 1979, the M.E.E.E. from the University of Idaho
at Moscow in 1986, and the Ph.D. from The University of Texas at Austin in 1993. He
was formally an active duty faculty member at the United States Air Force Academy,
Colorado and is now the Vice Provost of Undergraduate Education at the University of
Wyoming and Professor of Electrical and Computer Engineering. He is a member of IEEE
(Life Senior) and Tau Beta Pi (chief faculty advisor). His research interests include digital
and analog image processing, computer-assisted laser surgery, and embedded controller
systems. He is a registered Professional Engineer in Wyoming and Colorado. He co-wrote
with Dr. Daniel Pack several textbooks on microcontrollers and embedded systems. In
2004, Barrett was named “Wyoming Professor of the Year” by the Carnegie Foundation
for the Advancement of Teaching and in 2008 was the recipient of the National Society of
Professional Engineers (NSPE) Professional Engineers in Higher Education, Engineering
Education Excellence Award.
xv
Getting Started
1
Objectives: After reading this chapter, the reader should be able to do the following:
• Successfully download and execute a simple program using the Arduino Development
Environment; and
• Describe the key features of the Arduino Development Environment.
1.1 Overview
Welcome to the world of Arduino!1 The Arduino concept of open source hardware was
developed by the visionary Arduino team of Massimo Banzi, David Cuartilles, Tom Igoe,
Gianluca Martino, and David Mellis in Ivrea, Italy. The team’s goal was to develop a line of
easy–to–use microcontroller hardware and software such that processing power would be
readily available to everyone.
In this chapter we provide a brief review of the Arduino Development Environment
and Arduino sketch writing. We use a top–down design approach. We begin with the “big
picture” of the chapter. We then discuss the Arduino Development Environment and how it
may be used to quickly develop a program (sketch) for the Arduino Nano 33 BLE Sense.
Most microcontrollers are programmed with some variant of the C programming language.
The C programming language provides a nice balance between the programmer’s control
of the microcontroller hardware and time efficiency in program (sketch) writing. As an
1 This chapter is included for completeness with permission from “Arduino I: Getting Started.”.
computer
Arduino Development
Environment
Micro-B USB
Fig. 1.1 Programming the Arduino processor board. Arduino illustrations used with permission of
the Arduino Team (CC BY–NC–SA) (www.arduino.cc)
To get started using an Arduino–based platform, you will need the following hardware and
software:
The Arduino Development Environment may be downloaded from the Arduino website’s
at www.arduino.cc. Versions are available for Windows, Mac OS X, and Linux. Provided
below is a quick start step–by–step approach to blink an onboard LED.
//*****************************************************************
#define LED_PIN 13
void setup()
{
pinMode(LED_PIN, OUTPUT); //set digital pin to output
}
void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(500); //delay specified in ms
digitalWrite(LED_PIN, LOW);
delay(500);
}
//*****************************************************************
• Upload and execute the program by asserting the “Upload” (right arrow) button.
• The onboard LED should blink at one second intervals.
The Arduino Nano 33 BLE Sense is equipped with a Red, Green, and Blue (RGB) LEDs.
The following sketch demonstrates how to control each RGB and the Power LED. Note:
The R, G, B LEDs are asserted active low.
//*********************************************************************
//RGB_test
//
//Adapted from Controlling_RGB_and_Power_LED by the Arduino Team
// arduino.cc
//Demonstrates control of the RGB and Power LEDs on the NANO 33 BLE boards
//Note: The R, G, B LEDs are asserted active low.
//**********************************************************************
void setup()
{
pinMode(RED, OUTPUT); //initialize digital pins as output
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(LED_PWR, OUTPUT);
}
void loop()
{
digitalWrite(RED, HIGH); //turn LEDs off
1.3 Arduino Quickstart 5
digitalWrite(GREEN, HIGH);
digitalWrite(BLUE, HIGH);
digitalWrite(LED_PWR, LOW);
delay(1000); //delay 1s
digitalWrite(RED, LOW); //turn RGB LEDs on in sequence
delay(1000);
digitalWrite(RED, HIGH);
delay(1000);
digitalWrite(GREEN, LOW);
delay(1000);
digitalWrite(GREEN, HIGH);
delay(1000);
digitalWrite(BLUE, LOW);
delay(1000);
digitalWrite(BLUE, HIGH);
delay(1000);
digitalWrite(LED_PWR, HIGH);
delay(1000);
}
//**********************************************************************
//**********************************************************************
//RGB_test2
//
//Adapted from Controlling_RGB_and_Power_LED by the Arduino Team
// arduino.cc
//Demnstrates control of the RGB and Power LEDs on the NANO 33 BLE boards
//Note: The R, G, B LEDs are asserted active low.
//
//This sketch uses a function call to set the LED colors.
//**********************************************************************
void setup()
{
pinMode(RED, OUTPUT); //intitialize digital pins as output
pinMode(GREEN, OUTPUT);
pinMode(BLUE, OUTPUT);
pinMode(LED_PWR, OUTPUT);
}
void loop()
{
RGB_set(LOW, HIGH,HIGH); //red
RGB_set(HIGH,LOW, HIGH); //green
RGB_set(HIGH,HIGH, LOW); //blue
6 1 Getting Started
//**********************************************************************
//**********************************************************************
With the Arduino Development Environment downloaded and exercised, let’s take a
closer look at its features.
The Arduino Development Environment is illustrated in Fig. 1.2. The ADE contains a text
editor, a message area for displaying status, a text console, a tool bar of common functions,
and an extensive menuing system. The ADE also provides a user–friendly interface to the
Arduino processor board which allows for a quick upload of code. This is possible because
the Arduino processing boards are equipped with a bootloader program.
1.3 Arduino Quickstart 7
In keeping with a hardware and software platform for students of the arts, the Arduino
environment employs the concept of a sketchbook. An artist maintains their works in progress
in a sketchbook. Similarly, programs are maintained within a sketchbook in the Arduino
environment. Furthermore, we refer to individual programs as sketches. An individual sketch
within the sketchbook may be accessed via the Sketchbook entry under the file tab.
The Arduino Development Environment has a number of built–in features. Some of the
features may be directly accessed via the Arduino Development Environment drop down
toolbar illustrated in Fig. 1.2. Provided in Fig. 1.3 is a handy reference to show the available
features. The toolbar provides a wide variety of features to compose, compile, load and
execute a sketch.
The basic format of the Arduino sketch consists of a “setup” and a “loop” function. The
setup function is executed once at the beginning of the program. It is used to configure pins,
declare variables and constants, etc. The loop function will execute sequentially step–by-
Upload
Verify
List of
sketches
Board
Manager
Library
Manager
Debug
Search
Menu
–step. When the end of the loop function is reached it will automatically return to the first
step of the loop function and execute again. This goes on continuously until the program is
stopped.
//****************************************************************
void setup()
{
//place setup code here
}
void loop()
{
//main code steps are provided here
:
:
//*****************************************************************
1.3 Arduino Quickstart 9
//*****************************************************************
void setup()
{
pinMode(LED_PIN, OUTPUT); //set pin to output
}
void loop()
{
digitalWrite(LED_PIN, HIGH); //write pin to logic high
delay(500); //delay specified in ms
digitalWrite(LED_PIN, LOW); //write to logic low
delay(500); //delay specified in ms
}
//*****************************************************************
In the first line the #define statement links the designator “LED_PIN” to pin 13 on the
Arduino processor board. In the setup function, LED_PIN is designated as an output pin.
Recall the setup function is only executed once. The program then enters the loop function
that is executed sequentially step–by–step and continuously repeated. In this example, the
LED_PIN is first set to logic high to illuminate the LED onboard the Arduino processing
board. A 500 ms delay then occurs. The LED_PIN is then set low. A 500 ms delay then
occurs. The sequence then repeats.
Even the most complicated sketches follow the basic format of the setup function followed
by the loop function. To aid in the development of more complicated sketches, the Arduino
Development Environment has many built–in features that may be divided into the areas of
structure, variables and functions. The structure and variable features follow rules similar
to the C programming language. The built–in functions consists of a set of pre–defined
activities useful to the programmer. These built–in functions are summarized in Fig. 1.4.
There are many program examples available to allow the user to quickly construct a
sketch. These programs are summarized in Fig. 1.5. Complete documentation for these
programs is available at the Arduino homepage (www.arduino.cc). This documentation
is easily accessible via the Help tab on the Arduino Development Environment toolbar.
This documentation will not be repeated here. With the Arduino open source concept, users
throughout the world are constantly adding new built–in features. As new features are added,
they are released in future Arduino Development Environment versions. As an Arduino user,
you too may add to this collection of useful tools. Throughout the remainder of the book
we use both the Arduino Development Environment to program the Arduino Nano 33 BLE
Sense. In the next chapter we get acquainted with the features of the Nano 33.
10 1 Getting Started
Arduino Functions
Arduino Environment
Built-in Programs
Communication
Digital Input/Output Analog Input/Output Control Structures Sensors - ASCII Table
- Blink (under Basics) - Analog InOut Serial - Array - ADX3xx accelerometer - Dimmer
- Blink without delay - Analog Input - For loop interation - Knock detector - Graph
- Button - Analog Write Mega - If statement - Memsic2125 two-axis - MIDI
- Debounce - Calibration conditional accelerometer - MultiSerial
- Digital Input Pullup - Fading - Switch case - Ping ultrasonic range - Physical pixel
- State Change - Smoothing - Switch case 2 finder - Read ASCII String
Detection - While statement - Serial call response
- tone Keyboard conditional - Serial call response
ASCII
- tone Melody
- Serial Event
- tone Multiple - Serial Passthrough
- tone Pitch Follower - Virtual color mixer
Multiple Libraries
- Strings
- USB
- LCD
- Robot Control
- Robot Motor
- SD card
- Servo
- Stepper
:
Example: LED strips may be used for motivational (fun) optical displays, games, or for
instrumentation–based applications. In this example we control an LPD8806–based LED
strip using the Arduino Nano 33 BLE sense. We use a three meter, 96 RGB LED strip
available from Adafruit (#306) for approximately $30 USD per meter (www.adafruit.com).
The red, blue, and green component of each RGB LED is independently set using an
eight–bit code. The most significant bit (MSB) is logic one followed by seven bits to set the
LED intensity (0 to 127). The component values are sequentially shifted out of the Arduino
33 BLE Sense using the Serial Peripheral Interface (SPI) features as shown in Fig. 1.6a. We
discuss the SPI subsystem in the next chapter.
The first component value shifted out corresponds to the LED nearest the microcontroller.
Each shifted component value is latched to the corresponding R, G, and B component of the
Fig. 1.6 Nano 33 BLE Sense controlling an LED strip. LED strip illustration used with permission of
Adafruit (www.adafruit.com). Nano 33 BLE Sense illustration used with permission of the Arduino
Team (CC BY–NC–SA) (www.arduino.cc)
12 1 Getting Started
LED. As a new component value is received, the previous value is latched and held constant.
An extra byte is required to latch the final parameter value. A zero byte (00)16 is used to
complete the data sequence and reset back to the first LED (www.adafruit.com).
Only four connections are required between the Nano 33 and the LED strip as shown
in Fig. 1.6. The connections are color coded: red–power, black–ground, yellow–data, and
green–clock. It is important to note the LED strip requires a supply of 3.3 VDC and a current
rating of 2 amps per meter of LED strip.
In this example each RGB component is sent separately to the strip. The example illus-
trates how each variable in the program controls a specific aspect of the LED strip. Here are
some important implementation notes:
• SPI must be configured for most significant bit (MSB) first.
• LED brightness is seven bits. Most significant bit (MSB) must be set to logic one.
• Each LED requires a separate R–G–B intensity component. The order of data is G–R–B.
• After sending data for all LEDs. A byte of (0x00) must be sent to return the strip to the
first LED.
• Data stream for each LED is: 1–G6–G5–G4–G3–G2–G1–G0–1–R6–R5–R4–R3–R2–
R1–R0–1–B6–B5–B4–B3–B2–B1–B0
//***********************************************************************
//RGB_led_strip_tutorial: illustrates different variables within
//RGB LED strip
//
//LED strip LDP8806 - available from \url{www.adafruit.com} (#306)
//
//Connections:
// - External 3.3 VDC supply, 2A per LED meter - red
// - Ground - black - include common ground with Nano BLE Sense
// - Serial Data In - Arduino pin 29 (MOSI pin)- yellow
// - CLK Arduino pin 1 (SCK pin)- green
//
//Variables:
// - LED_brightness - set intensity from 0 to 127
// - segment_delay - delay between LED RGB segments
// - strip_delay - delay between LED strip update
//
//Notes:
// - SPI must be configured for Most Significant Bit (MSB) first
// - LED brightness is seven bits. Most Significant Bit (MSB)
// must be set to logic one
// - Each LED requires a separate R-G-B intensity component. The order
// of data is G-R-B.
// - After sending data for all strip LEDs. A byte of (0x00) must
// be sent to return strip to first LED.
// - Data stream for each LED is:
//1-G6-G5-G4-G3-G2-G1-G0-1-R6-R5-R4-R3-R2-R1-R0-1-B6-B5-B4-B3-B2-B1-B0
//
//This example code is in the public domain.
//********************************************************************
1.4 Application: LED Strip 13
#include <SPI.h>
void setup()
{
SPI.begin(); //SPI support functions
}
void loop()
{
SPI.beginTransaction(SPISettings(200000, MSBFIRST, SPI_MODE3));
SPI.transfer(LED_strip_latch); //reset to first segment
clear_strip(); //all strip LEDs to black
delay(50);
delay(strip_delay);
}
//****************************************************************
void clear_strip(void)
{
//clear strip
for(position = 0; position<strip_length; position = position+1)
{
SPI.transfer(0x80 | 0x00); //Green - none
SPI.transfer(0x80 | 0x00); //Red - none
SPI.transfer(0x80 | 0x00); //Blue - none
}
SPI.transfer(LED_strip_latch); //Latch with zero
delay(200); //clear delay
}
//******************************************************
1.5 Summary
The goal of this chapter is to provide an introduction and tutorial on the Arduino IDE. We
used a top–down design approach. We began with the “big picture” of the chapter followed
by an overview of the Arduino Development Environment.
References 15
1.6 Problems
1. Describe the steps in writing a sketch and executing it on an Arduino processing board.
2. What is the serial monitor feature used for in the Arduino Development Environment?
3. Describe what variables are required and returned and the basic function of the following
built–in Arduino functions: Blink, Analog Input.
4. What is meant by the term open source?
5. The RGB LEDs onboard the Nano 33 BLE are active low. What does this mean?
6. Be creative! Modify the sketch controlling the strip LEDs to generate a different pattern.
Have fun!
References
Objectives: After reading this chapter, the reader should be able to do the following:
• Name and describe the different subsystem peripherals onboard the Nordic Semiconduc-
tor nRF52840 processor;
• Name and describe the different features aboard the Arduino Nano 33 BLE Sense board;
• In your own words describe the background theory of operation for subsystems onboard
the nRF52840 processor and Arduino Nano 33 BLE Sense board; and
• Use the Arduino IDE to program and execute sketches for subsystems onboard the
nRF52840 processor and Arduino Nano 33 BLE Sense board.
2.1 Overview
In this chapter we explore the Arduino Nano 33 BLE Sense SoC board and its nRF52840
processor. We begin with an overview of the Arduino Nano 33 BLE Sense SoC board
features. We then examine the powerful and well–equipped nRF52840 processor and its
associated peripheral subsystems. We then investigate the multiple peripherals onboard the
Nano 33 BLE Sense SoC board. For all peripherals we provide a brief theory of operation,
feature overview, and examples. We conclude the chapter with an extended example featuring
a Bluetooth BLE application–a greenhouse monitoring system.1
1 Portions of the theory provided in the chapter was adapted with permission from “Arduino I: Getting
Started, S. Barrett, Morgan & Claypool Publishers, 2020.
The Arduino Nano 33 BLE Sense SoC board is illustrated in Fig. 2.1. The Nano 33 is a 3.3
VDC processor. Working clockwise from the left, the board is equipped with a Micro–B
USB connector to allow programming the processor from a host personal computer (PC) or
laptop.
The board is equipped with a series of LEDs including the Power LED (L2), the Red,
Green, Blue (RGB) LEDs (DL3), and the Built–In LED (L1). As we experienced in Chap. 1,
these LEDs are accessible via designated pins.
The Arduino Nano 33 BLE Sense SoC board is equipped with a rich complement of
sensors including the (ABX00031):
to host PC NINA-B306
via Micro-B module
USB cable BLE 5.0
module
Fig. 2.1 Arduino Nano 33 BLE Sense SoC board layout. (Figure adapted and used with permission
of Arduino Team (CC BY–NC–SA)(www.arduino.cc).)
2.3 Arduino Nano 33 BLE Sense Features 19
Onboard the Nano 33 board is the NINA B306 Module. It contains the Nordic Semi-
conductor nRF52840 processor. This is a 32–bit processor, operating at 64 MHz, with an
ARM Cortex–M4F architecture equipped with a floating point unit (FPU). The processor
is equipped with 1 MB of flash memory and 256 kB of Random Access Memory (RAM)
(nRF52840).
The Nano 33 BLE provides a tremendous amount of computing power in a very small
footprint. The processing power coupled with its peripherals and sensor package provides a
microcontroller ideally suited for AI and ML applications.
The B306 module is also equipped with a large complement of resident peripherals
including (ABX00031):
Access to these subsystems are via the Arduino Nano 33 BLE Sense SoC board pins as
shown in Fig. 2.2.
With the brief overview of the Arduino Nano 33 BLE Sense board complete, we take an
in–depth look at selected features and subsystems. As described in the previous section, we
partition features related to the NINA B306 Module from the Arduino Nano 33 BLE Sense
as shown in Fig. 2.3. We begin with an exploration of NINA B306 Module subsystems
followed by Arduino Nano 33 BLE Sense subsystems. For each subsystem we provide
related technical information and examples where appropriate.
20 2 Arduino Nano 33 BLE Sense
1. D13, digital, SPI SCK, GPIO 30. D12/MISO, D, SPI MISO, GPIO
2. +3V3, power out to ext devices 29. D11/MOSI, D, SPI MOSI, GPIO
3. AREF, A, analog reference, GPIO 28. D10/PWM, D, GPIO, PWM
4. A0/DAC0, ADC in/DACout, GPIO 27. D9/PWM, D, GPIO, PWM
5. A1, A, ADC in, GPIO 26. D8, D, GPIO
6. A2, A, ADC in, GPIO 25. D7, D, GPIO
7. A3, A, ADC in, GPIO 24. D6/PWM, D, GPIO, PWM
8. A4/SDA, A, ADC in, I2C SDA 23. D5/PWM, D, GPIO, PWM
9. A5/SCL, A, ADC in , I2C SCL 22. D4, D, GPIO
10. A6, A, ADC in, GPIO 21. D3/PWM, D, GPIO, PWM
11. A7, A, ADC in, GPIO 20. D2, D, GPIO
12. VUSB, power in/out, NC 19. GND, power ground
13. RST, D, active low reset 18. RST, D, active low reset
14. GND, power ground 17. RX, D, USART RX, GPIO
15. VIN, power in 16. TX, D, USART TX, GPIO
A: analog
D: digital
G: GPIO: general purpose I/O
PWM: pulse width modulation
NC: no connection
Fig. 2.2 Arduino Nano 33 BLE Sense SoC board pin out. (Figure adapted and used with permission
of Arduino Team (CC BY–NC–SA)(www.arduino.cc).)
In this section we explore the peripherals contained within the NINA B306 Module. The
B306 is equipped with the Nordic Semiconductor nRF52840 processor. This is a 32–bit
processor, operating at 64 MHz, with an ARM Cortex–M4F architecture equipped with a
floating point unit (FPU). In addition, it is equipped with specialized instructions to aid in
efficient AI and ML program execution including (nRF52840):
2.4 NINA B306 Module Subsystems 21
The 32–bit processor architecture allows a wide range of integer and floating point
(real number) processing capability. The processor is equipped with a floating point unit
to enhance processing. The processor’s 48 MHz clock speed provides enhanced capability
over other Arduino products. For example, the very capable Arduino UNO R3 processor
hosting the Microchip ATmega328 operates at 16 MHz.
The B306 is equipped with two main memory sections: flash electrically erasable pro-
grammable read only memory (EEPROM) and static random access memory (SRAM). The
processor is equipped with 1 MB (megabyte) of flash memory and 256 KB (kilobyte) of
Random Access Memory (RAM) (nRF52840). We discuss each memory component in turn.
In this section, we provide a brief overview of the internal peripherals of the B306 module. It
should be emphasized that these features are the internal systems contained within the con-
fines of the microcontroller chip. These built–in peripherals allow complex and sophisticated
tasks to be accomplished by the microcontroller.
The Nano 33 BLE Sense is equipped with five pulse width modulation (PWM) channels.
PWM output can be provided on digital pins 1–13 and analog pins A0–A7. We limit use to
pins 21, 23, 24, 27, and 28 as shown in the pinout diagram at Fig. 2.2. The Nano 33 BLE
sense baseline frequency of the PWM signal is set at 500 Hz.
A pulse width modulated or PWM signal is characterized by a fixed frequency and a
varying duty cycle. Duty cycle is the percentage of time a repetitive signal is logic high
during the signal period. It may be formally expressed as:
analogWrite(pin, value)
Example: In this example the intensity of an LED, connected to Nano 33 BLE Sense pin 21
(digital D3), is slowly increased and then decreased using PWM techniques. Note the use
of a 220 Ohm resistor in series with the LED. We discuss interface techniques in Chap. 3.
//******************************************************
//pwm_LED_test: the intensity of an LED, connected to
//Nano 33 BLE Sense pin 21, is slowly increased and then
//decreased using PWM techniques.
//
//Notes:
//- Provide a 220 Ohm resistor in series with the LED
// to common ground with the Nano 33.
//- Nano 33 BLE Sense pin 21 is specified as digital D3
// in the Arduino IDE sketch.
//*******************************************************
void setup()
{
pinMode(ext_red_LED_pin, OUTPUT); //sets the pin as output
}
void loop()
{
int LED_int = 0;
//increase intensity
for(LED_int=0; LED_int<=255; LED_int=LED_int+5)
{ //0% (0) to 100% (255)
analogWrite(ext_red_LED_pin, LED_int);
delay(100); //delay 100 ms
}
LED_int = 255;
//decrease intensity
for(LED_int=255; LED_int>=0; LED_int=LED_int-5)
{ //100% (255) to 0% (0)
analogWrite(ext_red_LED_pin, LED_int);
delay(100); //delay 100 ms
}
delay(100); //delay 100 ms
}
//******************************************************
PWM signals are used in a wide variety of applications including controlling the position
of a servo motor and controlling the speed of a DC motor. We explore these applications in
the next chapter.
The Arduino Nano 33 BLE Sense is equipped with a variety of different serial communication
subsystems including the Universal Synchronous and Asynchronous Serial Receiver and
Transmitter (USART), the serial peripheral interface (SPI), and the Two–wire Serial Interface
(TWI). What these systems have in common is the serial transmission of data. In a serial
communications transmission, serial data is sent a single bit at a time from transmitter to
receiver. The serial communication subsystems are typically used to add and communicate
with additional peripheral devices.
2.5.2.1 USART
The serial USART may be used for full duplex (two way) communication between a receiver
and transmitter. This is accomplished by equipping the Nano 33 with independent hardware
24 2 Arduino Nano 33 BLE Sense
for the transmitter and receiver. The USART is typically used for asynchronous communi-
cation. That is, there is not a common clock between the transmitter and receiver to keep
them synchronized with one another. To maintain synchronization between the transmitter
and receiver, framing start and stop bits are used at the beginning and end of each data byte
in a transmission sequence.
The Nano 33 USART is quite flexible. It has the capability to be set to different data
transmission rates known as the Baud (bits per second) rate. The USART may also be set
for several data bit widths and different BAUD rates. Furthermore, it is equipped with a
hardware generated parity bit (even or odd) and parity check hardware at the receiver. A
single parity bit allows for the detection of a single bit error within a byte of data.
Example: In this example we equip the Nano 33 with a liquid crystal display (LCD). An
LCD is an output device to display text information as shown in Fig. 2.5. LCDs come in a
wide variety of configurations including multi–character, multi–line format. A 16 x 2 LCD
format is common. That is, it has the capability of displaying two lines of 16 characters
each.
Characters are sent to the LCD via the American Standard Code for Information Inter-
change (ASCII) format a single character or control command at a time. ASCII is a stan-
dardized, seven bit method of encoding alphanumeric data. It has been in use for many
decades, so some of the characters and actions listed in the ASCII table are not in common
use today. However, ASCII is still the most common method of encoding alphanumeric data.
The ASCII code is shown in Fig. 2.4. We illustrate the use of the table with an example. The
capital letter “G” is encoded in ASCII as 0x47. The “0x” symbol indicates the hexadecimal
number representation.
Unicode is the international counterpart of ASCII. It provides a standardized 16–bit
encoding format for the written languages of the world. ASCII is a subset of Unicode. The
interested reader is referred to the Unicode home page website at: www.unicode.org for
additional information on this standardized encoding format.
LCDs are configured for either a serial or parallel interface to the host microcontroller. For
a parallel configured LCD, an eight bit data path and two control lines are required between
the microcontroller. Many parallel configured LCDs may also be configured for a four bit data
path thus saving several precious microcontroller pins. A small microcontroller mounted to
the back panel of the LCD translates the ASCII data characters and control signals to properly
display the characters. Several manufacturers provide 3.3 VDC compatible displays.
To conserve precious, limited microcontroller input/output pins a serial configured LCD
may be used. A serial LCD reduces the number of required microcontroller pins for interface,
from ten down to one. Display data and control information is sent to the LCD via an
asynchronous USART serial communication link (8 bit, 1 stop bit, no parity, 9600 Baud).
In this example a Sparkfun LCD–16397, 3.3 VDC, serial, 16 by 2 character LCD display
is connected to the Nano 33 BLE Sense. Communication between the Nano 33 and the LCD
is accomplished by a single 9600 bits per second (BAUD) connection using the onboard
USART.
2.5 NINA B306 Module Peripherals 25
Fig. 2.4 ASCII Code. The ASCII code is used to encode alphanumeric characters. The “0x” indicates
hexadecimal notation in the C programming language
serial interface
RT
, U 33
SA
16 o
n n
ro C
pi Na
d
G VD
un
to
3
3.
RX RAW -
Sparkfun LCD-16397
//***********************************************************************
//LCD_example
//
//Sparkfun LCD-16397, 3.3 VDC, 16x2 character display
//- Nano 33 BLE Sense, USART TX pin 16 is connected to LCD USART RX pin
//- Provide 3.3 VDC power to the LCD
//***********************************************************************
void setup()
{
Serial1.begin(9600); //Baud rate: 9600 Baud
delay(500); //Delay for display
}
void loop()
{
//read analog output from IR sensors – simulated maze wall data
left_IR_sensor_value = left_IR_sensor_value + 1;
center_IR_sensor_value = center_IR_sensor_value + 2;
right_IR_sensor_value = right_IR_sensor_value + 3;
//Clear LCD
//Cursor to line one, character one
Serial1.write(254); //Command prefix
Serial1.write(128); //Command
//clear display
Serial1.write(" ");
Serial1.write(" ");
delay(5);
Serial1.write(198); //Cursor line 2, position 8
delay(5);
Serial1.print(center_IR_sensor_value);
delay(5);
Serial1.write(254); //Command to LCD
delay(5);
Serial1.write(203); //Cursor line 2, position 13
delay(5);
Serial1.print(right_IR_sensor_value);
delay(5);
delay(500);
}
//*******************************************************************
MISO MISO
SPI Data Register (SDR) SPI Data Register (SDR)
MSB LSB MSB LSB
MOSI MOSI
• Pin 29, SPI MOSI also referred to as Computer Out Peripheral In (COPI),
• Pin 30, SPI MISO also referred to as Computer In Peripheral Out (CIPO),
• Pin 1, SPI SCK
To configure the Arduino Nano 33 BLE Sense for SPI operation, the following Arduino
IDE commands are used:
In Chap. 1 we used the SPI system to send RGB data to individual LEDs within an SPI
compatible LED strip.
Example: In this example we configure the Sparkfun LCD–16397. The required connec-
tions, shown in Fig. 2.7, between the Nano 33 and the LCD include:
Provided below is an Arduino sketch to communicate with LCD–16397 using the SPI
system. Several items of interest regarding the sketch:
2.5 NINA B306 Module Peripherals 29
SI
29 o K
O
pi Na I SC
to SP 3
un I M
serial peripheral interface
, 33
1, o
ro C
SP
n n
d
G VD
pi Na
n n
un
d
to
3
ro
3.
G
SCK SDI /CS RAW -
Sparkfun LCD-16397
• SparkFun documentation for the LCD provide the following LCD SPI settings: speed-
–100000, MSBFIRST, SPI_MODE0.
• Note the use of function transmit_int_via_SPI to send a three digit integer value to the
LCD. The function isolates each digit and sends its ASCII equivalent to the LCD.
//***********************************************************************
//LCD_SPI_example
//
//The robot is equipped with a Sparkfun LCD-16397
// - Nano 33 SCK pin 1 to SCK on LCD
// - Nano 33 SPI MOSI pin 29 to SDI (Serial Data In) on LCD
// - Ground LCD chip select (\CS)
//- Provide 3.3 VDC power to the LCD
//***********************************************************************
#include <SPI.h>
void setup()
{
30 2 Arduino Nano 33 BLE Sense
SPI.begin();
delay(500); //Delay for display
}
void loop()
{
SPI.beginTransaction(SPISettings(100000, MSBFIRST, SPI_MODE0));
//Clear LCD
//Cursor to line one, character one
SPI.transfer(254); //Command prefix
SPI.transfer(128); //Command
//clear display
spiSendString(" ");
spiSendString(" ");
SPI.endTransaction();
delay(500);
}
//*******************************************************************
SPI.transfer(data[x]);
}
}
//*******************************************************************
ones_place=(unsigned int)(num_to_convert-(hundreds_place*100)-(tens_place*10));
ones_place_char = (char)(ones_place + 48);
SPI.transfer(ones_place_char);
delay(5);
}
//***********************************************************************
//***********************************************************************
//LCD_I2C_example
//
//The robot is equipped with a Sparkfun LCD-16397
// - Nano 33 I2C SDA pin 8 to LCD DA pin
// - Nano 33 I2C CLK pin 9 to LCD CL
// - Ground LCD chip select (\CS)
//- Provide 3.3 VDC power to the LCD
//- LCD default I2C address: 0x72
//***********************************************************************
#include <Wire.h>
int cycles = 0;
void setup()
{
Wire.begin(); //Join I2C bus - master mode
Wire.beginTransmission(LCD_I2C_addr);
Wire.write(’|’); //LCD setting mode
Wire.write(’-’); //clear display command
Wire.endTransmission();
}
void loop()
{
//read analog output from IR sensors
left_IR_sensor_value = left_IR_sensor_value + 1;
center_IR_sensor_value = center_IR_sensor_value + 2;
right_IR_sensor_value = right_IR_sensor_value + 3;
//************************************************************************
Wire.print(value2);
Wire.print(" ");
Wire.print(value3);
Wire.print(" ");
Before the ADC process takes place, we first need to convert a physical signal into an
electrical signal with the help of a transducer. A transducer is an electrical and/or mechanical
system that converts physical signals into electrical signals or electrical signals to physical
signals.
Depending on the purpose, we categorize a transducer as an input transducer or an output
transducer. If the conversion is from physical to electrical, we call it an input transducer.
For example, a temperature sensor is considered an input transducer. The output transducer
converts electrical signals to physical signals. For example, an LCD or a motor would be
considered an output transducer.
It is important to carefully design the interface between transducers and the microcon-
troller to insure proper operation. A poorly designed interface could result in improper
embedded system operation or failure. Specific input and output transducer interface tech-
niques are discussed in Chap. 3.
The Arduino Nano 33 BLE Sense is equipped with an eight–channel, 12–bit resolution,
200 kilo samples per second (ksps) analog to digital converter (ADC) subsystem. The ADC
converts an analog signal from the outside world into a binary representation suitable for
use by the microcontroller. The 12–bit resolution means that an analog voltage between
0 and 3.3V will be encoded into one of 4096 binary representations between (000)16 and
(F F F)16 . This provides the Nano 33 with a voltage resolution of approximately 0.81 mV.
An analog channel is read using the “analogRead” function. This function uses a default
value of 10–bit ADC resolution. The resolution of the ADC process can be adjusted using
the “analogReadResolution(num_bits)” function. The desired level of resolution is specified
using the “num_bits” variable.
The Nano 33 has eight analog to digital conversion channels:
Example: In this example we measure the voltage from a variable power supply. Note the line
in code to convert the ADC reading from 0 to 1023 to an analog voltage: A0_voltage =
(analog_reading_A0 * 3.3)/1024. The circuit configuration is shown in Fig. 2.8.
34 2 Arduino Nano 33 BLE Sense
//***********************************************************************
//LCD_USART_ADC_example
//
//The robot is equipped with a Sparkfun LCD-16397
//- Nano 33 BLE Sense, USART TX pin 16 is connected to LCD USART RX pin
//- Provide 3.3 VDC power to the LCD
//- Nano 33 BLE Sense Analog A0 at pin 4
//***********************************************************************
int analog_reading_A0;
float A0_voltage;
void setup()
{
Serial1.begin(9600); //Baud rate: 9600 Baud
delay(500); //Delay for display
}
void loop()
{
analog_reading_A0 = analogRead(A0); //read A0
//convert to voltage
A0_voltage = (analog_reading_A0 * 3.3)/1024;
//Clear LCD
//Cursor to line one, character one
Serial1.write(254); //Command prefix
Serial1.write(128); //Command
//clear display
Serial1.write(" ");
Serial1.write(" ");
delay(500);
}
//*******************************************************************
2.5 NINA B306 Module Peripherals 35
TX
RT
, U 33
SA
16 o
n n
ro C
pi Na
d
G VD
un
to
3
3.
RX RAW -
to Nano 33
A0 pin 4
Sparkfun LCD-16397
variable
+ Line Character Position (n)
power
-
supply 1 0-15
2 64-79
Note: character position is specifed
as 0X80 + n
Note: Do not exceed 3.3 VDC on the Command Code Command
variable power supply. 0x01 Clear Display
0x14 Cursor one space right
0x10 Cursor one space left
0x80 + n Cursor to position
Note: precede command with 0xFE (25410)
The Arduino Nano 33 BLE Sense is equipped with Bluetooth features. The Classic form of
Bluetooth was designed to provide a wireless replacement for the common RS–232 serial
connection standard. The Arduino Nano 33 BLE sense is also equipped with Bluetooth Low
Energy (BLE) features. It is important to note that Bluetooth Classic and BLE features are
not compatible with one another. We explore Bluetooth Classic in “Arduino III: Internet of
Things.”2 We concentrate on BLE features here.
Bluetooth BLE provides for low transmit power (10 mW), short (maximum 100 m) range
RF connections to replace wires. It uses the crowded Industrial, Scientific, and Medical (ISM)
frequency band from 2.40 to approximately 2.50 GHz. The BLE band is divided into 40
different, 2 MHz channels as shown in Fig. 2.9. BT BLE employs an interesting frequency
hopping technique to communicate. Data for transmission is divided into packets at data
rates from 125 to 2 Mb/s. The device transmits a packet of data at the first carrier frequency.
It then hops to a different carrier frequency for the next packet and so on until the entire
message is transmitted as shown in Fig. 2.9b). Formally the BT BLE modulation technique
is called Direct Sequence Spread Spectrum (DSSS) (www.bluetooth.com).
BLE uses the Generic Attribute (GATT) Profile to establish two different primary roles
for a BLE connection:
2 “Arduino III: Internet of Things,” S.F. Barrett, Morgan and Claypool Publishers, 2021.
36 2 Arduino Nano 33 BLE Sense
g g
u u
a a
r r
d d
f [GHz]
40
41
42
43
44
45
46
47
48
2.
2.
2.
2.
2.
2.
2.
2.
2.
a) Industrial, Scientific, Medical (ISM) frequency band.
1 3 2
g g
u u
a a
r r
d d
f [GHz]
40
41
42
43
44
45
46
47
48
2.
2.
2.
2.
2.
2.
2.
2.
2.
b) Frequency Hopping Spread Spectrum (FHSS) [R and S].
• The peripheral or server role provides bulletin board features where data is posted for
reading.
• The central or client role can read and interact with the posted data.
In Fig. 2.10 we use an Arduino Nano 33 BLE Sense in a peripheral server role to col-
lect important greenhouse information such as external temperature, internal temperature,
humidity, and soil moisture content. The greenhouse related data is collected and organized
into a BLE service. The service related data is provided as BLE configured characteristics.
To allow ease of access to the information from an external central client device, the BLE
service and characteristics are each assigned a universally unique identifier (UUID) (www.
bluetooth.com). If we were to expand the features of the project with additional services,
we could group them into a profile.
There are a number of 16 bit pre–assigned UUIDs. The UUIDs represent different manu-
facturers and technology companies employing Bluetooth–based technologies. Also, UUIDs
have been pre–assigned to common Bluetooth features and common pre–assigned data types
(e.g. temperature, pressure, etc.) (www.bluetooth.com):
Central Client
Nano 33 BLE Sense cell phone
information
polling and control
Peripheral Server Greenhouse Data Center nRF Connect
Greenhouse Service for Mobile
- characteristic external temperature Applications
- characteristic internal temperature
- characteristic humidity
- characteristic soil moisture
:
For BLE services and characteristics without a 16 bit pre–assigned UUID, a unique 128
bit UUID code is used. A Bluetooth unique UUID may be obtained using a number of online
UUID generators.
In the greenhouse example, a cell phone is configured as a BLE central or client. Through
the BLE wireless radio interconnect, the cell phone can read and interact with the greenhouse
data and features.
Random documents with unrelated
content Scribd suggests to you:
bilious attacks. Those are the only circumstances upon which I formed that
opinion.
Cross-examined by Mr. James: I knew Mr. Cook for ten years; he hunted
regularly for the last two years in Nottinghamshire. He kept sometimes two
and sometimes three horses. I have known him to hunt three days a week
when he was well. I knew Mr. George Pell. There is a cricket club at
Welford. I do not know whether Cook was a member of the club. I have
seen him there. I saw Cook for the last time at Lutterworth, about the
middle of October last. I last knew him to have a bilious sick headache
about a year and a half ago [laughter].
Lord Chief Justice Campbell: I most strongly implore that there will be
no expression of any sensation evinced at the answers given by any of the
witnesses.
By Mr. James: I saw Cook at my own house when he complained of
suffering. He did not hunt on that day. He came to my house to meet the
hounds, but did not go. He was dressed in his hunting dress. I could not
swear I did not see him next within a week afterwards in the hunting-field.
By Lord Campbell: I never saw Cook sick on any other occasion, except
about seven years previous at Market Harborough, at the cricket match,
after dinner.
George Myatt, saddler, examined by Mr. Gray: I was at Shrewsbury
races on the day when Polestar won. I was at the Raven Hotel on the
evening of that day, Wednesday. I saw Cook and Palmer there about twelve
o’clock on the night of that day. I was waiting in the room at the hotel when
they came in. I considered Cook was the worse for liquor. They proposed
having a glass of brandy and water each before they went to bed. Each of us
had a glass of brandy and water. When Cook commenced to drink it he
made a remark that he fancied it was not good. He drank part of it off, and
said he thought there was something in it. He then gave it to some one near
him to taste. Cook proposed to have some more, and Palmer said he would
not have any more except Cook drank his up. They had no more brandy and
water, and Palmer and I went to bed. I slept in the same room with Palmer.
The brandy was brought in a decanter, and the brandy which I had was
poured out of the decanter, I don’t know by whom. I did not leave the room
during the time when Palmer and Cook came in to me until we went to bed.
I did not see anything put into the brandy and water, and I do not think
anything could have been put in without my seeing it. Palmer and I went
into the bedroom and left Cook in the sitting-room. I slept in the same
bedroom as Palmer. When I went to bed I locked the door, and Palmer did
not go out of the room during the night. When Palmer got up in the
morning, he asked me to go and call Cook. I did so. I went to Cook’s bed-
room door, rapped at it, and he told me to come in. I went in, and he told me
how ill he had been during the night, and that he had been obliged to send
for a doctor. He asked me what it was that was put into the brandy and
water, and I told him I did not know that anything had been put into it. He
asked me to send for the doctor, meaning Palmer. I did so. I next saw Cook
when he came in to his breakfast. Palmer was in the room. Palmer and I
breakfasted first, and Cook came in directly after we had finished, and had
breakfast in the same room. On the evening of that day Cook, Palmer, and
myself, left for Rugeley, having previously dined together at the Raven. We
started for Rugeley about six o’clock in the evening. We travelled by the
express train from Shrewsbury; Palmer paid for the three railway tickets.
On the way Palmer was sick, and both Cook and he said they could not
account for the circumstance of their being sick. Palmer vomited on the
road between Stafford and Rugeley. We left the train at Stafford, at the
junction. We then got into a fly to proceed to Rugeley, there being no train
for that place. It was on the way to Rugeley that Palmer was ill and
vomited. Palmer said he could not account for it unless it was that Cook had
some brass vessel which he had drank out of, or that the water was bad.
There had been a great many people ill during the Shrewsbury races. I
heard several people speak of their having been ill who could not account
for it. The distance by road from Stafford to Rugeley is about nine miles.
Cross-examined by Mr. James: I have known Palmer all my life. He
deals with me for saddlery. I have not been in the habit of going to the races
with him, but I have gone now and then. I was at Shrewsbury races with
him. I never was at Doncaster with him. I was there once with a gentleman
named Robinson. I was at Wolverhampton races in August last. I went with
Palmer. I did not sleep in the same room with him at Wolverhampton. I did
not stop at the same hotel with him. I stopped with my brother-in-law in
Wolverhampton. I believe I was there a couple of days. I did not dine or
breakfast with Palmer. I was at Lichfield races with Palmer in September.
Lichfield course is within ten miles of Rugeley. I did not sleep at Lichfield.
I did not either go to Lichfield or come home with Palmer. I believe I have
never slept in a double-bedded room with Palmer anywhere but at
Shrewsbury. I never did. I never was at Worcester in my life. I paid my own
expenses to Shrewsbury. Palmer paid the expenses of my living at the hotel
at Shrewsbury, and the fare back. He has never paid my expenses at any
other races. If he has paid any expenses for me, I have deducted them from
his bill. I dare say I went to some races with him the year before; I think
two or three, but I can’t call to mind how many. I had an interview with
Palmer in Stafford Gaol. I was with him a couple of hours. I should think
that that was a month or five weeks ago. I cannot say when it was that I saw
him. I cannot say whether it was before or after Stafford Assizes. Mr. Smith
said he was going, and I thought I should like to see Palmer. I have stood
half a sovereign or a sovereign with him occasionally. I know what “putting
on” a horse means. I did not bet at Shrewsbury. I did not back Cook’s mare,
Polestar. I have stood a sovereign with Palmer on a horse. The first time
when I saw Cook at the Raven on the Wednesday evening was as near
twelve o’clock as possible. I had not been dining with Palmer. I had dined
at home, at Rugeley. I arrived at Shrewsbury about eight o’clock. I went to
the Raven. I knew the room which Palmer generally had, and I went up to
see if he was there. That was between eight and nine o’clock. I went there
direct from the railway station. I saw Cook at the door outside. He asked me
what brought me there. I told him I was come to see how they were getting
on. I found that Palmer had gone out, and I then went into the town. I was
away about an hour, and then returned to the Raven. I went into Palmer’s
sitting-room. Palmer was not there. I waited in the sitting-room till he came.
There was a man named Shelley there. He was a betting man. I waited
about a couple of hours before Palmer came in. I think he came in about
twelve o’clock, but I can’t say exactly. He came in with Cook. I saw that
Cook was the worse for liquor. He was not very drunk, but I could see that
he was the worse for liquor. The brandy and water was brought in directly.
The brandy was in a decanter. I believe the water was on the table, but
cannot say. I should say the brandy and the tumbler were brought up
together. I don’t remember Mrs. Brooks coming. I don’t remember Palmer
being called out of the room. I remember a gentleman coming in. I know
now that he was Mr. Fisher. Before Fisher came in, Palmer had not left the
room. That I will swear. Palmer never left the room until he went to bed. I
swear that positively. I was close to him the whole time. When Fisher came
in, Cook asked Palmer to have some more brandy and water. Palmer said he
would not have any more unless Cook drank his. It was evident to any one
that Cook was the worse for liquor. Cook said, “I’ll drink mine,” and he
drank it at a draught. Directly after he drank it he said, “There’s something
in it.” He did not say, “It burns my throat dreadfully.” He said the brandy
was not good. I will swear he did not say, “it burns my throat dreadfully,” or
anything of that kind. He gave it to some one to taste. I believe it was
Fisher, but will not swear. I can’t say whether it was Palmer or Cook who
gave it to Fisher to taste. I believe there were only four persons in the room
at the time. I can’t say whether any other person came into the room before
we went to bed. Cook had emptied the glass as nearly as possible; there was
a little left in it. I can’t swear whether Palmer touched the glass or not. I
believe he did taste. I believe Palmer said he could not taste anything that
was the matter with the brandy and water, and he gave it to Fisher. I don’t
recollect Fisher saying, “It’s no good giving me the glass—it is empty.” I
can’t swear whether he said so or not. I should think we remained in the
room twenty minutes after that. Cook did not leave the room before we
went to bed. Palmer and I went straight up to bed. We left Cook in the
sitting-room. I did not hear that night that Cook had been vomiting and was
ill. I took one glass of brandy and water. We had one glass each. The water
was cold. On the following day I dined with Palmer at the Raven. Mr. Cook
served me with what I had to eat. During the first two days of the inquest I
was at home at Rugeley. I did not go to the inquest.
Re-examined by Mr. Grove: I was not subpœned for the Crown; I was
examined, but not summoned. The deputy-governor was not present all the
time I was with Palmer at Stafford. He went out once, but another officer
came in. Palmer did not say a word about this case. There was an officer
present the whole time.
The Attorney-General: I wish to ask the witness whether he did not
tell Mr. Gardner, when he was asked about the brandy and water, that he
knew nothing about it?
The Lord Chief Justice: There is no objection to that question.
Witness: I never spoke to him about brandy and water at all.
The Attorney-General: Did you meet him at Hednesford, where
Saunders lives?—Yes.
The Attorney-General: Did you not tell him there that you could
recollect nothing about brandy and water?—No.
The Attorney-General: Had you no conversation at all?—I had with
Mr. Stevens.
The Attorney-General: Did you not say, in Mr. Gardner’s presence,
that you could recollect nothing about the brandy and water?—I did not.
The Attorney-General: Were you not examined by Mr. Crisp and Mr.
Sweeting before the inquest was held, and did you not tell them that you
knew nothing about the brandy and water?—No, I did not.
The Attorney-General: You swear you did not tell them anything
about it?—Yes.
John Sargent, examined by Mr. Sergeant Shee: I am not in any
business or profession. I am in the habit of attending almost all public races
in the kingdom. I knew the late Mr. Cook intimately, and also the prisoner
Palmer. I received a letter from Cook during the Shrewsbury races. I was
subpœned on the part of the Crown. I have not had any notice to produce
that letter. I have not got it. I have searched for it, but I had sent it to
Saunders the trainer. I have made application to Saunders for it. The
application was by letter. I received a letter in answer. I have seen Saunders
since. I have done everything I could to get Cook’s letter. I have not a copy
of it, but I know what its contents were.
The Court decided that the contents of the letter could not be received at
that moment, as Saunders perhaps might attend before the conclusion of the
day.
Examination continued: I was not at Shrewsbury, and only know what
Cook stated in his letter. Shortly before Cook’s death I had an opportunity
of noticing the state of his throat. I was with him at Liverpool the week
previous to the Shrewsbury meeting. We slept in adjoining rooms. In the
morning he called my attention to the state of his throat. The back part of
the throat was a complete ulcer, and the throat was very much inflamed. His
tongue was swollen. I said I was surprised, on seeing the state of his mouth,
that he could eat anything. He said he had been in that state for weeks and
months, and now he did not take notice of it. That was all that passed
respecting the sore throat on that occasion. He had shown his throat to me
previously—at almost every meeting we attended. On the platform at
Liverpool, after the races, he took a gingerbread cayenne nut by mistake. I
saw him take it. He did not know it was a cayenne nut. He told me
afterwards that it had nearly killed him. He did not state more particularly
then the effect which it had produced on him. I know that Cook was very
poor at the Liverpool meeting. That was the week before the Shrewsbury
races. He owed me £25, and gave me £10 on account, and said he had not
sufficient to pay his expenses at Liverpool, but that I should have the
balance of £25 at the Shrewsbury meeting. Cook and Palmer were in the
habit of “putting on” horses for each other. They did so at the Liverpool
meeting. I put money on at Liverpool for Palmer, and Palmer told me that
Cook stood it along with him. I heard Cook, a short time before his death,
apply to Palmer to supply him with “black wash.” I don’t know whether it
is a mercurial lotion. I never saw Cook’s throat dressed by anybody.
Cross-examined by Mr. James: The black wash was not to be drunk [a
laugh]. The application was made to Palmer at the Warwick Spring meeting
in 1855. Cook was at Newmarket. I lived in the same house with him there.
He was at nearly all the race meetings last year. His appetite was very good,
and that surprised me. The cayenne nut is made up for a trick and mixed
with other gingerbread nuts. Cook got one of those. I have tasted them.
Some of them are stronger than others.
Jeremiah Smith, by Mr. Serjeant Shee: I am an attorney at Rugeley. I
am acquainted with the prisoner, and was acquainted with Cook. I saw
Cook at the Talbot Arms on Friday, the 16th of November. He was in his
bedroom. I saw him about ten o’clock. I was present at his breakfast. A
small tray was put on the bed. He took tea for breakfast, and had a
wineglass of brandy in it. I dined with him at Palmer’s house. I am not quite
positive that I had seen him between breakfast and dinner. We had a rump-
steak for dinner. We had some champagne at dinner. We drank port-wine
after dinner. He had three bottles altogether, and Cook took his share. Cook,
myself, and Palmer dined together. We left the house about six in the
evening. Cook and I left the house together. We went to my house, and
afterwards to the Albion Hotel, which is next door. We had a glass of cold
brandy-and-water. Cook left me there. He said he felt cold, and warmed
himself at the fire. He said he had borrowed a book, and would go home
and read it in bed. That was between seven and eight o’clock, but I can’t
say exactly. In the afternoon, after dinner, we were talking about racing. I
asked Cook for money—for £50. He gave me £5. When he was taking the
note out of his pocket-case, I said “Mr. Cook, you can pay me all.” He said,
“No; there is only £41 10s. due to you.” He said that he had given Palmer
money, and would pay me the remainder when he returned from Tattersall’s
on the Monday. On the night following (Saturday night) he was not well,
and I slept in his room. It was late when I went; I should think about eleven
or twelve o’clock. I had been at a concert during the early part of the night
on which Cook was unwell. He had got some toast-and-water, and was
washing his mouth. He was sick. There was a night chair in the room before
the fire. I saw him sitting there. He tried to vomit, but whether he did so or
not I cannot say, for I did not get out of bed. I went to sleep about two
o’clock. I slept until Palmer and Bamford came into the room in the
morning. I lay still in bed, and heard a conversation between the doctor and
Cook. Bamford said, “Well, Mr. Cook, how are you this morning?” Cook
said, “I am rather better this morning. I slept from about two or three
o’clock, after the house had become quiet.” Bamford said, “I’ll send you
some medicine.” I don’t recollect any further conversation. I know Mrs.
Palmer, prisoner’s mother. She sent a message to me on Monday, and I went
to her and saw her. In consequence of what had passed, I went to look for
the prisoner to see if he had arrived. That was about nine o’clock. I saw
Palmer at ten minutes past ten. He came from the direction of Stafford, in a
car. He said to me, “Have you seen Cook to-day?” I said, “No; I have been
to Lichfield on business;” on which Palmer said he had better go and see
how he was before he went to his mother’s. Palmer and I went up to Cook’s
room together. Cook said, “You are late, doctor, to-night. I did not expect
you to look in. I have taken the medicine which you gave me.” We did not
stay more than two or three minutes, and I think Cook asked me why I did
not call earlier. I said I had been detained on business. Cook said Bamford
had sent him some pills, which he had taken; and he intimated that he
would not have taken them if Palmer had come earlier. Cook told Palmer,
that he had been up talking with Saunders, and Palmer said, “You ought not
to have done so.” Palmer and I left the room together, and we went straight
to his mother’s.
The distance of Mr. Palmer’s house from the Talbot Arms is about four
or five hundred yards. We were there about half an hour. We both left
together and went to Palmer’s house. I entered with him. I asked him to let
me have a glass of grog, but did not get it. I then went home. After dining
with Palmer on Friday, I invited Cook and Palmer to dine with me on the
next day, Saturday. Cook sent me a message, stating that he was not well
and could not leave his room. I ordered a boiled leg of mutton for dinner,
and sent part of the broth from the Albion by the charwoman—I think her
name was Rowley. Previous to Cook’s death I borrowed £200 for Cook, and
negotiated a loan with Pratt for him for £500. The £200 transaction was in
May. I borrowed £100 of Mrs. Palmer, and £100 of William Palmer, making
together the £200 to which I have referred. I knew that Palmer and Cook
were jointly interested in one horse, and that they were in the habit of
betting for each other. When Cook’s horse was going to run, Palmer “put
on” for him; and when Palmer’s ran, Cook “put on” for him. I have seen
Thirlby, Palmer’s assistant, dress Cook’s throat with caustic. I think this was
before the races at Shrewsbury. I have some signatures of Cook’s which I
know to be in his handwriting. The two notes with instructions to negotiate
the loan of £500, I saw Cook sign. [The notes were put in.] One of them is
signed “J. P. Cook,” the other “J. Parsons Cook.” I knew from Cook that he
was served with a writ. I do not remember that I received any instruction to
appear for him.
The letters put in were read by Mr. Straight, the Clerk of the Arraigns.
The first was without date, and signed “J. Parsons Cook,” Monday. The
following is a copy of the letter:—
“My dear Sir,—I have been in a devil of a fix about the bill, but have at last settled it at
the cost of an extra two guineas, for the —— discounter had issued a writ against me. I am
very much disgusted at it.”
The letter was sent to me, but its envelope was destroyed. The next letter
bore the date 25th June, 1855; it was also without address, but witness
stated that it had been sent to him, and he had destroyed the envelope. The
following is a copy of the letter:—
“Dear Jerry,—I should like to have the bill renewed for two months. Can it be done?
Let me know by return. I have scratched Polestar for the Nottinghamshire and
Wolverhampton Stakes. I shall be down on Friday or Saturday. Fred. tells me Arabis will
win the Northumberland Stakes.”
The memorandum put in and read was signed J. P. Cook, and the
following is a copy:—
“Polestar three years, Sirius two years; by way of mortgage to secure £200 advanced
upon a bill of exchange for £200, dated 29th August, 1855, payable about three months
after date.”
ebookbell.com