Paradox
©
Fisana

Jump to content


Photo
- - - - -

Some ways to retrieve sensor date using a Raspberry PI


  • Please log in to reply
15 replies to this topic

#1 Alpoehi

Alpoehi

    Mycotopiate

  • VIP
  • 555 posts

Awards Bar:

Posted 06 March 2021 - 05:19 AM

Note to admin stuff: Maybe you can change date to data in the title?

 

For a long time I wanted to make a thread on using a Raspberry PI (RPI) in my grow projects.

 

Let's go straight into it:

 

Hardware requirements are RPI 3 or 4 with current OS Raspbian Buster.

 

Configure your network access and go here:

 

https://www.npmjs.co...ckage/raspberry

 

Install nodejs and npm with this command:

 

sudo apt-get install nodejs npm

 

After installation check the version of nodejs and npm

 

nodejs --version

 

npm -v

 

When you see version numbers in response to these commands continue with the next step:

 

npm install express.js

 

That's all you have to do in preparation for running a DHT-11 sensor on your RPI.

 

Instructions I got from this book:

 

https://www.packtpub...3/9781788295895

 

Of course you have to install a folder containing a few files with javascript instructions.

 

That's all you have to do in preparation for running a DHT-11 sensor on your RPI.

 

The DHT-11 sensor is a cheap sensor that can be used for Raspberry/Arduino projects and it has very good library backup.

 

The Raspbery PI repository is an ongoing affair and the book is 5 years old. Basically the book came out when the RPI 3 with Raspbian Jessie had been released.

 

So the author recommends a build of a driver library in order to run the DHT-11 sensor.

 

However I installed the whole thing with the instructions given in the above steps. It seems the DHT-11 is supported by Raspbian Buster now.

 

That being said, it's very easy to make simple things complicated so let's go ahead ...

 

If you want to play around a bit with this send me a pm for the files with the javascript instructions for running the sensor and the GPIO ports used.

 

I cannot publish here because it's copyright on it. But for educational use it should be fine when one wants to have a look at it before buying the book ... 

 

Same as creating a free trial on the PACK homepage that enables you to read the book online for a limited time. Also I have seen the ebook somewhere for 5 bucks on offer.

 

I purchased that book used for 7 EUR and I did not regret it although the writing style of the author is a bit stupid. He mentions changes that have to be made in the files and at the same time he does not point out what files he is talking about. 

 

That book serves as the starter for more to come. Stay tuned, for I found another book published in 2022 that is the cream on homemade IoT projects written in python programming language and I will expand in this thread on that as well.

Just wanted to introduce a quick solution for a fast, low cost approach to solve problems in our grows.

 

For instance I used the sensor to monitor the humidity and temperature in my grow tent during winter because I have left the larger part of my cacti outside on the balcony.

 

I had an automated frost guard in the tent that was not controlled by the RPI and when the temperature fell below 17,6 F it became critical inside of the tent.

 

I used the sensor to monitor the temp and inside of the protected environment it fell to 30 F a few times. No reason to hassle around with my cacti in the midst of the night, lol.

 

It is possible to make databank requests the next day to see what happened in the preceding hours if you want to.

 

This is how it looks like on the local machine as I am writing this. The sensor is already fulfilling a new job:

 

dht11.png

 

Note the graphical display when using a browser for displaying the data.

 

That's the situation at the desk where I'm sitting and my 20 petrie dishes are inside of a glass dome. Understand why the glass dome?

With 41% humidity the water in the agar will evaporate fast and that would inhibit growth of the mycelium.

 

I want to make things practical in this thread guys!

 

And there's more. You can feed a databank with data generated by the sensor and transfer it to a cloud service like Google firebase.

 

This requires rewriting of the code and it's shown in the more advanced chapters of the book.

I used it to get the sensor data on my tablet. Very practical when I was not at home and the sun shining brightly on the uncovered grow tent with the cacti inside.

