I'll start in reverse order, on how to access the peripheral devices:
To start with, the second I2C bus has to be activated as mentioned on the previous post using the following command:
Also, it shows three devices being connected on I2C#1
These have as follows:
device 1e: HMC5883L-based, triple axis magnetometer
device 48: 4 Channel ADC, Adafruit ADS1115
device 53: ADXL345-based triple axis accelerometer
The headings of the two compasses can be read using the following code:
Executing this code, we get these results:
The third peripheral I have connected is a Adafruit ADS1115, which can be managed using the appropriate Adafruit library (more about it in a later post).
So, the current status can be seen in the following photo:
The components shown have as follows:
Some porting has to be done from Python V2 to Python V3 but Ok, it is feasible, it will be done.
In all, I consider the hardware and low-level software to be in place.
What is left is all host and UI software, along with much needed solutions on some more core issues, for example, the lack of accuracy by the magnetometers! I have two devices that I work in parallel and they produce reading +/- 15 degrees from one another! I will investigate the possibility of providing some form of calibration for these, we 'll see.
More about the software:
Concerning the host software, well, I haven't touch it yet! I have done some tests on reading the sensors but that's it.
For version 1 of the host software, there are not that many things to do, there has to be a loop for reading the sensors, calculating the computed fields, store results in a DB, push metrics to the UIs etc.
For the Primary UI, I am investigating the possibility of using javascript and HTML5. It's a bit tough because things like websockets are new to me but the result will be something portable and possibly extensible so it is worth the effort.
As for the Secondary UI, programming the Pebble using SDK 1.12 was not that bad, and there is a new V2 SDK that came out a few days ago, it might need some reading but looks OK too.
Having said that, I am now forced to put the project on hold for one or two months, which means that I will probably be back early next year.
Thanks for reading!
G.
UPDATE:
I have totally forgotten about the wind direction and speed sensor! I have access to a Nasa Masthead Wind Sensor which produces two analog values for wind direction and a pulse signal for the wind speed.
I will use two ADC inputs on the ADS1115 for the wind direction and a I/O pin in interrupt mode for counting the length of the wind speed pulses (as shown here).
I have sent a message to Nasa Marine Instruments asking for documentation for the sensor but haven't had a reply yet, so whoever has any info about it, please let me know!
To start with, the second I2C bus has to be activated as mentioned on the previous post using the following command:
hipi-i2c e 0 1Following that, devices can be detected on both I2C buses:
root@akka-pc:~# i2cdetect -y 0The aboves shows one HMC5883L-based, triple axis magnetometer at I2C#0 (connected to P5) with I2C address 1e.
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
root@akka-pc:~# i2cdetect -y 1
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- 1e --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
40: -- -- -- -- -- -- -- -- 48 -- -- -- -- -- -- --
50: -- -- -- 53 -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
Also, it shows three devices being connected on I2C#1
These have as follows:
device 1e: HMC5883L-based, triple axis magnetometer
device 48: 4 Channel ADC, Adafruit ADS1115
device 53: ADXL345-based triple axis accelerometer
The headings of the two compasses can be read using the following code:
$ cat two-compasses
#!/usr/bin/python3On the above code I have highlighted the way we choose which magnetometer (i.e. on which I2C bus) we work with.
from i2clibraries import i2c_hmc5883l
hmc5883a = i2c_hmc5883l.i2c_hmc5883l(1)
hmc5883a.setContinuousMode()
hmc5883a.setDeclination(0,0)
hmc5883b = i2c_hmc5883l.i2c_hmc5883l(0)
hmc5883b.setContinuousMode()
hmc5883b.setDeclination(0,0)
print (hmc5883a.__str__())
print (hmc5883b.__str__())
Executing this code, we get these results:
$ ./two-compassesApart of the Compasses, we also have a 3D accelerometer, which can be read using something like:
Axis X: -122.36
Axis Y: -809.6
Axis Z: -160.08
Declination: 0 0'
Heading: 261 24'
Axis X: 411.24
Axis Y: -168.36
Axis Z: 215.28
Declination: 0 0'
Heading: 337 44'
# cat accelerometerand running the above while moving the accelerometer, we get:
#!/usr/bin/python3
from i2clibraries import i2c_adxl345
from time import *
adxl345 = i2c_adxl345.i2c_adxl345(1)
while True:
print(adxl345)
sleep(1)
# ./accelerometerIn order to access these peripherals, I use the Think Bowl I2C Libraries
X: 0.21875
Y: -0.625
Z: 0.65625
X: -0.34375
Y: 0.9375
Z: 0.28125
X: -0.5625
Y: -0.25
Z: -0.78125
X: -0.03125
Y: 0.6875
Z: 1.125
The third peripheral I have connected is a Adafruit ADS1115, which can be managed using the appropriate Adafruit library (more about it in a later post).
So, the current status can be seen in the following photo:
The components shown have as follows:
- The Raspberry PI: This is a model B, but since on the final version Ethernet won't be needed, it might be replaced with a Model A depending the the memory resources needed for the version of software that will eventually be running. Model A is considered for power consumption reasons. More about that below, when discussing item (3)
- This is a 12V battery. Since the outcome of this project is intended to work on my boat, I am doing all development with that in mind.
- This a switching voltage converter, that makes the 5V Raspberry needs out of the 12V the battery produces. Being a switching regulator, it has a very high efficiency, which is very important since electrical power on board is always scarce. I have been using a very low cost and light component that is usually being used in electric RC models and it is called "Battery Eliminator Circuit". On the final release of the ShipComputer, (the one I will be use on the boat) I will possibly make use of 2 BECs, one for creating 5V out of 12V and another one for creating 3.3V out of 12V. The Raspberry will be powered from both of these, and the 5V one will also be powering the USB hub that seems to be needed. The linear voltage regulator found on Raspberry, usually responsible for up to one third of the total power consumption, will be removed as it 'll be not longer needed.
- This is a Current Sensor based on the ACS714 Hall effect-based chip that produces a analog voltage based on the current that passes through, and its direction. When there's no current, the sensor produces a voltage of Vcc/2. This output changes by 185 mV per Amp. It will be connected to an analog input of the attached ADC and it will measure consumption and charging.
- This is the 3-axis Accelerometer
- ADS1115 ADC, I2C-based ADC, by Adafruit.
- Magnetometer of bus I2C#1
- USB Hub (need more that the 2 USBs provided)
- USB GPS, connected to the Raspberry through the USB hub
- Wifi USB Dongle. The system is set up as an Access Point, in order to enable connection of the tablet, on which the Primary User Interface will be running.
- Bluetooth Dongle for connectivity to the Pebble Smart Watch, on which the secondary UI will be running
- A splitter PCB for connecting all three I2C peripherals on the same I2C bus
- A PCB that holds the pull-up resistors needed for I2C#0
- The second magnetometer on I2C#0
Some porting has to be done from Python V2 to Python V3 but Ok, it is feasible, it will be done.
In all, I consider the hardware and low-level software to be in place.
What is left is all host and UI software, along with much needed solutions on some more core issues, for example, the lack of accuracy by the magnetometers! I have two devices that I work in parallel and they produce reading +/- 15 degrees from one another! I will investigate the possibility of providing some form of calibration for these, we 'll see.
More about the software:
Concerning the host software, well, I haven't touch it yet! I have done some tests on reading the sensors but that's it.
For version 1 of the host software, there are not that many things to do, there has to be a loop for reading the sensors, calculating the computed fields, store results in a DB, push metrics to the UIs etc.
For the Primary UI, I am investigating the possibility of using javascript and HTML5. It's a bit tough because things like websockets are new to me but the result will be something portable and possibly extensible so it is worth the effort.
As for the Secondary UI, programming the Pebble using SDK 1.12 was not that bad, and there is a new V2 SDK that came out a few days ago, it might need some reading but looks OK too.
Having said that, I am now forced to put the project on hold for one or two months, which means that I will probably be back early next year.
Thanks for reading!
G.
UPDATE:
I have totally forgotten about the wind direction and speed sensor! I have access to a Nasa Masthead Wind Sensor which produces two analog values for wind direction and a pulse signal for the wind speed.
I will use two ADC inputs on the ADS1115 for the wind direction and a I/O pin in interrupt mode for counting the length of the wind speed pulses (as shown here).
I have sent a message to Nasa Marine Instruments asking for documentation for the sensor but haven't had a reply yet, so whoever has any info about it, please let me know!