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
#18
(2021-11-22, 12:18 PM)|SCarns Wrote: |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.

I am looking to do the same thing you seem to have done here but am admittedly a sensESP newbie.  I've done a few arduino monitoring projects in the past and I have managed to get sensESP working doing digital and analog input (the examples).  

My question is this.   How does the tankedge sensor work for you?   I want to tape one to my fresh water tank and then measure the water level in my boat tank using this.   What type of range did you get from the device?   I'm assuming since you feed it 12V and step it down with a divider (something I think I have the equipment to do), you're measuring the voltage it passes.  What type of voltage range did you find and how did it vary based on tank level?   

Before I go and buy a sensor I'd like to make sure this will do what I'd like it to do.  Eventually I'd like to feed this reading to SignalK so I can find my tank level from any browser...     

Also - have you considered/done this with a WASTE tank?   Is the resistance similar and does sludge that sticks to the tank sides affect the readings through the plastic tank?    

In the end I'm sick of climbing in my bilge to see if I have fresh water to make it through another day -- and waste levels low enough I'm not in danger of a mess...    I've got esp32 wrooms, I've connected them to signalK.   My questions are more about this specific sensor and it's integration and what range of voltage you got in your example.    (Plus, has it worked for two years now that you've got this installed?)
Reply
#19
(2023-12-07, 02:45 PM)dwynalda Wrote: I am looking to do the same thing you seem to have done here but am admittedly a sensESP newbie.  I've done a few arduino monitoring projects in the past and I have managed to get sensESP working doing digital and analog input (the examples).  

My question is this.   How does the tankedge sensor work for you?   I want to tape one to my fresh water tank and then measure the water level in my boat tank using this.   What type of range did you get from the device?   I'm assuming since you feed it 12V and step it down with a divider (something I think I have the equipment to do), you're measuring the voltage it passes.  What type of voltage range did you find and how did it vary based on tank level?   

Before I go and buy a sensor I'd like to make sure this will do what I'd like it to do.  Eventually I'd like to feed this reading to SignalK so I can find my tank level from any browser...     

Also - have you considered/done this with a WASTE tank?   Is the resistance similar and does sludge that sticks to the tank sides affect the readings through the plastic tank?    

In the end I'm sick of climbing in my bilge to see if I have fresh water to make it through another day -- and waste levels low enough I'm not in danger of a mess...    I've got esp32 wrooms, I've connected them to signalK.   My questions are more about this specific sensor and it's integration and what range of voltage you got in your example.    (Plus, has it worked for two years now that you've got this installed?)

This worked well. You are correct that I fed the tankedge sensor 12 volt and got a reading through a voltage divider into SensESP. However, I got a digital value (0-1024), not a voltage. And I didn't bother converting it to anything else. The value was enough for the code to work. I just needed to read a "low" value and a "high" value. My low was something like "46" and my high was like "823." I plugged those two values into the code and SensESP did the rest, ultimately returning a ratio to the SignalK path tanks.blackwater.0.currentLevel.

I did this on my holding tank and it worked great. I could tell when sludge would "settle out" on the bottom. After a pump out, I wouldn't be at 0%, so I would know I needed to take extra steps to clean tank. Sure is nice to know when you are getting close to full. I used SignalK Zones to set up alarms letting me know when it was time to head over to the pump our, rather than wait for the Raritan sensor light to come on and shut off the toilet. 

Unfortunately, I sold that boat, but will be doing something similar to whatever next boat I get next year. I have the visual studio code on an old boat computer. I'll see if I can find it and I'll post it here.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)