Temps raise then very quickly over 100 F. No problem for the cacti but when you don't know what happens inside of the grow tent you may have a lot of concern as to what is going on with the 120 $ loph you have just purchased ... 

 

So this is the introduction. There are other approaches I am working on right now. I must say the before mentioned book gave me a good boost into IoT and I am grateful to the author.

But there's more to it.

 

You can even solder together an op amp with a CMOS chip and create an environmental sensor that gives off a trigger signal for an alarm or relay when temp exceeds a certain range.

This is a relatively easy PCB to solder together without using a single-board computer with software on it.

 

Kind of the doom scenario when electricity fails worldwide and all you have is a car battery, lol.


Edited by Alpoehi, 06 March 2021 - 05:26 AM.

  • Arathu, SteampunkScientist, Salem and 1 other like this

#2 Arathu

Arathu

    Dirtmaker

  • OG VIP
  • 7,035 posts

Awards Bar:

Posted 06 March 2021 - 05:44 AM

I have a Pi-3 and Pi-4, plus multiple Arduino's. Fun little computers and very powerful for what they are...My main PLC is also networked so I'll be exploring IIOT subjects and probably write a bunch of the code myself. It's always good to have links and new information/resources. Thanks for posting this. I'm certainly interested in all topics related to electronics, computing in general, and industrial controls. Sensor technology combined with networking makes for a broad spectrum of possibilities limited pretty much to the skills of the builder and the laws of physics....

 

One of the beauties of Rpi and even my PLC is they can be made to operate directly on DC sources readily available to folks with alternative energy solutions such as properly designed solar and wind sources without the need to invert the energy to AC. Note: that actuators, pumps, motors, and heating just to name a few can be quite power intensive so careful calculations of power budgets and consumption must be taken into account. That being said it's a good idea to plug a bunch of logs and plant a nice garden just in case we find it necessary to return to a much more natural state of living. (which IMHO IS COMING for most everyone) 

 

A

 

 


  • Alpoehi and rockyfungus like this

#3 Jrotten

Jrotten

    Amateurish

  • Gold VIP
  • 1,489 posts

Awards Bar:

Posted 12 March 2021 - 10:09 AM

so this is a Debian based linux os?



#4 jrh

jrh

    Mycotopiate

  • VIP
  • 583 posts

Awards Bar:

Posted 12 March 2021 - 10:29 AM

Raspbian OS is Debian based, but you could install Ubuntu.


  • Arathu and rockyfungus like this

#5 rockyfungus

rockyfungus

    Mycotopiate

  • Free Member
  • 1,839 posts

Awards Bar:

Posted 12 March 2021 - 10:55 AM

Damnit just what I need to get back into tinkering with Pi's, arduinos, and python...



#6 Alpoehi

Alpoehi

    Mycotopiate

  • VIP
  • 555 posts

Awards Bar:

Posted 12 March 2021 - 02:11 PM

Fun stuff. Turn on a 10 Amp relay switch by sending an email from your mobile phone.

IMG_0047.jpg

A small circuit with an optocoupler, transistor and a relay switch.

You can switch larger loads and have your Pi protected because you use two separate circuits for the switching.

 

Or receive an automated email message in case your temp/humidity sensor gets a reading that goes beyond/below a preset limit. Easy to do with ifttt.com.

Visualizing data can be done on cloud platforms like ThingSpeak on local machine with Thingsboard.

Thingsboard is a Java written app that is easy to install and runs perfectly on a Pi4.

All that runs on mosquitto or mqtt protocol.

 

There are soil hygrometers available like that one (Picture from sparkfun.com):

 

13322-01.jpg

 

Guess what - it's perfect for a tub.

You can use an analog to digital converter and measure the resistance value and interpret it in your program. Many sensors come with small PCBs but in many cases you will not make use of them.

I learned to solder my own small circuit for the PI. It's also possible to use a simple breadboard.

 

See the book: Practical Python Programming for IoT by Gary Smart that I'm working through right now.

 

