Monthly Archives: August 2021

DIY Barcode Scanner Game

via SparkFun: Commerce Blog

In my time working with electronics I’ve been exposed to so many different technologies, products, and just wicked cool gadgets. So what am I spending my free time doing? Chasing after those long lost feelings from childhood games, of course! Back in the early 2000s (yes, nearly TWO decades ago…) I got the chance to play with a handheld barcode scanning game called “Skannerz” from Radica Games Limited. You can find a wiki detailing this game in more detail here. Roll the tape!

Beware for those sensitive to old school cringe kid commercials

Basically, it was advertised as monsters and items hidden in everyday barcodes and you can scan to collect them. Training them, battling them, or just collecting them was an awesome time for me. So what better to do with my time than to put together some SparkFun components to make something similar? I’ve made my riff by having common electrical components as the "hidden" surprises - items like resistors, capacitors and LEDs are shown as pixel images on the display screen.

Overview

alt text

SPX Version Barcode Scanner pictured since I had one laying around.

The major components of the system are a barcode scanner, display and microcontroller. I’ve outlined a list of the components I’m using in my system here:

The brain of the system is the SparkFun RedBoard Artemis, since its features include 1 MB flash/384k RAM, an I2C bus and a UART bus, which is powerful enough for what I need. I’m also using the SparkFun DE2120 Barcode Scanner breakout and a SparkFun Qwiic Micro OLED breakout. If you want to make this system or tweak it you could use plenty of other screen options, but you'll have to modify the code. I opted to use the Qwiic Micro OLED because of its ease of use, with simple function calls.

It was easier to start prototyping this system by breaking it into two parts. First, I wanted to develop how I get an item from the barcode. Then, I want to display a pixel image of the component on the OLED screen.

Example 1 - Barcode, to do what?

Common barcodes I can find around my house are UPC-A codes, which are 13-digit barcodes. My initial thought was to break up the barcode into three portions just to have resistors, capacitors and LEDs. But I wanted something a bit more to start with, so I used the first nine digits to choose what component was found, and the last four digits to choose the color of the component (red, green or blue). You can find my code below:

