timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Campervan sensors?

Sun Mar 18, 2018 8:35 am

Hi all,

I'm embarking on a van build and would like it to have some data available through a web interface. I'm keen to use a RPi because I know my way around a Linux box and should be able to hack together the code from some examples I've seen online.

Electronics, on the other hand, is not an area of expertise. I've done some reading around and have a rough plan; I wonder if anyone would be so kind as to tell me whether I've got the right end of the stick, as it were!

I've got an old first gen Pi around somewhere, so will use this.

1) Water levels: 2) Gas pressure:
  • The gas tank I plan to use can be sold with a pressure sender described as follows: "It is 0-95 ohm sending and has 2 wires attached"
  • I understand I can use an rc timing circuit but every tutorial I look at prefaces with the fact that it's inaccurate. I appreciate that it's probably campervan-accurate but thought I'd try and make use of the spare channels on the ADC and have improved accuracy. Open to changing my mind if you folks think easier.
  • This led to my reading about Wheatstone bridges. Would throwing 3 other 45 Ohm resistors and the sender unit into a circuit like this work for me?
Image

(Edit: clearly not 100V input!! - This did remind me of another question I should have asked though... would the input voltage for the bridge just come from some pair of gpio pins on the Pi or direct from my 12V battery? Would it matter either way?)

I appreciate I'd then have some calibration work to do (as long as I can get the hardware and code working!) but I'm expecting linear relationships between the data from the ADC and pressure.

Should I start buying these things or stick to woodwork?!

Cheers,
Tim

stevend
Posts: 209
Joined: Fri Oct 11, 2013 12:28 pm

Re: Campervan sensors?

Sun Mar 18, 2018 9:06 am

timmyclub wrote:
Sun Mar 18, 2018 8:35 am
Should I start buying these things or stick to woodwork?!
Neither! Do some more research first. Plenty of comment on these forums.

You've got it right that you'll need an A-D converter for much of what you want to do; the one you've found looks unnecessarily good (and correspondingly costly). Something like the MCP3008 should be fine.
Depending on the board you buy, the input voltage will need scaling to come within range of the A-D converter. Sometimes a simple pair of resistors is sufficient; sometimes you'll need some sort of buffer amplifier. You may be able to get a board which makes this simple to implement.

I don't think the sensor you've highlighted on ebay is suitable for water levels. Again, read these forums, but I think you want either a float sensor or something ultrasonic.

For the gas pressure sensor you basically want to measure a resistance with reasonable accuracy. (i.e. the fact that it happens to be a pressure sensor is on secondary relevance here). Two main ways of doing this. The first is to connect a resistor in series with the sensor, power from some voltage, and measure the voltage at the mid-point. You will get variations in the voltage read as the supply voltage changes. You can minimise these by either using the A-D converter in ratiometric mode (if it supports it), or by using another A-D input to measure the supply voltage.
The second way is to feed the sensor from a constant current source. The voltage you measure across the sensor will then be directly proportional to sensor resistance, so possibly easier to work with.

A few more general points:
1. Speed of operation is not going to be important - nothing is going to change first. A reading which updates every 10-60 seconds should be plenty fast enough.
2. I imagine this will be connected to the vehicle power supply. This can be a fairly unfriendly environment, with noise spikes and overvoltages. Make sure your power supply can accommodate these.
3. I also imagine this will be powered from a battery when the van is parked, so minimising power consumption is important. Things like the gas sensor may need a switch controlled by the Pi to only turn it on during a measurement.

User avatar
thagrol
Posts: 1610
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Campervan sensors?

Sun Mar 18, 2018 4:44 pm

stevend wrote:
Sun Mar 18, 2018 9:06 am
2. I imagine this will be connected to the vehicle power supply. This can be a fairly unfriendly environment, with noise spikes and overvoltages. Make sure your power supply can accommodate these.
3. I also imagine this will be powered from a battery when the van is parked, so minimising power consumption is important. Things like the gas sensor may need a switch controlled by the Pi to only turn it on during a measurement.
Assuming your camper has a second/leisure battery power this system from that. You should also investigate whatever electric circuit and control panel is already installed to make sure you don't damage it.
This space unintentionally left blank.

timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Re: Campervan sensors?

