bkintz
I've located properly working C code to read the humidity and temp values from the AM2302, but my C coding skills has about 25 years of rust on it and I'm not able to translate it into the OpenPLC Code box where it functions. 

The code is the example located here: 
http://www.uugear.com/portfolio/read-dht1122-temperature-humidity-sensor-from-raspberry-pi/

only change is that my DHT_PIN is 7 vice 3. When compiled it reports data properly from the bash shell on the pi, so I know the libraries are there and both my hardware as well as my connection points to the GPIO are good.

Can someone assist?
Quote 0 0
NWT.Stuff
I think I have one of those in my bag of bits. I’ll give it a try next week sometime and get back to you.
Quote 0 0
bkintz
Awesome. That would be very much appreciated!
Quote 0 0
thiagoralves
I quickly check that code, it is heavily based on timings. It won’t ever work with OpenPLC unless it is placed on a separate thread. If you don’t, it will make OpenPLC scan time slow to a crawl. 
Quote 0 0
NWT.Stuff
blintz it would be useful to know the objective of your project ?
Why RPI ?
Why OpenPLC ?

For example if I wanted to log values to a database. I would:-
-use an arduino with Ethernet connectivity
-program in C language on Arduino IDE
-write values to database on required frequency.

if I wanted to control the temperature and humidity of a room I would
-still use arduino software to read values
-connect arduino to RPI with a USB cable
-use PID control in Open PLC
-configure arduino as slave device in OpenPLC.

The arduino is very well suited to this application and this is kind of mentioned at the bottom of the link that you posted.



Quote 0 0
bkintz
I'm building a ICS pen testing lab and want to have a setup with an HMI that can collecting point values from a variety of PLCs that I can manipulate with my attacks and I have a handful of pi boards on hand. If arduino is the path of least resistance, i can certainly explore that route.
Quote 0 0
thiagoralves
Definitely Arduino would be the easiest route. You can have the arduino reading your DHT sensors and sending the data over to the host (Raspberry Pi running OpenPLC) over Modbus. All you have to do is get the OpenPLC firmware for the Arduino and slightly modify it to add the DHT11 readings
Quote 0 0
bkintz
OK, I'll give that a go and see what happens
Quote 0 0
NWT.Stuff
I have attached the current project I am working on.  The kit on page 1 (python + mysql + flask) has been active for about 4 Years now without any hardware failures.  I still like to have the pi as my first level on the TCP/IP network as it makes it easy to make changes to the Arduino using Arduino IDE on the PI (As i can log in as a VNC Client from a PC).  But for Analogues in , pulses etc. and simplicity the Arduino works a treat.  Plenty of code and support around to.  I guess I'm saying the best solution is to use them together.  And OpenPLC will do that nicely too with the Slave Option.

I'll give the temp & Humidity sensor a run on my Arduino next week  ðŸ™‚
Quote 0 0
NWT.Stuff
OK Bkintz

I found a KY-015 in my bag of bits. Pretty sure the physical nature of the device will be similar.  I did a bit of googling and found these two projects.

https://www.tutorialspoint.com/arduino/arduino_humidity_sensor.htm

https://arduinomodules.info/ky-015-temperature-humidity-sensor-module/

I went with the 2nd one as it doesn't require the additional step of including a library.

Wiring.jpg 

Downloaded the Code to Arduino
ArduinDL.jpg 

Results in Serial Monitor

SerialMon.jpg 

Fairly happy as my room thermostat said 20.2 degC.  I also tried heating it up with my partners hairdryer.  Responded as exepected.

I think the next thing I will do is put a long wire on it an see what it says in the bathroom 🙂

Not sure of the best way now to get these values into the PLC register.  So hopefully someone on the forum can help with that.

Good Luck, Kevin 
Quote 0 0