/*******************************************************************************************
 * This example allows a user to scan a Barcode and 'find' a component in the barcode. The 
 * serial terminal then reports the type of component and color of the component.
 * 
 * Brandon Williams @ SparkFun Electronics
 * Original Creation Date: August 10, 2021
 * 
 * This code is Lemonadeware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board Artemis to computer using micro-B USB cable.
 * Attach SparkFun Barcode Scanner Breakout - DE2120 to Red Board using 24/26 AWG Jumper Wires
 * 
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <SparkFun_DE2120_Arduino_Library.h>
#include <SoftwareSerial.h>

SoftwareSerial softSerial(2,3);

DE2120 scanner;

#define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];

int scan_int[12];
char component[2]; //{item,color}

void setup() {
  Serial.begin(115200);
  Serial.println("**** SparkFun HIDDEN COMPONENTS Game! ****");

  if(scanner.begin(softSerial) == false){
    Serial.println("Scanner did not respond.");
    Serial.println("Please check your wiring. Did you scan the POR232 barcode?");
    while(1);
  }
  Serial.println("Scanner online!");
  Serial.println("\nLet's scan some stuff!! ===>\n");
}

void loop() {
  if(scanner.readBarcode(scanBuffer,BUFFER_LEN)){
    convertCharToInt();
    getHiddenItem();
    Serial.print("Wow! A ");
    if(component[0] == 'R'){
      if(component[1] == 'r'){
        Serial.print("Red Resistor");
      }
      else if(component[1] == 'g'){
        Serial.print("Green Resistor");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue Resistor");
      }
    }
    else if(component[0] == 'C'){
      if(component[1] == 'r'){
        Serial.print("Red Capacitor");
      }
      else if(component[1] == 'g'){
        Serial.print("Green Capacitor");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue Capacitor");
      }
    }
    else if(component[0] == 'L'){
      if(component[1] == 'r'){
        Serial.print("Red LED");
      }
      else if(component[1] == 'g'){
        Serial.print("Green LED");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue LED");
      }
    }
    Serial.println(" was hidden inside that barcode!!!\n\tYou better hang onto that!");
  }
  delay(200);
}

void convertCharToInt(){
  for(int i = 0; i < 12; i++){
    switch (scanBuffer[i]){
      case '0':
        scan_int[i] = 0;
        break;
      case '1':
        scan_int[i] = 1;
        break;
      case '2':
        scan_int[i] = 2;
        break;
      case '3':
        scan_int[i] = 3;
        break;
      case '4':
        scan_int[i] = 4;
        break;
      case '5':
        scan_int[i] = 5;
        break;
      case '6':
        scan_int[i] = 6;
        break;
      case '7':
        scan_int[i] = 7;
        break;
      case '8':
        scan_int[i] = 8;
        break;
      case '9':
        scan_int[i] = 9;
        break;
      default:
        break;
    }
  }
}

void getHiddenItem(){
  int sum1, sum2, sum3, sum4;
  char itemColor;

  for(int i = 0; i < 3; i++){
    sum1 += scan_int[i];
  }
  for(int i = 3; i < 6; i++){
    sum2 += scan_int[i];
  }
  for(int i = 6; i < 9; i++){
    sum3 += scan_int[i];
  }
  for(int i = 9; i < 12; i++){
    sum4 += scan_int[i];
  }

  itemColor = checkColor(sum4);

  //If all 3 sums are equal rely on 4th sum to determine type, will also determine color
  if(sum1 == sum2 && sum2 == sum3){
    Serial.println("\tAll 3 sums are equal...");

    if(itemColor == 'r'){ //resistor, red
      component[0] = 'R';
      component[1] = itemColor;
    }
    else if(itemColor == 'g'){ //capacitor, green
      component[0] = 'C';
      component[1] = itemColor;
    }
    else if(itemColor == 'b'){ //LED, blue
      component[0] = 'L';
      component[1] = itemColor;
    }
    else{
      Serial.println("Something broke, report the BUG!!");
      Serial.print("\tError code: ");
      Serial.println(itemColor);
    }
  }
  //If sum1 equal to sum2 but larger than sum3 then default to making it an LED
  else if(sum1 == sum2 && sum1 > sum3){
    component[0] = 'L';
    component[1] = itemColor;
  }
  //If sum1 is larger than sum2 but equal to sum3 then default to Capcitor
  else if(sum1 > sum2 && sum1 == sum3){
    component[0] = 'C';
    component[1] = itemColor;    
  }
  //if sum1 is larger than both sum2 and sum3 then item is Resistor
  else if(sum1 > sum2 && sum1 > sum3){
    component[0] = 'R';
    component[1] = itemColor;
  }
  //if sum2 is equal to sum3 but larger than sum1 then default to Resistor
  else if(sum2 == sum3 && sum2 > sum1){
    component[0] = 'R';
    component[1] = itemColor;
  }
  //if sum2 is greater than sum1 and sum 3 then item is capacitor
  else if(sum2 > sum1 && sum2 > sum3){
    component[0] = 'C';
    component[1] = itemColor;
  }
  //if sum3 is greater than sum1 and sum2 then item is LED
  else if(sum3 > sum1 && sum3 > sum2){
    component[0] = 'L';
    component[1] = itemColor;
  }
  else{
    Serial.println("[ITEM] Barcode didn't yeild a known option. Report BUG!");
    Serial.print("\tSUM 1: ");
    Serial.println(sum1);
    Serial.print("\tSUM 2: ");
    Serial.println(sum2);
    Serial.print("\tSUM 3: ");
    Serial.println(sum3);
    Serial.print("\tSUM 4: ");
    Serial.println(sum4);
  }
}

char checkColor(int color){
  char res;

  if(color >= 0 && color < 9){ //red
    res = 'r';
  }
  else if(color >=9 && color < 18){ //green
    res = 'g';
  }
  else if(color >= 18 && color <= 27){ //blue
    res = 'b';
  }
  else{
    Serial.println("[Color] Barcode didn't yeild a valid result, report the BUG!!");
    Serial.print("\tSUM 4: ");
    Serial.println(color);
    res = 'N';
  }

  return res;
}

Example 2 - Show yourself, component!

alt text

The next step was to integrate the OLED screen with the barcode scanner to display the component as a pixel art image. I made these images with the help of GIMP and a tool found in the SparkFun Micro OLED hookup guide to export the bitmap to an easy to copy array.

I set up the canvas size, grid size and pencil settings. You want the canvas size to be 64x48 px (units) to match the OLED screen size. The grid size needs to be 1x1 on that first line, because that sets the grid units to pixels. Alternatively you could set the next line below, but that is for units other than pixels, which gets really messy since the OLED screen isn’t even a full inch, but I digress. You also want to set your pencil to 1 px width. These settings help set for point and click painting of dot by dot in your pixel art. I had a blast with it, but it took some time to get the hang of.

When you have the pixel art finished and exported to a BMP file then you can use the export tool to get the bitmap array. You can find my finished arrays in my code below:

/*******************************************************************************************
 * This example allows a user to scan a barcode for 'find' a component in the barcode. The 
 * OLED display then shows a pixel art representation of the component and it's corresponding
 * color. 
 *
 * Brandon Williams @ SparkFun Electronics
 * Original Creation Date: August 10, 2021
 * 
 * This code is Lemonadeware; if you see me (or any other SparkFun employee) at the 
 * local, and you've found our code helpful, please buy us a round!
 * 
 * Hardware Connections:
 * Attach Red Board Artemis to computer using micro-B USB cable.
 * Attach SparkFun Barcode Scanner Breakout - DE2120 to Red Board using 24/26 AWG Jumper Wires
 * Attach Qwiic Micro OLED Breakout using a Qwiic cable 
 *
 * Distributed as-is; no warranty is given.
 *****************************************************************************************/
#include <SFE_MicroOLED.h>
#include <SparkFun_DE2120_Arduino_Library.h>

#include <SoftwareSerial.h>

