OpenMarine

Full Version: Anyone sending Signal-k from Arduino?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
Hi,
I've just built a prototype of a wide sensor for my boat using parts of the weathersensor code from pypilot based on an Arduino Nano. I could of course use the NMEA0183 output as pypilot is doing but I also have an ethernet shield available so I was thinking of going directly for signal-k instead of over NMEA. Is there anyone who has done this?

It is so much to read up on (being new to openplotter) so a pointer on how to go about this would be really appreciated (unless it is a stupid idea -??)

The reason for not using the pypilot full implementation is also that I already have the barometric sensor in openplotter (directly on the PI3) and that my wind instruments are 4-20mA units so that is different from the pypilot implementation anyhow...

Any insight or ideas?
/Lars
Hi!

You can connect to the signalk server and send the delta directly. You can do either udp (just fire off a packet) or you can use a websocket. I did similar on my project (ESP8266, but with Arduino IDE). You can see the code here: https://github.com/mxtommy/SigkSens Smile
(2018-02-05, 05:14 PM)LarsD Wrote: [ -> ]Hi,
I've just built a prototype of a wide sensor for my boat using parts of the weathersensor code from pypilot based on an Arduino Nano. I could of course use the NMEA0183 output as pypilot is doing but I also have an ethernet shield available so I was thinking of going directly for signal-k instead of over NMEA. Is there anyone who has done this?
It maybe makes sense with the ethernet shield as you can create a udp connection or even websocket.

It would make perfect sense for a 3d wind sensor, or wind sensor that gives data besides only speed and direction.

Converting NMEA to signalk is well supported, so unless you have data that cannot be represented in NMEA I don't really see the advantage of signalk here.

Quote:It is so much to read up on (being new to openplotter) so a pointer on how to go about this would be really appreciated (unless it is a stupid idea -??)

The reason for not using the pypilot full implementation is also that I already have the barometric sensor in openplotter (directly on the PI3) and that my wind instruments are 4-20mA units so that is different from the pypilot implementation anyhow...
How is your instrument different? Details please! What does "4-20mA" mean?

Did you make the instruments?
(2018-02-15, 12:08 AM)seandepagnier Wrote: [ -> ]
(2018-02-05, 05:14 PM)LarsD Wrote: [ -> ]Hi,
I've just built a prototype of a wide sensor for my boat using parts of the weathersensor code from pypilot based on an Arduino Nano. I could of course use the NMEA0183 output as pypilot is doing but I also have an ethernet shield available so I was thinking of going directly for signal-k instead of over NMEA. Is there anyone who has done this?
It maybe makes sense with the ethernet shield as you can create a udp connection or even websocket.

It would make perfect sense for a 3d wind sensor, or wind sensor that gives data besides only speed and direction.

Converting NMEA to signalk is well supported, so unless you have data that cannot be represented in NMEA I don't really see the advantage of signalk here.

Quote:It is so much to read up on (being new to openplotter) so a pointer on how to go about this would be really appreciated (unless it is a stupid idea -??)

The reason for not using the pypilot full implementation is also that I already have the barometric sensor in openplotter (directly on the PI3) and that my wind instruments are 4-20mA units so that is different from the pypilot implementation anyhow...
How is your instrument different?  Details please!  What does "4-20mA" mean?

Did you make the instruments?

Hi,
I bought two wind sensors about 2 years ago (one direction and one speed)  that outputs a current between 4 and 20 mA. The 4-20mA current loop is a well established industrial sensor standard,  the device has three wires: gnd, power (9-24v of I remember correctly) and then signal (current) output.  It is very simple to detect the signal,  just a resistor ( less than 200 ohm) and an adc (or rather two as there are two sensors) . The advantage with the current loop is that if I detect less than 4 mA I know the sensor (or cable) is faulty. 
For direction 4mA is 0 degrees and 40mA 359,9 and for speed 4mA is 0 m/s and 40 is 32.4 m/s. Yes max is 32.4 but if I'm out in heavier wind than 32 I guess I have other problems besides inaccurate wind speed readings     Wink

