Solar level and temperature sensor GHBO1/SHBO1

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
oasisone
Normal user
Posts: 5
Joined: 08 May 2021, 08:39

Solar level and temperature sensor GHBO1/SHBO1

#1 Post by oasisone » 08 May 2021, 08:51

Hello, i am trying to get a temperature and level sensor for solar panels hooked up to the Espeasy to monitor it online.
I managed to read the sensor using an arduino UNO after following the instructions on http://hack4life.pbworks.com/w/page/756 ... r%20Sensor but i need the sensor hooked in parallel to the solar controller SR-500 wich provides 12VDC TTL signal, so i cannot use it further on the uno.
I installed easyesp on a tinyESP because the tinyesp seems to have a digital in pin that suppports up to 20V inputs and from there i didnt manage to do anything further.

Can you please help me out with hooking the sensor up to the tinyesp so i can monitor it online? I have very few experience with arduino and dont know where to start tackling this problem.

Thanks.

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Solar level and temperature sensor GHBO1/SHBO1

#2 Post by Ath » 08 May 2021, 14:56

Why are you using that complex controller for measuring?
And I don't fully get what you are exactly measuring, temperature is clear but what 'level' are you measuring, voltage?

For temperature you can connect 1 or more DS18b20 sensors (in parallel if desired, ESPEasy can handle up to 4 such sensors in 1 task, and multiple tasks can be defined on the same 1-wire pin. It is called 1-wire for a reason :)).

Assuming you want to measure voltage:
For voltage there are several options,
the most simple one would be to use the analog input, depending on the board you can provide 0-1V or 0-3.3V, and your TinyESP handles 0-3.3V, so using a 'voltage divider' (actually 2 resistors) you can bring down that level to something the ESP can handle without damage. The resolution of the internal A/D converter is 10 bit (0-1023).
a somewhat more complex solution, but possibly more accurate, could be to use an ADS1115 I2C sensor, that also needs that voltage divider because the highest input is equal to its VCC, and the I2C bus must use signals of max 3.3V so VCC should be 3.3V too, and has an accuracy of 16 bit (0-65535).
/Ton

oasisone
Normal user
Posts: 5
Joined: 08 May 2021, 08:39

Re: Solar level and temperature sensor GHBO1/SHBO1

#3 Post by oasisone » 08 May 2021, 16:13

Hello and thanks for the reply, the sensor is part of the SR-500 controller of the solar water heating panel and is located in its special port outside, it measures the level of water and it's temperature inside the tank. The sr-500 provides it with 12V and the output ttl is also at 12V unless you power it at 5V.
I want to use the same sensor for both the SR-500 which controlls the electrical heater ( for when the sun is not shining enough) and the water inlet of the tank and the easyesp to log water usage, temperature and so on.
Adding another set of level and temperature sensors is quite difficult as there are no other openings in that container.
As an alternative ,i could use the uno to read the sensor and send the output via serial to the easyesp but i still bump into the same problem, how to turn the data from the serial input into data that can be sent to an MQTT logger

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Solar level and temperature sensor GHBO1/SHBO1

#4 Post by Ath » 08 May 2021, 17:21

If there is only 1-way communication, from SR-500 to the ESP, then a voltage divider on the TTL signal, resulting in a 12/3.3 value, should be a solution, that can also be applied to the UNO input, or there you could possibly use a 12/5 divider.
When commands need to be sent to that SR-500 you will need a full-fledged level converter. (like this I googled for)

I haven't studied the protocol description you linked to, so I can't tell what's needed to decode the signal, though.
Using that UNO sketch to get the reading, then sending it to an MQTT server, either with or without an ESP in between, seems feasible, depending on wether you can add the MQTT part yourself to the UNO sketch (there are plenty examples available on the interwebs), or pass it via serial to ESPEasy, where a MQTT server could be used to send the serial data to.
/Ton

oasisone
Normal user
Posts: 5
Joined: 08 May 2021, 08:39

Re: Solar level and temperature sensor GHBO1/SHBO1

#5 Post by oasisone » 09 May 2021, 08:32

The communication is 1-way, the sensor sends a package each second to the SR-500 with the current values. I can build a voltage divider, to get to a lower voltage but that doesnt get me much further.
Basically i have no idea where to start on running this sketch on the ESP so i can use the espeasy to get the info to the MQTT

Code: Select all

// Extracted from http://hack4life.pbworks.com/Arduino%20Solar%20Water%20Heater%20Sensor

const int inPin = 22; 

 

void setup() {

  pinMode(inPin, INPUT);

  Serial.begin(9600);

}

 

#define TIMEOUT 50000

