6. Embedded Programming

In week 4 we learned how to create a pcb and what it is and does. This week we take it one step further. With the Barduino 4.0.1 we get to explore the possibilities of programming.

Furthermore, I created my own pcb and now you can see how i programmed it with the blink code to test it.

Software

To program the board, a specific software is necessary. Now I'm using Arduino. Another program that could be used isThonny.

Unfortunatly, due to a problem with an unknown license that i can't seem to solve, I decided to continue with Arduino.

To swith softwares from Arduino to Thonny, it is important the reboot the board. To do this, you have to press the "B" and hold it and press the "R" too.

Boot: "B" Restart the board with the "B" pressed.

Reset: "R", this erases the code.

Just like the pcb we made in week 4, it is important to understand and have the Pinout explained.

Excel sheet of the Seed Rp 2040

Here you can download the excelsheet for the RP2040

Pinout of the Barduino 4.0.1

Coding

Here's a list of important things in arduino: (Used Chatgpt for this list)

Testing the board

With the Barduino board, there are many things to try out.

Neopixel, buzzer, touch, photoresistor, phototransistor, temperature, etc

This is the example of the temperature test:

With the written code, it is possible to receive information from the board and read it.

As you can see, it is 26°C (in the classroom!)

Code explanation

This code uses an external library called "Temperature_LM75_Derived.h" to interface with a temperature sensor. The sensor being used here is a TI TMP102 temperature sensor.

In the setup() function:

The code initializes serial communication with the computer at a baud rate of 115200 bauds per second using Serial.begin(115200). It also initializes the I2C communication bus with Wire.begin(). This is necessary because the TMP102 sensor communicates over the I2C protocol.

In the loop() function:

The code continuously reads the temperature from the TMP102 sensor and prints it to the serial monitor in the Arduino IDE. It prints a message "Temperature = " followed by the temperature value in degrees Celsius obtained from temperature.readTemperatureC(). It then prints " C" to indicate that the temperature is in Celsius. After printing the temperature, it waits for 250 milliseconds (delay(250)) before repeating the process.

So, overall, this code continuously reads the temperature from the TMP102 sensor and prints it to the serial monitor every 250 milliseconds.

Code for measuring the temperature

#include Temperature_LM75_Derived.h

  TI_TMP102 temperature;
  
  void setup() {
    Serial.begin(115200);
    Wire.begin();
  }
  
  void loop() {
    Serial.print("Temperature = ");
    Serial.print(temperature.readTemperatureC());
    Serial.println(" C");
  
    delay(250);
  }
  

Testing my own board

I created this board with the ESP32s3wroom1 microcontroller. The reason for choosing this microcontroller is that this might be the one i will use in the final project!

This is the code for the blinking program:

    const int LED = 21;
// the setup function runs once when you press reset or power the board
void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED, HIGH);  // turn the LED on (HIGH is the voltage level)
  delay(1000);                      // wait for a second
  digitalWrite(LED, LOW);   // turn the LED off by making the voltage LOW
  delay(1000);                      // wait for a second
}
      

This is a video of the blinking LED on my board.

Useful links

Stuff i need to check and do:

PWM=Pulse Width Modulation

Adafruit neopixel website info

group assignment

week 6