I started with a Arduino Nano and serial output and an RS422 driver for nema 0183 but as this consumes a USB port on my RPi and an RS422 to USB converter I instead added a ethernet shield to the Nano but had some stability challenges.  I then ordered a bunch of Wemos d1 minis (esp8266 based with WiFi) but they only have one adc so there I need an adc expander (ads1115) or an analogue mux. I'm also  waiting for a bunch of esp32's and they have multiple adc's so I might in fact go for those instead as I also want to reduce cabling on my boat and use WiFi as much as possible.

This sort of leads me back to the original question about using signalk directly,  I have a bunch of other sensors (engine, tank levels, temperature, water flow etc etc) that will output signalk directly over WiFi (udp ) so if pypilot could use the same I would have less code to maintain on the sensors side....

I stil have a challenge getting the signalk server in openplotter to understand my  udp messages but I assume that I will eventually sort that out,  there are several others that got it to work so eventually I'll sort that out as well...  Netcat in my RPi gets the data ok and if I use Netcat to send the data to the signalk servers udp port it works fine - I must have missed something in the esp8266 code so far .....
Using ratiometric cable and voltage signal.. if the cable is bad the wind speed will be 0, and the direction random. It is usually obvious there is a problem if the wind direction never changes.

It is nice to detect a problem in the cable. It is annoying to read 40mA though. Unless you have an amplifier and low ohm resistor, you need at least 30 ohms. This wastes quite a bit of power, up to 100mW, not to mention losses in the cable.

It might make more sense to put the uC in the sensors and send digital data down the cable.

For wireless... I don't really like it, because you already need a cable to supply power. Maybe 2 wires instead of 4, but wireless links also may have lag which can be bad and may be difficult to diagnose problems.

For signalk vs nmea0183... You probably are going to want both anyway for the foreseeable future. kplex converts nmea0183 to signalk. So for this reason, unless you have more interesting data than only speed and direction, what do you gain by using signalk here?

For wasting a usb port. It's possible to use any pin on the raspberry gpio header as a virtual serial port. It consumes a few % cpu, but it isn't really an issue with low data rates especially with 4 cores

pypilot can get the wind data from different sources, It can receive from opencpn, or kplex for example, but this adds lag. lag is bad in the autopilot control loop, so for this openplotter defaults to setting kplex to read the wind data from pypilot which reads the data directly from the sensor on a serial port. So the autopilot has it first. If you don't use the autopilot, then it's not important, and can be configured differently.
ESP32 with WiFi & Bluetooth (and a 18650 rechargable battery) are so cheap nowadays that this seems to be the way to go. Safes you all the cables and for recharging the batteries a simple solar will suffice. (or have backup one during recharging conventionally )
I am aiming to have one ESP32 for Temp/Pressure/Humidity and IMU (am still struggling to get the GY-BME/P280 sensor fully recognized - some library incompatibility issues) and am still undecided if NMEA183 or signalK is the better way to beam over wifi. Have a small preference for NMEA though. Anyone else working on this?
i have an arduino for use with 5v sensors, currently have a mq2 gas sensor, getting the data in node-red, gpio node, and publishing with mqtt node, then in op subscribe mqtt tab and setting message to sk "notifications fire" thats for the digital pin.. then a chart on the dash shows the data of the analog pin as concentration .going to use it in the propain locker.i have another to use as smoke detector or under the stove..
(2018-02-15, 07:44 PM)seandepagnier Wrote: [ -> ]Using ratiometric cable and voltage signal..   if the cable is bad  the wind speed will be 0, and the direction random.   It is usually obvious there is a problem if the wind direction never changes.

It is nice to detect a problem in the cable.  It is annoying to read 40mA though.   Unless you have an amplifier and low ohm resistor, you need at least 30 ohms.   This wastes quite a bit of power, up to 100mW, not to mention losses in the cable.

It might make more sense to put the uC in the sensors and send digital data down the cable.

For wireless...  I don't really like it, because you already need a cable to supply power.   Maybe 2 wires instead of 4, but wireless links also may have lag which can be bad and may be difficult to diagnose problems.

