Skip to content

Embedded Programming

Scheduling

There’s a lot of stuff to do this week, and school is starting to pick up. I tried my best to fit in as much Fab Academy time as possible in my schedule this week.

alt text


Individual Assignment

This week, we had to program a microcontroller development board to interact with input devices and/or output devices. I decided to create a board this week, since it’d be good practice, and because I’m most likely going to use the ESP32-WROOM-32 for my final project.

PCB Construction

Designing

I started off by going through the Fab Academy page and I found resources for the ESP32-WROOM-32 on the embedded programming resources page. I used these images as a reference to start off my design.

alt text


The Schematic Editor

I opened KiCad, which you can learn more about here, and then started dragging my components onto my workspace.

No. Components Quantity
1 Conn_PinHeader_FTDI_1x06_P2.54mm_Horizontal_SMD 1
3 ESP32-WROOM-32D 1
4 Regulator_Linear_ZLDO1117-3.3V-1A 1
5 Button_Omron_B3SN_6.0x6.0mm 1
6 1uF capacitor 2
7 10uF capacitor 1
8 Standard LED_1206 1
2 109 Ω resistor 1
9 10k Ω resistor 1

I followed the above images as a reference, and then added one LED and resistor (as my output device). After connecting the pins, this is what my schematic editor looked like.

alt text

You can access this file here


The PCB Editor

After confirming that all the components were properly connected, and that nothing was wrong, I moved onto editing the actual PCB footprints. I opened the PCB editor, and all my footprints were on the screen!

alt text

After confirming, I started connecting the components 😭 I spent about 20 minutes connecting everything, and this is how it came out.

alt text

You can access this file here


Mods CE

After exporting my design as SVG files, I opened Mods CE, and then formatted them. I already documented the basic process here, but here are the settings that I used.

alt text

alt text

You can access the RML files here and here


Milling

I used the monoFab SRM-20 to mill this design. I set the origin, and then I started milling.

alt text

The first trace cut was pretty rough in a few areas, and that meant that we didn’t set the copper base plate properly, but the middle area was smooth, so I moved my design there and then printed it successfully (or so I thought 😨).

alt text

When taking this picture of my PCB, I noticed that the ESP footprint looked really weird, and then I realized that everything has short-circuited. So I went back to my Mods CE page, and realized that my DPI was a bit too high. So I went online and found that the ideal DPI was 500. I fixed the DPI settings, and this is what the g-code looked like (no short circuits this time 😉)

alt text

You can access my new and improved file here


Soldering

I made a list of all the components that I needed, and then started to solder.

alt text

alt text


Testing

After soldering, I needed to make sure that all of the components were connected properly, and that the board works properly, so I tested it using a multimeter.

During this time, I realized that there was a short circuit somewhere on my board, but I couldn’t find it anywhere. After double checking everything, I decided to redo my board (with an input device this time). So I redid everything but with an additional LED, and this is how the board came out. Be careful throughout this process, the top 3 pins on the left side are very vulnerable to being short-circuited !!!

alt text


Programming

The Quentorres

Now it’s time to do the actual assignment; programming. For this portion, I decided to program the Quentorres board that we created in week 4.

I opened Arduino IDE, and then opened a “button” code which you can access by following file> examples> digital> button

I selected the Raspberry Pi Pico board, and connected the board to my computer. If you’d like to follow, go through my week 4 page. After that, I selected my tactile switch pin (27), the LED pin (1), and then I uploaded the code.

alt text

This is the code I used:

const int buttonPin = 27;  // the number of the pushbutton pin
const int ledPin = 1;    // the number of the LED pin

// variables will change:
int buttonState = 0;  // variable for reading the pushbutton status

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, HIGH);
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
  }
}

Will it work? 😨

It did !!!

PreFab Academy

Before Fab Academy started, we started learning electronics on our own, taught to us by our local instructor. During this time, all of us made a board each, and I decided to try and program it again for this week.

Similarly to the Quentorres, I opened a new blink file ,

file> examples> basic> blink

After entering my pins, I edited my settings under the tool panel.

alt text I uploaded the code and this is how it came out.

Final Project Board

A few weeks later, and I have a new board. You can find out how to fabricate it at this link.

I’ve decided to communicate to my computer via the serial monitor, but before you start, you’re going to need a Bluetooth/WiFi antenna.

alt text

They usually come with your XIAO ESP32 C3, but you can find tonnes of them online incase you don’t have one. Just search up “Bluetooth antenna for XIAO ESP32 C3”.

Once you have your antenna connected, you’re good to go.

Scanning for WiFi (Station Mode)

I found this code to search for nearby internet connections on the official webpage for the XIAO ESP32C3.For some practice, I decided to follow along with whatever the website had, and so, I started by connecting my board to a WiFi network.

#include "WiFi.h"

void setup()
{
    Serial.begin(115200);

    // Set WiFi to station mode and disconnect from an AP if it was previously connected
    WiFi.mode(WIFI_STA);
    WiFi.disconnect();
    delay(100);

    Serial.println("Setup done");
}

void loop()
{
    Serial.println("scan start");

    // WiFi.scanNetworks will return the number of networks found
    int n = WiFi.scanNetworks();
    Serial.println("scan done");
    if (n == 0) {
        Serial.println("no networks found");
    } else {
        Serial.print(n);
        Serial.println(" networks found");
        for (int i = 0; i < n; ++i) {
            // Print SSID and RSSI for each network found
            Serial.print(i + 1);
            Serial.print(": ");
            Serial.print(WiFi.SSID(i));
            Serial.print(" (");
            Serial.print(WiFi.RSSI(i));
            Serial.print(")");
            Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
            delay(10);
        }
    }
    Serial.println("");

    // Wait a bit before scanning again
    delay(5000);
}

Once you’ve uploaded this code, open your serial monitor to see what connections are nearby!

alt text


The Mentioned Files

(tap the file to download it)

The Trace Cut

alt text

The Interior Cut

alt text


This website was created using a template provided by Mr. Anith Ghalley and was used with his permission.*


Last update: June 23, 2024