Giter Site home page Giter Site logo

bjarnebitscrambler / signalk-orientation Goto Github PK

View Code? Open in Web Editor NEW
5.0 3.0 8.0 904 KB

Provides Vessel Attitude, eCompass, Orientation, etc using SensESP, Signal K, and a 9DoF sensor.

License: BSD 3-Clause "New" or "Revised" License

C++ 100.00%
esp8266 esp32 orientation signalk 9dof attitude ecompass sensor-fusion arduino-library vessel navigation

signalk-orientation's Introduction

SignalK-Orientation

Overview

This library provides vessel and vehicle orientation information in Signal K message format. Available orientation data include:

  • Attitude (yaw, pitch, roll)
  • Compass Heading and Magnetic Heading (corrected for deviation)
  • Acceleration in 3 axes
  • Turn Rate
  • Pitch Rate
  • Roll Rate

It uses a 9-axis combination accelerometer/magnetometer/gyroscope attached to an Espressif ESP32 processor. Sensor fusion is performed by the ESP using a port of NXP's version 7 sensor fusion library, and formatted into Signal K by the SensESP library. SensESP also takes care of transferring the orientation data via WiFi to a Signal K server.

Using the hardware below, Signal K messages containing heading data can be output at up to 40 Hz.

Hardware

Orientation sensing uses an NXP FXOS8700 and FXAS21002C/FXAS21002CQ combination sensor, like the Adafruit 3463 module

Processing and WiFi connection is provided by an ESP32 module. It has been tested successfully on following boards:

The software is adaptable to work with other orientation sensors, but the most straightforward approach is to use the above already-tested hardware.

Software

The PlatformIO development environment and Arduino framework are used, with standard Arduino libraries plus these two:

Setup

Follow the instructions in the SensESP README to install Signal K and SensESP. The base installation of SensESP provides several built-in sensors - reporting information like Uptime, Freemem, and IP Address - which will be readable on your Signal K server once you have your hardware and software set up properly. For the most stress-free experience, it's recommended you don't try to use the orientation library until after you have successfully built and seen the desired output in the Signal K Server.

After you have the basic setup working:

  1. Start a new Project in PlatformIO for the Arduino and your processor platform
  2. Copy the platformio.ini file from your working basic project (above) into your new project folder
  3. Make one modification to your shiny new platformio.ini: add these two libraries to the lib_deps section, as follows. See this project's sample platformio.ini for more details and options.
lib_deps =
   [...]
   SignalK/SensESP @ ^2.5.0
   https://github.com/BjarneBitscrambler/SignalK-Orientation.git
  1. Replace the contents of your Project's main.cpp file with the contents of the sample file included with this library (found in examples/example_main.cpp Then edit your main.cpp to reflect the details of your particular setup (e.g. WiFi credentials, I2C pins connected to the sensor, etc). Be sure to read the comments in main.cpp that explain how to enable the various orientation parameters, setup the Signal K paths, and so forth.
  2. Build, upload, and test your Project.

Troubleshooting and Going Further

If you start with a basic configuration and proceed in small testable steps, it should go reasonably smoothly. If you run into difficulty, or just want to learn more, here are some resources:

ESP8266 Support Note

Versions of this library prior to v0.2.0 also ran on the ESP8266 platform, like the d1_mini board. In migrating to use the SensESP v2 library, support for the ESP8266 was dropped. If you really need to run on an ESP8266, you will need to pull into your build environment a version of this library prior to v0.2.0, plus a version of SensESP prior to v2.0, plus several other historical libraries needed by SensESP. This is not a trivial effort.

Memory Use Note

The more sensors producing Signal K reports on a single ESP32 module, the greater the run-time memory usage will be. If the module has less than about 9000 bytes of freemem (as reported by one of the SensESP standard sensors, and seen in the Signal K Instrument Panel), then this may cause difficulties. Symptoms of insufficient free memory include an inability to access the ESP module's web interface. No problems were observed when using all sensors in the example_main_all_sensors.cpp file, running on an ESP32.

One way of reducing memory requirements is to compile the ESP software with #define DEBUG_DISABLED. This causes the RemoteDebug library to ignore all the debugI(), debugE() etc calls throughout the SensESP code and saves about 8900 bytes of RAM. The downside to doing this is that any information one was gleaning from the serial terminal won't be sent anymore, however the Signal K and the sensor's web interface are unaffected. To define DEBUG_DISABLED you can either uncomment the appropriate line in RemoteDebug.h and RemoteDebug.cpp, or the easier way is to add -D DEBUG_DISABLED to your list of build_flags = ... in platformio.ini Remember to do a clean before rebuilding.

More memory-saving details can be found at SignalK/SensESP#239

signalk-orientation's People

Contributors

bjarnebitscrambler avatar tedenda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

signalk-orientation's Issues

status of this repo

forked and tried to build this for esp-wrover-kit, planning to move this to an M5stack Core2

is this maintained or should I look elsewhere like https://github.com/BjarneBitscrambler/OrientationSensorFusion-ESP.git ?
could it be SensESP has diverged so much this does not build any more?

Building in release mode
Compiling .pio/build/esp-wrover-kit/src/main.cpp.o
Compiling .pio/build/esp-wrover-kit/src/orientation_sensor.cpp.o
Generating partitions .pio/build/esp-wrover-kit/partitions.bin
Compiling .pio/build/esp-wrover-kit/lib4b7/EEPROM/EEPROM.cpp.o
In file included from src/orientation_sensor.cpp:5:
src/orientation_sensor.h:13:10: fatal error: sensors/sensor.h: No such file or directory
 #include "sensors/sensor.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFi.cpp.o
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFiAP.cpp.o
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFiClient.cpp.o
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFiGeneric.cpp.o
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFiMulti.cpp.o
Compiling .pio/build/esp-wrover-kit/lib46f/WiFi/WiFiSTA.cpp.o
*** [.pio/build/esp-wrover-kit/src/orientation_sensor.cpp.o] Error 1
In file included from src/main.cpp:28:
src/orientation_sensor.h:13:10: fatal error: sensors/sensor.h: No such file or directory
 #include "sensors/sensor.h"
          ^~~~~~~~~~~~~~~~~~
compilation terminated.
*** [.pio/build/esp-wrover-kit/src/main.cpp.o] Error 1

thanks in advance
Michael

new IMU?

The Adafruit 3463 has been discontinued, replaced by the 4517, which uses a different IMU and magnetometer. I'm assuming the code won't work on the 4517 but wanted to check. If not, any plans to update this repo? Or are there any modules still available that work with the existing code?

Compiled on ESP32-Pico

Hello Bjarne,

I've compiled your code now on an ESP32-Pico, an M5StackAtimLite module. They come in a nice form factor (incl physical button which you can use to store the calibration), and you can buy an ProtoKit to fit the sensor and a RS485 module to have a 12V input. Quite a nightmare before I got it running on PlatformIO though, but with some help on Slack, I have it operational now.

Next thing is to take a look at the calibration, which seems to be not so good, despite several actions to calibrate. I'll report back on the subject later

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.