Go Down

Topic: NMEA 2000 Shield (Read 398234 times) previous topic - next topic

timolappalainen

Sorry I did not understood your first message right about getting only 0 and 100 and nothing between.

Goto https://forum.arduino.cc/index.php?topic=50893.870 . Click his name autopilotNOR and select SendPM to send personal message to him.

Sigi_S

Bennett Trim Tab NMEA2000  "insect"  PGN:130576.  
Does anyone have information/code on Calibration method for this device? Currently the unit is toggling between 0 and 100 indicating "Hello I am on the buss but please calibrate me" Thanks for your help... this is a road block for me.
I have written a Windows program to calibrate the Bennett Trimtab NMEA1.
You can use a Actisences NGW1 or Timo┬┤s Arduino Gateway

floron

#992
Nov 04, 2020, 07:00 pm Last Edit: Nov 04, 2020, 07:09 pm by floron
Hello, i have been working on a small n2k to wifi converter for my boat. I have a Yamaha outboard which has a Diagnosis/NMEA2k port on front of it which i want to take advantage off. I tried to use the DataDisplay2.ino example but my board always stays stuck at "Ready" without any messages popping in. I am attaching my board schematics if anyone is interested and parts of the code i changed. I know some of you are really good at coding and may find my question dumb perhaps, but i don't have coding experience so i am making the best of it. Hardware wise i am using a ESP32-WROOM-32D chip with the SN65HVD232Q chip on a custom pcb I appreciate any feedback or help.


#include <Arduino.h>
//#include <Time.h>  //
//#define N2k_CAN_INT_PIN 35
#include <NMEA2000_esp32.h> --- I added NMEA2000_ESP32 since i am using a ESP32 board
#include <NMEA2000_CAN.h>
#include <N2kMessages.h>
#include <N2kMessagesEnumToStr.h>

typedef struct {
unsigned long PGN;
void (*Handler)(const tN2kMsg &N2kMsg);
} tNMEA2000Handler;







timolappalainen

You do not need to have
#include <NMEA2000_esp32.h> --- I added NMEA2000_ESP32 since i am using a ESP32 board
#include <NMEA2000_CAN.h> does it automatically, when you have ESP32 selected environment.


Instead you have to define pins used for your can bus. As default library uses pins 16 and 4. See comments on beginning of NMEA2000_CAN.h. So you have to add 
    #define ESP32_CAN_TX_PIN GPIO_NUM_35
    #define ESP32_CAN_RX_PIN GPIO_NUM_34
 before #include <NMEA2000_CAN.h>


landsea

I've been studying manuals for a week and acquiring too much knowledge that my mind is able to assimilate in such a short time. I apologize if my question is very silly. A little clarification to a question: #define N2k_CAN_INT_PIN 21 is only for boards without a controller or that need a MCP2515 controller. If I use an esp32 or teensy 3.6 or higher I must deactivate it: // #define N2k_CAN_INT_PIN 21.
I am considering creating a J1939-N2k gateway for volvo panta MEFI-4. Is there any documentation, example, project or help to convert png / SPN from J1939 to Png from N2k? Thanks for your help.

timolappalainen

Definition has no effect for other than mcp_can. So you can remove it or leave it. I left it to examples so it may be easier to start with mcp_can devices. Also it helps, since I use same project for quick testing with different boards. If you will not use this project with mcp_can device, I prefer just delete row. All unnecessary rows in code just confuses.

landsea


Thanks Timo. I am trying to understand the code.

hirppa10

Hello,

I'm having troubles with AsyncWebServer and Timo's libraries. Anyone got these working together? My code gives errors on LinkedLists and StringArrays when I try to compile simple_server.ino with Nmea2000 libraries included.

https://github.com/me-no-dev/ESPAsyncWebServer/blob/master/examples/simple_server/simple_server.ino

timolappalainen

I use AsyncWebServer with NMEA2000, but not on same module. 

I also just made simple test with clean installation 
- Install Arduino IDE
- Added library NMEA2000 
- Added library NMEA2000_Esp32 
- Added library AsyncWebServer 
- Added library AsyncTCP
- Added ESP32 boards
- open simple_server and add parts of NMEA2000 example DataDisplay2.
Compiles fine.

Often these your type of errors are caused by conflicts with libraries under Arduino/Libraries. E.g. my main Arduino installation does not compile unmodified simple_server due to conflicts. I prefer to move something better environment like VSCode+PlatformIO, where you have handle each project libraries separetely.

hirppa10

Hello,

I'm using PlatformIO with VSCode currently. I have the following definitions in platformio.ini

Code: [Select]
[env:esp-wrover-kit]
platform = espressif32
board = esp32dev
framework = arduino
monitor_speed = 115200

lib_deps = 
    https://github.com/ttlappalainen/NMEA2000.git
    https://github.com/ttlappalainen/NMEA2000_esp32.git
    https://github.com/me-no-dev/ESPAsyncWebServer.git
    https://github.com/me-no-dev/AsyncTCP.git
    https://github.com/ttlappalainen/NMEA0183.git


I have made previous code with these settings and it's working fine. Now when I want to include the AsyncWebServer library tens of errors pop up. I think now that this has nothing to do with your library. Most probably I just don't have the correct way to include libraries. 

timolappalainen

Instead of using libdeps I normally just put extra libraries under project lib path. In this way I have harder control for library versions and will not automatically update to the newest version.

I made test by copying those libraries under project lib path and removed libdeps. Compiled file. With libdeps I had some missing python scripts and did not wasted time with it.

hirppa10

#1001
Nov 29, 2020, 04:18 pm Last Edit: Nov 29, 2020, 04:19 pm by hirppa10
Still unable to get this thing working  :smiley-confuse:


I'm using your NMEA2000ToWiFiAsSeaSmart.ino as base and I have ArduinoOTA integrated to it. Everything works fine.


As soon as I try to implement ASyncWebServer to same code I start to get errors. I don't know is there some problems more specifically with NMEA2000ToWiFiAsSeaSmart.ino and ASyncWebServer together.


Code: [Select]
//WEBUI
#include <ESPAsyncWebServer.h>
#include <AsyncTCP.h>



