Unsupported Sensors? Try Arduino + Lua!

Thanks for the quick response @Yuri_Rage , checked it on another pc and got the same warning, wonder if this is Espressif related… have no idea on how to check it as well…
using wire.h directly did not yield this error.

I just compiled for ESP32 in a recently updated PlatformIO environment, and I do see a compiler warning about similar, but the build finishes and results in a functional binary.

If you are using PlatformIO, the following platformio.ini entry fixes the warning (forcing compilation with gnu++17):

[env:esp32]
platform = espressif32
board = esp32dev
build_unflags = -std=gnu++11
build_flags = -std=gnu++17

using Arduino IDE 2.0.4 that gives me the error and stops compiling.
compiling for AVR Nano platform did not give this error.

I’m not going to rewrite the library because Arduino’s sh*tty IDE won’t accept compiler flags. Recommend using PlatformIO or another, better build environment.

3 Likes

Well @Yuri_Rage … you were right, my ESP32 board library was obsolete, changed to the correct (and updated one) and now it works … many thanks :slight_smile:

1 Like

Thats a very interesting blog post. I’m planning on using it to add multiple rpm sensors.

Can you please explain the connection of the arduino to the autopilot? Lets say that we have an arduino Nano and a cube orange.

Whatever pins you use as SCL and SDA on the Arduino must be connected to the I2C port on the autopilot, along with a common ground.

1 Like

Hi, I am using a Arduino with Some sensors mounted inside water tank of Drone. My plan is to detect water level using this and has to display message on GCS. Please help me to integrate my Arduino with Pixhawk in this case.

But how to make biderectional communication. With arduino read value from slave.lua?

Look at the temperature sensor example. It is bi-directional.

1 Like

This is a nice example of offloading work from ardupilot and using i2c for communications, and scripting.
(Just to mention, I did this ten years ago for Multiwii, with an i2c GPS which also contained navigation code, to allow waypoint missions on an AtMega386 based MultiWii, GitHub - ckuethe/i2c-gps-nav: Automatically exported from code.google.com/p/i2c-gps-nav)

3 Likes

that’s cool, I was looking at that code recently for adding navigation to an Arduino boat controller I was making, but I ended up using tinygps as I couldnt find much documentation on interfacing with it.

Does this library also support connections beside I2C like the serial TX/RX port?

What are you trying ti do?

I’m trying to send data from an Arduino to Pixhawk so that the date gets displayed in Mission Planner on the quick tab. So far I could send NAMED_VALUE_FLOAT mavlink messages, I can see them in the mavlink inspector but the value can’t be displayed on MP quick tab, only the name of the variable.
Later I want to modify it an add sensors to the Arduino

You should be sending named float MavLink messages (as it appears you are attempting but failing due to malformed messages). This project will not help you do that, nor is it appropriate use of the libraries involved.

1 Like

why cant you use i2c?

1 Like

I wonder why because…I think my code doesn’t have any error
Did you see my code in the other post?

In general I can use also I2C, I just started with serial

If you want to use Lua and have a serial port available, just follow the serial examples already provided…

ardupilot/libraries/AP_Scripting/examples/serial_test.lua at master · ArduPilot/ardupilot (github.com)
ardupilot/libraries/AP_Scripting/examples/Serial_Dump.lua at master · ArduPilot/ardupilot (github.com)
ardupilot/libraries/AP_Scripting/examples/UART_log.lua at master · ArduPilot/ardupilot (github.com)