This is a bit of a step for me, having not done any half serious coding for may years. Given the atrophied state of my aged brain, this won't be easy. However, Claude Code has come to the rescue....
To install this collection you need to:
- Install Visual Studio Code, aka VSC (already present, as I've been using this for a variety of applications, such as Javascript for post processor modification, LinuxCNC HAL file development, CNC file editing etc).
- Install Espressif's ESP-IDF, which is their IDE for development of code for their ESP micrcontroller family.
- Install the ESP-IDF extension for VSC. On the face of it, this should be possible (easy?) from within VSC but I tried and failed a few times. Apparently this is not unusual (being a MS product and all), so installing IDF first seems to be the workaround.
- Also, ideally install Microsoft's C/C++ development tools, debugger etc extensions for VSC (install from within VSC).
- Then, set them up and get them working (arguably shouldn't be a big task but....). I used the "Hello world" example as the simplest possible instance for testing.
- And of course, you need to install Claude Code from Anthropic. If you want Claude to create code for you, you will need the Individual / Pro subscription option which costs £15/mo. It's cancellable at any time.
And of course, you now need to be using full-blown C, rather than the higher level, simplified C++ that Arduino is based on. But that's where Claude Code (CC) comes in.
Copying the hello_world example and renaming / resaving it is the cowardly way to get started with VSC/IDF once it's actually up and running. Then you can get Claude busy coding for you:
The little symbols on the taskbar at the bottom allow you to configure the ESP-IDF for your specific ESP32 board (ESP32-S3 in my case), select the COM port, compile, build and flash the code and start the output monitor.
I'd equate the competence of Claude with that of a fairy enthusiastic and excitable but far from infallible senior software engineer - very much like your archetypal American (Microsoft?) cliche.
What about that test jig you promised, Fatty?
Well, in order to test out the software, I need a physical setup that will allow the Bojke laser distance sensor and the load cell / HX711 to send data simultaneously to the ESP32. Trying to do this by hand merely results in the graph producing horizontal or vertical lines (if twiddling one or other of the sensors) or just a load of random bollocks if I twiddle them at the same time.
What I need is a spring element that generates both a force at the load cell and a displacement at the distance sensor. Ideally I'd also be able to generate some degree of hysteresis (lost motion) but that might be a step for later. To get up and running, I've created the following assembly:
Forgive the auto-generated colours - they allow you to see the different elements within the assembly. It's possible the section view will add some clarity:
- the awkwardly shaped load cell (yellow, bottom)
- the laser sensor (shell body at the top right).
- the spring element (which is actually a 10cm steel ruler)
- a sliding block that allows physical limitation of the movement of the spring.
And indeed, here it is, hot off the 3D printer:
Operation is simple and crude:
- Start the web server by powering up the ESP32 and opening a browser that points to the hard coded IP address.
- The load cell is tared at the initial setting and the displacement measurement is zeroed at its rest position.
- Start the graphing function (clear the screen first, if necessary) and press on the end of the spring. To characterise the opposite direction, lift the end of the spring.
- Stop the graphing function, to prevent further readings.
Here's the output of the first iteration of my stiffness gauge code, which generates a web page with the acquired data:
That works. Next steps:
- Linear regression on loading and unloading curves separately for accurate stiffness calculation
- Automatic reversal detection to split the two curves
- Backlash calculation from the hysteresis gap
It's not intended to be some finely honed device at this stage. But I'm exploring how useful (competent) Claude Code is as much as anything. But that will do for the moment......

No comments:
Post a Comment