SoftwareSerial softSerial(2,3);

DE2120 scanner;

#define BUFFER_LEN 40
char scanBuffer[BUFFER_LEN];

#define PIN_RESET 9
#define DC_JUMPER 1
MicroOLED oled(PIN_RESET, DC_JUMPER);

int scan_int[12];

uint8_t capacitor [] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x07, 0xEB, 0xEB, 0xDD, 0xDD, 0xD5, 0xC1,
0xC1, 0xC1, 0xD5, 0x9D, 0x1D, 0x0B, 0x6B, 0x07, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 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color}

//struct inventory{
//  char userName;
//  uint8_t inventorySize; //limit 255 items
//  uint8_t resistor[3]; //color codes go [Red,Green,Blue]
//  uint8_t capacitor[3];
//  uint8_t led[3];
//};

void setup() {
//  SerialUSB.begin(115200);
  Serial.begin(115200);
  Wire.begin();
//  SerialUSB.println("**** SparkFun HIDDEN COMPONENTS Game! ****");
  Serial.println("**** SparkFun HIDDEN COMPONENTS Game! ****");

  //  if(scanner.begin(Serial) == false){
  if(scanner.begin(softSerial) == false){
    Serial.println("Scanner did not respond.");
    Serial.println("Please check your wiring. Did you scan the POR232 barcode?");
    while(1);
  }
  Serial.println("Scanner online!");
  Serial.println("\nLet's scan some stuff!! ===>\n");

  if(oled.begin()){
    oled.clear(ALL);
    oled.display();
    delay(1000);
    oled.clear(PAGE);
    oled.clear(ALL);
  }
  else{
    Serial.println("OLED didn't initialize, please retry");
    while(1);
  }
  //erase garbage data that may be in the buffer after initialization
  scanner.readBarcode(scanBuffer,BUFFER_LEN);
}
void loop() {
  if(scanner.readBarcode(scanBuffer,BUFFER_LEN)){
    convertCharToInt();
    getHiddenItem();
    Serial.print("Wow! A ");
    drawHiddenObject(component[0],component[1]);
    if(component[0] == 'R'){
      if(component[1] == 'r'){
        Serial.print("Red Resistor");
      }
      else if(component[1] == 'g'){
        Serial.print("Green Resistor");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue Resistor");
      }
    }
    else if(component[0] == 'C'){
      if(component[1] == 'r'){
        Serial.print("Red Capacitor");
      }
      else if(component[1] == 'g'){
        Serial.print("Green Capacitor");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue Capacitor");
      }
    }
    else if(component[0] == 'L'){
      if(component[1] == 'r'){
        Serial.print("Red LED");
      }
      else if(component[1] == 'g'){
        Serial.print("Green LED");
      }
      else if(component[1] == 'b'){
        Serial.print("Blue LED");
      }
    }
    Serial.println(" was hidden inside that barcode!!!\n\tYou better hang onto that!");
    delay(5000);
    oled.clear(ALL);
    oled.clear(PAGE);
  }
  delay(500);
}

void convertCharToInt(){
  for(int i = 0; i < 12; i++){
    switch (scanBuffer[i]){
      case '0':
        scan_int[i] = 0;
        break;
      case '1':
        scan_int[i] = 1;
        break;
      case '2':
        scan_int[i] = 2;
        break;
      case '3':
        scan_int[i] = 3;
        break;
      case '4':
        scan_int[i] = 4;
        break;
      case '5':
        scan_int[i] = 5;
        break;
      case '6':
        scan_int[i] = 6;
        break;
      case '7':
        scan_int[i] = 7;
        break;
      case '8':
        scan_int[i] = 8;
        break;
      case '9':
        scan_int[i] = 9;
        break;
      default:
        break;
    }
  }
}

