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) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Digitise an older engine - ESP32
#41
@Boatingbaileys,

I just tried to apply your Bildge code and go an error when compliing:

Code:
  //// Bilge Monitor /////

auto* bilge = new DigitalInputState(17, INPUT_PULLUP, 5000);

auto int_to_string_function = [](int input) ->String {
     if (input == 1) {
       return "Water present!";
     }
     else { // input == 0
       return "bilge clear";
     }
};

auto int_to_string_transform = new LambdaTransform<int, String>(int_to_string_function);

bilge->connect_to(int_to_string_transform)
      ->connect_to(new SKOutputString("propulsion.engine.bilge"));

and the error I get when compiling is:

Code:
src/main.cpp:56:36: error: 'LambdaTransform' does not name a type
auto int_to_string_transform = new LambdaTransform<int, String>[](int_to_string_function);
                                    ^~~~~~~~~~~~~~~
src/main.cpp:56:52: error: expected primary-expression before 'int'
auto int_to_string_transform = new LambdaTransform<int, String>[](int_to_string_function);

I have:

Code:
#include "sensesp/system/lambda_consumer.h"
but still can't compile, any ideas?
Reply
#42
Shouldn't "int_to_string_transform" be a pointer?

auto* int_to_string_transform = new LambdaTransform<int, String>[](int_to_string_function);

(note the asterisk after auto)
Reply
#43
Interesting, I've just cleaned and complied mine and it seems to get past that stage ok. To confirm the code:

#include "sensesp/system/lambda_consumer.h"

//// Bilge Monitor /////

auto* bilge = new DigitalInputState(25, INPUT_PULLUP, 5000);

auto int_to_string_function = [](int input) ->String {
if (input == 1) {
return "Water present!";
}
else { // input == 0
return "bilge clear";
}
};

auto int_to_string_transform = new LambdaTransform<int, String>(int_to_string_function);

bilge->connect_to(int_to_string_transform)
->connect_to(new SKOutputString("propulsion.engine.bilge"));

bilge->connect_to(new SKOutputString("propulsion.engine.bilge.raw"));

Is 'input' used anywhere else on your code? I'll have another look through this tomorrow to see if I can spot anything else.

Thanks,
Reply
#44
(2023-03-26, 07:28 PM)Boatingbaileys Wrote: Interesting, I've just cleaned and complied mine and it seems to get past that stage ok. To confirm the code:

#include "sensesp/system/lambda_consumer.h"

//// Bilge Monitor /////

auto* bilge = new DigitalInputState(25, INPUT_PULLUP, 5000);

auto int_to_string_function = [](int input) ->String {
    if (input == 1) {
      return "Water present!";
    }
    else { // input == 0
      return "bilge clear";
    }
};

auto int_to_string_transform = new LambdaTransform<int, String>(int_to_string_function);

bilge->connect_to(int_to_string_transform)
      ->connect_to(new SKOutputString("propulsion.engine.bilge"));

bilge->connect_to(new SKOutputString("propulsion.engine.bilge.raw"));

Is 'input' used anywhere else on your code? I'll have another look through this tomorrow to see if I can spot anything else.

Thanks,

It seems that:
Code:
#include "sensesp/transforms/lambda_transform.h"
needs to be added, and neither of us had that in our code, but you had:
Code:
#include "sensesp/transforms/linear.h"
which itself references  "lambda_transform.h" and therefore it worked for you but not for me.  It might be a good idea to add it just incase someone else steals your code like I did!!

thanks for this work!
Reply
#45
Hi BoatingBailyes!

I've been a subscriber to your channel from Spain for some time now. Smile

I'm trying to follow your ESP32 video series and am encountering some issues with the temperature sensor. I can't seem to find a temperature curve for the sensor used in my engine anywhere.

The best I can do is measure the resistance at various temperatures using the analog temperature gauge. However, there are a couple of challenges:

It won't be precise.
The highest temperature I can measure would be 80º from the engine. (Unless I were to remove the temperature sensor and apply controlled heat while taking measurements.)
Is there any other method to determine the ohms resistance at different temperatures?

Another idea I had was to replace the temperature sensor with another that has a known temperature curve. Does anyone know of such a sensor?

