Pressure sensor and input trough optocoupler

  • Hi all,

    I have a hard time asking this but if I don't I will never get this working. 🤦

    The situation is:
    I have 7points of 230v to check in my heating system and one pressure sensor, I have optocouplers installed so basically the signal is an 0 or an 3,3v to read. The pressure sensor is an cheap one and reads from 0,5 to 5volt. At this moment I have nothing wired up to my arduino yet so that's still flexible.

    How do I make an working script for a arduino mega so I can read it trough the usb on my PI with Domticz? If someone can put me in the right direction that would be great 🙇

  • @Olaf-Jacobs If it's a typical screw in pressure sensor from China I've found they work on 3.3v fine. You lose 10% voltage off the bottom and top, so from your ADC reading of 1023 full scale to Vcc you lose 204.6 from the ADC reading. So your pressure range is 818.4 increments of the sensor pressure value... Voila...
    When you do a float calculation on the pressure value, you simply send it in to however many decimal points you want (rounded up 0.5, 0.05, 0.005 etc)
    I have 5 bar and psi units down to 5psi for a tank all working perfectly.
    Hope this helps

  • @zboblamont Thanks for your reply, that sounds like it gets a little easier.
    I was planning on using this script for the 7 inputs but how can I read this only over serial, how do I use more then only pin 3 and how do I integrate an script to read that pressure sensor?
    I hope to make some time this weekend..

  • @Olaf-Jacobs It's a straight analogue read on a single ADC pin relative to Vcc and ground of the Arduino Node.
    In my case it's a pro-mini, the ADC pin in this example earlier defined as "Pressure", the result radioed in only if the ADC reading has changed. Three other binary inputs for contactors are polled every second on separate digital pins (one of which is pin 3), which uses all 4 pins available on this pro-mini due to the radio etc.

    if ((!hidro&&!Hidro&&(counter2>=132))||initialise){
      int incoming=analogRead(Pressure);
      if (prevolume!=incoming){
      float tankvolume=(((incoming-102.3)*6.704199635)+0.5);//5psi sensor
      send(msg8.set(tankvolume,0));//This is actual volume

    I'm not clear on the rest of what you're trying to incorporate or what pin 3 (digital interrupt) has to do with it, the pressure sensor signal goes to an analogue pin to enable the voltage to be read.

Log in to reply

Suggested Topics