Anyone got an Arduino boat project to swap?

Not an arduino project to swap but esp32. Tonights fun was getting victron data into a Pi over wifi.

kieYru1.jpg


The ESP is 3.3v and the data coming out of the victron is 5v so it goes into an rs232/TTL adaptor which is powered by 3.3v from the esp so the TTL comes out at 3.3v. Not sure if that's how you're supposed to do it but it works. then the esp reads the data through a spare uart and sends it as UDP over wifi. After that there's a signalk app which reads the victron data and turns it into signalk. Shame the victron 5v out wasn't beefy enough to run the esp with wifi turned on, needed that little 12v/5v converter otherwise it would have been a right result :cool:

K7rRifR.png


And of course once in signalk it all gets saved to a database automatically. Project for someone on jlcpcb :) Who will surface mount esp chips for you now apparently. Programmed in micropython which is pretty cool, you can access the esp over the web so upload or download direct from the device. Powerful little things!!

2KzM4Gr.png


There's a basic class doing some wifi stuff as well, but the gist of it is below. Love python, it works and it makes sense. Shame the esp8266 doesn't have a spare uart input, would have been cheaper and less power though there may be a way to get serial data into an 8266. For another night :)

Python:
#!/usr/bin/env python3

import machine
import esp32
import boatymon
import uasyncio as asyncio
import uos

from machine import UART

uart = UART(1, tx=12, rx=14, timeout=50)
uart.init(baudrate=19200,bits=8,parity=None, invert=UART.INV_RX)
# # machine.UART(uart_num, tx=pin, rx=pin, stop=1, invert=UART.INV_TX | UART.INV_RX)

loop = asyncio.get_event_loop()
mySensors = boatymon.sensors()

import usocket as socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

def sendudp(data):
    address = ("192.168.43.74", 10111)
    sock.sendto(data, address)
    address = ("192.168.43.93", 10111)
    sock.sendto(data, address)

async def call_sensors():
    while True:
        try:
            mySensors.flashLed()           
            print("Looping")
        except Exception as e:
            print('error in call sensors function, error =',e)
            pass
        await asyncio.sleep(1)
        
async def check_wifi():
    while True:
        try:
            mySensors.connectWifi()
        except Exception as e:
            print('check wifi error, error =',e)
            pass
        await asyncio.sleep(10)

async def fast_loop():
    sreader = asyncio.StreamReader(uart)
    while True:
        try:
            res = await sreader.readline()
            sendudp(res)
            res = res.decode("ASCII").rstrip()       
            values = res.split("\t")
        except Exception as e:
            print("Serial input decode error",e)
            pass

loop.create_task(call_sensors())
loop.create_task(check_wifi())
loop.create_task(fast_loop())

loop.run_forever()
 
Last edited:
GHA, regarding this obsession you have for the ESPs, I think you need to see a specialist :p

Victron MPPT VE.Direct socket (old school CDROM audio socket btw) to a usbserial adapter and straight into a pi.
pi runs venus (as I guess yours does) signalk and all that jazz.
still learning but looks good.
about to embark in mosquitoing from the pi then over the internet to the server to write them to influxdb...
apparently the only way to throttle traffic properly!

V.
 
GHA, regarding this obsession you have for the ESPs, I think you need to see a specialist :p

Victron MPPT VE.Direct socket (old school CDROM audio socket btw) to a usbserial adapter and straight into a pi.
pi runs venus (as I guess yours does) signalk and all that jazz.
still learning but looks good.
about to embark in mosquitoing from the pi then over the internet to the server to write them to influxdb...
apparently the only way to throttle traffic properly!

V.
Thing is you end up with a hundred and one usb/serial adapters, ...... and yet more cables converging into the Pi :)
Not running venus, just signalk ona Pi zero to keep the power down. 150mA or about 200mA with music blaring from piggy backed amp. :cool:

New signalk plugin looks interesting, batch write to a could influxdb database when it's available, could be the way forward to get our lovely boat data into the cloud when away from the boat>>
pbegg/signalk-to-influxdb-v2-buffering
 
Not an arduino project to swap but esp32. Tonights fun was getting victron data into a Pi over wifi.

kieYru1.jpg


The ESP is 3.3v and the data coming out of the victron is 5v so it goes into an rs232/TTL adaptor which is powered by 3.3v from the esp so the TTL comes out at 3.3v. Not sure if that's how you're supposed to do it but it works. then the esp reads the data through a spare uart and sends it as UDP over wifi. After that there's a signalk app which reads the victron data and turns it into signalk. Shame the victron 5v out wasn't beefy enough to run the esp with wifi turned on, needed that little 12v/5v converter otherwise it would have been a right result :cool:

K7rRifR.png


