This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
arduino on I2C
#11
(2017-11-13, 12:09 AM)Sprokkie Wrote: i will google on arduino and node red, this might be the solution, only how to get the information from the arduino to the node red server ?
As Paddy and I said before. Why wont you use wifi?
Reply
#12
(2017-11-13, 12:09 AM)Sprokkie Wrote: Hi Paddy,

i have nmea2000 and not nmea0183.
I look in the sketch and i see also mqtt do need that ?
MQTT is already installed in openplotter, there's a tab to set it up. 

What do you want to read from NMEA2000? 

If you're interested in the Esp8266 (they're great Smile )  then easyesp is well worth a look -
https://www.letscontrolit.com/wiki/index.php/ESPEasy
Just load it onto the board then you can set up NMEA serial, thermometers   and voltage without having to write any code. Probably lots more like reed contacts etc.
Reply
#13
I have a netwerok nmea2000 in my shio so basically all data would be interested. i have to read the nmea2000 for displaying with signalk and write the sensordata from my engine en batteries to the n2k network so i can see that on mij plotter.

is there a msqtt server in openplotter ?
Reply
#14
the guages i am using are steelseries here is a link to install them.
http://forum.openmarine.net/showthread.php?tid=631
you are going to need a nema -N2K converter.
http://forum.openmarine.net/showthread.p...hlight=n2k
Reply
#15
i tried the firmata  that failed Smile

do i need to configure someting more ?
i just pluged in the arduino  named the usbport firm and then i wait
any thing to do on the arduino  ?
i just serial.print to the usb port of the arduino
Reply
#16
You have to load standard firmata onto the arduino.

Open arduino ide select correct board and com port (in Tools) then
File->Examples->Firmata->StandardFirmata
Sketch->Upload
Reply
#17
and than implement my sketch en serial.print the data to the raspberry ?
Reply
#18
here is a simple switch example node red arduino FIRM
Code:
[{"id":"62bec414.c7eedc","type":"arduino out","z":"7546b9b.db0b448","name":"test","pin":"9","state":"OUTPUT","arduino":"76bceb09.5fdb64","x":410,"y":180,"wires":[]},{"id":"ef4bd92e.ef2178","type":"ui_switch","z":"7546b9b.db0b448","name":"","label":"switch","group":"4df6113f.e3385","order":0,"width":"2","height":"1","passthru":true,"decouple":"false","topic":"","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":230,"y":180,"wires":[["62bec414.c7eedc"]]},{"id":"d9555482.182e68","type":"arduino in","z":"7546b9b.db0b448","name":"","pin":"9","state":"INPUT","arduino":"76bceb09.5fdb64","x":69.07292175292969,"y":179.85417938232422,"wires":[["ef4bd92e.ef2178"]]},{"id":"76bceb09.5fdb64","type":"arduino-board","z":"","device":"/dev/ttyUSB1"},{"id":"4df6113f.e3385","type":"ui_group","z":"","name":"NAV 1","tab":"aa2f5087.f81f3","order":1,"disp":true,"width":"4"},{"id":"aa2f5087.f81f3","type":"ui_tab","z":"","name":"Engine","icon":"dashboard"}]
Reply
#19
Please just look firmata up. It seems like you haven't understand the concept yet. 

https://github.com/firmata/protocol
http://firmata.org/

Basically you upload the firmata sketch to your Arduino and then leave it untouched. Connect the Arduino to a serialport. Pick your favourite programming language. Install the firmata library and implement your programming logic.
It's sort of a remote control via uart.

As i wrote before I had some performance issues using firmata. A quick example:
You hook up an I2C sensor to your Arduino and a LED that blinks every 200 ms. Now every time the sensor sends it's data the LED will get stuck in the current state and stop the blinking until the sensor's data is submitted. So depending on your usage you might run into some problems.

edit: lovely cross posting Smile
Reply
#20
(2017-11-03, 11:35 AM)PaddyB Wrote:
(2017-11-03, 10:40 AM)Sprokkie Wrote: It will be oil pressure, oil temperature, coolant temperature, RPM,  I want to build a fuel consumption meter, but for that I need much more arduino skills Smile

the idea for that is having two flow measurement sensors on in the fuel line to the engine and one in the return to the dieseltank.
If I know the amount of diesel for each impulse from that sensor I know the amount of fuel that is going in to the engine and the amount of fuel that is going back
to the dieseltank. The result of both is the actual fuel usage.

So for now it will be pressure, temp and RPM.
Eventually I want to connect reedcontacts as well for a alarm system.

How do I get the nmeaxdr to the arduino ? Where can I find some information how to create such a message ?

For temperature it might be easier just to use ds18b20 thermometers straight into the Raspberry Pi, there's a tab in openplotter to set them up, then a node red dashboard to display - really handy, I have one on the alternator, exhaust & engine headblock. Also openplotter turns the engine head temperature into water temperature so it cn be displayed in an  openpcn dashboard so the info can be seen on a tablet without having to change screens. It all gets saved to a database as well.
Cheap waterproof ones available on ebay. Openplotter can handle reed contacts directly as well, on a gpio pin. 