void getHiddenItem(){
  int sum1, sum2, sum3, sum4;
  char itemColor;

  for(int i = 0; i < 3; i++){
    sum1 += scan_int[i];
  }
  for(int i = 3; i < 6; i++){
    sum2 += scan_int[i];
  }
  for(int i = 6; i < 9; i++){
    sum3 += scan_int[i];
  }
  for(int i = 9; i < 12; i++){
    sum4 += scan_int[i];
  }

  itemColor = checkColor(sum4);

  //If all 3 sums are equal rely on 4th sum to determine type, will also determine color
  if(sum1 == sum2 && sum2 == sum3){
    Serial.println("\tAll 3 sums are equal...");

    if(itemColor == 'r'){ //resistor, red
      component[0] = 'R';
      component[1] = itemColor;
    }
    else if(itemColor == 'g'){ //capacitor, green
      component[0] = 'C';
      component[1] = itemColor;
    }
    else if(itemColor == 'b'){ //LED, blue
      component[0] = 'L';
      component[1] = itemColor;
    }
    else{
      Serial.println("Something broke, report the BUG!!");
      Serial.print("\tError code: ");
      Serial.println(itemColor);
    }
  }
  //If sum1 equal to sum2 but larger than sum3 then default to making it an LED
  else if(sum1 == sum2 && sum1 > sum3){
    component[0] = 'L';
    component[1] = itemColor;
  }
  //If sum1 is larger than sum2 but equal to sum3 then default to Capcitor
  else if(sum1 > sum2 && sum1 == sum3){
    component[0] = 'C';
    component[1] = itemColor;    
  }
  //if sum1 is larger than both sum2 and sum3 then item is Resistor
  else if(sum1 > sum2 && sum1 > sum3){
    component[0] = 'R';
    component[1] = itemColor;
  }
  //if sum2 is equal to sum3 but larger than sum1 then default to Resistor
  else if(sum2 == sum3 && sum2 > sum1){
    component[0] = 'R';
    component[1] = itemColor;
  }
  //if sum2 is greater than sum1 and sum 3 then item is capacitor
  else if(sum2 > sum1 && sum2 > sum3){
    component[0] = 'C';
    component[1] = itemColor;
  }
  //if sum3 is greater than sum1 and sum2 then item is LED
  else if(sum3 > sum1 && sum3 > sum2){
    component[0] = 'L';
    component[1] = itemColor;
  }
  else{
    Serial.println("[ITEM] Barcode didn't yeild a known option. Report BUG!");
    Serial.print("\tSUM 1: ");
    Serial.println(sum1);
    Serial.print("\tSUM 2: ");
    Serial.println(sum2);
    Serial.print("\tSUM 3: ");
    Serial.println(sum3);
    Serial.print("\tSUM 4: ");
    Serial.println(sum4);
  }
}

char checkColor(int color){
  char res;

  if(color >= 0 && color < 9){ //red
    res = 'r';
  }
  else if(color >=9 && color < 18){ //green
    res = 'g';
  }
  else if(color >= 18 && color <= 27){ //blue
    res = 'b';
  }
  else{
    Serial.println("[Color] Barcode didn't yeild a valid result, report the BUG!!");
    Serial.print("\tSUM 4: ");
    Serial.println(color);
    res = 'N';
  }

  return res;
}

void drawHiddenObject(char obj, char color){
  if(obj == 'R'){
    oled.clear(ALL);
    oled.clear(PAGE);
    oled.drawBitmap(resistor);
    switch(color){
      case 'r':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Red Resistor");
        oled.display();
        break;
      case 'g':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Green Resistor");
        oled.display();
        break;
      case 'b':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Blue Resistor");
        oled.display();
        break;
      default:
        break;
    }
  }
  else if(obj == 'L'){
    oled.clear(ALL);
    oled.clear(PAGE);
    oled.drawBitmap(led);
    switch(color){
      case 'r':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Red LED");
        oled.display();
        break;
      case 'g':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Green LED");
        oled.display();
        break;
      case 'b':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Blue LED");
        oled.display();
        break;
      default:
        break;
    }
  }
  else if(obj == 'C'){
    oled.clear(ALL);
    oled.clear(PAGE);
    oled.drawBitmap(capacitor);
    switch(color){
      case 'r':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Red Capacitor");
        oled.display();
        break;
      case 'g':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Green Capacitor");
        oled.display();
        break;
      case 'b':
        oled.setCursor(0,0);
        oled.setFontType(0);
        oled.print("Blue Capacitor");
        oled.display();
        break;
      default:
        break;
    }
  }
  else Serial.println("\tObject passed doesn't register, report the BUG!!");
}

Until next time...

I’ve got a long way to go in this project, and I’m having a blast. I want to take it further by incorporating an inventory system and making it a mobile handheld device, like the Skannerz toy. Either way, the parts I used in this project are easy to use and make a fun game with. I’ve been scanning several shelves of cans in the pantry, much to the bewilderment of my family. I hope you like this project and get some inspiration for your own barcode-based game. I’ve found that time flies when you scan the day away!

comments | comment feed

Meet Anna Ploszajski: Where making and materials meet

via Raspberry Pi

In the latest issue of HackSpace magazine, Andrew Gregory meets Anna Ploszajski to explore the bit of the Venn diagram where making and materials meet.

Anna Ploszajski (pronounced Por-shy-ski) is a cross-channel swimmer, a materials scientist, a writer, and a breaker-down of barriers to scientific understanding. 50% of the HackSpace editorial team listen to her podcast, Handmade, from which has arisen a book: Handmade: A scientist’s search for meaning through making. Naturally, we wanted to talk to her to find out why we humans do what we do when we turn object A into object B. That’s a pretty big question, but if anyone can answer it for us, Anna can.

anna ploszajski glass blowing
Anna’s journey into making began with watching a bit of broken glassware getting fixed
(Image: Charlie Murphy)

HackSpace: Hi Anna! You’ve written a book about making. Before we get on to that, though, we’d like to ask you about something you’ve been working on in your non-writing life – 4D printing. A while ago we saw a box with a hinged lid; the hinges were fabric, and the box was PLA, so you get the benefits of two types of material in one object. I guess what you’re doing is rather more advanced than that?