And of course once in signalk it all gets saved to a database automatically. Project for someone on jlcpcb :) Who will surface mount esp chips for you now apparently. Programmed in micropython which is pretty cool, you can access the esp over the web so upload or download direct from the device. Powerful little things!!

2KzM4Gr.png


There's a basic class doing some wifi stuff as well, but the gist of it is below. Love python, it works and it makes sense. Shame the esp8266 doesn't have a spare uart input, would have been cheaper and less power though there may be a way to get serial data into an 8266. For another night :)

Python:
#!/usr/bin/env python3

import machine
import esp32
import boatymon
import uasyncio as asyncio
import uos

from machine import UART

uart = UART(1, tx=12, rx=14, timeout=50)
uart.init(baudrate=19200,bits=8,parity=None, invert=UART.INV_RX)
# # machine.UART(uart_num, tx=pin, rx=pin, stop=1, invert=UART.INV_TX | UART.INV_RX)

loop = asyncio.get_event_loop()
mySensors = boatymon.sensors()

import usocket as socket
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)

def sendudp(data):
    address = ("192.168.43.74", 10111)
    sock.sendto(data, address)
    address = ("192.168.43.93", 10111)
    sock.sendto(data, address)

async def call_sensors():
    while True:
        try:
            mySensors.flashLed()          
            print("Looping")
        except Exception as e:
            print('error in call sensors function, error =',e)
            pass
        await asyncio.sleep(1)
       
async def check_wifi():
    while True:
        try:
            mySensors.connectWifi()
        except Exception as e:
            print('check wifi error, error =',e)
            pass
        await asyncio.sleep(10)

async def fast_loop():
    sreader = asyncio.StreamReader(uart)
    while True:
        try:
            res = await sreader.readline()
            sendudp(res)
            res = res.decode("ASCII").rstrip()      
            values = res.split("\t")
        except Exception as e:
            print("Serial input decode error",e)
            pass

loop.create_task(call_sensors())
loop.create_task(check_wifi())
loop.create_task(fast_loop())

loop.run_forever()
Love your stuff @GHA.
 
  • Love
Reactions: GHA
My recent lockdown Arduino project, but nought to do with boats I’m afraid.

IR detector mounted on a servo, atop a 4 wheeled chassis. The aim was for a heat-seeking robot to annoy the cats. I came up with some really pleasing routines to scan, flag detection and then centroid track the “target”, plus a break-lock routine in case the target faded. Steering commands to the wheels for a pure-pursuit terminal engagement.

Unfortunately, it was as blind as a bat. I googled the spec for the IR sensor which revealed an optimum detect range of 3 to 5 cm. Yep, centimetres. So my heat-seeking robot is awesome at detecting a boiling kettle within about a foot and a half, but the cats sleep on...

Still it passed an evening or ten and all that fun for the price of about 40 boiled kettles.
 
My recent lockdown Arduino project, but nought to do with boats I’m afraid.

IR detector mounted on a servo, atop a 4 wheeled chassis. The aim was for a heat-seeking robot to annoy the cats. I came up with some really pleasing routines to scan, flag detection and then centroid track the “target”, plus a break-lock routine in case the target faded. Steering commands to the wheels for a pure-pursuit terminal engagement.

Unfortunately, it was as blind as a bat. I googled the spec for the IR sensor which revealed an optimum detect range of 3 to 5 cm. Yep, centimetres. So my heat-seeking robot is awesome at detecting a boiling kettle within about a foot and a half, but the cats sleep on...

Still it passed an evening or ten and all that fun for the price of about 40 boiled kettles.
I'm sure you can do better than that! the parking sensors have a range of 20-40cm pretty sure about that! have a look, sounds like a fun project, deffo better than siting in front of the tv drinking and eating!
V.
 
Signalk app to write to cloud influxdb works!
G6GHYKY.png

well,

I'm doing that now:

raspberry pi with CAN HAT picking up Victron and all NMEA2000 data off the boat network, sending them via signalk (running on the pi) and the signalk-2-influxdb plugin to my office server running influxDB and then grafana for visualisation.
even managed the throttling of data on the signalk2influxdb pluggin so now only sends every 1 min which is better bandwidthwise to sending five times a second ffs!
HOWEVER, I still cannot have a buffer to keep my data when system is down wifi off/whatever, hence the mosquito thingie (which btw is a pain!)

still looking.
The other big issue is that comms is now one way: boat -> office server
However I'm about to get signalk to read and write some custom PGNs of mine that do interesting things (like start the generator :) ) and was hoping to be able to do that from home (for the fun of it)
That means bi-directional comms, which when I connect via a wifi, have no luck! so dead on the blocks :-(

oh well, still searching and improving!
at least I'm down from 0.5GB/h to probably around 50MB/day :cool:

V.
 
Top