Inkplate 6 GPIO Expander pin detection not returning HIGH/LOW values

Customer:

I want to be able to detect on Inkplate 6 when USB power is present and when it is not. I placed a voltage divider (3.3 kOhm - 33 kOhm) between USB and GND and connected it to pin P1-7. Measurements show that when USB power is absent, P1-7 is at approximately 1V, and when USB is connected, P1-7 is at approximately 4.5V. However, I cannot get HIGH/LOW readings from this pin in my application. Do you have any idea where the error might be? Note: I put pin P1-6 in the application only to test whether I can control it from the application at all, and it is not important for this purpose.

Original message (Croatian)

Želim na Inkplate 6 bit u mogućnosti detektirati kada je USB napajanje prisutno a kada nije.
Stavio sam djelilo (3.3 kOhm - 33 kOhm) izmedju USB i GND i spojio na pin P1-7.
Mjerenje pokazuje da kada USB napona nema P1-7 tocka je na cca. 1V … kada je USB spojen P1-7 je na cca. 4.5V
Međutim ne mogu dobiti HIGH/LOW očitavanja na predmetnom pinu u aplikaciji.
Imate li možda ideju gdje je grieška?
Napomena: Pin P1-6 sam stavio u aplikaciju samo kako bih provjerio mogu li uopće upravljati sa njim iz aplikacije i nije bitan za ovu svrhu.

[name removed] Majdenić

Attachment omitted in migration: 13-05-2024 07-23-58.jpg

Attachment omitted in migration: 13-05-2024 07-22-02.jpg

Attachment omitted in migration: USBDetection.ino.ino

Originally submitted via the contact form on soldered.com on 13 May 2024. Migrated to the forum for community visibility.

Soldered Support:

The PCAL GPIO expander operates at 3V3, which means its logic levels are approximately as follows:

If USB power is absent and that point is at 1V, that is too high for the expander’s logic levels.

Try desoldering that connection, then try reading from that pin. With a wire, connect that pin to 3V3, then to GND, then to 3V3 and so on. The readings should correspond to what is connected. This can be an indicator of whether the pin works correctly.

If you cannot read from that pin, try IO expander 2, denoted in code as IO_EXT_ADDR.

To get proper voltage levels, a voltage divider with 100kohm on both sides connected to VUSB is recommended. You can then reliably read whether USB is connected or not.

For proper voltage levels on the pins, ESP32 pins can also be used for I/O. IO 12-15 are for SPI but should be free on Inkplate 6 if you don’t want to use the SPI protocol. IO34 is an interrupt for expander 1, IO35 is used for reading battery voltage (this only reads voltage; if the battery is not connected it will always read around ~4V so it cannot really be used for detection). IO36 is the pushbutton (wake button), IO39 is used for reading from the RTC. So you can use some of them depending on which functionalities you are willing to replace.

Original message (Croatian)

PCAL GPIO expander radi na 3V3, što znači da su mu logičke razine otpirlike sljedeće:

Ako USB napona nema, i ta točka je na 1V - to je previše za logičke razine expandera.

Probaj odlemiti tu konekciju, i onda probaj očitavati sa tog pina i sa žicom spoji taj pin na 3V3 pa na GND pa na 3v3 i tako dalje, očitavanja bi trebala odgovarati tomu što je spojeno - tako možeš testirati radi li pin i očitavanje kako treba. To može biti pokazatelj radi li pin dobro.

Ako ne možeš očitavati s tog pina, probaj io expander 2, u kodu označen sa IO_EXT_ADDR.

Da dobiješ OK naponske razine, moj kolega je preporučio naponski djeljitelj od 100kohm s obje strane i da to spojiš na VUSB, koji se u odnosu na padove nalazi ovdje:

Tako možeš sigurno dobro pročitati je li USB spojen ili ne. Nadam se da je ovo bilo informativno, javi ako imaš dodatnih pitanja, tu smo :slight_smile:

Attachment omitted in migration: image.png

Customer:

I tried using 3.3V / GND on pin P1-7 but I am not getting a HIGH/LOW response (the value is always 0). How are the “new” and “old” versions referenced in the examples that come with Inkplate 6, both in terms of designation and the boards themselves? Is it feasible for you to mark on the image I am attaching which pins are actually available for “Input” and how I can reference them in code (for example, take one of those pins and show what the setup and reading should look like in code)?

#define USB_DETECTION_PIN1 IO_PIN_B7

display.pinModeIO(USB_DETECTION_PIN1, INPUT, IO_INT_ADDR);

int tempVal = display.digitalReadIO(USB_DETECTION_PIN1);

What about ESP32 pins? Can they also be used for input/output? If they can be used, how do I reference them?

Original message (Croatian)