Anna Ploszajski: You say that, but I’ve been doing quite a lot of experiments in 3D printing onto fabric to try and make a 4D thing, because PLA has a kind of shape memory. I was wanting to do the experiment that I was doing (which actually I described at the end of the book). I’m trying to draw a conclusion about how my adventures in craft had also impacted my scientific research life. And the example that I use is this experiment that I did 3D printing onto fabrics. 

What I was doing began with  sort of pre-stressing, just normal textiles. I think there was a cotton, linen, pre-stressing it, just stretching them out with my hands, and then attaching them onto the print bed. And so, you already put in a kind of internal strain into the fabric, then 3D-print a very simple design that was either a circle, or just simple lines. And then obviously, when you print onto it, then the PLA plastic is bonded onto the textile. My idea was that if you then heated that material up, then it would soften, and that tension that you’d put into the fabric would be released. So that was my idea. 

anna ploszajski with woollen materials
Anna’s mission is to make science available to non-scientists
(Image: Steve Cross)

My project was all to do with exploring this idea of 4D printing. So printing, using 3D printing, to make objects that move in some way after you’ve printed them. The thing about it is, it’s adjacent to this topic of smart materials. There’s a family of materials that have some kind of smart property, usually it’s colour-changing or shape-changing in response to an external stimulus. So, that could be temperature change, or light levels or moisture levels. 

And those smart materials are not actually that smart, it turns out, because what they do is really simple. Let’s take the example of a really simple shape change: wood is a really good example. It expands when it gets wet. And it contracts when it dries out. By our definition of a smart material, that is a smart material because it changes shape when there’s a change in environment. And that’s a very simple  movement. And these smart materials tend to just have this kind of flip-flopping between two simple states – either, you know, an expanded state or a contracted state in this example. That’s not actually that useful, unless you can do a clever design to use that movement to form a clever kind of motion. 

A really good example in nature is the pine cone; the spines of a pine cone have this really ingenious bi-layer structure, where one side of them has a very hygroscopic wood – it expands a lot when it gets wet. And the other side doesn’t expand a lot when it gets wet. So, when the pine cone gets wet, it’s that bi-layer structure that causes that movement. The wood itself is just expanding. But the contrast between the two is what causes that motion. So I was trying to get inspired by that and combine, using clever design, a quite simple, smart material with some design that would combine it with a non-smart material that would cause some kind of motion.

It’s all to do with stored tension, and  triggering that tension release. And to be honest with you, I didn’t get very far with it. I understand the material side; that was fine. And I could do all my experiments in the lab, and I could characterise the materials fine, but I just don’t have a designer’s brain. 

And that is what the book is about in a way: trying to access or tap into these other skills that designers and makers and craftspeople have which I don’t.

hand made bookcover
Anna’s book Handmade: A scientist’s search for meaning through making is available to buy now

HS: How much have you learned over the course of writing the book? You must have had to speak to all sorts of people to research it.

AP:  I think that meeting all those craftspeople, and getting a view into their world, really gave me an appreciation for exactly how much work and time and skill and practice goes into really honing these skills. Wood is a really good example: when I did the wood carving workshop with Barn the Spoon, it took hours trying to make a spoon, but when I did it, mine didn’t look anything like 
his spoons. 

The skills themselves are often not that complicated or difficult to do. It’s the constant practice in refinement and design, which are the skills that I didn’t necessarily have.

HS: What led you to write the book? 

AP:  A few things. Firstly, I wanted to write a popular science book that didn’t cater to the normal popular science audience, by which I mean people who are already relatively interested in science, the types of people who would browse the popular science sections in a bookshop and pick things up about space, or the gut, or whatever. I feel like that audience is already very well catered for.

What I wanted to do was try and write a popular book that would be read by someone who would never normally read a science book – that’s the whole of the rest of the population. So you’ll notice in   the book that there are a lot of scientific analyses and explanations, but they’re all quite short. And my hope was that, if someone’s coming at this with not very much prior knowledge of science, they 
get to a description of the quantum mechanics behind why glass is transparent. But on the next page, we’re back to the story. And it’s really those stories that were the most important thing to me.

anna ploszajski
Like the sound of a materials scientist on a journey into making? Listen to Anna’s excellent Handmade podcast
(Image: Steve Cross)

And so, in each of the ten chapters on different materials, the story isn’t the story of the material – it’s the story of something else. So in Plastics, it’s the story of my Polish grandad and, you know, his life story throughout the 20th century, which intertwines with the story of the rise and fall of plastics. 

I wanted to draw all these other audiences in by storytelling, and then hopefully, sneak the science in when they weren’t looking. 

The story of the book itself is to do with feeling very inadequate, I suppose. I had this realisation, having walked into the Institute of Making for the first time, that I was supposedly this expert in materials, having studied the science of it, having studied all on paper, but actually, there were all of these different people that had so much more in-depth knowledge than me. The craftspeople and the makers and the artists and the historians and the designers and the architects… And so it was them that I really wanted to spend time with and learn from. 

That was four years ago. That was when I started my podcast, which is also called Handmade. And that was where I started interviewing makers and craftspeople. And the book just grew from that. Quite a few of the people that I interviewed on the podcast have ended up being featured in the book as the very, very, very kind craftspeople that took me under their wing and showed me the ropes of what they do.