Thanks in advance!
Camilo
Reply
#46
Hi, thanks for your comments and for subscribing. I have responded on the video also. Some of what I had to do with mine at the very beginning was due to the code not being fully correct. Help from people on here, in particular Techstyle sorted that out.

You will need some sort of control to get your ohm values unless you can find the sensor specification. You could use an IR heat sensor gun or even a digital temp sensor to check the temp and record the ohm value. Once you have this, you are good to go.

If you are replacing, you just need to know the thread size, for example I found out that a car temp sensor I think it was from a Peugeot was the same as mine.

Your other option is you use my curve and see what happens. If at normal run temp it reads correctly then you should be ok. It’s no real substitute for the full set of values unfortunately.

Let us know if we can help further.

Mat
Reply
#47
Hi!

Thank you so much for your quick response!

Finally, I found a website that has the temperature curve! Just in case someone needs it for FAS only-one-terminal Temperature Sensor here you can find it: https://www.si-parts.com/en/temperature-...20045.html

I will try tomorrow once I get to my sailboat.

@Boatingbaileys I found another problem and don't know if you face it: I would like to keep the analog temperature clock. If I followed your voltage divider correctly, what happened is that when I connect the ESP32 to the positive and negative of the temperature sensor, the clock rise to 120º.

I am not an expert in electronics, just small projects, so I asked ChatGPT ? He is saying that sharing ground between ESP32 and the sensor generates a "Ground Loop" and that I should use an optocoupler/optoisolator.

Did you keep your analog clock? If yes, it is working correctly? Or are you just using the digital one?

Thanks!
Reply
#48
(2023-09-04, 05:36 PM)MusaSailing Wrote: Hi!

Thank you so much for your quick response!

Finally, I found a website that has the temperature curve! Just in case someone needs it for FAS only-one-terminal Temperature Sensor here you can find it: https://www.si-parts.com/en/temperature-...20045.html

I will try tomorrow once I get to my sailboat.

@Boatingbaileys I found another problem and don't know if you face it: I would like to keep the analog temperature clock. If I followed your voltage divider correctly, what happened is that when I connect the ESP32 to the positive and negative of the temperature sensor, the clock rise to 120º.

I am not an expert in electronics, just small projects, so I asked ChatGPT ? He is saying that sharing ground between ESP32 and the sensor generates a "Ground Loop" and that I should use an optocoupler/optoisolator.

Did you keep your analog clock? If yes, it is working correctly? Or are you just using the digital one?

Thanks!

Excellent, that will save you some time and will be useful for someone else.

I didn’t have the sharing a sensor issue as my panel only has the temperature light which works off a different sensor, basically just switching at a set temperature. 

Someone else asked this question before so I’ll try and find out if they solved it. I have a feeling you can’t measure the sensor with two different devices as you are finding out, however someone with more electrical knowledge than me might be able to help ?

One option if you trust this is to replace that display with an NMEA2k one or simply attach a 1-wire digital temp sensor near to your current one and use that instead? That might then give you some redundancy and if you ever want to change your plan in the future the engine is as it was.
Reply
#49
(2023-09-04, 05:36 PM)MusaSailing Wrote: @Boatingbaileys I found another problem and don't know if you face it: I would like to keep the analog temperature clock. If I followed your voltage divider correctly, what happened is that when I connect the ESP32 to the positive and negative of the temperature sensor, the clock rise to 120º.

You should be able to connect an INA219 board to either side of the analogue gage (Vin+ to the supply side, Vin- to the temp sender side), you do need to remove the 'R100' shunt resistor from the board - then you can use the INA219 as a voltage sensor and then use the following equation to get the resistance of the temp sensor:

R2= (VOUT * R1)/(VIN - VOUT)

where R2 is the Temp sensor resistance
Vout is Vin-
Vin is Vin+
R1 is the resistance of the analogue gage (measure with a multimeter with nothing connected)

you are basically checking the voltages in the existing voltage divider circuit where the gage is the other resistor.

I have yet to try this but it should work.

I have used these for my Battery monitor: https://amzn.to/45ZZ8ka
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)