Wednesday, February 14, 2024

The electronics test bed.

 


I have most of the devices in the above picture all wired to that Raspberry Pico W plugged into a project board withs screw terminals.. It is only running a small subroutine about once every tenth of a second for the motion detector. All the other sensors execute a function once a minute. The LEDs only execute a function to turn on or off. So basically I have millions of spare cycles every second.

I always create the sketch for a new project all on its own. Just to isolate it from interactions with everything else that is going on in the main project. Once it is fully working I bring it into my main project.

I have to copy the headers at the top of the file, copy the setup for the device and merge it into the existing setup. Then I add a task for the new sensor with a function scheduled to run at the ideal rate for that sensor. That task function contains what was running in the main loop of the example sketch.

I have to add a few lines to the task function to re-add the task each time the function is called. If I need a state machine to control operation, like turning an led on or off, that logic goes in the task function. 

It only takes a couple of minutes to do integrate a functioning example into my test bed with everything else. And so far it is not straining the pico at all, it runs maybe a dozen small function calls a second.

A lot of sensors only need to be ran every few minutes.  Things like temperature, pressure, and humidity don't change rapidly, so you can just read them every 5 minutes.  This also saves a lot of space if you are creating logs. 

The pico has a second core on the cpu and I am hoping to be able to use that extra core to run a web interface.   This interface will allow the device to be controlled and share the data it collects over the network.  And the core that is running all the hardware has millions of spare cycles to do a lot of processing.

I hope to eventually build a weather station, perform home automation tasks, control lighting, build a thermostat, control a greenhouse, control home audio, build answering machine doorbells all with this same small framework programmed by arduino. 

Why am I doing this? I don't love IoT because I have seen too many companies break perfectly good existing hardware when they decide that they want to force everyone to upgrade. It would be impressive to add an "OpenHardware" tag onto everyone that uses this framework in their products to allow anyone else to reprogram it when needed.  And the "OpenHardware" branding means that it 100% runs locally on hardware you own and control. 

No comments:

Post a Comment