mastodon.me.uk is one of the many independent Mastodon servers you can use to participate in the fediverse.
Open, user-supported, corporation-free social media for the UK.

Administered by:

Server stats:

532
active users

#PicoW

0 posts0 participants0 posts today

Right, current status with all my mucking about with #Rust on #RaspberryPi #PicoW: yvan.seth.id.au/rusty-pico-w-c

With all the hard work done by embassy, picoserve, and libscd — I can display some sensor data on a web page served by the PicoW... this has taken me at least 5 days. 😅

It's a steeper learning curve than I expected!

A bunch more work to do, but right now I really need refresh my Python knowledge. As ever it's hard to know what things to focus on in my limited time... I've got it boiled down at present to refreshing myself on Python and C++ whilst learning some Rust... with the goal of hopefully being able to prove my employability.

Yvan's Posts · Rusty Pico W - CO2 PPM SensorThe Meat-Pi project takes a deviation via a SCD40 CO2 PPM sensor (learning embedded Rust)

Hurrah... my #Rust based #PicoW SCD40 CO2 sensor thing is working. Had a few gnarly problems, have some definite concurrency issues going on I think, I need to dig deeper into how the whole async/mutex situation in Rust/embassy works. But we were also self-DoS-ing as the sample HTTP code I started with had keepalives on, which just doesn't make any sense for this use-case. The moment I added the JS stuff it broke, turn off the keepalives: no problems!

So now I have a page served by the Pico which has the CO2 PPM, temp, and humidity being updated every couple of seconds.

This forms a base for adding further/different sensors and expanding on that, learning as I go, as always. Want to get the built in RTC working, and timestamp results, and store in flash with a bulk-get capability.

And on the topic of flash, need to work out persistent configuration too.

Fairly happy with that at day ~5 of using Rust for the first time.

FUCKING A!

I have a #Rust programme on my #RaspberryPi #PicoW that reads data (an u16) from a sensor and you can then get that data from a web request. HUGE ACHIEVEMENT.

It has taken me like… a large chunk of three days… To get to this point from having code that reads the sensor and serves web requests. 😂 I feel like a moron. But hey, I've only been coding Rust for ~5 days. Probably taking the hard path by going straight into embedded with no::std…

It has taken so many attempts to get to grips with scopes, mutables, Rust's bloody intense syntax, etc, etc… but in the end I've worked out a way to pass a u16 to both spawned workers via some sort of a Mutex. I think I might have an extra level of indirection I don't need… but fuck it, I'll take that I can do this at all as a win.

Now I can take it outside (i.e. not USB-tethered) and see what it reads as an outdoor CO2 PPM measurement.

(I could have had this working in C++ in… minutes, but no, I'm a masochist.)

Continued thread

RIGHT. Fucksake! Arghhh...

I have a solution to this, I do not like my solution to this, but it is a solution...

I reverted my project to use embassy from GitHub again.

I have then grabbed picoserve from GitHub and I have edited the relevant Cargo.toml to use the embassy packages from GitHub.

An in my project Cargo.toml I have referenced my downloaded and modified picoserve instead of using Crates.io... because no matter what I try I cannot make this work using Crates.io packages.

I have now successfully compiled the project modified to use picoserve, loaded it onto the #PicoW, and it runs and serves a "Hello World" via HTTP.

So, another #Rust #embassy #PicoW question.

I started out with embassy examples and had a working thing that compiled and ran on a Pico W.

But then I wanted to use picoserve and this ran me into some dumb looking dependency problems.

I fixed that by following advice to remove the git entries from my Cargo.toml.

However I then have a linker error, one that can be fixed by removing build.rs - but then I get a binary that doesn't work on the Pico W: "entry point is not in mapped part of file"

I think that this is because build.rs was adding these linker arguments: -C link-arg=--nmagic -C link-arg=-Tlink.x -C link-arg=-Tlink-rp.x.

Any one of these being there causes the linker error. I assume something is missing from what needs to be linked in, thus the "undefined symbol" errors. But WHY is this different with the only difference being getting the same versions of packages from git vs crates?!

Edit: hacked a solution, see down-thread

Today I successfully got #Rust code working for a #RaspberryPi #PicoW board! Not bad. All credit goes to the toolchains and projects... my efforts here are purely exploratory / discovery. My current status is I got some Pico / Pico W sample code working and then merged some samples together to form a foundation I'll build more code on top of. The merged code achieves:

  1. DHCP to local network
  2. Listen and respond to TCP
  3. Poke a GPIO (blink)
  4. Logging to USB-TTY

The real TL;DR is: The embassy project seems to be the best starting point for Rust on a Pico W. (Not a Pico 2, this is an older RP2040 board.)

The long version is: yvan.seth.id.au/rusty-pico-w.h

Yvan's Posts · Rusty Pico WGetting Rust working for Pi Pico W

I think I've confused my poor #PicoW running #CircuitPython. It thinks I've pressed a reset button the board doesn't have 😆 (I shorted another USB port on the HUB).

You are in safe mode because:
You pressed the reset button during boot.
Press reset to exit safe mode.

So for what it's worth while the family have been away my "recreational" evening hacking has been to create an #ultrasound depth sensor in #micropython on the #picow: github.com/stsquad/mp-depth

I've done my best to ensure well formed #bluetooth #ble packets have gone out but my phone monitoring tools seem confused. However I think the next thing I need to check is my bluetooth proxy is picking up the packets.

GitHubGitHub - stsquad/mp-depth: A simple micropython depth sensor that broadcasts BTHome BLE advertising packetsA simple micropython depth sensor that broadcasts BTHome BLE advertising packets - stsquad/mp-depth
Replied in thread

@themagpi Finishing off my pair of Farnsworth's ( from Warehouse 13 fame.)

They can talk to each other with both audio and video, either both on the same network or externally via a python "Strowger" server (I decided against calling this Exchange) over UDP

Each contain a PI #PicoW a Circular display, microphone, speaker and a camera

Details on the build extremeelectronics.co.uk/farns

@Raspberry_Pi

Replied in thread

@themagpi I've been slowly checking a design for an event/temp/humidity logger. The #PicoW should spend most of it's time powered off until the RTC/pin change wakes it. At the cost of a few uA (and £) I'm using an I/O expander to record what changed/woke it so reading GPIO isn't a high priority after power up which should make the code a little easier.

I also bodged up a 3 to 4-pin cable to repurpose the I2C port for UART "print" debugging when it's on battery 😇 .