Contributing sensor code ALS31313

I believe I have this working but my puny brain only has the faintest grasp c++, the math, or how simpleFOC actually works

What’s the best way to contribute this?
Was using method overrides the right way to implement this?
Did I make any mistakes?

There is a faster loop read capability for the sensor but I wasn’t sure how to integrate that.

Here is the code, appreciate any feedback:

Nice one for getting this working! Is it running OK? I look forward to seeing your next video with it in action.

Typically contributions take the form of a git pull request. i.e.

  1. go to
  2. click the fork button
  3. once the fork is complete you do the normal git steps
  • git clone<your github alias?/Arduino-FOC.git
  • git branch -b branch-for-als31313
  • (copy cpp and .h files to src/sensors. Probably don’t need the ino unless you think it is worth adding as a demo)
  • git add .
  • git commit -m “this commit is for a new sensor”
  • git push -set-upstream origin branch-for-als31313
  1. Then go to github - swap to your new branch and click create pull request. It should now that you want to do the pull request to simplefoc/Arduino-FOC. If you can target dev branch rather than master that would be cool!

As for feedback - it’s probably easier to do that on the pull request. Some quick points - remove commented or unused code. Don’t assume everyone is using Serial (I’m not sure if our other sensors have any print statements!). If you can think of ways to simplify or make it more common with existing code all the better.

It’s tough reading these datasheets and getting sensors working. You can code!

Thanks for the response Owen.

I can do a pull request, I have a few things to tidy up like the address configuration. If I keep it in it’s current form it would require the user to include the header. I wasn’t sure that was how additional drivers were expected to be included. That method works fine for me.

Should I create an example?
Where should i put the files, how about: ./src/sensors
What about documentation?