This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Sailor Hat with ESP32
#11
(2021-06-24, 09:00 PM)SCarns Wrote: mairas,

I have a couple of questions on a project I'm working on using SH-ESP32. I've successfully built three N2K gateways, but am moving on to a more difficult (to me) project involving more interfacing and programming. Is there a place I can go to get answers to questions? Or can I just post them here?

Steve

Hi Steve,

feel free to post your questions here. I've also started a dedicated discussion forum at https://github.com/hatlabs/discussions/discussions. Or, for a bit more "chatty" interface, Signal K Slack #sensors channel works great!

Matti
Reply
#12
Thanks Matti,

I'm on slack, but that moves too fast to be able to get me going in the correct direction.

So far, I've built two N2K Gateways, which I've given to buddies of mine. I have one SH left which I'm experimenting with (will get some extras from you soon).

I've successfully loaded SensESP. Nice work!

I want to begin with simple tank level sensors. My issue is they are still connected to my 12 volt system and I know that will required stepping that voltage down. For now, I'll just remove the 12 volt and attempt to go from the hat to the sending unit to keep things simple. I'll use the "fuel level sensor" as a base "Main.cpp" and make adjustments from that. I assume that I'll need a ground to all sending units and and bring the positive side back to the SH32 and land them on GPIO pins 12, 13, 14, 15. Then it should be a simple matter of defining the SK paths to use and the pins to read in the software.

Correct?

Now, the SH32 will sample those reads to the equivalent of 4,096 different readings. I see in the sw that I can set a low and a high, but I'm a little lost in what to start with, except 0 and 4096. I'll eventually pull the senders and operate them to see where I'm at, but am a little unclear what the ADC would out put as a value, if low voltage is input on the analog side.

And if I decide to leave them on the 12 volt gauges they are on, I'll need a voltage divider to lower the voltage to 5.5 and under.
Reply
#13
(2021-06-26, 11:14 PM)SCarns Wrote: I want to begin with simple tank level sensors. My issue is they are still connected to my 12 volt system and I know that will required stepping that voltage down. For now, I'll just remove the 12 volt and attempt to go from the hat to the sending unit to keep things simple. I'll use the "fuel level sensor" as a base "Main.cpp" and make adjustments from that. I assume that I'll need a ground to all sending units and and bring the positive side back to the SH32 and land them on GPIO pins 12, 13, 14, 15. Then it should be a simple matter of defining the SK paths to use and the pins to read in the software.

Correct?

Now, the SH32 will sample those reads to the equivalent of 4,096 different readings. I see in the sw that I can set a low and a high, but I'm a little lost in what to start with, except 0 and 4096. I'll eventually pull the senders and operate them to see where I'm at, but am a little unclear what the ADC would out put as a value, if low voltage is input on the analog side.

And if I decide to leave them on the 12 volt gauges they are on, I'll need a voltage divider to lower the voltage to 5.5 and under.

To measure the tank level sensor resistance, you also need some reference. The reference can be either constant current or constant voltage and a voltage divider. The latter is much easier to implement in DIY settings. You'd connect a 3.3V output to a 180 ohm resistor in series with the tank sensor and measure the voltage between the tank sensor and the resistor. The voltage will swing from 1.65V to 3.3V that can be read with GPIO pins connected to ADC1 (or ADC2, if you're not using WiFi).

If you want to measure the tank level in parallel with an existing gauge, you'd need to scale the existing voltage down to a suitable level using a voltage divider. That scaled value can then be read with the ADC pins.
Reply
#14
Thanks, but I still can't make it work. I'll wait for your engine hat and further instructions...
Reply
#15
mairas,

I'm still playing around and learning here...

does SensEsp contain a capacitive library? Thinking to set up the SH-Esp to a water bottle and test capacity with some foil and see if I can make it work. Then, I can go step up to installing a sensor onto my holding tank. I can install one of my boxes near by and send the data to SignalK over wifi.

Thanks

Steve

Another question:

In one of the NMEA gateways I built, I ran into a compatibility issue. Exhibition requires Actisense to run at 250,000 baud and their instructions say that ISO versions (at 115,200 baud) need to be upgraded. Is this something that can be adjusted in software somewhere? If not, then that box may become the box for previous post...

Steve
Reply
#16
Hi there,

Using the ESP32 capacitive touch capabilities to read tank levels is a brilliant idea! I'd love to use it myself but my boat only has metal tanks everywhere...

SensESP itself doesn't have a capacitive library but using the capacitive touch sensors with the Arduino Framework is so simple that you don't necessarily need one. You can fake a SensESP sensor with an
Code:
ObservableValue<int>
type variable that you then update externally. Transforms and outputs can be connected to that variable and when the variable value is updated, the variable will emit the value updates just like any other input. Something like this should work:

Code:
auto touch_sensor = new ObservableValue<int>();

app.onRepeat(100, [touch_sensor]() {
  touch_sensor = touchRead(4); // read the touch sensor connected to GPIO 4
});

touch_sensor->connect_to(...);


This would read the capacitive touch sensor every 100 ms and emit the updates to whoever is listening.

As to your second question, the serial port baud rate can indeed be adjusted. At the moment the value is hard-coded but can be changed easily. See line 54 of the main.cpp file of the nmea2000 gateway example. If you change the value there to 250000 and then build and upload, that should do it.

I'll need to look into making the baud rate configurable...
Reply
#17
I finally got this working!

I ended up using a Moda sensor from Tank-Edge https://tankedge.com/accessories.html. It was easier thank trying to make one and use touch sensor to try to figure it all out. This sensor takes 12volt in and outputs a signal that I measure through a voltage divider. The divider probably isn’t necessary, as I think the sense wire is less than 5 volts, but I figured better safe than sorry.

I used the ADC code as the base. Due to voltage fluctuations I added MovingAverage after linear to level out the readings.

To get calibration numbers, I had added in a new SK field to display the reading, making it easy to see my highs and lows. Commented it out when I was done.

My next idea is to try to figure out how to use MovingAverage to create a high and low readings averaged over long periods, add some simple math to adjust offset/scale and make the unit self-calibrating.

Question: When you choose “Reset Device” on the web interface of SensESP, does it reset the data also? In essence, would it reset the calibration averages to start from scratch? That would be very slick.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)