martinpihrt / OSPy

A highly cusomizable DIY timer/controller based on Raspberry Pi
10 stars 5 forks source link

Remote station #5

Closed garudaonekh closed 3 years ago

garudaonekh commented 3 years ago

I want to use OSPy for farm irrigation so we need to manage mainly remote stations. I used to use Tasmota to control relays but it is not efficient enough due to distance of Wifi so I want to use LORA instead due to the distance from one stations group to another can be up to 500 meters or 1 km.

My initial idea is to use MQTT gateway to collect the incoming LORA messages and let OSPY consume that data and publish MQTT message to turn on/off stations but the shortcoming is the acknowledgement from the LORA stations, which I don't think OSPY has the mechanism for this.

What's your suggestion?

martinpihrt commented 3 years ago

OSPy allow you to be controlled by MQTT commands. It can even work in such a way that one OSPy will then publish as a master (with, for example, 50 stations - virtual) to the MQTT server. OSPy are variously located as slaves over the network, and they read the MQTT and control it remotely. There is also an e-mail plugin in OSPy, which can send an email to users after each execution (switching off the station). In your case I would go all the way (master - xxx slave). Instead of LORa, I would stretch the optics (today both the cable and the converter are cheap) and make a network. In addition, you can then use IP cameras for monitoring. Here is plugin: https://github.com/martinpihrt/OSPy-plugins/tree/master/plugins/mqtt

garudaonekh commented 3 years ago

A lot more to explore in OSPy. I am very excited with this OSPy.

Instead of email, i will use SMS and telegram. I can't manage to get Gammu to work with Raspberry pi and my Huawei modem E3531 yet-but will try again soon.

Regarding wifi, i don't understand why we need MAC address in OSPy--are you using ESP-Now?

I think for the LORA gateway, I will try to use OpenMQTTGateway.

martinpihrt commented 3 years ago

Regarding wifi, i don't understand why we need MAC address in OSPy--are you using ESP-Now? -> Yes, I already use ESP32 my modules as multisensors https://pihrt.com/elektronika/444-esp32-multisnimac-pro-opensprinkler-system The MAC address is only an identifier in the OSPy for ESP32 (not important, but must be entered). After connecting the sensor to the WiFi network, the sensor is searched in the OSPy and easily added to the system (there is a search engine). Check print screen. I do not know OpenMQTTGateway. Screenshot 2021-08-05 at 09-48-59 Chata - Meteorologická stanice Screenshot 2021-08-05 at 09-48-36 Chata - Upravit snímač Screenshot 2021-08-05 at 09-48-11 Chata - Graf vzorků snímače Screenshot 2021-08-05 at 09-47-54 Chata - Dostupné snímače Screenshot 2021-08-05 at 09-47-34 Chata - Seznam snímačů so far, a multisensor with ESP32 is supported in ospy. I also plan to add sensors based on ESP8266 (for example, Chinese Sonoof). I would like to extend it to radio sensors (such as LORa), but that is the distant future. I am on the project alone and I am self-taught (trial and error method). I have been working on OSPy since 2013. Today, the original project of SIP by Dan and OSPy by Rimco (from whom I deviated) is already incompatible with my version. I have made a lot of changes. Moreover, neither version of SIP and OSPy Rimco allows what I have in the system now.

martinpihrt commented 3 years ago

Rimco: https://github.com/Rimco/OSPy Dan: https://github.com/Dan-in-CA/SIP

garudaonekh commented 3 years ago