http://www.ebay.co.uk/itm/DS18B20-18B20-...0784248550

Pressure & RPM might be better going into node-red like Jim said. 

Lots info on the web for NMEA message types. 

http://www.catb.org/gpsd/NMEA.html#_xdr_...easurement




[Image: n63uskc.png]

Something else worth considering is the ESP32 or ESP8266 and pass the data over wifi. I haven't got a ESP32 to play with yet but the ESP8266 works OK over wifi. Programmed just like an Arduino. This sketch connects to the AIS nmea output of a GX2100 radio and sends the data to openplotter.
The ESP32 looks even more powerful. 
Also, adding a ADS1115 board to Openplotter means you can measure battery voltage so you can keep and eye if all this stuff is draining your bank too much Cool 

You'll need a serial to TTL convertor to get NMEA into an arduino or ESP, cheap on ebay.
Code:
/**  This sketch sends broadcast udp message.
*
*
*/




#include <SoftwareSerial.h>
#include <ESP8266WiFi.h>
#include <WiFiUDP.h>
#include <PubSubClient.h>    // mqtt library


#define mqtt_server "10.10.10.1"
#define mqtt_user "User"
#define mqtt_password "Password"
const char* ssid     = "OpenPlotter";
const char* password = "password";
//const char* ssid     = "*****";
//const char* password = "*******";


IPAddress ipBroadCast(10, 10, 10, 255);
unsigned int udpRemotePort=10112;
unsigned int udplocalPort=2390;
const int UDP_PACKET_SIZE = 70;
char udpBuffer[ UDP_PACKET_SIZE];


String  inData;


WiFiUDP udp;
WiFiClient espClient;
PubSubClient client(espClient);
SoftwareSerial mySerial(14, 12);


void callback(char* topic, byte* payload, unsigned int length) {
Serial.print("Message arrived [");
Serial.print(topic);
Serial.print("] ");
for (int i=0;i<length;i++) {
 char receivedChar = (char)payload[i];
 Serial.print(receivedChar);
 }
 Serial.println();
}


void reconnect() {
 // Loop until we're reconnected
 while (!client.connected()) {
   Serial.print("Attempting MQTT connection...");
   // Attempt to connect
   // If you do not want to use a username and password, change next line to
   // if (client.connect("ESP8266Client")) {
   if (client.connect("ESP8266Client", mqtt_user, mqtt_password)) {
     Serial.println("connected");
     client.subscribe("myfirstin");
   } else {
     Serial.print("failed, rc=");
     Serial.print(client.state());
     Serial.println(" try again in 5 seconds");
     // Wait 5 seconds before retrying
     delay(5000);
   }
 }
}




//================================================================
// Setup hardware, serial port, and connect to wifi.
//================================================================

void setup() {
 Serial.begin(115200);
 mySerial.begin(4800);
 delay(10);
 // We start by connecting to a WiFi network
 Serial.println();
 Serial.println();
 Serial.print("Connecting to ");
 Serial.println(ssid);

 //  Try to connect to wifi access point
 WiFi.begin(ssid, password);
 while (WiFi.status() != WL_CONNECTED) {
     delay(500);
     Serial.print(".");
 }
 Serial.println("");
 Serial.println("WiFi connected");
 Serial.println("IP address: ");
 Serial.println(WiFi.localIP());
 Serial.println("Starting UDP");

 // set udp port for listen
 udp.begin(udplocalPort);
 Serial.print("Local port: ");
 Serial.println(udp.localPort());


 client.setServer(mqtt_server, 1883);  //start mqtt
 client.setCallback(callback);  // set callback routine to monitor incoming mqtt
 client.subscribe("myfirst");


 
}
//================================================================
// Function to send udp message
//================================================================
void fncUdpSend(String inData)
{
 char temp[50];
 inData.toCharArray(temp, 50) ;
 udp.beginPacket(ipBroadCast, udpRemotePort);
 udp.write(temp, sizeof(temp));
 udp.endPacket();
 Serial.print("sent - ");
 Serial.println(inData);
 }


 
//================================================================
// LOOP MAIN
//================================================================
void loop() {
 
while (mySerial.available() > 0)   {
       char recieved = mySerial.read();
       inData+= recieved;
 
       // Process message when new line character is recieved
       if (recieved == '\n')
       {
           Serial.print("Arduino Received: ");
           Serial.print(inData);


           fncUdpSend(inData);


           char temp[50];
           inData.toCharArray(temp, 50) ;
           client.publish("myfirstout", temp);
           inData = ""; // Clear recieved buffer          
       }
   }
 // if (!client.connected()) {
 //  reconnect();
 //}
//client.loop();
}

Hi PaddyB
If you have a moment free could you walk me through how you did two temp gauges. I have got two DS18B20 sensors working but in node-red they will both have the same SignalK_Key value so not sure how to differentiate between them, many thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)