AAIMI GPIO is a web-based control interface for the Raspberry Pi and Arduino. Check out the tutorials below.
Using AAIMI GPIO
23rd November 2017
In the previous article we prepared the Pi and set up our program files. Now lets configure some pins and start using them.
Shut down the Raspberry Pi in the On/Off tab, and connect some stuff to your GPIO pins. In these tutorials I plan to cover LEDs, PIR sensors and motors, so if you have any of those you can follow along.
Power on the Pi and start the AAIMI GPIO program as described in the previous article.
We'll start with some Raspi examples then finish on the Arduino.
I have the positive wire of a LED connected to GPIO4 and the negative wire to GND via a current-limiting. resistor
Click on the pin you wish to configure and you'll see the current setting and status of the pin. In this case I'll select GPIO4 and press the Change Setting button.
The initial pin form will load.
Give the pin a descriptive name, then choose a pin type. I'll call this pin Light1.
To keep the first example simple I'll define a standard output to switch a LED. Click Next.
In the next section you can choose the default state for the pin, Low or High. At the moment the High option will only work for manually operated pins, not timed or timer switched pins.
You can choose to manually switch the pin High or Low. This setting will also allow the pin to switch in response to input pin changes.
If you want the pin to switch on a schedule, select On/Off on timer. You can then enter On and Off times for the pin.
If you want the pin to switch Low a set time after it is activated, select Off on timeout, then enter a timeout in seconds.
I'll cover the timer and timeout options later. For now we'll select Manually switch on and off. Click Finish and you'll see a summary of your new settings.
Click Back to return to the main window. You'll see that the pin button has changed to the default output color.
Now click the Run tab at the top of the screen and you'll be taken to the Run page.
You'll see your new pin along with its current settings. Any pins you have set will show here.
Click the pin and the control buttons will appear. If you click On, the pin will go High and your light will switch on.
The border will change to red to represent the High state.
There is our output, lets set up an input.
For the next example I have a PIR movement sensor connected to GPIO17.
Once again, I'll click on the GPIO17 button and select Change settings.
You can choose standard input, or input with pull up or pull down resistors.
You can use pull-down resistors with PIRs, but I prefer to set them as standard inputs because it provides a level of tamper-proofing. If someone cuts the signal cable the voltage will float and send the pin High and Low randomly and trigger an event.
Choose the event trigger for the input. Should the system react when the pin goes High or Low? PIR sensors stay Low, then switch High when they sense motion, so I'll select High as the trigger.
Next you can select what happens when the input pin triggers. You can choose to switch an output pin on to activate another device. You can count the input events, or receive an Email. The HTTP request option allows you to send event details to a website.
I'll cover the other options in later articles, for this example I'm going to use this input to switch an output pin on. I'll use the output pin we created earlier, GPIO4
Under Choose when this applies, you can choose whether the action occurs all the time, or just within certain times. For example you could use this timing feature to create a motion-sensing night-light that only switches on outside daylight hours. To keep things simple I'm selecting Always.
Under 'Choose how long to leave the output set' you can choose Indefinately to keep the output on, or set a timeout to switch it off either after the initial input event or after the input has returned to, and stayed Low.
I'm choosing to leave the output High for 30 seconds after the input pin stays Low.
Once again you'll see a summary of the new settings. Click Back and the GPIO17 button should be the default Input color.
Now you can head back to the Run tab and you'll see your PIR sensor underneath the light on GPIO4.
Stroll past the PIR sensor and your LED will switch on, and the borders for each pin will turn red.
The PIR will stay High for a few seconds then return to Low. Thirty seconds after that the LED will switch off.
The Arduino pins work different to the Raspberry Pi in that they each have reserved settings for input, outputs and analog pins. This is because the pins are defined as soon as the Arduino powers on and there is currently no way to change them.
Pins D11 and D12 are reserved inputs. You won't see the drop-down menu for the input/output setting. It will be automatically configured as an input.
The rest of the digital pins are reserved outputs, and all of the analog-to-digital pins are reserved analog inputs.
The Arduino currently lacks PWM motor and LED control, once again because the sketch we are using has no reserved pins for PWM. In coming weeks I'll mod the sketch to use four of the digital output pins for PWM to control two DC motors or four dimmable LEDs.
The reason I want PWM on the Arduino is it runs 5v IO pins, meaning it can fire 5V transistors and MOSFETs that would require extra equipment to run on a Raspberry PI with its 3.3V GPIO pins.
I think I'll also convert a couple more of the existing Arduino digital outputs to reserved inputs. This would give an even balance of inputs, analog inputs, digital outputs and PWM outputs.
There is also a relay powering an electric fan connected to D3. I haven't included the relay wiring in the diagram. If you are new to relays you can learn about them in our relay tutorial.There you'll also find links to our other relay tutorials about salvaging relays from old televisions and using them with your Raspberry Pi.
You can set your D3 output the same way we did with the Raspi outputs earlier. The only difference is not having to select a pin type, because D3 is a reserved output.
To set up the analog input on A1, click on the A1 button and click Change settings. Give the sensor a name and click Next. The analog input form will load.
These temperature sensors receive 5V and return a voltage reading dependant on the temperature. The warmer the temperature the higher the voltage returned. I won't go into the formula I use to convert this to degrees because it's all covered in the temperature sensor tutorial mention above.
Basically my sensors read 2V about 23 degrees celsius, and I'm going to set that as my trigger point to switch on the fan.
Because they go up with the temperature, choose Low in the High or Low menu, and enter your desired trigger point.
As before, select Switch an output on, but this time, add 100 to the output pin number. This tells the program you wish to use an Arduino output instead of a raspberry Pi outlet. In this case I enter 103 to represent D3.
Select 'Set time after pin returns to normal', and enter zero in the 'Choose how long to leave the output set' field.
Click next, and you are done.
From now on, any time the temperature gets to 23 degress, the fan will switch on, and stay on until the temperature drops back below 23. You can monitor it in the Run tab.
As you can see, it's pretty cold in Aus at the moment, and the fan is unlikely to switch on today, but that's okay. Summer is on the way, and I can save this pin configuration for when I need it, and move onto another pin configuration for now.