To take blacksmithing as one example – I thought I was an expert in materials, but I had never felt metal softening under my fingers. Yes, I knew the theory, I could draw you the iron-carbon phase diagram, I could talk about the phases and melting, and all of the ways that carbon and iron interact at the atomic level inside steel. But I’ve never done it. And I didn’t know how hard you had to hit it to make it change shape. Agnes, the blacksmith who taught me, is just so, so brilliant. I’m such a huge fangirl of her. And it was very humbling, actually, to spend time with people like that. 

anna ploszajski mug from ceramic materials
It’s one thing to understand the molecular changes that occur when you fire clay; it’s another thing entirely to be able to make a pot

HS: Getting to touch and feel the materials rather than study them, was there any one in particular that you gained an appreciation of? 

AP:  My favourite chapter in the book is Sugar, because it was the most fun story to write. And it’s the story of my English Channel swim. [Yes, you read that right – Anna has swum the English Channel.] One of the reasons was, I think, it already is one of the strongest chapters for storytelling. Because it is this kind of archetypal physical journey from A to B, but also a journey of discovery about yourself. And intertwined in that story is the story of sugar, and all its different forms, and how it affects the body and the mind. 

In terms of the crafts, it was really wool that caught my imagination, and I’ve stuck with it. The story of wool is the story of my camper-van trip around Scotland and the north of England. I acquired wool from all these different places that I went to on my trip, and then knitted a patchwork blanket with all the wool I got from the different places. And through doing that, I taught myself how to knit and I met all of these kinds of amazing knitters and wool-craft people throughout Scotland and the north of England, and chatted to them and got an insight into this amazing world of women who knit – and they were all women – and what it means to them, and how it connects them. And it’s very meditative, I find, and that’s the craft that I’ve taken through since finishing the book a year ago. That’s the craft that I’ve continued with. 

anna ploszajski made a blanket from wool materials
Knitting contains loads of mathematical patterns, which knitters seem to understand intuitively

I don’t know what it is about it. It just feels so nice to create something, you know, especially in the last year when we were all sitting at home watching Netflix and trawling through the movies and TV shows on there. Although that felt like perhaps a bit of a waste of time, actually, if I was knitting while watching TV, it wasn’t all a waste of time; I had something to show for it at the end. And I think that’s what craft gives us – it’s a sense of purpose almost, and a sense of achievement at the end. 

You know, to have that sense of achievement of ‘I’ve made this’ and now I can wear it, or now I can use it. I haven’t had that in science before. I only got that when I started entering this world 
of craft. 

HS: It sounds like you see a disconnect between science and making. Is that fair to say?

AP:  I’ve thought a lot about this: this kind of compartmentalising of making and science, or art and science as I talk about in the book (and I know that art and making are absolutely not the same thing). And I think there are a lot of reasons why the arts and sciences have been sort of severed from each other. In formal education, we separate them. At school, we have to often choose between those types of subjects. I ended up going down the science route, but I did A-level music. I love writing and music and history, and I was always crap at art, but I enjoy it. I think it’s really unhelpful that   we do that, because it means that we brand people as ‘you’re a scientist’, or ‘you’re more of an artist’. And actually, I think the majority of people are probably somewhere in the middle. Actually, they have interest in both. 

anna ploszajski socks
Wool was hugely important for England’s development into a major mediaeval power. It’s also good for keeping your feet warm

It’s a real shame that we often get siphoned off into these different camps, and often don’t get the chance to rediscover the other one. As someone who was siphoned off into the scientific track, it was really liberating to be able to discover the craft and artistic world. It was, like I say, very humbling. It was also really nice to be a complete beginner again at something, to be able to ask the silly questions from a place of curiosity, with no pressure, no educational pressure. I wasn’t trying to achieve anything apart from trying to make a spoon, or forge a knife, or throw a pot, or whatever it was. 

Materials is a really interesting subject because it can sit at this intersection between the artistic world and the scientific world. Materials, perhaps uniquely in the sciences, is a really lovely way to explore the more artistic side. And what I’ve discovered through the book and through the podcast, is that we all understand these materials, maybe in slightly different ways. But quite often, it’s just that we use different language to talk about them. I remember interviewing a silversmith on my podcast called John Cussell, who described cold-working silver metal to me as making the atoms angry. So, when you cold-work silver, it becomes more and more stiff. I would describe that as putting dislocations into the material and putting internal stresses and strains to make them more brittle. We’re both talking about the same thing in different ways. And I think that, really, the wonderful thing that I love about materials is that it can be this  common substance, literally, through which all sorts of different people can talk to each other. 

anna ploszajski smiling in a blue top
We’re fascinated by the idea of 4D printing – printing an object that’s designed to move
(Image: Steve Cross)

HS: Citizen science has taken huge steps forward recently in broadening access to scientific research, but very often it’s locked away inside university buildings and it’s a real shame. What do you think can be done about that?

