DEV Community

iioaia
iioaia

Posted on

What is this type of programming?

Hi, I'm fairly new to programming. I am using a raspberry Pi, a few sensors and a Unicorn Hat HD.

There are a few sensors that I want to use but they have no python library and my google searches do not find any. Mostly for Arduino.

What field or topic would I need to study in order to create a library for any sensor I decide to use?

Here is an example of what I mean.

Adafruit has released a python library for their cs811 air quality sensor. This is the type of thing I want to learn to create. (Not for the cs811 this is only an example.)

https://github.com/adafruit/Adafruit_CircuitPython_CCS811/blob/master/adafruit_ccs811.py

I understand that is something to do with Registers.

Thank you!

Top comments (4)

Collapse
 
bradtaniguchi profile image
Brad

I'm not sure what you would call this sort of programming, as it really depends on how the hardware is setup to handle the code you write. Most of the time Python code could be considered "high-level", but its flexible enough to leverage C drivers, so it could be considered "low-level-ish". When I say low/high level, I mean lower-level can be considered closer to machine code (yes 1's and 0's) compared to a higher level language that has more abstractions, such as Java or JavaScript running in a browser.

Registers are part of Assembly programming(more or less the lowest-level you can write code in) but I'm not sure if you need to "go that deep".


Now onto your actual library, I'd look into these resources:
piwheels.org/
Which provides a lot of pre-compiled python binaries for ARM architectures. (what raspberry pi's use)

After doing a little searching I did find this package, which might be what you want:
piwheels.org/project/unicornhathd/

Seems to be python libs to interact with the board:
github.com/pimoroni/unicorn-hat-hd

goodluck :D

Collapse
 
iioaia profile image
iioaia

Thanks for the reply Brad, the first part of your reply seems to hint a bit at what I'm looking for.

How to take information from the sensor datasheet, with it's registers and such and create a python library for it.

The second part makes me see a way to refine my question 🙂.

The folks at piwheels are doing what action/coding when they create these libraries?

Collapse
 
bradtaniguchi profile image
Brad

I believe if you were to programing specific hardware to do what you want you'd call it embedded software. Unlike writing code for a general computer, your writing code for a specific machine with specific constraints.

The key is you need to understand how to interact with the underlying hardware. You could end up writing low level C drivers, or something higher level if available. It seems like most of the time the pinwheel libs are the hardware makers themselves, or at least that is what I've seen. So they have access to the hardware+specs to know what and how to interact with the specialized hardware.

Unfortunately I'm getting at the end of what I know about this sorta stuff haha. I only looked into it a few years ago when I was just starting out and learning some basic assembly. 😄

Thread Thread
 
iioaia profile image
iioaia

This looks promising thanks Brad!