Overwhelmed on where to start

Hi all - my first post :slight_smile:

I’ve just stumbled across the Balena cloud and it looks like something that might suit my purposes further down the line.

Only thing is - I’m not finding it easy to start…

I’ve got the Raspberry Pi 4 up and running with the Balena OS, the device is now connected to Balena Cloud and has an air sensor project running (no actual sensor installed, but just so I know that the thing is working … and it is…)

The end goal is to have a nice GUI (Grafana) taking data from sensors (I think via Telegraf and mqtt) on the Raspberry Pi and possibly an Arduino for analog inputs and handling appropriate outputs with some user interactions via touchscreen buttons - I’m pretty sure this system has everything I want and more.

QUESTION 1 -Can this system handle input, the output of data from the device (seems so), and handle user interaction with buttons \ touchscreen via the web interface?

QUESTION 2 - More of a request… Can someone point me at a simple barebones test platform that triggers an LED attached to the GPIO on the Raspberry Pi and takes input from something (switch \ sensor etc) which it stores - I think once I’m at this level and have a starting point I’ll be able to learn (via copy and modify) the rest myself… The project Balena Sense (air quality monitor) was too complex for me to really understand and I need something easier to start with - or a ground-up tutorial on how to build this kind of application.

Is anyone able to point me to a basic program like this and get me started?
(I need something really simple to start with - the Docker system was new to me until yesterday)

Thanks guys :slight_smile:

Hi Lex, and welcome!

Glad to hear you’ve gotten started, have a device attached and functional, and are reaching the point of constructing your application!

As you found the balenaSense project already, that is one of our primary Grafana / Telegraf building blocks. Each service is running in a separate container, so, you can actually strip down, modify, or alter just those pieces in order to pivot and build precisely what you have in mind.

Specifically looking at your questions,

  1. Anything that can run in a container, will work on balena / balenaCloud. Thus, any touchscreens, buttons, or other interactions that can be run inside a container, properly exposing the underlying hardware, will work. So you’ll just want to do some research on your chose hardware / software, to make sure it runs properly in a container.

  2. I think this might be what you are looking for: https://github.com/balena-io-playground/balena-rpi-nodejs-basic-gpio. Keep in mind though, this code is sitting in our “Playground”. It is not meant for production deployments, and can be altered / removed, so you can definitely learn from it but it would be worthwhile to clone, fork, or create your own if you’re going to use if for production purposes.

Hope that helps, and once again, welcome!

Thanks - that’s a good place for me to start.
Never used Javascript before - so it’s going to be a bit of retraining - I managed to get a sleep function going to alternate a couple of lights quite quickly so am happy I can proceed under my own steam.
Thanks for the initial resource - it’s a great starting point.

Is there a way to automatically convert this to a Python file?

Sorry, I do not think there is a good automatic translation from Javascript to Python.

Hey there,

Perhaps you can take inspiration from our example python project.

You can then use a python library for gpio access. I’ve used gpiozero before.

Hope this helps :slight_smile:

What is the correct line to install the gpiozero library and where do I put this line?
I’ve tried putting it in the dockerfile and in the main.py, but no matter what line of code I use or what combination I always end up with a ModuleNotFoundError

Hi there,

I’m not a Pythonista, unfortunately, but my understanding is that if you put the dependencies in the requirements.txt file then the RUN pip install -r requirements.txt line in the dockerfile will take care of that for you.

Good luck,
James.