Connecting to PADI via GPIO

Like almost all microcontrollers, PADI has general-purpose I / O pins (GPIO). They can be used for direct connection of sensors or other actuating devices, as well as for connecting several microcontrollers to the network using various interfaces displayed on the pins.

Like almost all microcontrollers, PADI has general-purpose I / O pins (GPIO). They can be used for direct connection of sensors or other actuating devices, as well as for connecting several microcontrollers to the network using various interfaces displayed on the pins.

In this article, we will learn the pinout of the module, learn how to control the pins from the program, and then connect the DHT11 temperature and humidity sensor!

To implement the project from this article, we need the following components:

  • PADI IoT Stamp – WiFi module based on RTL8710AF
  • PADI Breadboard Adapter – Breadboard Adapter
  • DHT11 – digital temperature and humidity sensor
  • Breadboard
  • Wires kit

In total, the PADI has 17 I / O pins (from max. 21 for RTL8710), but not all the pins are used. It’s possible that we’ll be content with the existing ones.

Designation No PWM Interrupt
GA5 2
GA4 5
GC0 10 +
GC2 11 +
GC3 12 + +
GC1 13 + +
GB3 14 +
GB2 15
GA0 17 +

As you can see, at least all pins with PWM support are described, which can be useful later.

If you have ever worked with standard Arduino boards, you can relax – all operations with pins are performed in the same way! Look at the Blink example:

// the setup function runs once when you press reset or power the board
void setup() {
// initialize digital pin LED_BUILTIN as an output.

// the loop function runs over and over again forever
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second

The value is written to the pin by the command

digitalWrite (pin, state)
The state can be HIGH (then the pin will be a logical unit = module supply voltage) or LOW (then the pin will be a logical zero or voltage GND).

If you plug this sketch into the module and connect the LED to the GC1 (pin 13 according to the table), connect the second end to the ground via a 200 Ohm resistor, the LED blinks with a period of 2 seconds!

Unfortunately, there is no built-in LED on the debug board, except for the power indicator, so you always have to use 2 external components for the indication.

An example for reading a value from a pin would be a DigitalReadSerial sketch:

// digital pin 2 has a pushbutton attached to it. Give it a name:
int pushButton = 2;

// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
// make the pushbutton’s pin an input:
pinMode(pushButton, INPUT);

// the loop routine runs over and over again forever:
void loop() {
// read the input pin:
int buttonState = digitalRead(pushButton);
// print out the state of the button:
delay(1); // delay in between reads for stability

The pin voltage can be found using the digitalRead () function. Note that when reading, only two options are possible – 1 and 0, intermediate values will be rounded to the nearest of the two, this is the specificity of the operation of digital ports.

There are no analog inputs (with ADC support) in the RTL8710, so to get accurate values, you will have to connect an external ADC or a microcontroller with its support.

But after a short game with LEDs and buttons in various configurations, you quickly get tired of experimenting and you want to find out what else you can connect to the microcontroller or PADI?

So let’s try to find out something useful about the world around us – let’s connect the temperature sensor and relative humidity of the air DHT11!

We warn you that it’s a problem with measuring humidity specifically – the readings vary greatly depending on the level of interference, ambient temperature, and many other parameters.

The DHT22 sensor, also supported by the library in question, or the SI7021 will provide an incomparably better performance, but we’ll talk about it in another article.

We will use such a sensor already installed on the board for convenient connection. In this embodiment, it does not require external strapping. If you have a “bare” sensor, then you will need to install a resistor at 4.7 … 10 Com between the first and second legs of the module (Vcc and signal, respectively).

We have the same resistor that is already installed on the board and can be connected directly. The legs of the signal and the power supply minus on the board are signed, the central output is plus power.

Open the example of AmebaGPIO-> DHTtester and see the settings we need:

The 6 line indicates the pin to which the signal output of the sensor will be connected. Specify any of the available table (we used the 13th – GC1).

Line 10 indicates that the DHT22 sensor type is currently selected. Their protocols are different, you need to comment out this line and uncomment the ninth.

The final view of the sketch:

Now it can be poured into the PADI, connect the sensor and open the serial port monitor! It is enough to connect only the GND and RXD terminals of the PADI Serial Console converter (note that the RXD converter is for the TXD module, i.e., GB0). Connection speed – 38400.

First, you will see the debug information, then the data packets from the sensor:

This means that we have correctly connected to the sensor!

With the help of GPIO ports, as a result, all wired connections to the microprocessor are made, and, as you saw, it is easy to make such a connection!

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on pinterest