Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
Teo Serra
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Academany
Fab Academy
2024
Fab Academy 2024 Labs
ULB
ULB students
Teo Serra
Commits
b70433c6
Commit
b70433c6
authored
1 year ago
by
Teo Serra
Browse files
Options
Downloads
Patches
Plain Diff
Week 9 add doc
parent
8f12c801
Branches
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#446470
passed
1 year ago
Stage: test
Stage: deploy
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
content/WeeklyAssignments/week9.md
+152
-5
152 additions, 5 deletions
content/WeeklyAssignments/week9.md
with
152 additions
and
5 deletions
content/WeeklyAssignments/week9.md
+
152
−
5
View file @
b70433c6
...
...
@@ -30,14 +30,161 @@ This part was done in group and is accessible on the [group page](https://fabaca
## Adding Output Device to my Board
Add c
ontext
(final project)
### C
ontext
e of the Week
add oled panel using i2C my Board.
This week I decided to continue with my final project. The first phase of
development focuses on the development of a frequency-controllable high-voltage
generator. Last week I developed a first version of the electrical board and
ordered the various components.
Explain I2C communication.
This week I've decided to add an OLED screen to display various control information.
This will be very useful for the final project.
Explain programming oled (adafruit livrary)
To do this, I'll need to use the I2C protocol to communicate with my display.
### What's I2C ?
I2C, which stands for Inter-Integrated Circuit and is said like "I-squared-C,"
is basically a way for gadgets to talk to each other using just two wires, even
if there are lots of them on the same bus. Think of it as a party line for
electronics where:
*
**SDA (Serial Data Line):**
This is the line where all the gossip (data)
gets passed around.
*
**SCL (Serial Clock Line):**
This is like the rhythm of the music at the
party, keeping everyone in sync.
Why do people love I2C?
*
**Crowded Parties:**
You can have a bunch of devices chatting it up on the same
two wires without missing a beat.
*
**Easy Setup:**
Only needing two wires keeps things simple and cheap, especially
when adding more friends (devices) to the party.
*
**Flexible Guest List:**
You can invite or kick devices off the bus without
ruining the vibe for everyone else.
In the DIY electronics world, I2C is everywhere because it's super handy for making
different parts, like sensors or displays, talk to your main controller without
a wiring nightmare.
### Adding OLED Display
Given that the manufacture of my electronic board has been delayed due to the
delay in orders, I've decided to do the development on a raspberry pi pico.
This will then be easily transferable to the Seeed RP2040.
The OLED screen I'm going to use needs to be powered by either 3V3.
It must also have an I2C connection to my microcontroller
, as explain before, for information transmission.
These are the four pins I had planned for the previous week.
*Add scheme & picture*
### Programming OLED Display
I wanted to try out programming the Raspberry in python, so
there are a few extra steps before I get into the coding part.
This will enable you to write and run MicroPython scripts directly on your
Pico from within VSCode.
#### Flashing MicroPython onto the Raspberry Pi Pico
First things first, I needed to get MicroPython onto my Pico. Here's what I did:
1.
**Downloading MicroPython Firmware:**
I visited the official Raspberry Pi website and downloaded the latest
MicroPython firmware
`.uf2`
file tailored for the Pico.
2.
**Entering BOOTSEL Mode:**
With my Pico unplugged, I held down the BOOTSEL button and connected it to
my computer via USB. This action put the Pico into BOOTSEL mode, ready to
receive firmware updates.
3.
**Flashing the Firmware:**
I located the downloaded MicroPython firmware
`.uf2`
file and dragged it
onto the Pico's USB drive. The Pico rebooted automatically, indicating that
the firmware had been successfully flashed.
#### Setting Up the Micro Pico Extension in Visual Studio Code
Now that MicroPython was running on my Pico, it was time to configure VSCode
with the Micro Pico extension:
1.
**Installing Visual Studio Code:**
If I hadn't already, I downloaded and installed Visual Studio Code from the
official website.
2.
**Installing the Micro Pico Extension:**
I opened VSCode, navigated to the Extensions view, and searched for "Micro Pico"
in the Extensions Marketplace. After installing it, I was ready to connect my Pico.
3.
**Connecting My Pico:**
I connected my Raspberry Pi Pico to my computer via USB.
4.
**Opening the Micro Pico Extension:**
I clicked on the Micro Pico icon in the sidebar or used the Command Palette
to open it.
5.
**Selecting My Pico:**
If prompted, I selected my Pico from the list of available devices. The
extension automatically detected my connected Pico.
With MicroPython flashed onto my Pico and the Micro Pico extension set up
in Visual Studio Code, I was ready to dive into coding.
This code sets up an OLED display and dynamically updates it with various
pieces of information. Here's a breakdown of the code:
```
Python
import machine
from lib import ssd1306
import time
# Define pins for Raspberry Pi Pico
i2c = machine.I2C(1, scl=machine.Pin(7), sda=machine.Pin(6))
# Define OLED screen resolution (128x64 pixels)
oled = ssd1306.SSD1306_I2C(128, 64, i2c)
# Initialize OLED screen
oled.fill(0)
oled.text("Hello, World!", 0, 0)
oled.show()
# Define frequency variable
frequency = 100 # For example, 100 Hz
# Define signal type variable
signal_type = 'sine wave' # For example, sine
# Define power consumption variable
power = 15 # For example, 15 Watts
# Define time from starting
start_time = time.time()
# Main loop
while True:
# Clear the screen
oled.fill(0)
# Display title and frame
oled.text("HV Gene infos",0,0)
oled.rect(0, 10, 128, 54,1)
# Display variables
oled.text("Type: {}".format(signal_type), 2, 12)
oled.text("Freq: {} Hz".format(frequency), 2, 22)
oled.text("Power: {} Watts".format(power), 2, 32)
oled.text("Timer: {} min".format(round((time.time() - start_time)/60,1)), 2, 42)
# Update the display
oled.show()
# Wait for a short period of time (for example, 1 second)
time.sleep(1)
```
### Measure Power consumption of my OLED
How and how much (but here not constrain because not on battery)
\ No newline at end of file
see group page
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment