Plugging Arduino in NMEA2000 Bus Stops it working :(

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
It seems it does. But a quick internet trawl comes up with very few people who know how to use it!

I bought one, thought it's straight forward (or rather hoped!) I'll try and test it tonight and report.

I could be wrong but I seem to remember that it's better to do it slightly differently as the above has an issue when the Arduino wraps the integer after 49 days.

considering that GHA suggest this as a debug tool, I hope you wont be debugging for 49days in a row without rebooting the thing :D

V.
 

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
I bought one, thought it's straight forward (or rather hoped!) I'll try and test it tonight and report.



considering that GHA suggest this as a debug tool, I hope you wont be debugging for 49days in a row without rebooting the thing :D

V.

Oh I don't know, you might be debugging an edge case that only goes wrong every 49.5 days :eek::rolleyes:
 

pagoda

Active member
Joined
19 May 2008
Messages
2,227
Location
Scotland
Visit site
I've just looked at them.. I can't believe how cheap they are for such functionality. I might have to get one to play with.

It does sound great, But it's target audience is more multimedia support oriented then CAN hardware oriented. From a brief exploration of the development boards that exist - not many seem to break out the CAN interface clearly - though there is some multiplexing of the available pins. Needs checking before buying.

Also - apropos using Timo's Mega/Teensy code etc. It works. Have had 2 megas, a Teensy and a B&G Vulcan sharing data successfully.

If you make use of the Actisense NMEAReader to monitor the behaviour do be aware that the Actisense NMEA Reader also SENDS stuff TO the serial/USB port . If your Teensys or Megas are not set up to deal with the incoming data - they may well stall and freeze up.
Timo put a serial incoming buffer clear into SOME of the examples . That flushes away any of the NMEAReader handshaking - not relevant to the Areduino environment. Well worth adding.

At the start of your main loop add-

// Dummy to empty input buffer to avoid board to stuck with e.g. NMEA Reader
if ( Serial.available() ) { Serial.read();
//

This is supposed to be a sailing /boating forum - I should not be posting code!! :eek:
 

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
Oh I don't know, you might be debugging an edge case that only goes wrong every 49.5 days :eek::rolleyes:

in which case I'm afraid programming is the wrong hobby for you, you should take up golf or something... :p

on a more serious note, over the last hour I've tried to run some of my code (working on due or teensy) on the ESP32S
MegunoLink.h is not compatible, throws one gazillion error messages, probably something v.simple, for the time I just removed the smoothing I'm using it for.
program compiles, wouldn't initially upload as I had to keep the rhs button pressed to wake up and connect to the ide.
However, although program runs (as reported and shown by serial monitor) the garmin doesn't see it. It's not listed in the N2K bus.

got some other things to do tonight, will try again tomorrow

cheers

V.
 

dolabriform

Well-known member
Joined
12 Sep 2016
Messages
1,759
Location
London / Suffolk
freewheeling.world
in which case I'm afraid programming is the wrong hobby for you, you should take up golf or something... :p

on a more serious note, over the last hour I've tried to run some of my code (working on due or teensy) on the ESP32S
MegunoLink.h is not compatible, throws one gazillion error messages, probably something v.simple, for the time I just removed the smoothing I'm using it for.
program compiles, wouldn't initially upload as I had to keep the rhs button pressed to wake up and connect to the ide.
However, although program runs (as reported and shown by serial monitor) the garmin doesn't see it. It's not listed in the N2K bus.

got some other things to do tonight, will try again tomorrow

cheers

V.

I never could get the hang of those odd shaped sticks ;)

Seriously, thanks for the update, I am very interested to know how you get on with it
 

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
From a brief exploration of the development boards that exist - not many seem to break out the CAN interface clearly - though there is some multiplexing of the available pins. Needs checking before buying.

G,

looks like everyone does the implementation however they like... So need careful examination before buying.


Seriously, thanks for the update, I am very interested to know how you get on with it

At least now I can report success!

Eventually the problem was that the NodeMCU-ESP32S I bought (amogst the cheapest options ebayable from EU) didn't like:

#define ESP32_CAN_TX_PIN GPIO_NUM_16
#define ESP32_CAN_RX_PIN GPIO_NUM_4

I noticed that on the docs I found online the NodeMCU-ESP32S they mention:
TX0 ->GPIO1
RX0 ->GPIO3
and
TX2 ->GPIO17
RX2 ->GPIO16

so changed to

#define ESP32_CAN_TX_PIN GPIO_NUM_17
#define ESP32_CAN_RX_PIN GPIO_NUM_16

and it worked straight away.

BTW, it did so with both 2551 (no current on pin5) and 2562 with 3V3 on pin5 so everything is fine!

However, there's still an issue with waking and connecting the thing up with the IDE. Tried running TX0 and RX0 options as well and now it wont connect :p

so, yes pending a decent solution to programming the chip (cannot really expect someone to press the IOI whatever button on the rhs of the microusb port to program it!) it's working fine!

cheers

V.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,257
Location
Hopefully somewhere warm
Visit site

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
Thanks for the update, I've ordered one so I'll let you know if I have the same programming problem

CAREFUL NOT TO USE GPIO1 and 3 (TX0-RX0) as it wont load anything! use TX2 and RX2 instead. Will report if I figure out how to avoid having to hit the boot button

Tried over the air uploading?

https://randomnerdtutorials.com/esp32-over-the-air-ota-programming/

Pretty handy to get things up and running without having to be next to the board.

wasn't aware of that, will give it a go.
TBH that alone can be a reason to use ESP32s on the engine black boxes I'm planning. Nothing beats NOT having to get down to the e/r with the laptop at hand to do some programming...

cheers

V.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,257
Location
Hopefully somewhere warm
Visit site
wasn't aware of that, will give it a go.
TBH that alone can be a reason to use ESP32s on the engine black boxes I'm planning. Nothing beats NOT having to get down to the e/r with the laptop at hand to do some programming...

The wifi on esp8266's & esp32's has pretty much kicked arduinos into touch onboard , more for the ease of getting data into signalk on the trusty do everything raspberry pi, then displaying the data & saving it into a database is easy and quick - plotting pretty graphs is simple. How did we survive before cheap and powerful microelectronics!! :)



Code:
void sendSigK(String sigKey, float data) {    //    send SigK via UDP *****************************************



  DynamicJsonBuffer jsonBuffer;
  String deltaText;


  //  build delta message
  JsonObject& delta = jsonBuffer.createObject();


  //updated array
  JsonArray& updatesArr = delta.createNestedArray("updates");
  JsonObject& thisUpdate = updatesArr.createNestedObject();   //Json Object nested inside delta [...
  JsonArray& values = thisUpdate.createNestedArray("values"); // Values array nested in delta[ values....
  JsonObject& thisValue = values.createNestedObject();
  thisValue["path"] = sigKey;
  thisValue["value"] = data;


  thisUpdate["Source"] = "ESP11";


  // Send UDP packet
  Udp.beginPacket(remoteIp, remotePort);
  delta.printTo(Udp);
  Udp.println();
  Udp.endPacket();
}
 

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
apologies again (not my day is it...)

I was meant to link to this:
https://github.com/ttlappalainen/NMEA2000/blob/master/Documents/ArduinoDUE_CAN_with_MCP2562.pdf

it says 2562, but also works fine with 2551 (I have 2DUEs and 1teensy running with 2551)

cheers

V.

and following today's comment by Timo on the ESP32S problem I was facing, he recons we shouldn't use 2551 but only use 2562 which does the trick of using pin5 (the only one not used in 2551) give a pilot current for the output so you feed the chip with 5V to operate but tell it to ouput 3.3V (or anyway something like that...)

Mine as I said works with 2551 and I'm not going to get it out of there and resolder a 2562 anytime soon, but I'll try and use 2562 on the new projects.

GHA, currently on the boat but will try the over the air in the evening, thanks!

V.
 

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
GHA,

OK, I did configure the thing, it works, just a few Q for OTA uploading:

A. can I have more than one running?
OK, I can, but

B. booting rebooting etc, are they gonna keep the same IP? I mean once I built two ESP32S and put them in nice waterproof boxes in the e/r, there's no way in hell I'm going to get down there with the laptop and cable, undo the box/seal just to press the bloody EN(able) button to get on the serial monitor the IP of the thing.
Can the IPs be hardcoded?

C. I need a webserver on the boat (and I don't have one and haven't yet found a reason to have one...) Otherwise the thing wont work :(


am I missing something?

cheers

V.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,257
Location
Hopefully somewhere warm
Visit site
GHA,

OK, I did configure the thing, it works, just a few Q for OTA uploading:

A. can I have more than one running?
OK, I can, but

B. booting rebooting etc, are they gonna keep the same IP? I mean once I built two ESP32S and put them in nice waterproof boxes in the e/r, there's no way in hell I'm going to get down there with the laptop and cable, undo the box/seal just to press the bloody EN(able) button to get on the serial monitor the IP of the thing.
Can the IPs be hardcoded?

C. I need a webserver on the boat (and I don't have one and haven't yet found a reason to have one...) Otherwise the thing wont work :(


am I missing something?

How annoying is this!! Can't get OTA to work again & it did before. Grr, anyway - B - they do seem to get the same IP address each time, but doesn't matter for uploading, the arduino IDE lists any available with whatever host name you gave the ESP in the sketch. C - Dunno, don't think you need web server, the ESP does that I think, just a wifi network to log into.
 

vas

Well-known member
Joined
21 Jun 2011
Messages
7,933
Location
Volos-Athens
Visit site
How annoying is this!! Can't get OTA to work again & it did before. Grr, anyway - B - they do seem to get the same IP address each time, but doesn't matter for uploading, the arduino IDE lists any available with whatever host name you gave the ESP in the sketch. C - Dunno, don't think you need web server, the ESP does that I think, just a wifi network to log into.

can you please explain where the IDE is involved in uploading code?
From my understanding I cannot see how it's going to come up with a list of ESPs since you go to the browser on your laptop and specifically type in the address.
Or is there another way to up code to the ESP?
On C you are right, don't need a webserver, but definitely a wifi router of some sort for both the ESP and the laptop to join to.

V.
 

GHA

Well-known member
Joined
26 Jun 2013
Messages
12,257
Location
Hopefully somewhere warm
Visit site
can you please explain where the IDE is involved in uploading code?
From my understanding I cannot see how it's going to come up with a list of ESPs since you go to the browser on your laptop and specifically type in the address.
Or is there another way to up code to the ESP?
On C you are right, don't need a webserver, but definitely a wifi router of some sort for both the ESP and the laptop to join to.

V.

The ESP(s) show up in the port selection menu in the Arduino IDE so you just select whatever one you want in there. You might be able to get an ESP to create the wifi network, done this standalone but not tried it with OTA, I just use Openplotter access point on the RPi ( or mobile phone to create a hotspot). Though thinking about it maybe not, OTA takes complete control of the ESP for the upload so likely won't run any create access pont code while it's doing that though cheap mobile phone should be able to provide a hotspot for the upload.


ota-ide-ota-port-selection.png


http://esp8266.github.io/Arduino/versions/2.0.0/doc/ota_updates/ota_updates.html


Edit - still couldn't get that to work, but using the web updater to upload a BIN compiled file has worked on a ESP32, looks like that will be the way for now.

https://randomnerdtutorials.com/esp32-over-the-air-ota-programming/
 
Last edited:

andypag

New member
Joined
18 Aug 2018
Messages
10
Visit site
I came across a post on another forum saying that the wrong clock speed would stop the bus working.
Guess what... in order to get it to talk to the other Arduino, I had to set the clock speed to 8 MHZ. I changed it back to 16, and WOW, it shows on the device list :)
Hi, old post I know.

Did you set the speed on the Arduino script? Is 16mhz the same as 16000 baud?
 

andypag

New member
Joined
18 Aug 2018
Messages
10
Visit site
Thanks. I've just ordered a nano, a bpe280 (pressure temp and rel humidity) and an MCP2251 board for the sting connection.

My first time playing with Arduino. Eventually I'd like to develop a squall warning device but for now I just want to put the data onto the stng network.

I'm getting ChatGPT to write the code but I don't know what I don't know.

If your code is open source can you point me to your GitHub?
 
Top