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
Also send I2C sensor data to Node-Red so ALL instruments show on the dashboard
#3
(2018-11-07, 03:31 PM)NaturalBornCamper Wrote: So anyways, I managed to make our analog oil pressure sensors work with an Arduino Uno board I had lying around and send it over I2C to OpenPlotter, until I realized that you can only add sensors that were pre-configured in OpenPlotter, 

You can send the data direct to signalk over serial from the arduino, like this - 
Code:
#include "ArduinoJson.h"
int LED_pin = 2;


void setup() {
 // put your setup code here, to run once:
 Serial.begin(4800);

// Serial.println("Starting Up, Please Wait...");
 // initialize digital pin LED_BUILTIN as an output.
 pinMode(LED_pin, OUTPUT);
}

void loop() {
 // put your main code here, to run repeatedly:

 int randon_num = random(1, 300);
 sendSigK("mytest.test.test", randon_num);
 
 int state = digitalRead(LED_pin);
 digitalWrite(LED_pin, !state);
 delay(2000);

}



void sendSigK(String sigKey, float data) {    //    send SigK


 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";
 delta.printTo(Serial);
 Serial.println();
}

Then you need to add this to   /home/pi/.signalk/settings.json - underneath the lines >
 },
  "loggingDirectory": "/home/pi/Logs",
  "mdns": false,
  "pipedProviders": [
Code:
{
      "enabled": true,
     "id": "nmeaFromFile",
     "pipeElements": [
       {
         "type": "providers/serialport",
         "options": {
           "device": "/dev/ttyUSB2",
           "baudrate": 4800,
           "toStdout": ["nmea0183out1", "nmea0183out2"]
         },
         "optionMappings": [
           {
             "fromAppProperty": "argv.nmeadevice",
             "toOption": "device"
           },

           {
             "fromAppProperty": "argv.nmeabaudrate",
             "toOption": "baudrate"
           }
         ]
       },
       {
         "type": "providers/from_json",
         "options": {
           "sentenceEvent": "nmea0183in1"
         },
         "optionMappings": [
           {
             "fromAppProperty": "selfId",
             "toOption": "selfId"
           },
           {
             "fromAppProperty": "selfType",
             "toOption": "selfType"
           }
         ]
       }
     ]
   },

Then it should be added as signalk. Opencpn only see NMEA data so you'll need to convert it to NMEA it you want to see the data in that prog.
Reply


Messages In This Thread
RE: Also send I2C sensor data to Node-Red so ALL instruments show on the dashboard - by PaddyB - 2018-11-09, 01:19 PM

Forum Jump:


Users browsing this thread: 2 Guest(s)