Sun Mar 18, 2018 6:30 pm

stevend wrote:
Sun Mar 18, 2018 9:06 am
timmyclub wrote:
Sun Mar 18, 2018 8:35 am
Should I start buying these things or stick to woodwork?!
Neither! Do some more research first. Plenty of comment on these forums.
I think you could have responded with a 'stick to woodwork' (not that I'm great at that, either!). Clearly you're one of the internet's gentlemen. Thanks!
Something like the MCP3008 should be fine.
Depending on the board you buy, the input voltage will need scaling to come within range of the A-D converter. Sometimes a simple pair of resistors is sufficient; sometimes you'll need some sort of buffer amplifier. You may be able to get a board which makes this simple to implement.
I don't have a great understanding of this part of your post. I'm hoping by buying one of these, it might fall under 'board which makes this simple'?! ADS1015: https://www.adafruit.com/product/1083
I don't think the sensor you've highlighted on ebay is suitable for water levels. Again, read these forums, but I think you want either a float sensor or something ultrasonic.
I thought about ultrasonic sensors but all the cheap ones have a min range of 25cm - probably not far from the depth of my entire tanks. Float would definitely work. I figured I could calculate height of a column of water using the pressure sensor. Happy to think about a float sensor instead though...
For the gas pressure sensor you basically want to measure a resistance with reasonable accuracy. (i.e. the fact that it happens to be a pressure sensor is on secondary relevance here). Two main ways of doing this.
..snip...
The second way is to feed the sensor from a constant current source. The voltage you measure across the sensor will then be directly proportional to sensor resistance, so possibly easier to work with.
That makes sense to me. I think.

I looked up how to supply a constant current and came up with an LM317 (wired according to this: https://youtu.be/iuMngik0GR8?t=2m1s). With apologies for the slightly eccentric diagram (and no doubt eccentric wiring!), I wonder if anyone might be able to tell me whether I'm closer or further away now?

Image

It seems weird to be trying to measure a voltage with one wire. I know the ADC measures between that wire and ground, if configured to do so. Still that 3rd yellow wire (**) seems weird to me. Have I got badly it wrong?
A few more general points:
1. Speed of operation is not going to be important - nothing is going to change first. A reading which updates every 10-60 seconds should be plenty fast enough.

Meaning, go cheap?
2. I imagine this will be connected to the vehicle power supply. This can be a fairly unfriendly environment, with noise spikes and overvoltages. Make sure your power supply can accommodate these.
I'm hoping that BEC will do it. I have no idea what it is or how it works but might have ordered one after a beer last night. (they're cheap, fortunately!)
3. I also imagine this will be powered from a battery when the van is parked, so minimising power consumption is important. Things like the gas sensor may need a switch controlled by the Pi to only turn it on during a measurement.
Very open to that idea. Might get it all working first, check out the current draw of the whole lot and think about this if needs be. Will eventually have solar but it's for keeping my fridge cold, not unnecessarily powering sensors whilst nobody is looking!
thagrol wrote: Assuming your camper has a second/leisure battery power this system from that. You should also investigate whatever electric circuit and control panel is already installed to make sure you don't damage it.
Starting from scratch here, so will all be of my own horrendous design! ;-)

stevend
Posts: 209
Joined: Fri Oct 11, 2013 12:28 pm

Re: Campervan sensors?

Sun Mar 18, 2018 11:20 pm