Ha ha! Yes, I have tried the original version by Dan and also the OpenSprinkler(https://github.com/OpenSprinkler) but I like your the most because of the functionalities you provided and space for expansion. In my opinion, OpenSprinkler(https://github.com/OpenSprinkler) is more for end user as it's very user friendly and have good mobile UI but I think it's difficult to extend and it's in C++, which I am not comfortable with. Even though I know Python only for a few months(much less than C++), but I prefer Python.

I have used many sensors, I mainly depend on Tasmota(they support a great deal of common sensors). It supports i2c, adc and RS485 sensors. Tasmota will act as gateway to collect all the sensor data and publish them to MQTT and Tasmota also good at managing Relays. Tastmota also support Rule(which is a great Swiss knife). However, when it comes to LORA, it's not a good choice as Tasmota is made for Home Automation not for long range. So when it comes to farming, I need LORA and my choice for the gateway is OpenMQTTGateway as it supports LORA and other RF.

OpenMQTTGateway will collect all the sensor data from LORA, BLE, RF... and publish them to MQTT. It support many BLE sensors as well.

I am checking and trying to understand your MQTT implementation and see if it can work with them.

martinpihrt commented 3 years ago

Or use this extension, rather it will suit your control needs. https://github.com/martinpihrt/OSPy-plugins/tree/master/plugins/mqtt_runonce

MQTT data example Sending message in MQTT as list: Station 1 -> OFF, 2 -> OFF, 3 -> ON 100 second, 4 -> ON 30 second...

[0,0,100,30]

Sending message in MQTT as dict:
Station 1 -> OFF, 2 -> OFF, 3 -> ON 100 second, 4 -> ON 30 second...

{"station name 1": 0, "station name 2": 0, "station name 3": 100, "station name 4": 30}

garudaonekh commented 3 years ago

Regarding wifi, i don't understand why we need MAC address in OSPy--are you using ESP-Now? -> Yes, I already use ESP32 my modules as multisensors https://pihrt.com/elektronika/444-esp32-multisnimac-pro-opensprinkler-system The MAC address is only an identifier in the OSPy for ESP32 (not important, but must be entered). After connecting the sensor to the WiFi network, the sensor is searched in the OSPy and easily added to the system (there is a search engine). Check print screen. I do not know OpenMQTTGateway. Screenshot 2021-08-05 at 09-48-59 Chata - Meteorologická stanice Screenshot 2021-08-05 at 09-48-36 Chata - Upravit snímač Screenshot 2021-08-05 at 09-48-11 Chata - Graf vzorků snímače Screenshot 2021-08-05 at 09-47-54 Chata - Dostupné snímače Screenshot 2021-08-05 at 09-47-34 Chata - Seznam snímačů so far, a multisensor with ESP32 is supported in ospy. I also plan to add sensors based on ESP8266 (for example, Chinese Sonoof). I would like to extend it to radio sensors (such as LORa), but that is the distant future. I am on the project alone and I am self-taught (trial and error method). I have been working on OSPy since 2013. Today, the original project of SIP by Dan and OSPy by Rimco (from whom I deviated) is already incompatible with my version. I have made a lot of changes. Moreover, neither version of SIP and OSPy Rimco allows what I have in the system now.

I see you are using ADC sensors directly with ESP32. What's its accuracy? I heard many people complaining about accuracy of ADC on ESP32.

So for me, I use ADS1115 with my ESP32 for all my soil moisture sensors.

martinpihrt commented 3 years ago

yes ADS1115 looks like a good solution. In ESP32 I use AD only for orientation measurement of the supply voltage of the source (how much goes into the switched stabilizer LM2576. My multi sensor with ESP32 has an I2C bus connected to the connector. This connector already allows you to connect different types of humidity sensors (DHT11, 22 ...) and an ultrasonic sensor. Add support for the sensor in ESP32 to ADS1115 and a soil moisture probe would be connected to it. The ADS option would be selected in the ESP32 sensor settings. the sensor would send the value to the OSPy and the ADS sensor option would be selected there. Where the value be assigned to certain stations and consequently would the program time be adjusted. (if I understand correctly).

garudaonekh commented 3 years ago

ADS1115 is 4 channel with IIC output and it supports 4 addresses so we can attach 4 ADs1115 thus we can have 16 sensor attach to it. It can work with 5v analog input which EsP32 and most controller cannot

martinpihrt commented 3 years ago

I read the datasheet and i know it has 4 inputs and 4 address options on I2C bus. Idea: in to my multisensor is connected 4 circuits ADS1115 (ie 16 inputs) via I2C. Next the sensor send all values in to to the OSPy?

garudaonekh commented 3 years ago

yes, but i do not know if your code support multiple channel yet and I think for soil sensor, calibration also needed

martinpihrt commented 3 years ago

So I will order ADS1115 converters and when it arrives, I will add an option for 4 pcs of these converters to my multisensor, I will also add support for sending these 16 channels to the OSPy. Calibration will take place only within the OSPy - not in sensor (calibration, but we will solve it only then) In OSPy I will receive this data and then we will deal with further processing within OSPy. Please write me the exact one type soil sensor.

garudaonekh commented 3 years ago

currently, I am using 8 soil moisture sensor with two ADs1115. maximum distance i tested is 10meters(enough to cover 1 greenhouse)-I see it is 0.01voltage drop which I think this can be compensated with calibration.

garudaonekh commented 3 years ago

I will write you more about my findout of these sensors, but please note that I am not a professional😆. I am a programmer only. not much experience with electronics

martinpihrt commented 3 years ago

don't worry, I'm also self-taught and I'm not a programmer :-)

martinpihrt commented 3 years ago

Hi, The work is done, and when the A/D converter runs out, so I can try the whole thing.

changes OSPy - 4.0.142 (2021-08-20): 754673c Czech language update. Sensor ESP32 - soil moisture (16x probes): Added to all types of sensors - sending e-mails in case the sensor does not respond (or now again responds). On the OSPy side, soil moisture processing is complete (data reception, logging, adjustment of the running time of the selected program according to the humidity from the probe). The ESP32 sensor already sends data to the OSPy. It remains to test the connection of the A/D converter to the sensor ESP32 and verify the values of the transmitted voltage (I have not yet tested physically for the test -> hw is ordered). An image with the connection of probes to the ESP32 sensor has been added to the "create a new sensor" section (documentation on how to connect a specific sensor). Whoever already owns the ESP32 multi-sensor and has the ADS1115 converter together with a humidity probe (which has a voltage at the output in the range from 0 to max 5V), can test this functionality. Good luck with OSPy! Screenshot 2021-08-20 at 07-09-02 OpenSprinkler Pi - Domů Screenshot 2021-08-20 at 07-08-07 OpenSprinkler Pi - Seznam snímačů Screenshot 2021-08-20 at 07-08-24 OpenSprinkler Pi - Záznam snímače Screenshot 2021-08-20 at 07-08-34 OpenSprinkler Pi - Upravit snímač Martin

garudaonekh commented 3 years ago

ADS1115 will output digital value 0 to 16383. and most soil moisture sensor I used give 0 volt for 100% moisture and 3.3 volt for 0% moisture.

Normally, we use dry calibrate in the air to get its 0 moisture and put in water to get 100% moisture. and use ADC range to convert it to % of moisture. Correct me if i am wrong

garudaonekh commented 3 years ago

This is how I configure it after calibration. SO when I calibrate it, I have to adjust the ADC high and Low.

So for calibration, you need to show the real time ADC value so that user can pick the highest and lowest

This is my setting screen:

Screen Shot 2021-08-22 at 10 51 49 PM
garudaonekh commented 3 years ago

How about calibration? Where'll you add this function? For me, i think by adding live reading here on this screen, user can know what's the max and min of their soil moisture reading. https://user-images.githubusercontent.com/7847139/130186759-a8952d1b-4a76-409b-a626-395da824a61a.png

martinpihrt commented 3 years ago

The procedure is simple: 1) connect the probe to the A / D converter 2) in the sensor settings set that it is a "soil" sensor and connection to OSPy (IP, password ...) 3) In OSPy, assign a new soil sensor 4) after the assignment in the sensor tab I see the instantaneous voltage value in volts (not some sensor from the converter - I may not be interested). The value is sent from the sensor every 30 seconds. 5) I put the probe dry (ie 0% humidity) I look at the value of volts and I remember it (or I write it down) 6) I put the probe in water (ie 100% humidity) I look at the value of volts and I remember it (or I write it down) 7) I open a sensor in the OSPy to adjust the values and the lower min and max voltages I found 8) I set the program that I want to be affected

don't look for science in it. When I have all the components, I will shoot a video on youtube 1301867

garudaonekh commented 3 years ago

Can we bind more than 1 sensors to the same program and use the average of all the sensors reading? I think it's more practical to use more multiple soil moisture sensors

garudaonekh commented 3 years ago

One more thing, among all the soil moisture sensors I tested give reverse result, i.e 0 for 100%moisture and 3v for 0% moisture

martinpihrt commented 3 years ago

I will add to OSPy the possibility to invert states for these sensors (check mark). You can connect sensors to one AD input using resistors (for example 1 kohm) by connecting the sensor outputs together via resistors to a common node and placing it on the AD

martinpihrt commented 3 years ago

Hi, I will be updating the code on the github soon to allow the humidity to be measured and the program run time to be adjusted. more info: https://pihrt.com/elektronika/447-esp32-multisnimac-snimani-vlhkosti-pudy-v-ospy Use Google translator to Englisgh... Martin