Just got stuck a little bit because the author refers to the use of ThingSpeak, it appears you can only create an account when you have a valid university email address.

I'm not inscribed anywhere so it's not for me  :rolleyes: .

 

For three days I study now alternatives. Of course there are plenty available but I can't get the code adopted to the new platform I want to use.

Also on cloud services you'll get fucked up on a regular bases with the credentials. They hide them so well from you and never refer to where they are in the documentation.

Steep learning curve by now ...

 

 

 


Edited by Alpoehi, 12 March 2021 - 04:18 PM.

  • Arathu, SteampunkScientist and makinbones69 like this

#7 pastyoureyes

pastyoureyes

    Manure Muscler

  • OG VIP
  • 1,017 posts

Donator


Awards Bar:

Posted 13 March 2021 - 12:29 PM

I'm experimenting with a co2 sensor and a fan at the moment.
gallery_150062_1776_166976.jpg

You should look into mycodo.
https://github.com/kizniche/Mycodo
  • Arathu and Alpoehi like this

#8 Alpoehi

Alpoehi

    Mycotopiate

  • VIP
  • 555 posts

Awards Bar:

Posted 17 March 2021 - 03:20 AM

Cool stuff pastyoureyes, I will install and have a look. What sensor do you use for carbon dioxide?

 

First I had to sort out the trouble I had with thingspeak.com.

I tried to make an account on my Pi and failed. On a windows machine everything worked out fine.

Now I have it up and running and it looks like this:

 

2021-03-17-092753_1920x1080_scrot.png

 

This is how it looks in terminal window:

 

2021-03-17-091537_1920x1080_scrot.png

 

I use a DHT22 sensor now and it is much more precise.

It's 80F so a bit edgy for my grows. In summer it gets way too hot here and I have to work out a cooling solution.


Edited by Alpoehi, 17 March 2021 - 03:30 AM.

  • Arathu, pastyoureyes and makinbones69 like this

#9 pastyoureyes

pastyoureyes

    Manure Muscler

  • OG VIP
  • 1,017 posts

Donator


Awards Bar:

Posted 17 March 2021 - 04:14 AM

Co2 sensor I'm using is a cozir co2 sensor. Mine measures from 0-5000ppm. The problem I have is that the co2 in my house is measuring about 1700-1800 ppm with the windows closed and gas furnace running. I want to improve my indoor air quality by the time winter rolls around. Thinking about a whole house dehumidifier but that is going to be pretty expensive.

When I have time I'll be adding an shtxx sensor for humidity and temperature readings.

#10 Arathu

Arathu

    Dirtmaker

  • OG VIP
  • 7,035 posts

Awards Bar:

Posted 17 March 2021 - 05:09 AM

Amazing what we find in the house, and elsewhere in fact, when we use tools like these to greatly extend or bandwidth and measure conditions that our senses don't easily present to us......

 

I'm thinking about making my own portable instrument to carry with me, especially at work, to monitor what I'm being exposed to by people that are "legitimate" businessmen....... (extreme sarcasm there folks)

 

Good stuff in this thread right here. I need to dig through my goodies and figure out where I put my CO2 and temperature sensors....

 


Edited by Arathu, 17 March 2021 - 05:10 AM.

  • Alpoehi likes this

#11 Arathu

Arathu

    Dirtmaker

  • OG VIP
  • 7,035 posts

Awards Bar:

Posted 17 March 2021 - 05:46 AM

Be careful switching relays on and off with low voltage device drivers. The inductive kickback from a relay coil can be quite significant and will cause damage to the output stages of SBC's like Arduino and PI so I recommend snubbing of some sort. Fly-back diode REVERSE POLARITY across the relay coil, RC snubber network(s), and my favorite, preferably the appropriate TVS diode(s). 

 

Man I love automation and industrial controls....

 

A


  • kcmoxtractor, pastyoureyes and Alpoehi like this

#12 pastyoureyes

pastyoureyes

    Manure Muscler

  • OG VIP
  • 1,017 posts

