Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » 4DIAC - Framework for Distributed Industrial Automation and Control » Reading a DHT22 Temperature Sensor with an SIFB(Writing and then reading to the same GPIO port on a Raspberry Pi)
Reading a DHT22 Temperature Sensor with an SIFB [message #1840040] Tue, 06 April 2021 05:39 Go to next message
Barry Dowdeswell is currently offline Barry DowdeswellFriend
Messages: 49
Registered: November 2018
Member
I am currently building a custom SIFB which can read the temperature from a DHT22 temperature sensor. This is a serial I/O three-wire device. However, since the DHT22 uses a serial interface, it only uses one GPIO pin. I am not sure how to make the QX and IX share the same GPIO pin - that looks tricky. The protocol requires the GPIO pin to be an output first to wake up the device with a pulse, and then switch to being an input to sample the data stream.

I have the C++ code running fine on an Arduino and I have written the C++ code on a Raspberry Pi in a small program using wiringPi, but I want to learn how to do this in sysfs rather than wiringPi if possible.

I have studied the QX and IX function blocks thoroughly. They are running in a test application fine. with a LED and a switch. What I need to build is a new block that combines the capabilities of the QX and IX in a single block.

What I am finding hard to see in the QX and IX C++ source is where the PARAMS value that specifies which GPIO pin is used by specifying the BCM number.

Any help would be appreciated. Note that the DHT22 does not follow the SPI protocol properly otherwise I could perhaps use one of the SPI function blocks.

Thanks,
Barry

[Updated on: Tue, 06 April 2021 05:43]

Report message to a moderator

Re: Reading a DHT22 Temperature Sensor with an SIFB [message #1840060 is a reply to message #1840040] Tue, 06 April 2021 08:57 Go to previous messageGo to next message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

You are right I also think an own FB with C++ code and not using wiringPI is definitely the better way to go. The IX QX code for the RaspberryPI is hidden in CSysFsProcessInterface. Not sure if our code is a good starting point as it is very tailored to the IX QX fbs.
Re: Reading a DHT22 Temperature Sensor with an SIFB [message #1840098 is a reply to message #1840060] Tue, 06 April 2021 18:42 Go to previous messageGo to next message
Barry Dowdeswell is currently offline Barry DowdeswellFriend
Messages: 49
Registered: November 2018
Member
Thank you Alois,

I agree with you about wiringPi. The code in the CSysFsProcessInterface has some internal documentation inside the .cpp file I have been looking it. That is really helpful. The code for the IX and QX blocks look similar to each other. I think it will be an enjoyable task to see if I can get this going. It would provide a good example for other users.
Re: Reading a DHT22 Temperature Sensor with an SIFB [message #1840178 is a reply to message #1840098] Thu, 08 April 2021 06:35 Go to previous message
Alois Zoitl is currently offline Alois ZoitlFriend
Messages: 1585
Registered: January 2014
Senior Member

Happy that I could point you to the right direction. Looking forward to your results. If you need anything let us know.
Previous Topic:Memory problem with freertos+lwip
Next Topic:Dynamic Type Loading
Goto Forum:
  


Current Time: Thu Apr 25 22:26:56 GMT 2024

Powered by FUDForum. Page generated in 0.03536 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top