For signalk vs nmea0183...  You probably are going to want both anyway for the foreseeable future.  kplex converts nmea0183 to signalk.  So for this reason, unless you have more interesting data than only speed and direction, what do you gain by using signalk here?

For wasting a usb port.   It's possible to use any pin on the raspberry gpio header as a virtual serial port.  It consumes a few % cpu, but it isn't really an issue with low data rates especially with 4 cores

pypilot can get the wind data from different sources, It can receive from opencpn, or kplex for example, but this adds lag.  lag is bad in the autopilot control loop, so for this openplotter defaults to setting kplex to read the wind data from pypilot which reads the data directly from the sensor on a serial port. So the autopilot has it first.   If you don't use the autopilot, then it's not important, and can be configured differently.
Thanks for your reply,
OK, the lag might be an serious issue as you say - I hadn't understood that you "squeezed" pypilot in between the windsensor and openplotter - I assume it is still ok to run the main pypilot sw on the same RPI3 as where openplotter/OpenCPN is running?
 - Are you handling the GPS in the same way?
 - What about the rudder sensor? I'd like this data also to be available to OpenPlotter - do you send that onwards??
 - How do you interface the motor controller - is that also nmea? In that case I will be short of one USB/RS422 adapter and need to share with the AIS tranciever...

All my other sensors on the boat will use WiFi but if this would be an issue for wind then cables it will be.... I just got my 4 port USB extension for my RPI so I guess I could "afford" nmea0183 for wind. (1 for my AIS tranciever, 1 for the VHF, 1 for my STD Horizon plotter, 1 for wind instruments, 1 for GPS, 1 for kbd/mouse - that's 6 -> one spare - two if/when I retire the old plotter)

I thought you used signalk converted data in pypilot so I didn't think signalk was an issue but if you take nmea directly then I agree that doing a diversion through signalk makes no sense.... This would make use of one of my Arduino Nanos  in the first place anyhow....

On the wasted power issue, in my current test implementation i use the Arduino VCC as reference but I planned to turn to the internal 1.1 V reference and with 40 mA max current that would be like a 25 ohm resistor and if i didn't go absolutely wrong that would mean around 40mW + losses in the cable - assume a few more ohms there - say 5 -> 44 mW --- Not so bad.... 

How did you get to 100 mW?? Perhaps I've missunderstood something....
I use Mqtt to beam a load of stuff from an esp8266 into openplotter with easyesp on the 8266. Makes it easy to set up and change over wifi. Though thinking now of going signalk and writing the code so the 8266 can spend more time asleep, all those little bits of power add up when on 24/7.
Anyone using micropython on esp's? Better than Arduino code?

Sent from my SGP511 using Tapatalk
I just started to get a ardunio nano set up as a mast head unit running. I use a NRF24l01+ on the ardunio to send wind speed and it will turn the anchorli on and off via a Mosfet. The rpi openplotter has a switch wired into GPIO25 that sends message to mast to turn on/off anchor light. The Pi /openplotter  receives sensor data and sends this to siglnalK ie environment.wind.speedApparent.

here is the code i use to send data from pi to SignalK
Code:
import socket
   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   SignalK = '{"updates": [{"source": {"type": "wind","src" : "arduino"},"values":['
   SignalK += '{"path": "environment.wind.speedApparent","value":'+str(aws)+'}'
    SignalK += '{"path":.....add more here 

    SignalK += ']}]}\n'
   sock.sendto(SignalK, ('localhost', 55559))
   sock.close()
 
It works and i am just sending the minimal data via the nrf24. Much lower power then WiFi. I now just have to send 12 dc up the mask to power unit. It appearers to use about .220a/hr when Anchor light is on.

I think a mesh network of low power sensors run on batteries could clean up the system. "Sensor pucks" Eh! they take a lickin and keep on tickin..

I would like a SignalK Display modules ie 3"/3" that could read the stream and display selected data wired or wireless and sunlight readable.
Pages: 1 2