timmyclub wrote:
Sun Mar 18, 2018 6:30 pm
stevend wrote:
Sun Mar 18, 2018 9:06 am
timmyclub wrote:
Sun Mar 18, 2018 8:35 am
Should I start buying these things or stick to woodwork?!
Neither! Do some more research first. Plenty of comment on these forums.
I think you could have responded with a 'stick to woodwork' (not that I'm great at that, either!). Clearly you're one of the internet's gentlemen. Thanks!
Hopefully you got the idea from the continuation that you're actually on the right lines; there's never just one 'right' answer, so its well worth looking at the options before diving in. And you'll hopefully have some fun along the way, as well as some useful hardware at the end of it.

timmyclub wrote:
Sun Mar 18, 2018 6:30 pm
Something like the MCP3008 should be fine.
Depending on the board you buy, the input voltage will need scaling to come within range of the A-D converter. Sometimes a simple pair of resistors is sufficient; sometimes you'll need some sort of buffer amplifier. You may be able to get a board which makes this simple to implement.
I don't have a great understanding of this part of your post. I'm hoping by buying one of these, it might fall under 'board which makes this simple'?! ADS1015: https://www.adafruit.com/product/1083
Don't know the particular part, but looks like it should do the job (and maybe avoid external hardware!)

timmyclub wrote:
Sun Mar 18, 2018 6:30 pm
I don't think the sensor you've highlighted on ebay is suitable for water levels. Again, read these forums, but I think you want either a float sensor or something ultrasonic.
I thought about ultrasonic sensors but all the cheap ones have a min range of 25cm - probably not far from the depth of my entire tanks. Float would definitely work. I figured I could calculate height of a column of water using the pressure sensor. Happy to think about a float sensor instead though...
Worth having a good read of the forums on this one; I'm sure level sensing is a relatively common problem. Can't remember enough physics to decide whether the pressure sensor might work.
timmyclub wrote:
Sun Mar 18, 2018 6:30 pm
For the gas pressure sensor you basically want to measure a resistance with reasonable accuracy. (i.e. the fact that it happens to be a pressure sensor is on secondary relevance here). Two main ways of doing this.
..snip...
The second way is to feed the sensor from a constant current source. The voltage you measure across the sensor will then be directly proportional to sensor resistance, so possibly easier to work with.
That makes sense to me. I think.

I looked up how to supply a constant current and came up with an LM317 (wired according to this: https://youtu.be/iuMngik0GR8?t=2m1s). With apologies for the slightly eccentric diagram (and no doubt eccentric wiring!), I wonder if anyone might be able to tell me whether I'm closer or further away now?

Image

It seems weird to be trying to measure a voltage with one wire. I know the ADC measures between that wire and ground, if configured to do so. Still that 3rd yellow wire (**) seems weird to me. Have I got badly it wrong?
Principle looks fine. You might need to play with the layout of the wiring to get the best analog performance, and you might need a few small capacitors (100nF or so) to filter out noise. Looks like a good starting point to me.
timmyclub wrote:
Sun Mar 18, 2018 6:30 pm
A few more general points:
1. Speed of operation is not going to be important - nothing is going to change fast. A reading which updates every 10-60 seconds should be plenty fast enough.

Meaning, go cheap?
Not necessarily. But if you're going for something 'better' than the cheapest, make sure the extra buys features that are relevant to your application. Speed is definitely not one of them!

timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Re: Campervan sensors?

Mon Mar 19, 2018 6:06 am

Thanks again for your insight, Steven. Really, much appreciated.

I'll start tinkering along those lines. Better add one of those breadboard thingies to the shopping list, eh (along with some of those capacitors just in case)?

I'll report back with the details of my working setup! :mrgreen:

User avatar
Gavinmc42
Posts: 3138
Joined: Wed Aug 28, 2013 3:31 am

Re: Campervan sensors?

Mon Mar 19, 2018 11:11 am

BEC, battery eliminator circuit could be as simple as a cigarette lighter socket USB charger.
You won't need a Pi2 or3 to serve a webpage, but use a light LInux like TinyCore.

Lots of i2c sensors around, I use them all the time, even i2c isolators for high voltage DC (Solar panel) monitoring.
For single purpose apps I find i2c sensors running Ultibo, baremetal, no Linux, to be rock solid.
Even an old B would do this, because Ultibo may only need 3-10MB of ram, TinyCore <100MB, Raspbian er lots ;)

For weird stuff like analog low pressure sensors I use Cypress PSoC1 8pin micros, which I can program to interface to just about anything.
TMP112 for fridges, LTC2945 for solar panels.
Got an old model A that runs 2 x HDMI monitor in a Solar energy demo trailer, monitors everything.
Been running ok with a few SDcard failures since 2012.
Probably because the A has no network so Raspbian (very old software) does not try to update.

Adafruit/Sparkfun/Seeed Studio all have i2c sensors, just find one with a suitable breakout board to make wiring simpler.
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Re: Campervan sensors?

Mon Mar 19, 2018 12:54 pm

Your setup sounds fab!

I guess there's probably a lesson to be learned for me - why use a fully functional computer when a microcontoller will do. I'm clinging on to some semblance of my comfort zone with the Pi and I've ordered some bits and pieces now. I should probably have learned what an Arduino is/does.

Hopefully, I'll get there with the RPi. I'll try Tiny Core - if needs be, I'll use a more modern Pi.
Gavinmc42 wrote: Adafruit/Sparkfun/Seeed Studio all have i2c sensors, just find one with a suitable breakout board to make wiring simpler.
This is the bit that worries me! I'm clueless as to what will do the job... Am I going to cook the Pi if that ADS1015 I've bough uses 5v and the Pi 3.3V across it's gpio pins?

I'm cheating on the monitoring of the electrical side of things and have bought an old Tracer MT5 solar controller so that I can use this library to dump all the data I want from that instead.. https://github.com/xxv/tracer - which, I think, includes the charging current, battery voltage, voltage across the pannel(s) etc

strebor54
Posts: 3
Joined: Wed Mar 28, 2018 7:22 am

Re: Campervan sensors?

Wed Mar 28, 2018 7:43 am

Hi, Tim, google found your thread for me, as about to begin to start to commence on a similar project.
Few random thoughts:
Pi probably a good idea as you have a huge range of options open to you to display your data, I will be using Domoticz for mine as I already use it in the house. You probably don't require the advantages of a small microcontroller.

Gas, there is possibly a regulatory/safety aspect as well as the technical. The variable resistor will have a current limit and there are probably limits for safety in terms of an ignition source.

Bonne chance Strebor

timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Re: Campervan sensors?

Tue Apr 10, 2018 8:56 pm

Domoticz looks seriously cool, thanks!

If anyone has any thoughts on this, I'd be very interested -

Pressure sensors are sat on my desk and i'm getting pretty wild fluctuations. They're just wired to +5V, gnd and the third wire to the adc..

Here are some readings from the last few minutes.

Code: Select all

{
  "10/04/2018 20:48:38": 823, 
  "10/04/2018 20:49:28": 292, 
  "10/04/2018 20:50:18": 263, 
  "10/04/2018 20:51:08": 261, 
  "10/04/2018 20:51:58": 259, 
  "10/04/2018 20:52:48": 285, 
  "10/04/2018 20:53:38": 212
}

User avatar
Gavinmc42
Posts: 3138
Joined: Wed Aug 28, 2013 3:31 am

Re: Campervan sensors?

Wed Apr 11, 2018 10:30 am

Pressure sensors are sat on my desk and i'm getting pretty wild fluctuations.
Low PSI pressure sensors can fluctuate some,but perhaps put some power supply bypass caps in circuit.
0.1uF X7R types across the power supply etc.

The low pressure sensors can detect doors/windows opening and closing...

Use a Zero and $2 WiFi dongle if you are worried about toasting it.
At $5 it is a cheap wiring education ;)

