Skip to content

Commit b7a9896

Browse files
author
Jim Bennett
authored
Lesson 16 (#62)
* Adding content * Update en.json * Update README.md * Update TRANSLATIONS.md * Adding lesson tempolates * Fixing code files with each others code in * Update README.md * Adding lesson 16 * Adding virtual camera * Adding Wio Terminal camera capture * Adding wio terminal code * Adding SBC classification to lesson 16 * Adding challenge, review and assignment
1 parent d98f3cb commit b7a9896

File tree

52 files changed

+1506
-45
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+1506
-45
lines changed

.vscode/settings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
"geofencing",
1616
"microcontrollers",
1717
"mosquitto",
18+
"photodiode",
19+
"photodiodes",
1820
"sketchnote"
1921
]
2022
}

1-getting-started/lessons/4-connect-internet/wio-terminal-mqtt.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Libraries can be installed globally and compiled in if needed, or into a specifi
1414

1515
✅ You can learn more about library management and how to find and install libraries in the [PlatformIO library documentation](https://docs.platformio.org/en/latest/librarymanager/index.html).
1616

17-
### Task
17+
### Task - install the WiFi and MQTT Arduino libraries
1818

1919
Install the Arduino libraries.
2020

@@ -49,7 +49,7 @@ Install the Arduino libraries.
4949
5050
The Wio Terminal can now be connected to WiFi.
5151
52-
### Task
52+
### Task - connect to WiFi
5353
5454
Connect the Wio Terminal to WiFi.
5555
@@ -85,7 +85,7 @@ Connect the Wio Terminal to WiFi.
8585
#include "config.h"
8686
```
8787
88-
This includes header files for the libraries you added earlier, as well as the config header file.
88+
This includes header files for the libraries you added earlier, as well as the config header file. These header files are needed to tell PlatformIO to bring in the code from the libraries. Without explicitly including these header files, some code won't be compiled in and you will get compiler errors.
8989

9090
1. Add the following code above the `setup` function:
9191

@@ -128,7 +128,7 @@ Connect the Wio Terminal to WiFi.
128128

129129
Once the Wio Terminal is connected to WiFi, it can connect to the MQTT broker.
130130

131-
### Task
131+
### Task - connect to MQTT
132132

133133
Connect to the MQTT broker.
134134

3-transport/lessons/1-location-tracking/code-gps-decode/pi/gps-sensor/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
device_client.connect()
1717
print("Connected")
1818

19-
def print_gps_data(line):
19+
def printGPSData(line):
2020
msg = pynmea2.parse(line)
2121
if msg.sentence_type == 'GGA':
2222
lat = pynmea2.dm_to_sd(msg.lat)
@@ -37,7 +37,7 @@ def print_gps_data(line):
3737
line = serial.readline().decode('utf-8')
3838

3939
while len(line) > 0:
40-
print_gps_data(line)
40+
printGPSData(line)
4141
line = serial.readline().decode('utf-8')
4242

4343
time.sleep(1)

3-transport/lessons/1-location-tracking/code-gps-decode/wio-terminal/gps-sensor/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void setup()
2424
pinPeripheral(PIN_WIRE_SCL, PIO_SERCOM_ALT);
2525
}
2626

27-
void print_gps_data()
27+
void printGPSData()
2828
{
2929
if (gps.encode(Serial3.read()))
3030
{
@@ -44,7 +44,7 @@ void loop()
4444
{
4545
while (Serial3.available() > 0)
4646
{
47-
print_gps_data();
47+
printGPSData();
4848
}
4949

5050
delay(1000);

3-transport/lessons/1-location-tracking/code-gps/pi/gps-sensor/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
serial.reset_input_buffer()
66
serial.flush()
77

8-
def print_gps_data():
8+
def printGPSData():
99
print(line.rstrip())
1010

1111
while True:
1212
line = serial.readline().decode('utf-8')
1313

1414
while len(line) > 0:
15-
print_gps_data()
15+
printGPSData()
1616
line = serial.readline().decode('utf-8')
1717

1818
time.sleep(1)

3-transport/lessons/1-location-tracking/code-gps/virtual-device/gps-sensor/app.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@
66

77
serial = counterfit_shims_serial.Serial('/dev/ttyAMA0')
88

9-
def print_gps_data(line):
9+
def printGPSData(line):
1010
print(line.rstrip())
1111

1212
while True:
1313
line = serial.readline().decode('utf-8')
1414

1515
while len(line) > 0:
16-
print_gps_data(line)
16+
printGPSData(line)
1717
line = serial.readline().decode('utf-8')
1818

1919
time.sleep(1)

3-transport/lessons/1-location-tracking/code-gps/wio-terminal/gps-sensor/src/main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ void setup()
2222
pinPeripheral(PIN_WIRE_SCL, PIO_SERCOM_ALT);
2323
}
2424

25-
void print_gps_data()
25+
void printGPSData()
2626
{
2727
Serial.println(Serial3.readStringUntil('\n'));
2828
}
@@ -31,7 +31,7 @@ void loop()
3131
{
3232
while (Serial3.available() > 0)
3333
{
34-
print_gps_data();
34+
printGPSData();
3535
}
3636

3737
delay(1000);

3-transport/lessons/1-location-tracking/pi-gps-sensor.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ The sensor you'll use is a [Grove GPS Air530 sensor](https://www.seeedstudio.com
1010

1111
This is a UART sensor, so sends GPS data over UART.
1212

13-
### Connect the GPS sensor
13+
## Connect the GPS sensor
1414

1515
The Grove GPS sensor can be connected to the Raspberry Pi.
1616

17-
#### Task - connect the GPS sensor
17+
### Task - connect the GPS sensor
1818

1919
Connect the GPS sensor.
2020

@@ -98,14 +98,14 @@ Program the device.
9898

9999
1. Reboot your Pi, then reconnect in VS Code once the Pi has rebooted.
100100

101-
1. From the terminal, create a new folder in the `pi` users home directory called `gps-sensor`. Create a file in this folder called `app.py`:
101+
1. From the terminal, create a new folder in the `pi` users home directory called `gps-sensor`. Create a file in this folder called `app.py`.
102102

103103
1. Open this folder in VS Code
104104

105105
1. The GPS module sends UART data over a serial port. Install the `pyserial` Pip package to communicate with the serial port from your Python code:
106106

107107
```sh
108-
pip3 install pip install pyserial
108+
pip3 install pyserial
109109
```
110110

111111
1. Add the following code to your `app.py` file:
@@ -118,24 +118,24 @@ Program the device.
118118
serial.reset_input_buffer()
119119
serial.flush()
120120
121-
def print_gps_data(line):
121+
def printGPSData(line):
122122
print(line.rstrip())
123123
124124
while True:
125125
line = serial.readline().decode('utf-8')
126126
127127
while len(line) > 0:
128-
print_gps_data(line)
128+
printGPSData(line)
129129
line = serial.readline().decode('utf-8')
130130
131131
time.sleep(1)
132132
```
133133
134134
This code imports the `serial` module from the `pyserial` Pip package. It then connects to the `/dev/ttyAMA0` serial port - this is the address of the serial port that the Grove Pi Base Hat uses for its UART port. It then clears any existing data from this serial connection.
135135
136-
Next a function called `print_gps_data` is defined that prints out the line passed to it to the console.
136+
Next a function called `printGPSData` is defined that prints out the line passed to it to the console.
137137
138-
Next the code loops forever, reading as many lines of text as it can from the serial port in each loop. It calls the `print_gps_data` function for each line.
138+
Next the code loops forever, reading as many lines of text as it can from the serial port in each loop. It calls the `printGPSData` function for each line.
139139
140140
After all the data has been read, the loop sleeps for 1 second, then tries again.
141141

3-transport/lessons/1-location-tracking/single-board-computer-gps-decode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Program the device to decode the GPS data.
2424
import pynmea2
2525
```
2626

27-
1. Replace the contents of the `print_gps_data` function with the following:
27+
1. Replace the contents of the `printGPSData` function with the following:
2828

2929
```python
3030
msg = pynmea2.parse(line)

3-transport/lessons/1-location-tracking/virtual-device-gps-sensor.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A physical GPS sensor will have an antenna to pick up radio waves from GPS satel
1414

1515
To use a virtual GPS sensor, you need to add one to the CounterFit app
1616

17-
#### Task
17+
#### Task - add the sensor to CounterFit
1818

1919
Add the GPS sensor to the CounterFit app.
2020

@@ -36,7 +36,7 @@ Add the GPS sensor to the CounterFit app.
3636

3737
1. Leave the *Port* set to */dev/ttyAMA0*
3838

39-
1. Select the **Add** button to create the humidity sensor on port `/dev/ttyAMA0`
39+
1. Select the **Add** button to create the GPS sensor on port `/dev/ttyAMA0`
4040

4141
![The GPS sensor settings](../../../images/counterfit-create-gps-sensor.png)
4242

@@ -77,22 +77,22 @@ Program the GPS sensor app.
7777
1. Add the following code below this to read from the serial port and print the values to the console:
7878

7979
```python
80-
def print_gps_data(line):
80+
def printGPSData(line):
8181
print(line.rstrip())
8282
8383
while True:
8484
line = serial.readline().decode('utf-8')
8585
8686
while len(line) > 0:
87-
print_gps_data(line)
87+
printGPSData(line)
8888
line = serial.readline().decode('utf-8')
8989
9090
time.sleep(1)
9191
```
9292
93-
A function called `print_gps_data` is defined that prints out the line passed to it to the console.
93+
A function called `printGPSData` is defined that prints out the line passed to it to the console.
9494
95-
Next the code loops forever, reading as many lines of text as it can from the serial port in each loop. It calls the `print_gps_data` function for each line.
95+
Next the code loops forever, reading as many lines of text as it can from the serial port in each loop. It calls the `printGPSData` function for each line.
9696
9797
After all the data has been read, the loop sleeps for 1 second, then tries again.
9898

3-transport/lessons/1-location-tracking/wio-terminal-gps-decode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ Program the device to decode the GPS data.
3131
TinyGPSPlus gps;
3232
```
3333

34-
1. Change the contents of the `print_gps_data` function to be the following:
34+
1. Change the contents of the `printGPSData` function to be the following:
3535

3636
```cpp
3737
if (gps.encode(Serial3.read()))

3-transport/lessons/1-location-tracking/wio-terminal-gps-sensor.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Program the device.
9898
1. Add the following function before the `loop` function to send the GPS data to the serial monitor:
9999

100100
```cpp
101-
void print_gps_data()
101+
void printGPSData()
102102
{
103103
Serial.println(Serial3.readStringUntil('\n'));
104104
}
@@ -109,13 +109,13 @@ Program the device.
109109
```cpp
110110
while (Serial3.available() > 0)
111111
{
112-
print_gps_data();
112+
printGPSData();
113113
}
114114

115115
delay(1000);
116116
```
117117

118-
This code reads from the UART serial port. The `readStringUntil` function reads up until a terminator character, in this case a new line. This will read a whole NMEA sentence (NMEA sentences are terminated with a new line character). All the while data can be read from the UART serial port, it is read and sent to the serial monitor via the `print_gps_data` function. Once no more data can be read, the `loop` delays for 1 second (1,000ms).
118+
This code reads from the UART serial port. The `readStringUntil` function reads up until a terminator character, in this case a new line. This will read a whole NMEA sentence (NMEA sentences are terminated with a new line character). All the while data can be read from the UART serial port, it is read and sent to the serial monitor via the `printGPSData` function. Once no more data can be read, the `loop` delays for 1 second (1,000ms).
119119

120120
1. Build and upload the code to the Wio Terminal.
121121

4-manufacturing/lessons/1-train-fruit-detector/README.md

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ In this lesson we'll cover:
2222
* [Image classification via Machine Learning](#image-classification-via-machine-learning)
2323
* [Train an image classifier](#train-an-image-classifier)
2424
* [Test your image classifier](#test-your-image-classifier)
25+
* [Retrain your image classifier](#retrain-your-image-classifier)
2526

2627
## Using AI and ML to sort food
2728

@@ -133,6 +134,8 @@ To use Custom Vision, you first need to create two cognitive services resources
133134

134135
### Task - create an image classifier project
135136

137+
1. Launch the Custom Vision portal at [CustomVision.ai](https://customvision.ai), and sign in with the Microsoft account you used for your Azure account.
138+
136139
1. Follow the [Create a new Project section of the Build a classifier quickstart on the Microsoft docs](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/getting-started-build-a-classifier?WT.mc_id=academic-17441-jabenn#create-a-new-project) to create a new Custom Vision project. The UI may change and these docs are always the most up to date reference.
137140

138141
Call your project `fruit-quality-detector`.
@@ -151,6 +154,8 @@ Ideally each picture should be just the fruit, with either a consistent backgrou
151154

152155
> 💁 It's important not to have specific backgrounds, or specific items that are not related to the thing being classified for each tag, otherwise the classifier may just classify based on the background. There was a classifier for skin cancer that was trained on moles both normal and cancerous, and the cancerous ones all had rulers against them to measure the size. It turned out the classifier was almost 100% accurate at identifying rulers in pictures, not cancerous moles.
153156
157+
Image classifiers run at very low resolution. For example Custom Vision can take training and prediction images up to 10240x10240, but trains and runs the model on images at 227x227. Larger images are shrunk to this size, so ensure the thing you are classifying takes up a large part of the image otherwise it may be too small in the smaller image used by the classifier.
158+
154159
1. Gather pictures for your classifier. You will need at least 5 pictures for each label to train the classifier, but the more the better. You will also need a few additional images to test the classifier. These images should all be different images of the same thing. For example:
155160
156161
* Using 2 ripe bananas, take some pictures of each one from a few different angles, taking at least 7 pictures (5 to train, 2 to test), but ideally more.
@@ -181,18 +186,28 @@ Once your classifier is trained, you can test it by giving it a new image to cla
181186
182187
### Task - test your image classifier
183188
184-
1. Follow the [Test and retrain a model with Custom Vision Service documentation on the Microsoft docs](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/test-your-model?WT.mc_id=academic-17441-jabenn#test-your-model) to test your image classifier. Use the testing images you created earlier, not any of the images you used for training.
189+
1. Follow the [Test your model documentation on the Microsoft docs](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/test-your-model?WT.mc_id=academic-17441-jabenn#test-your-model) to test your image classifier. Use the testing images you created earlier, not any of the images you used for training.
185190
186191
![A unripe banana predicted as unripe with a 98.9% probability, ripe with a 1.1% probability](../../../images/banana-unripe-quick-test-prediction.png)
187192
188193
1. Try all the testing images you have access to and observe the probabilities.
189194
195+
## Retrain your image classifier
196+
197+
When you test you classifier, it may not give the results you expect. Image classifiers use machine learning to make predictions about what is in an image, based of probabilities that particular features of an image mean that it matches a particular label. It doesn't understand what is in the image - it doesn't know what a banana is or understand what makes a banana a banana instead of a boat. You can improve your classifier by retraining it with images it gets wrong.
198+
199+
Every time you make a prediction using the quick test option, the image and results are stored. You can use these images to retrain your model.
200+
201+
### Task - retrain your image classifier
202+
203+
1. Follow the [Use the predicted image for training documentation on the Microsoft docs](https://docs.microsoft.com/azure/cognitive-services/custom-vision-service/test-your-model?WT.mc_id=academic-17441-jabenn#use-the-predicted-image-for-training) to retrain your model, using the correct tag for each image.
204+
205+
1. Once you model has been retrained, test on new images.
206+
190207
---
191208
192209
## 🚀 Challenge
193210
194-
Image classifiers use machine learning to make predictions about what is in an image, based of probabilities that particular features of an image mean that it matches a particular label. It doesn't understand what is in the image - it doesn't know what a banana is or understand what makes a banana a banana instead of a boat.
195-
196211
What do you think would happen if you used a picture of a strawberry with a model trained on bananas, or a picture of an inflatable banana, or a person in a banana suit, or even a yellow cartoon character like someone from the Simpsons?
197212
198213
Try it out and see what the predictions are. You can find images to try with using [Bing Image search](https://www.bing.com/images/trending).

0 commit comments

Comments
 (0)