RPi GPIO update for HG

A lot of work no doubt and here’s hoping your PR will acted upon sooner rather than later.

I imagine @enterprised will be interested in your findings and the resulting solution as he did encounter some problems with GPIO on the RPI3 if I recall. Nice work :+1:

It was a lot of work but hopefully it will help someone out. I hated the idea of tossing the RPi3 to the parts bin and buying a RPi4 because of some presumably small software bug. If I had the RPi4 already this might have been a different story. I guess being stubborn pays of once in a while!

Yes with the rate of production of new RPI model versions it probably would have gone unnoticed certainly as far as HG is concerned. Just proves that no software is ever a completed project.

If Gene wants other contributors, he should provide better documentation. Some of that would need to include a guide on a development environment. I was able to compile one library but not another. I would have modified the code of both if I could compile everything. As is, it works for now.

@bkenobi I’m new to playing with the GPIO. Thanks for this.
I picked up a DHT-22 to add to my pi Zero W at my off grid location sometime ago.
I decided to test it in the city on my Zero W board and 3B+ as I had never got around to playing with it until now.
The DHT-22 program is loaded and running in both the zero and 3B+
HG sees it on my Zero W and I can add to a group even though it is connected to the 3B+ However HG fails to see the DHT-22 to load to a group on my 3B+ :disappointed:

I can get the DHT-22 to report on my 3B+ using the python code, however the values are not correct (0.0 C and 1.0 % humid)
I figure the sensor is bad so I’ve ordered a couple more to play with

There are lots of examples of DHT code that work with Arduino and RPi. I cant comment on failure rate of these sensors, but if it responds then it’s not likely faulty. The response isnt a single value, it’s a formed phrase with temperature and humidity. As I recall a failed sensor would respond with a different message or no response at all. They can be out of calibration but I’d guess it’s a problem with the code before I assumed it was a sensor that’s been sitting in a desk drawer.

Yes, the same python program on the Zero W reports check wiring with no sensor connected.

I downloaded the HG program on my off grid setup but can’t switch(update) the files you create as I need to be on that network.
HG can’t add the DHT-22 module to a group there just like the pi 3B+ here, so I’m wondering if something needs to be added to the files for a 3B+

The update will make GPIO function on all versions of the RPi through 4 and through Buster. I don’t know what will change with the 400 or in the next version of the OS but it currently should get things back in order. The RPi4 should already work but any older boards will not unless you install Wheezy or older and use HG 500 or older.

I played a bit with my DHT22 in a Zero W & 3B+ boards using some python codes and did get it reporting correct values with some code modifications. However the DHT22 program in HG fails to load a widget in the 3b+ and will not display any info in the Zero W. Digging into the HG DHT program code I am seeing errors so although the GPIO Program appears to work it doesn’t completely fix the issue with the DHT Sensor programs.
Loading either the DHT11 or 22 programs into HG with or with out a sensor connected and compiling produces the same errors. At least it does for me in both a Zero W and 3b+.

As I said, I’d assume the code is broken and the sensors are ok. If you didn’t replace the file I posted for a RPi 1-3 based system then you will have to be using an ancient setup for GPIo to work. The update fixed the GPIO on all variants of hardware I tested. I have never used DHT sensors with HG so you will have to fix that if it’s still broken after replacing the dll.

I have updated to the GPIO file you posted. The only pi I can’t get to work with it (that I have) is the Pi 3B+. I don’t plan on using the 3B+ with HG so not a big deal for me just thought I’d mention the issue I have noticed with it.

When I updated the code I only had access to a few boards. All of those I tested worked great with GPIO. I looked at the hardware revision list and determined that there was a subset that would not work with my fix so I have modified it such that it should work with the following too:

  • RPi 3B (1 version was missed)
  • RPi 3A+
  • RPi 3B+
  • RPi CM3+

All other versions should have already been working up and including RPi4 though I have not tested all variants of hardware. If you test the attached update and it does not work for you, run the Test.Board.exe and post the output here and perhaps I can figure out why it’s not happy.

Raspberry.System.update.20201227.zip (14.0 KB)

The GPIO Program in HG seems to work it was/is only the DHT programs that I couldn’t pull into a group to test. I suspect that was(is still) due to errors in the programs them selves.
Not sure why I can pull the DHT programs into a group on a Zero W board but that’s where I plan to use the DHT sensors anyways.
In any case I ran the Test.Board.exe and here is its output:

Raspberry Pi running on Bcm2709 processor
Firmware rev10494163, board model B3 (Raspberry Pi 3 Model B)

Serial number: 000000006fff3f2f

Not sure why it shows Raspberry Pi 3 Model B when I have the Raspberry Pi 3 Model B+ :crazy_face:

It shows the 3B because it was easier that way and it doesn’t matter. If you ran the previous version I posted it would have reported unknown.

A lot of the code examples from the old forum will need to be edited and recompiled.

Do bear this in mind when running any program snippets pre 2016.

Best to start fresh bearing in mind the results of @bkenobi investigations into the whole subject of board compatibility when it comes to GPIO and should there be any updates that do not incorporate his revisions they will need to be redone again.

@bkenobi thanks again for this it will make adding GPIO projects to HG so much easier.

@Petediscrete so true Ive had to this for a few things now. Saddly that makes a HG update to much of a pain for many. Even I hold off updating now till I’m about 3 updates behind unless there is a fix or improvement that interests me.

The last update was 6 months ago. Gene seems to have taken a sabbatical so if you aren’t up to date, you probably won’t be any time soon.

The current version is fine but there are always improvements/fixes required. Staying on 1.3.17 doesn’t fix the GPIO issue. The problem is that there is nobody to turn to in order to fix issues once identified.

1.3.19 was released to fix the backup bug in 1.3.17 so if anyone is running this version be mindful you won’t be able to make a HG config backup to the location of your choice. You’ll need to physically go looking for it on the SD card as that’s where backup is pointing to.

I have to clean some things up, but this is an image of all of my senors working happily.

The widget was pretty simple change, just modify line 155.

if (!ctx.isUnknown || parameter.Name.indexOf("Sensor.") >= 0 || parameter.Name.indexOf("Meter.") >= 0 ) {

I was planning on modifying it further to use a different icon for things like wind direction but I haven’t found an icon I like yet for the different values. I have been looking through other submitted widgets and the ones already included trying to find some images to borrow but haven’t located the right ones yet.

The other option to modifying the widget is to update the HG file that controls the default icon. I started with that, but have been waffling on whether I want to modify the widget or the base code. Gene will never update a push request at this point, so I’m not sure I want to modify anything on that side right now. If you wanted to look at what is built in, check out:

/usr/local/bin/homegenie/html/js/api/homegenie.ui.js

Yes I think active HG users are on their own here. While a lot code examples pre 2016 are a useful learning tool, in their current state most are not functional without editing.

I imagine those still using HG have heavily modified their install and users like yourself have submitted very useful revisions that have gotten GPIO back working on the RPI 2 and 3 range of boards.

As we know GPIO on the RPI 4 works “out of the box” on HG as demonstrated by @enterprised so the RPI range of boards function with GPIO again.

It would be nice to hear some feedback from the more experienced HG users on where they are at with their current installs. Remember we were told back in 2017 that HG was a finished project. That statement could be interpreted in two ways.