TinyCore requires some Linux MoJo but the forum is very active if you get into trouble.
These days I use Ultibo, it has proven to be even more reliable for me, but it is a bit like Arduino on Steroids.
You will need to learn to code :D
I'm dancing on Rainbows.
Raspberries are not Apples or Oranges

strebor54
Posts: 3
Joined: Wed Mar 28, 2018 7:22 am

Re: Campervan sensors?

Wed Apr 11, 2018 3:48 pm

I like the look of Ultibo and Blynk for that matter.
Low pressure sensor, I'm not sure what you were intending to measure but if it's head of water then I can see all sorts of heferlump traps .
I have seen a Thermos bottle used to integrate a low pressure sensor but it smacks of desperation!

Bonne chance....s

timmyclub
Posts: 10
Joined: Thu Jan 12, 2012 9:34 pm

Re: Campervan sensors?

Wed Apr 11, 2018 4:50 pm

I'll try the caps and then see what they're like submersed. Cheers!

Head of water is the plan. I know it'll be a little all over the place, especially during transit - but it should give some indication, right?! :mrgreen:

mardimus
Posts: 7
Joined: Sat Nov 30, 2013 8:59 pm

Re: Campervan sensors?

Tue Jun 25, 2019 4:41 am

Any updates

Return to “Automation, sensing and robotics”