Stepping up your project might mean using higher quality sensors or more robust ones like the ones in the automotive industry. Most of these automotive sensors rely on CAN bus technology, and with the XMC14_2GO, CAN is more accessible, expanding your sensory portfolio. We have previously posted an article where we explained how to use CAN bus. And now we use CAN in a new project on our Maker Monday. In this project we want to take CAN to the extreme. CAN is known for its robustness under harsh and noisy conditions, but will it stand under a new noise: water!
Data like underwater temp, water quality, and pressure along or coupled with data from surface water like the wave activity and altitude can give us a valuable insight on the nature of the lake.
Freshwater lakes, with their delicate ecosystems, offer the perfect testing ground for CAN communication over short distances. As sensitive indicators of environmental and climate shifts, these lakes require reliable monitoring systems that can operate in demanding conditions. Our project aims to evaluate CAN's ability to maintain stable communication between nodes at depths ranging from 1 to 10 meters.
A 10 m cable will be used to collect data from under the deepest level in a nearby lake. The 10 m cable carries CAN signal and power to the underwater device (submerged device). The device features a TDS meter along with the S2GO PRESSURE DPS368 for temperature and pressure providing an insight of the lake's environment. This data is then transmitted via CAN protocol to the second floating node.
The S2GO PRESSURE DPS368 plays a crucial role in this project. It can work at very low depths underwater, and the temperature it provides is used to calculate the quality of the water accurately, as the measurements from the TDS meter rely on the temperature. Under high depth, the temperature drastically drops with the pressure. The pressure data from the S2GO PRESSURE DPS368 is used to control the depth of the device, which is highly important as we don’t want to over-submerge our device.
It is important to not keep the device at high depth for a long time, that’s why we use a motorized system to control the depth and only measure data at high depths for a limited time. Additionally, the water quality and temperature change significantly from depth to depth. This variability has been observed during lake testing.
The CAN relies on transferring the data from underwater to another XMC14_2GO which allows us to get real time data which can be transmitted from surface later. For us the data will be visualized on a small OLED screen on top of the buoys. A more common solution is to use wireless communication to send from floating device. The buoys have a spool with a motor that pulls and drops the sensor pack in a controlled way. In this way we can leave buoys to travel in the lake while dropping and testing in various places. The whole system is powered by two battery packs.
HardwareThe system consists of two nodes: Node 0, which is the underwater node, and Node 1, which is the surface node. For powering both nodes we used a 9V battery pack and an Infineon TLS4120 5V CORE-BOARD, which converts the 9V input from the battery pack to a stable 5V output voltage. This 5V output is then used to power the surface node, including the microcontroller and OLED display, as well as the dc motor. Additionally, the 5V output is transmitted along with CAN bus wires. XMC14_2GO has CAN which allows for fast prototyping with CAN sensors and other CAN devices, leveraging the robustness of CAN communication.
1.Underwater Node
- Microcontroller: KIT_XMC14_2GO, responsible for managing sensor readings and transmitting data via CAN communication.
- Sensor: S2GO PRESSURE DPS368, measures pressure and temperature.
- Housing: Safe Box Protection Capsule, waterproofed with silicone sealing to keep the components safe and dry.
- TDS meter: measures the concentration of dissolved solids in the water, which is an important parameter for water quality monitoring.
2.Surface Node
- Microcontroller: KIT_XMC14_2GO, responsible for receiving data from Node 0 via CAN communication.
- Push Button Control: Toggles the state of the motorized system, switching between deploying and retrieving the underwater node with each press.
- OLED Display: Displays live data from Node 0 for local monitoring and debugging.
In summary, Node 0 is responsible for collecting pressure and temperature data and transmitting it to Node 1 via CAN communication. Node 1 receives this data and displays it on an OLED display, while also controlling the deployment and retrieval of Node 0 using a motorized pulley system.
Part One: Submerged DeviceThe submerged device has to be water tight. It has to include TDS meter for measuring the number of dissolved parts per million (PPM) in water (PPM refers to the concentration of chemicals or impurities within the water. One part per million means that there is one unit of a substance for every million units of the mixture). Coupled with the water tight DPS368 for temperature and pressure and a KIT_XMC14_2GO for powering the sensors and reading data and transmitting the data through CAN, we will go through various steps to finish the small sensor capsule.
First, is to prepare the XMC:
Getstarted with Arduino IDE and XMC Boards
To start programming with XMC boards, you need to set up the Arduino IDE. Follow our step-by-step guide to get started with XMC for Arduino: documentation.
With everything prepared we’re ready to flash the first code example to the microcontroller. In order to do that you have to do the following steps in the Arduino IDE:
1.Select the right board
Once you have installed the XMC board family, you can select one of the supported boards from the menu: Tools > Board > Infineon’s XMC Microcontroller. In our case we have to choose the XMC1400 XMC2Go in order to select the correct board.
Now follow the schematics so we can connect the DPS328 with the XMC via I2C.
Next, open the code example and select, as shown in the screenshot below, the correct code so we can start sampling data from our DPS368. After uploading the code, you should be able to read the sensor data on the serial monitor.
Now this was fairly quick and simple. In a couple of minutes already reading 2 valuable data in this project.
Next is to add our TDS sensor to our setup and thus we will be already close to finishing the circuit of the underwater device.
I have found this article where it explains the TDS sensor and how to measure ppm. I just modified the existing code provided by them to incorporate the temperature data.Adding the TDS sensor is fairly simple a signal wire goes to the analog input of the XMC (A0) along with 2 wires 3, 3v and GND
Try experimenting with the setup.
To validate the system's performance, we can conduct a series of tests to verify the accuracy of the pressure, temperature, and TDS measurements.
Pressure Testing:
To test the pressure sensor, we can vary the altitude of the Underwater Node (Node 0) and observe the corresponding changes in pressure readings. The attached test code can be used to facilitate this process. By analyzing the pressure data, we can ensure that the sensor is accurately responding to changes in altitude.
Temperature Testing:
To test the temperature sensor, we can simply cover the sensor and observe the temperature reading. This will allow us to verify that the sensor is accurately measuring temperature changes.
TDS Testing:
For the TDS meter, we have already conducted tests using tap water, bottled water, and highly salted water. These tests have helped to validate the sensor's ability to accurately measure the concentration of dissolved solids in water.
By conducting these tests, we can ensure that the system is accurately measuring pressure, temperature, and TDS levels, providing reliable data for water quality monitoring.
The data collected was reasonable with 150 ppm for bottled water, 350 for tap water, and 2500 for the salt water. We will get later the ppm values from our lake and compare. Salt concentration in slightly saline water is 1, 000 to 3, 000 ppm (0.1–0.3%); in moderately saline water is 3, 000 to 10, 000 ppm (0.3–1%); and in highly saline water is 10, 000 to 35, 000 ppm (1–3.5%). Seawater has a salinity of roughly 35, 000 ppm, equivalent to 35 grams of salt per one liter (or kilogram) of water.
Now that we have the data printed on our serial monitor, the final step in completing the software part is to set up the XMC to send this data via CAN. We will assign an ID to each sensor's data, and the packages sent via CAN will be later received by our surface device with the help of another XMC.
To achieve this, you can upload the attached code (underwater_node) to the first XMC. This code will configure the XMC to send the collected data via CAN. It is crucial at this point to test with the example code of the receiver CAN to ensure that the CAN communication is functioning correctly.
For quick testing of the CAN, I have boxed an XMC in a 3D printed small box filled with silicon for waterproofing, and the aim is to firstly test the CAN capability under water. This is simply set to send data from under the water to check if CAN is working.
For a better and more sustainable solution, I have changed the design to be of two boxes.
One empty housing the electronics without the pressure sensor and the other box is bigger and will provide further waterproofing. It will house pressure sensors and it allows for a thick layer of silicon between the two housings, ensuring a water tight setup and with retrievable electronics.
After uploading our final code that sends TDS, pressure, and temp over CAN before assembling it, it is better to test the CAN bus.
All we need is another XMC that we set up to receive CAN data.
You can follow schematics and now upload this code example to test if CAN sending data.
You might want sometimes press on the reset buttons of both XMC if there is a problem with serial monitor or CAN.
Now we can go to the assembly of our underwater CAN node.
We have 4 3D printed parts that form the small and big housing.
1. Pass the long CAN wire through both holes of the housings and the TDS meter cable the same and the pressure sensor only through the hole of small housing.
2.Next we can solder the CAN wires and the power to the XMC.
3. Connect -+ of both TDS meter and pressure and shield them respectively to GND and 3.3 of the XMC, while the signal of TDS to analog pin 0 (the ADC of the XMC) and the SCL and SDA of the XMC and the DPS368 for the I2C communication.
At this point it is important to test again your soldering and wiring with the code provided.
4. Now close the smaller capsule and spray it with waterproofing spray.
5. Next I have positioned the pressure sensor through a hole of the outer capsule and glued it.
6. At this point we can fill the inner walls of the capsules with silicon and close it tight.
I have also made sure no opening not covered like wires and pressure while minimizing silicon on the DPS for accurate measurements.
Also it is better to zip-tie the water sensor at the level of the DPS sensor and this will be attached to a heavier object so it is always not touching the soil and get damaged.
Assembly Finished !
Now we can test again our setup and if working we take it to water.
The results were great. The device successfully measured data underwater via CAN and provided us with valuable insights on the lake. However, the pressure readings were not entirely accurate, possibly due to the silicone used which may have affected the sensitivity of the sensor.
Despite the inaccuracies, the pressure readings still changed reasonably with the change in depth. During the first test at a very low depth, almost at the surface, the water quality was measured at around 500 ppm with a temperature of 6 degrees Celsius. At a slightly deeper depth, the temperature dropped to 3 degrees Celsius, the ppm increased to above 600, and there was a slight increase in pressure.
I could not test the device at greater depths because most of the wire length was used to keep the battery and components away from water. Additionally, testing in the middle of the lake was not feasible since the contour is not deep. Therefore, it is time to build the buoys to facilitate further testing in deeper parts of the lake.
Part 2: BuoysThe second part of this project involves more mechanics and moving parts. We use the Infineon DC-SHIELD BTN9970LV to control a DC motor that pulls and drops the wire from a spool, allowing us to transfer our measurement device to varied depths. Let’s dive into the hardware for this part:
We will use a DC motor with the BTN9970LV to control the depth based on pressure information. This setup allows the device to auto-retract after 30 minutes to prevent damage and facilitate auto-sampling at various depths.
Data will be received via CAN bus using the XMC1400 microcontroller, which also controls the motor via a push button or pressure sensor. Ideally, underwater data will be broadcast via RC signal. Although I planned to use a GSM module (potentially to send data to the cloud along with solar panels), cloud integration is currently out of scope for this project. The data will be displayed on an OLED screen for monitoring, making integration straightforward.
For this project, also a 9-axis inertial measurement unit (IMU) can potentially to gather position, Euler orientation, and other important data. This provides an overview of water surface movement.
For the hardware setup, we can reuse the previous configuration, adding our motor control circuit based on the provided schematics.
For motor control, I selected the Infineon DC-SHIELD BTN9970LV, a versatile and easy-to-use platform. This shield is directly connected to the 12V power supply, which powers the motor control circuitry. However, to enable communication between the shield and the XMC1400 2GO KIT, we still need the 3.3V and GND pins from the MCU to the shield. This allows the two components to exchange data and control signals. BTN9970LV has two input pins IN1 and IN2 to receive control signals from the XMC1400 2GO KIT. The DC motor is now connected and powered between the pins OUT1 and OUT2. For a more detailed explanation check out this article.
Here is a simple test code to verify motor functionality along with a push button.
#include "btn99x0_motor_control.hpp"
#include "btn99x0_half_bridge.hpp"
using namespace btn99x0;
// Pin definitions
#define HB1_IN 1 // PWM Pin for DC-Shield
#define HB2_IN 2 // PWM Pin for DC-Shield
#define HB1_INH 3 // Inhibit PIN for Halfbridge 1 on DC shield
#define HB2_INH 4 // Inhibit PIN for Halfbridge 2 on DC shield
#define HB1_Isense A1 // Diagnosis pin for Half-bridge 1
#define HB2_Isense A0 // Diagnosis pin for Half-bridge 2
// Motor speed setting
#define SPEED 150
// Button pin
#define BUTTON_PIN 0
// IO pins structs
io_pins_t hb1_io_pins {
HB1_Isense,
HB1_IN,
HB1_INH
};
io_pins_t hb2_io_pins {
HB2_Isense,
HB2_IN,
HB2_INH
};
hw_conf_t hw_conf = {
2000, // Resistor on the DC shield for the Diagnosis pin
3.3, // Maximum voltage on the ADC Pin
1023
};
DCShield shield(hb1_io_pins, hb2_io_pins, hw_conf);
MotorControl btn_motor_control(shield);
// Direction state variable
bool direction = false; // false for positive, true for negative
void setup() {
Serial.begin(9600);
Serial.println("Serial initialized");
// Set the button pin mode. Adjust if you have a pull-up or pull-down:
pinMode(BUTTON_PIN, INPUT);
delay(5000);
btn_motor_control.begin();
delay(2000);
// Set the slew rate
btn_motor_control.set_slew_rate(SLEW_RATE_LEVEL_7);
}
void loop() {
static int lastButtonState = HIGH;
int buttonState = digitalRead(BUTTON_PIN);
// Check for rising edge: HIGH -> LOW
if (buttonState == LOW && lastButtonState == HIGH) {
// Toggle direction on each new press
direction = !direction;
}
// Run motor if button is pressed, else stop
if (buttonState == LOW) {
if (direction) {
btn_motor_control.set_speed(SPEED); // Turn motor in one direction
} else {
btn_motor_control.set_speed(-SPEED); // Turn motor in opposite direction
}
} else {
// Stop the motor when button is not pressed
btn_motor_control.set_speed(0);
}
// Store the button state for next loop iteration
lastButtonState = buttonState;
// Short delay to reduce switch bounce (can be improved with actual debouncing)
delay(50);
}
Next, will be to combine the necessary code to configure the XMC1400 to read pressure data and control the motor.
Upload the complete provided (surface node) code and connect the underwater node to test all components together: the motor and underwater data should be displayed on the screen. If the OLED does not work, press the reset button on the XMC or disconnect the power supply and back again.
Next, we move to the assembly of our buoys.
One of the critical 3D-printed parts, the core of the buoy, sustained minor damage during printing. I repaired it with epoxy and coated it with waterproof spray for durability.
Next, assemble the spooling system. Pass the underwater node wire through the hole in the cylindrical spool, then solder the connections to the slip ring. The slip ring prevents the CAN wires from getting ripped while the spool rotates.
Initially, I used a strong gear motor, but it broke at the last minute. I had to improvise by using a small plastic gear and replacing the motor with a stronger one from an old helicopter toy. I also used an old plastic gearbox, removed the gears, and used it to guide the slip ring along with a custom 3D-printed holder.
Start by passing the slip ring wires through the empty gearbox and attach the gearbox to the spool holder as shown in the photos. Mount the first side of the spool, then close the spool with the motor and gearbox.
Now, it’s time to test the spool system. The motor successfully pulls and drops the underwater device. Next, we assemble the spool onto the buoy cover and secure our electronics inside the buoy to protect them from water. Adding a water sensor could provide an alert in case of a leakage, which will be more meaningful when integrating a GSM or LTE module. This way, we can alert if the CAN signal is interrupted or if there is water damage.
Finally, we can take our system and test it in even more challenging environments with more control and precision. I will use my phone to record data from inside the buoys.
By integrating the KIT_XMC14_2GO’s CAN capabilities, the DPS368’s precise pressure and temperature readings, and a reliable TDS sensor into a robust underwater system, we’ve demonstrated how CAN can withstand the “noise” of the underwater environment. This approach can pave the way for new insights into our lakes and oceans, empowering further research and environmental monitoring.
Stay tuned for more updates, and consider exploring how the XMC14_2GO platform and its CAN functionality can enhance your next project—even beyond the depths!
With the completion of our project setup, the system is now ready for field testing. By submerging the underwater node, we can evaluate the performance of the CAN protocol in transmitting data from a depth of 1 to 10 meters. The seamless communication between the underwater and surface nodes will ensure the collection of valuable environmental data in real-time. As a future update, we plan to integrate a GSM module for cloud-based data broadcasting and a solar panel system to enhance the operational longevity of the device. These upgrades will further increase the system's utility for environmental monitoring in remote and challenging locations
FarewellAs we conclude this phase of our project, we are excited about the possibilities that lie ahead. By combining innovative technologies and robust design, we aim to make a meaningful contribution to environmental monitoring and data collection. Thank you for following our journey so far, and stay tuned for the results of our testing and future enhancements. See you next time!
Comments
Please log in or sign up to comment.