AP:  That’s my life’s mission, to try and break science out of universities through doing things like writing the book and the podcast, and the talks that I give. I really want to invite people in and show them that science – it’s a huge cliché but science really is everywhere. It’s never been more important than in the last 18 months to understand science, virology, how contagions spread – that’s all science. And the science communication that’s going on around that has been mixed. Some of it’s been really good, but some of it’s been really damaging. That’s what’s important to me is to break science out of these institutions, because a lot of people are turned off science at a very early age. And unlike a lot of other areas, it’s impossible to turn back. If you go down a non-scientific route, through school, and then maybe through university or through a job, it’s impossible to go back on that and pick it up again later. I feel like subjects like history and literature are much more accessible to everybody. Whereas science is considered to be more for a select few, you know, a chosen few who are allowed to do it. And that’s really not fair. 

HS: Are craftspeople scientists? There must be a lot of crossover in terms of learning, experimentation, and so on. 

AP:  I think you’d have to ask them, but whatever it is they do is experimentation, right? And they do experiments all the time – what temperature do I need to make my steel to make it do X? Or, what composition do I need my clay to be to make it do Y? How do I do the settings on my furnace to make sure that my pots don’t explode? And that is exactly the sort of stuff that we would do in the lab, you know: methodical experimentation. So in that way, definitely. I can’t see that there’s any difference at all between that. And in terms of the way that craftspeople and scientists think, that’s much more difficult to answer. 

Most science has arisen from craftspeople and early experimenters. The subject of material science arose out of the subject of metallurgy, which arose out of blacksmiths like Agnes. If you go back far enough, it’s all the same thing.

HackSpace magazine issue 46 out NOW!

Each month, HackSpace magazine brings you the best projects, tips, tricks and tutorials from the makersphere. You can get it from the Raspberry Pi Press online store or your local newsagents.

hackspace front cover red and yellow graphics featuring a spanner and test tube

As always, every issue is free to download from the HackSpace magazine website.

The post Meet Anna Ploszajski: Where making and materials meet appeared first on Raspberry Pi.

Sustainable transformation of agriculture with the Internet of Things

via Arduino Blog

With the urgency to prevent environmental degradation, reduce waste and increase profitability, farmers around the globe are increasingly opting for more efficient crop management solutions supported by optimization and controlling technologies derived from the Industrial Internet of Things (IIoT). 

Intelligent information and communication technologies (IICT) (machine Learning (ML), AI, IoT, cloud-based analytics, actuators, and sensors) are being implemented to achieve higher control of spatial and temporal variabilities with the aid of satellite remote sensing. The use and application of this set of related technologies are known as “Smart Agriculture.”  

In SA, real-time and continuous monitoring of weather, crop growth, plant physical/chemical variables, and other critical environmental factors allow the optimization of yield production, reduction of labor, and improvement of farming products. Practices such as irrigation management, resource management, production, or fertilization operations are being facilitated by integrating IoT systems capable of providing information about multiple crop factors. In this way, while quality and quantity of production are boosted, the negative aspects of unsustainable and costly agriculture practices are also prevented with advanced interconnected actuators and sensors.

Arduino Smart Agriculture

Why Smart Agriculture?

The major focus in this relatively new field is crop optimization through higher productivity and significant control over environmental variations. Smart agriculture provides a convenient way to integrate farming management by having in-hand mobile devices that receive data collected from Unmanned Aerial Vehicles (UAV), satellites, or wireless sensors that operate directly at the plant level and are connected, for example, to cloud-based systems.

In general, SA can potentially:

  • Reduce water consumption,
  • Implement a better plant nursing process with optimized nutrient levels,
  • Decrease risk of yield loss,
  • Assurance of higher revenue,
  • Better yield quality,
  • Decrease overall production of waste,
  • Simplification of labor,
  • Enhance environmental protection.

From small farming to urban gardening

The IoT can provide solutions for small farmers ranging from resource management to climate adaptability. However, urban gardeners or small producers are also benefiting from innovations brought through the evolution of IoT. Figure 4 shows a typical low budget and high precision system designed to improve irrigation in urban gardens. 

The system is relatively simple, but it offers the potential easiness of building open-source solutions without significant technical constraints in different setups where adaptation to environmental conditions is required. Basic electromagnetic sensors, power supply, a water pump, relays, and the irrigation system are hardware interconnected and managed via cloud-based monitoring. A control unit receives the data that the user later accesses via the internet. 

Arduino small farming to urban gardening

Technology democratization can boost the competitiveness of small producers. 

Despite the tremendous potential of SA, technical issues are just one aspect of the whole story. The deployment of high-tech solutions that are less costly, accessible, reliable, and durable has not yet reached maximum potential. The limited internet coverage in rural areas, especially in emerging economies, slows down the deployment of SA technologies.  It is why the democratization of IICT, including the internet, is not a discussion of privilege. It is crucial to support the sustainable transformation of agriculture in which small farmers and rural communities can also benefit from technological development. 