Code: [Select]
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32doit-devkit-v1.html
PLATFORM: Espressif 32 (2.0.0) > DOIT ESP32 DEVKIT V1
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10004.201016 (1.0.4)
 - tool-esptoolpy 1.20600.0 (2.6.0)
 - tool-openocd-esp32 1.1000.20190709 (10.0)
 - toolchain-xtensa32 2.50200.80 (5.2.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 46 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <NMEA0183> 1.6.0
|-- <NMEA2000-library> 4.13.2
|   |-- <NMEA2000_esp32> 1.0.3
|   |-- <SPI> 1.0
|-- <ArduinoOTA> 1.0
|   |-- <Update> 1.0
|   |-- <WiFi> 1.0
|   |-- <ESPmDNS> 1.0
|   |   |-- <WiFi> 1.0
|-- <AsyncTCP> 1.1.1
|-- <ESP Async WebServer> 1.2.3
|   |-- <AsyncTCP> 1.1.1
|   |-- <FS> 1.0
|   |-- <WiFi> 1.0
|-- <ESPmDNS> 1.0
|   |-- <WiFi> 1.0
|-- <WiFi> 1.0
Building in release mode
Compiling .pio\build\esp32doit-devkit-v1\src\main.cpp.o
In file included from lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:29:0,
                 from src\main.cpp:22:
lib/ESPAsyncWebServer-master/src/StringArray.h:39:7: error: redeclared with 2 template parameters
 class LinkedList {
       ^
In file included from src\main.cpp:19:0:
src\List.h:43:26: note: previous declaration 'template<class T> class LinkedList' used 1 template parameter
 template <class T> class LinkedList {
                          ^
In file included from lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:29:0,
                 from src\main.cpp:22:
lib/ESPAsyncWebServer-master/src/StringArray.h: In constructor 'StringArray::StringArray()':
lib/ESPAsyncWebServer-master/src/StringArray.h:178:37: error: no matching function for call to 'LinkedList<String>::LinkedList(std::nullptr_t)'
   StringArray() : LinkedList(nullptr) {}
                                     ^
In file included from src\main.cpp:19:0:
src\List.h:67:5: note: candidate: LinkedList<T>::LinkedList(const LinkedList<T>&) [with T = String]
     LinkedList(const LinkedList &l) : head(0) {
     ^
src\List.h:67:5: note:   no known conversion for argument 1 from 'std::nullptr_t' to 'const LinkedList<String>&'
src\List.h:65:5: note: candidate: LinkedList<T>::LinkedList() [with T = String]
     LinkedList() : head(0) {};
     ^
src\List.h:65:5: note:   candidate expects 0 arguments, 1 provided
In file included from src\main.cpp:22:0:
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h: At global scope:
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:449:36: error: 'ConstIterator' in 'using headers_t = class LinkedList<AsyncWebHeader*> {aka class LinkedList<AsyncWebHeader*>}' does not name a type
   using ConstIterator = headers_t::ConstIterator;
                                    ^
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:455:3: error: 'ConstIterator' does not name a type
   ConstIterator begin() const { return _headers.begin(); }
   ^
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:456:3: error: 'ConstIterator' does not name a type
   ConstIterator end() const { return _headers.end(); }
   ^
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h: In constructor 'DefaultHeaders::DefaultHeaders()':
lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:446:57: error: no matching function for call to 'LinkedList<AsyncWebHeader*>::LinkedList(DefaultHeaders::DefaultHeaders()::<lambda(AsyncWebHeader*)>)'
   :_headers(headers_t([](AsyncWebHeader *h){ delete h; }))
                                                         ^
In file included from src\main.cpp:19:0:
src\List.h:67:5: note: candidate: LinkedList<T>::LinkedList(const LinkedList<T>&) [with T = AsyncWebHeader*]
     LinkedList(const LinkedList &l) : head(0) {
     ^
src\List.h:67:5: note:   no known conversion for argument 1 from 'DefaultHeaders::DefaultHeaders()::<lambda(AsyncWebHeader*)>' to 'const LinkedList<AsyncWebHeader*>&'
src\List.h:65:5: note: candidate: LinkedList<T>::LinkedList() [with T = AsyncWebHeader*]
     LinkedList() : head(0) {};
     ^
src\List.h:65:5: note:   candidate expects 0 arguments, 1 provided
In file included from lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:468:0,
                 from src\main.cpp:22:
lib/ESPAsyncWebServer-master/src/AsyncWebSocket.h: In member function 'bool AsyncWebSocketClient::canSend()':
lib/ESPAsyncWebServer-master/src/AsyncWebSocket.h:229:43: error: 'class LinkedList<AsyncWebSocketMessage*>' has no member named 'length'
     bool canSend() { return _messageQueue.length() < WS_MAX_QUEUED_MESSAGES; }
                                           ^
In file included from lib/ESPAsyncWebServer-master/src/ESPAsyncWebServer.h:469:0,
                 from src\main.cpp:22:
lib/ESPAsyncWebServer-master/src/AsyncEventSource.h: In member function 'size_t AsyncEventSourceClient::packetsWaiting() const':
lib/ESPAsyncWebServer-master/src/AsyncEventSource.h:89:59: error: 'const class LinkedList<AsyncEventSourceMessage*>' has no member named 'length'
     size_t  packetsWaiting() const { return _messageQueue.length(); }
                                                           ^
Archiving .pio\build\esp32doit-devkit-v1\lib141\libESPAsyncWebServer-master.a
*** [.pio\build\esp32doit-devkit-v1\src\main.cpp.o] Error 1
============================================================================================== [FAILED] Took 4.87 seconds ==============================================================================================
The terminal process "C:\Users\Hirppa\.platformio\penv\Scripts\pio.exe 'run'" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.



timolappalainen

As I said it is because of conflicts with libraries. That example includes list.h, which defines LinkedList as far as ESPAsyncWebServer.h defines an other LinkedList as you can read from error messages. You need to build your own logic. NMEA2000ToWiFiAsSeaSmart has is sample for sending N2k data to connected clients, which are hold by LinkedList. If you are making web server, logic is totally different and you do not need.

Since LinkedList on example has been defined totally on List.h, you may go around by using namespace for that list. On example ino change include
namespace N2k {
  #include "List.h"
}
and modify on same example every LinkedList to N2k::LinkedList

cmtas

I know this may sound basic. I have looked hear and GitHub can the Teensy 4.1 connect directly to the bus or is a transceiver required?

seamaster

I know this may sound basic. I have looked hear and GitHub can the Teensy 4.1 connect directly to the bus or is a transceiver required?
Yes you do need a transceiver. You can use isolated transceiver such as Texas Instrument ISO1050 (best solution for avoiding ground loops) but this will require also isolated power supply. Or you can use simple MCP2562 transceiver.
Do not forget to connect Rx on the transceiver to Rx on the uC, and Tx on the transceiver to Tx on the uC.
It is not like serial ports where Rx connects to Tx and Tx connects to Rx.
Good luck!

Go Up