Donator


Awards Bar:

Posted 17 March 2021 - 01:17 PM

Be careful switching relays on and off with low voltage device drivers. The inductive kickback from a relay coil can be quite significant and will cause damage to the output stages of SBC's like Arduino and PI so I recommend snubbing of some sort. Fly-back diode REVERSE POLARITY across the relay coil, RC snubber network(s), and my favorite, preferably the appropriate TVS diode(s). 
 
Man I love automation and industrial controls....
 
A


Now I know who to talk to when I start building my homebrewing controller.
  • Arathu likes this

#13 cflashor

cflashor

    Mycophiliac

  • VIP
  • 55 posts

Posted 05 May 2021 - 07:23 PM

Though I haven't implemented this solution, I set it up about 6 months ago then I got busy with school and a baby.  Maybe one day when I get this setup and running I'll make a post about it, but I have been beyond busy lately.

 

On the backend I have a SHT15 humidity and temperature sensor connected to a raspberry pi 4, which logs sensor readings to a SQL database.  On the frontend I'm running flask with matplotlib to generate graphs for recent time intervals.  These plots are generated on the fly (multithreaded calculation too :)) depending on the parameters passed to the plotting script.

 

Like I said, I had never set this up to control fans/humidifiers (it has been sitting in my workshop for many moons), but the sensor script logging to database was working perfectly (except for the fact that my sensor is dead):
 

+---------------------+----------+-------+
| datetime            | humidity | temp  |
+---------------------+----------+-------+
| 2021-02-11 08:32:23 | 84.62    | 62.34 |
| 2021-02-11 08:32:53 | 84.62    | 62.34 |
| 2021-02-11 08:33:23 | 84.61    | 62.33 |
+---------------------+----------+-------+
 
This is the last data that was logged to the database (RIP).  As you can see I have been preoccupied and hadn't checked on it in a while.  Though, once I'm ready to implement this controlling relays will be easy since it can simply access readings from the database, control relays, and adjust the polling interval if needed.  Adding additional sensors would be trivial.
 
Sensor source code: https://pastebin.com/cd61FuMT
 
 
Screenshot of message of the day when logging into mykos vis ssh:
 
motd.jpg
 
Screenshots of sensor plots of the last 1 hour humidity and last 14 days temperature:
 
1H_Humidity.png
14D_Temperature.png

Edited by cflashor, 05 May 2021 - 07:30 PM.

  • Arathu, UnHeisenbug and Alpoehi like this

#14 Arathu

Arathu

    Dirtmaker

  • OG VIP
  • 7,035 posts

Awards Bar:

Posted 09 May 2021 - 01:39 PM

That's freaking beautiful cflashor!

 

A



#15 Ringo

Ringo

    Mycotopiate

  • Free Member
  • 305 posts

Posted 09 May 2021 - 02:44 PM

I love these things. Before I moved I had a handful of them monitoring various tasks in my grow rooms. I still use 2 of them. One in my flowering tent and one in my drying tent. Doesn't really do anything but it lets me logs what goes on. The cam snaps a pic every 15 minutes and displays it on the interface. Clicking the small pic gives a large pic.  I did a cool time lapse using the RPi and the cam it uses. I'll see if I can dig it up. Here is the interface I used.

 

 

RPi interface.jpg

 

 

Found the gif I did. It's pretty lame but kind of cool for a first attempt.

 

Raspberrytlcropped-3.gif

 

 


Edited by Ringo, 09 May 2021 - 03:47 PM.

  • Alpoehi likes this

#16 Alpoehi

Alpoehi

    Mycotopiate

  • VIP
  • 555 posts

Awards Bar:

Posted 11 May 2021 - 01:03 PM

Very cool with the time lapse.
A brilliant idea for sharing pictures of one's grows. I once did a surveillance cam with the PI. A few lines of code and bang you have it.
  • Ringo likes this




Like Mycotopia? Become a member today!