To increase the adaptation of IIoT solutions, Arduino Pro has recently launched ARDUINO EDGE CONTROL (AEC). With its ease to adapt to solar-based power supply, AEC offers the power of AI with state-of-the-art connectivity modems. To learn more about how you can use the Edge Control, check out how to get started.

This is an edited version of an article originally published on Wevolver. For references used in this article, check the full piece at Wevolver.

This is an edited version of an article originally published on Wevolver. Please check the original article for references used within this post.

The post Sustainable transformation of agriculture with the Internet of Things appeared first on Arduino Blog.

Trakcore is a Nano 33 IoT-based posture correction device

via Arduino Blog

Poor posture is an epidemic for nearly anyone who spends an excessive amount of time sitting, and this can lead to a whole host of problems later in life. Some of these might include back pain, limited range of motion, and muscle tightness. Recognizing that his own posture was lacking, element14 user vlasov01 got to work designing and constructing a small wearable device for element14 Design for a Cause 2021 contest, which could help him alter his posture throughout the day to a more correct one. This project was dubbed the Trakcore, and it uses the sensors on the Arduino Nano 33 IoT to sense how a person is sitting or standing and then sends an alert when it needs adjustment. 

Trakcore started with collecting large amounts of data that included positional data for both straight and curved spinal shapes. Next, this dataset was used to train a model within Edge Impulse’s Studio that could infer which position the user is currently in. Once the code to integrate the model with the IMU, vibration motor, LED, and BLE stack was finished, an app was created to receive notifications from the wearable device and display them.

After adjusting some variables within the code and making the wearable ignore posture while the user is walking, the Trakcore was subsequently tested and performed quite well at notifying the wearer when their posture was incorrect. 

You can read more about the Trakcore here.

The post Trakcore is a Nano 33 IoT-based posture correction device appeared first on Arduino Blog.

Name that Ware, August 2021

via Hacking – bunnie's blog

The Ware for August 2021 is shown below.

This months ware is probably a pretty easy guess. To make things a bit more interesting, the prize will go to the entry that has the most feasible (or the most entertaining!) theory as to the purpose for the tiny break-away, stand-alone PCB is on the left hand side, as indicated by the red arrow. The cropping just barely obscures the edge of the PCB, but basically there are three mouse bites on the edges that retain the sub-assembly PCB, so it could be sheared off and turned into a separate item. I always pay extra attention to blank spots like this PCBs, because they are riddles into some aspect of a product’s design or supply chain: someone put the effort in to design a thing — but then decided not to use it. This PCB has a lot of blank spots, but this is the only one that could be readily sheared off into a separate assembly.

This ware is also a guest ware, courtesy of “JeffA”. Thanks for the submission!

Winner, Name that Ware July 2021

via Hacking – bunnie's blog

The Ware for July 2021 is a PC-60FW Fingertip Oximeter, which was distributed to each household in Singapore by the Temasek Foundation, free of charge. I thought this was a pretty interesting ware for a few reasons. First, it’s a free oximeter! Kind of a neat thing to play with. You can hold your breath and watch your SPO2 levels go down, or try to meditate and control your pulse.

Second, I found it quite interesting because no where on the box or the manual does it mention that this thing has Bluetooth. Of course, I take apart most things that arrive at my doorstep to see what’s inside — that’s just how I roll. Since it was a free device, I assumed it would probably be a bare-bones implementation, not expecting to see much more than a black glob of epoxy and a few wires when I opened it. Instead, it had these fairly name-brand components, and the antenna came as a bit of a shocker because I didn’t expect any sort of telemetry from the device. The box bears no indication of a radio transmitter — there’s no EMC-compliance notice, MAC address, icons, or any kind of verbiage that would typically compliment a radio transmitter. Must be nice to be able to ship millions of units of a product without having to deal with EMC compliance. After a careful inspection of the manual, however, there is a reference to the fact that you could download the “@Health” app, which includes a QR code to a random website to side-load an APK into your phone from “Shenzhen Creative”.

I’m not quite sure what was the thought behind including the Bluetooth function — it’s not cheap, especially for a nationwide-scale deployment. I would have assumed they were going to integrate this into their “Healthhub” app which is the official government app for managing healthcare, to allow them an opportunity to triage COVID cases before bringing them into the ward. However, I didn’t investigate the @Health app any further; it was served from a Chinese-style domain name I didn’t recognize, without https, etc. etc. I don’t have the time to deal with disassembling the app to make sure it’s clean before installing it, so I just steered clear of it. A Nordic Bluetooth radio on its own isn’t a perilous surveillance threat, due to its limited range and capability. However, once paired with a smartphone app, the scope of the data goes global and the threat is much more severe due to the potential for data fusion with the smartphone’s sensors, and other private data within.

Anyways, I found it a bit surprising that my pulse oximeter has a radio, and thought it’d be a neat ware to share!

This is a picture of the “less-interesting” side of the oximeter PCB. It uses the same OLED display that found its way into the $12 Shanzhai phones from the turn of the millennium. That characteristic cyan-and-amber color scheme seems to be the “go-to” display for budget-conscious IoT devices these days.

Bienvenu is the clear winner on guessing this one, congrats! email me for your prize.