Probao sam koristiti 3.3 / GND nad pinom P1-7 medjutim ne dobivam HIGH/LOW odgovor (vrijednost je uvijek 0).
Kako se u primjerima koji dolaze uz Inkplate6 referencira na “nove” i “stare” verzije kako oznacavanja tako i samih ploca je li vam izvedivo da na slici koju prilazem oznaciti koji su pinovi zapravo dostupni za “Input” te kako ih mogu referencirati u kodu (npr. uzmite jedan od tih pinova kao primjer te navedite ako treba izgledati setup odnosno ocitavanje u kodu)

#define USB_DETECTION_PIN1 IO_PIN_B7

display.pinModeIO(USB_DETECTION_PIN1, INPUT, IO_INT_ADDR);

int tempVal = display.digitalReadIO(USB_DETECTION_PIN1);

Sto je sa pinovima ESP32 … mogu li se i oni koristiti za input/output?
Ako se mogu koristiti kako njih referenciram?

[name removed] Majdenic

Attachment omitted in migration: 14-05-2024 13-39-38.jpg

Soldered Support:

If your Inkplate works OK and the screen updates, then you have selected the correct device version through the board definition.

On the first expander, for example:
In code, P1_7 (visible on the schematic along with the others) is marked as IO_PIN_B7 on IO_INT_ADDR.
P1_3 is IO_PIN_B3 on IO_INT_ADDR.

On the second expander, for example:
P0_2 is IO_PIN_A2 on IO_EXT_ADDR.
P1_5 is IO_PIN_B5 on IO_EXT_ADDR.

The key lines of code are that in setup() you need to have, for example:
display.pinModeIO(IO_PIN_A2 , OUTPUT, IO_EXT_ADDR);

and then in the loop you can:
display.digitalWriteIO(IO_PIN_A2 , HIGH, IO_EXT_ADDR);

For now, try just writing to an LED (put a resistor on the LED so it doesn’t burn out :slight_smile: ) with that simplest example (https://github.com/SolderedElectronics/Inkplate-Arduino-library/blob/master/examples/Inkplate6/Advanced/IO/Inkplate6_Internal_IO_Expander/Inkplate6_Internal_IO_Expander.ino )

Then try with reading. I think the IO expanders should work well because updating the ePaper depends on them.

P1_3 through P1_7 are free on the first expander, and all are free on the second expander.

ESP32 pins can be used for I/O. IO 12-15 are for SPI but as far as I can see they should be free on Inkplate 6 if you don’t want to use the SPI protocol. IO34 is an interrupt for expander 1, IO35 is used for reading battery voltage (this only reads voltage; if the battery is not connected it will always read around ~4V so it cannot really be used for detection). IO36 is the pushbutton (wake button), IO39 is used for reading from the RTC. So you can use some of them depending on which functionalities you are willing to replace.

Original message (Croatian)

Ako ti Inkplate radi OK i ekran se update-a, onda si izabrao dobru verziju uređaja kroz board definition. Šaljem ti screenshot sa sheme Inkplate 6:

Kao što vidiš, P1_3 do P1_7 su slobodni na prvom expanderu, i svi su slobodni na drugom ekspanderu.

Na prvom ekspanderu, npr:
U kodu je P1_7 (vidljivo na slici kao i ostali) označen sa IO_PIN_B7 na IO_INT_ADDR.
P1_3 je IO_PIN_B3 na IO_INT_ADDR.

Na drugom, npr:
P0_2 je IO_PIN_A2 na IO_EXT_ADDR.
P1_5 je IO_PIN_B5 na IO_EXT_ADDR.

Linije koda koje su ključne je da u setup() trebaš imati npr:
display.pinModeIO(IO_PIN_A2 , OUTPUT, IO_EXT_ADDR);

i onda u loopu možeš:
display.digitalWriteIO(IO_PIN_A2 , HIGH, IO_EXT_ADDR);

Probaj zasad samo pisati na LEDicu (stavi otpornik na LEDicu da ne pregori :slight_smile: ) zasad sa tim najjednostavnijim primjerom (https://github.com/SolderedElectronics/Inkplate-Arduino-library/blob/master/examples/Inkplate6/Advanced/IO/Inkplate6_Internal_IO_Expander/Inkplate6_Internal_IO_Expander.ino )

Pa onda probaj sa čitanjem. Mislim da bi IO ekspanderi trebali raditi dobro jer update-anje ePapera ovisi o njima.

Pinovi od ESP32 se mogu koristiti za I/O, IO 12-15 su za SPI ali koliko vidim trebali bi biti slobodni na Inkplate6 ako ne želiš koristiti SPI protokol. IO34 je interrupt za expander 1, IO35 se koristi za čitanje napona s baterije (ovo samo čita količinu napona, ako baterija nije spojena uvijek će čitati oko ~4V tako da se ne može baš koristiti za detekciju). IO36 je pushbutton (wake button), IO39 se koristi za čitanje s RTC-a. Tako da, možeš koristiti neke od njih ovisno o tom koje funkcionalnosti si spreman zamijeniti.

Nadam se da je ovo bilo informativno :slight_smile:

Attachment omitted in migration: image.png