#define MARK_HEADER 7000

#define SPACE_HEADER 3000

#define MARK 500

#define SPACE_ONE 1500

#define SPACE_ZERO 600

 

int expectPulse(int val){

  unsigned long t=micros();

  while(digitalRead(inPin)==val){

    if( (micros()-t)>TIMEOUT ) return 0;

  }

  return micros()-t;

}

 

// temp in celsious and level goes from 0 to 3

bool readTempNLevelSensor(char inPin, char &temp, char &level){

   byte data[5]={0,0,0,0,0};

   unsigned long val1;

   unsigned long st=micros();

   val1 = expectPulse(HIGH);

   if(val1>MARK_HEADER){

     val1 = expectPulse(LOW);

     if(val1>SPACE_HEADER){

       int c=39;

       for(;c>-1;c--){

         val1 = expectPulse(HIGH);

         if(val1<MARK){

          val1 = expectPulse(LOW);

          if(val1==0){

            //Serial.println("Mark error 0");

            break; 

          }

          if(val1<SPACE_ZERO){

            //0

            //data[c>>3]|=(1<<(c & B111));

          }else if(val1<SPACE_ONE){

            //1

            data[c>>3]|=(1<<(c & B111));

          }else{

           //Serial.print(val1);Serial.println(" Space error");

           break; 

          }

         }else{

          //Serial.println("Mark error");

          break; 

         }  

       }

       // Each reading should not take more than 70ms (use time to detect errors)

       if(micros()-st<70000){

         temp=data[3];

         level=data[2];

         //Serial.print(data[3]);Serial.print(" ");Serial.println((data[2]));

         //Serial.print(data[4],HEX);Serial.print(" ");Serial.print(data[3],HEX);Serial.print(" ");Serial.print(data[2],HEX);Serial.print(" ");Serial.print(data[1],HEX);Serial.print(" ");Serial.println(data[0],HEX);

         return true;

       }

    }

   }  

   return false;

}

 

void loop() {

  char temp,level;

  if(readTempNLevelSensor(inPin, temp, level)){

    Serial.print(temp,DEC);Serial.print("c ");Serial.println(level,DEC);

  }

}
Alternatives are:
1. get eth shield, voltage divider and run it on the UNO -
2. run it on the UNO, send serial info to the esp and take it from there, alltho i have no idea how to take the serial data and make it into something useful
3. get the esp somehow to run this script and get the data on the MQTT - i would prefer this as i can hook also other sensors and run other scripts on the esp without much programming

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Solar level and temperature sensor GHBO1/SHBO1

#6 Post by Ath » 09 May 2021, 10:56

I have had a bit longer look at your link, but seeing that the decoding is very specific (don't know if it is an actual serial protocol or something, I'm not into that kind of stuff), it probably needs a specific plugin created to extract the data from the device. And if it is serial, it will still need some processing to peel out the exact bytes into values. I don't know if the current ESPEasy serial plugins support that kind of processing.
Quite hard to investigate without having access to the hardware :(

You can do some investigation by adding the voltage divider, connect the 3.3V output to RX of a serial to usb converter, and start a terminal program like putty or the serial monitor from Arduino IDE or VSCode, experimenting with baudrates etc. to see if something usable is coming in (it should at least be somewhat readable). If so, a serial plugin of ESPEasy can probably be used to read the desired data.
/Ton

oasisone
Normal user
Posts: 5
Joined: 08 May 2021, 08:39

Re: Solar level and temperature sensor GHBO1/SHBO1

#7 Post by oasisone » 09 May 2021, 11:28

Hi, the script works, i tested it and spits out correct values on the UNO via the serial interface, the com pin of the sensor was hooked up on pin D3 of the uno.
I can setup a voltage divider and get it down to 3.3V but what further?
Is there a way to adapt and include that script in the espeasy?

User avatar
Ath
Normal user
Posts: 891
Joined: 10 Jun 2018, 12:06
Location: NL

Re: Solar level and temperature sensor GHBO1/SHBO1

#8 Post by Ath » 09 May 2021, 11:32

Before trying to create a plugin for ESPEasy, I'd like to investigate if your device can be connected via an existing, serial, plugin. That's what I described above ;)
/Ton

oasisone
Normal user
Posts: 5
Joined: 08 May 2021, 08:39

Re: Solar level and temperature sensor GHBO1/SHBO1

#9 Post by oasisone » 09 May 2021, 17:41

got any documentation on where to start doing that? i am sure that this has been done in some form or another on other serial devices, just that i dont know where to start looking.

Post Reply

Who is online

Users browsing this forum: No registered users and 10 guests