
PiFinder4
brickbots/PiFinder
A plate solving telescope finder based around a Raspberry PI and RPI HQ Camera

Collection of Arduino and Linux code to integrate with a NMEA2000 Can bus.
DueBridge is an open-source printed circuit board by ieb, from the ieb/nmea2000 repository on GitHub. It is a 2-layer board of 90 × 70 mm with 38 parts on 34 nets, routed with 381 tracks and 2 vias.
It is built around the BNO055. Its parts include 13 resistors, 8 ICs, 6 capacitors, 5 connectors and 3 diodes. It belongs with the interfaces and adapters boards of this library.
This repository contains a number of utilities generally aimed at interfacing with a NMEA2000 CAN bus and collecting stats in InfluxDB for analysis in Grafana.
The repository is mainly to keep a record of work in progress, rather than a neat and tidy implementation, but if it helps others, great.
The code runs on an Arduino Due with a CAN bus trancever. Some code may also run on an Arduino Mega to simulate Raymarine wind, speed and temperature sensors. The heavy lifting on the Arduino as been done by https://github.com/ttlappalainen/NMEA2000.git to use the code here on a Due you may also need https://github.com/collin80/due_can.git https://github.com/ttlappalainen/NMEA2000_due.git which the NMEA2000 implementation and CAN Bus drivers for the Due.
The Marine instrument installation is a Raymarine SeatalkNG installation with a e7 MFD, althogh there is nothing here that is specific to Raymarine. At the electrical and protocol level SeatalkNG == NMEA2000 == CAN@250kb/s. The differences are physical, mainly to ease installation.
As well as emitting CAM messages onto the NMEA2000 bus the Arduino Due runs code to implement sufficient of the Actisense protocol to feed SignalK running on a Pi Zero W. Installation of that part is listed below. Most of this is achieved with confgiguration and no additional code.
Installation on a Pi Zero W for pushing stats from NMEA2000 -> Arduino Due -> SkignalK -> InfluxDB -> Grafana
Using Raspbain Lite written to a SDMicro card boot and configure the Pi Zero W, once booted. At the console (HDMI+USB Keyboard)
cat << EOF > /etc/wpa_supplicant/wpa_supplicant.conf
country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
ssid="yourSSID"
psk="*********"
}
EOFraspi-config
# then enable ssh serverNow switch to using ssh in from a Linux box.
apt-get update
apt-get install -y curl git build-essential libnss-mdns avahi-utils libavahi-compat-libdnssd-dev
cd /opt/// wget https://nodejs.org/dist/v6.10.2/node-v6.10.2-linux-armv6l.tar.xz
wget https://nodejs.org/dist/v6.11.1/node-v6.11.1-linux-armv6l.tar.gz
tar xvzf node-v6.11.1-linux-armv6l.tar.gz
rm node-v6.11.1-linux-armv6l.tar.gz
cd /usr/local/bin/
ln -s /opt/node-v6.11.1-linux-armv6l/bin/* .
cd
wget http://ftp.us.debian.org/debian/pool/main/i/influxdb/influxdb_1.1.1+dfsg1-4_armhf.deb
wget http://ftp.us.debian.org/debian/pool/main/i/influxdb/influxdb-client_1.1.1+dfsg1-4_armhf.deb
dpkg -i influxdb_1.1.1+dfsg1-4_armhf.deb
dpkg -i influxdb-client_1.1.1+dfsg1-4_armhf.deb
apt-get install -fwget https://bintray.com/fg2it/deb-rpi-1b/download_file?file_path=main%2Fg%2Fgrafana_4.2.0_armhf.deb
mv download_file\?file_path\=main%2Fg%2Fgrafana_4.2.0_armhf.deb grafana_4.2.0_armhf.deb
dpkg -i grafana_4.2.0_armhf.deb
systemctl daemon-reload
systemctl enable grafana-server
systemctl start grafana-serverThis will allow you to see if the Pi Zero is overloaded.
apt-get install collectdEdit collectd to disable rrdtool, battery and irq plugins, removing the config sections. Enable network and add the following
<Plugin network>
Server "127.0.0.1" "8096"
</Plugin>Edit /etc/influxdb/influxdb.conf to enable collectd
[[collectd]]
enabled = true
bind-address = ":8096"
database = "collectd"
typesdb = "/usr/share/collectd/types.db"Check that /usr/share/collectd/types.db exists (if not its at https://github.com/collectd/collectd/blob/master/src/types.db)
service influxdb restart
service collectd restartCheck all is Ok
service influxdb status
service collectd status
service grafana-server statusAs a normal user who is a member of the staff group
cd /usr/local/src
git clone https://github.com/SignalK/signalk-server-node.git
cd signalk-server-node
npm install # Wait for some time as everything gets installed.
npm install mdns
sudo bash rpi-setup.shuse port 80 to run SignalK see https://github.com/SignalK/signalk-server-node/blob/master/raspberry_pi_installation.md for more detailed info
cd /usr/local/src/signalk-server-node
npm install https://github.com/sbender9/signalk-to-influxdb
service signalk restartcheck all ok
service signalk status Then go to http://localhost and configure the influxDB plugn
check all ok again
service signalk status OS level info should now be in the collectd db, create a Grafana datasource pointing to that DB. See OS Dashboard.json and windDashboard.json for exmaples.
The SignalK process will report to InfluxDB over the http API, which involves 1 POST oepration per report. This is probably less overhead than reporting using the InfluxDB UDP route, but keep an eye on load average and IO stats in Grafana (see OSDashboard.json for a Grafana Daskboard on the OS). Also see WindDashboard for a Dashboard on AWA etc.
The Arduino is connected to the Pi using a USB Cable, the Arduino appears as a USB CDC Serial port at /dev/ttyACM0 which can be opened at 115200 baud.
lsusb should show
root@lunacore:/usr/local/src/signalk-server-node# lsusb
Bus 001 Device 005: ID 2341:003d Arduino SA
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@lunacore:/usr/local/src/signalk-server-node#
root@lunacore:/usr/local/src/signalk-server-node# usb-devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev=04.04
S: Manufacturer=Linux 4.4.50+ dwc_otg_hcd
S: Product=DWC OTG Controller
S: SerialNumber=20980000.usb
C: #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=0mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 5 Spd=12 MxCh= 0
D: Ver= 1.10 Cls=02(commc) Sub=00 Prot=00 MxPS= 8 #Cfgs= 1
P: Vendor=2341 ProdID=003d Rev=00.01
S: Manufacturer=Arduino (www.arduino.cc)
S: Product=Arduino Due Prog. Port
S: SerialNumber=9543334393335111B181
C: #Ifs= 2 Cfg#= 1 Atr=c0 MxPwr=100mA
I: If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=01 Driver=cdc_acm
I: If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=cdc_acm
root@lunacore:/usr/local/src/signalk-server-node# Signak node server should be configured with an actisense input listening to this port, and should have plugins configured to a) send data to InfluxDB b) NMEA0183. Currently there are only plugins for TCP connections which causes a high level of turnover of TCP ports, it might be better to use UDP, that that will need some coding.
It is possible to power the Pi from the ArduinoDue over USB and visa versa. The Arduino uses < 100mA, but the Pi might use a bit more when under full load.
Sending data to influxDB on a standard SignalK setup swamps InfluxDB making it unusable, probably as a result of the frequency of packets > 1s in some cases, and the way the standard signalk-to-influxDB plugin is written. New signalk-telemetry plugin dixes this sending data in one block, queued to be more effcient at a fixed rate.
It may be possible to run everything from the Pi using socketCan rather than using a Due. This needs MCP2515 trancevers, 12C for the 10Dof sensor. In addition 1Wire temperature sensors and a I2C RTC can be added. Potentially this reduces power consumption as 80mA isnt needed to power the Due any more. the Pi has no A2D so a SPI based chip would need to be used.
The Pi supports 2x CAN trancevers with SocketCAN.
Raspberry Pi 10Dof
The npm module https://www.npmjs.com/package/nodeimu works for several 10DOf sensors on i2C, setup only requires i2c is enabled. The IMU Requires configuration see https://github.com/RTIMULib/RTIMULib2 which also requires Octave to be installed for full calibration.
dtparam=i2c_arm=on
Raspberry Pi RTC Disconnected from ntp the Pi will not keep time, using a ds3231 over i2c gives acurate time once setup.
dtoverlay=i2c-rtc,ds3231 see http://raspmer.blogspot.co.uk/2015/07/how-to-use-ds3231-i2c-real-time-clock.html
Raspberry Pi 1 Wire
DS18B20 are 1 wire temperature sensors. To read on a Pi enable 1wire and connedt with a 4K7 pullup to 3.3v, where the 1 wire is the default pin 7
Output is at cat /sys/bus/w1/devices//w1_slave. Map the ID to the sensor by warming each sensor in turn.
https://www.npmjs.com/package/ds18b20 for NPM
Raspberry Pi CanBus
Investigating how to run over SocketCan
2x MCP2515 drivers with Trancevers from eBay, MUST be connected with 3.3V to 5V level shifters to avoid GPIO damage as the trancevers will run at 5V. 2 can be connected to get CAN0 and CAN1
Wiring
2 5V --------------- Vdd
1 3V3 ------> LS 3V3
2 5V ---------> LS 5V
9 GND --------> LS GND
9 GND -------------- GND
19 MOSI ----> LS ----> SI0 & SI1
21 MOSO <---- LS <---- SO0 & SO1
23 SCLK ------> LS ----> SCLK0 & SCLK1
24 CE0 ------> LS ----> CS0
26 CE1 ------> LS ----> CS1
18 GPIO24 <-- LS <---- INT0
22 xGPIO25 <-- LS <---- INT1
dtoverlay mcp2515-can0 oscillator=8000000 interrupt=24
dtoverlay mcp2515-can1 oscillator=8000000 interrupt=25
root@raspb:~/can-utils# dmesg | egrep "spi|can"
[ 477.594591] mcp251x spi0.0 can0: MCP2515 successfully initialized.
[ 487.165293] mcp251x spi0.1 can1: MCP2515 successfully initialized.
[ 495.704786] can: controller area network core (rev 20120528 abi 9)
root@raspb:~/can-utils# ifconfig can0
can0: flags=128<NOARP> mtu 16
unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 10 (UNSPEC)
RX packets 0 bytes 0 (0.0 B)Install can-utils from source.
# git clone https://github.com/linux-can/can-utils.git
# cd can-utils
# ./autogen.sh
# ./configure
# make
# sudo make installIf initialisation reports a wiring problem, then there almost cerainly is a wiring problem.
Configure interface
root@raspb:~/can-utils# ip link set can0 up type can bitrate 250000
root@raspb:~/can-utils# ip link set can1 up type can bitrate 250000Test
root@raspb:~/can-utils# ./candump can1 &
[1]+ ./candump can1 &
root@raspb:~/can-utils# ./cansend can0 001#1122334455667788
can1 001 [8] 11 22 33 44 55 66 77 88
root@raspb:~/can-utils# ./cansend can0 001#1122334455667788
can1 001 [8] 11 22 33 44 55 66 77 88
root@raspb:~/can-utils# ./cansend can0 001#1122334455667788
can1 001 [8] 11 22 33 44 55 66 77 88
root@raspb:~/can-utils# To echo all CAN1 traffic to CAN0, setup CAN1 to listen only, and setup CAN0 to have loopback enabled to anything reading CAN0 gets the CAN0 messages as well.
root@raspb:~/can-utils# ip link set can0 up type can bitrate 250000 loopback on
root@raspb:~/can-utils# ip link set can1 up type can bitrate 250000 listen-only onThen to bridge
candump can1 -B can0For can0 -> SK
see https://github.com/chacal/signalk-socketcan-device
Moved back to the Due for now as its single threaded and doesnt stop expecially with no memory allocation. Processing power is a lot less, but it does a lot less also, not having an OS. 84MHz is plenty for this usage.
Todo: Test polar calcs - partially done. Test Can0 - done Test IMU and calibrate - done. Test Cos and Sin - done Test Pulse counters - done Test SD card Test 1 Wire Test wind and speed calcs Test linear voltage regulator vs noise from dc-dc converter Linear voltage is no nose, but too hot LTSpice model indicates a 10uF cap will eliminate ripple from buck converter.
Input is candump can0 pipe, output is signalk-socketcan-device.
"pipedProviders": [{
"id": "can0",
"pipeElements": [
{
"type": "providers/execute",
"options": {
"command": "candump can0 | candump2analyzer | analyzer -json -si -nv"
}
},
{
"type": "providers/liner"
},
{
"type": "providers/from_json"
},
{
"type": "signalk-socketcan-device",
"options": {
"n2kAddress": 110,
"canDevice": "can0"
}
},
{
"type": "providers/n2k-signalk"| Qty | Value | Footprint | References |
|---|---|---|---|
| 5 | 4K7 | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | R3, R4, R5, R6, R13 |
| 4 | 10nF | Capacitors_ThroughHole:C_Disc_D7.5_P5 | C3, C4, C5, C6 |
| 4 | 2K2 | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | R7, R8, R11, R12 |
| 2 | 10K | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | R9, R10 |
| 2 | 3v3 Zener | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | D1, D2 |
| 2 | 4N35 | Housings_DIP:DIP-6_W7.62mm | IC1, IC2 |
| 2 | CanTX | footprints:CanTrans | U5, U6 |
| 1 | 100nF | Capacitors_ThroughHole:C_Disc_D7.5_P5 | C2 |
| 1 | 10uF | Capacitors_ThroughHole:C_Radial_D10_L13_P5 | C1 |
| 1 | 1Wire | Pin_Headers:Pin_Header_Straight_1x03 | K1 |
| 1 | 33K | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | R1 |
| 1 | 56K | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | R2 |
| 1 | ArduinoDue | footprints:Arduino_Mega_Due | U3 |
| 1 | BNo055 | footprints:BNo055 | U4 |
| 1 | CAN0 | footprints:CanCon | P3 |
| 1 | CAN1 | footprints:CanCon | P4 |
| 1 | DCDC | footprints:DCDC | U1 |
| 1 | I2C | Pin_Headers:Pin_Header_Straight_1x04 | P5 |
| 1 | SDCard | footprints:SDCard | U2 |
| 1 | Water Sensor | Connect:bornier5 | P2 |
| 1 | Wind Sensor | Connect:bornier5 | P1 |
| 1 | Zener 3v3 | Resistors_ThroughHole:Resistor_Horizontal_RM7mm | D3 |
The 36 most common of 38 parts.
It measures 90 × 70 mm and has 2 copper layers, 1.6 mm thick.
38 parts, built around the BNO055. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the ieb/nmea2000 repository on GitHub, at the commit this page was made from: the board is duebridge/DueBridge.kicad_pcb. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask ieb before reusing the design.

brickbots/PiFinder
A plate solving telescope finder based around a Raspberry PI and RPI HQ Camera




01binary/str1ker
A human-scale mech integrated with Robot Operating System



Aharoni-Lab/Miniscope-LFOV
Large field-of-view miniature microscope for rats and larger animals.