Component: API (ESP32) (API Slave Devices): Difference between revisions
No edit summary |
m Text replacement - "style="background-color:#EAE1EA;"" to "class="mtx-class-propfolder"" |
||
| (9 intermediate revisions by 3 users not shown) | |||
| Line 17: | Line 17: | ||
==Component Source Code== | ==Component Source Code== | ||
Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/ | Please click here to download the component source project: [https://www.flowcode.co.uk/wiki/componentsource/FC_Comp_Source_ESP32_API_Comp.fcfx FC_Comp_Source_ESP32_API_Comp.fcfx] | ||
Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/ | Please click here to view the component source code (Beta): [https://www.flowcode.co.uk/FlowchartView/?wfile=componentsource/FC_Comp_Source_ESP32_API_Comp.fcfx FC_Comp_Source_ESP32_API_Comp.fcfx] | ||
==Detailed description== | ==Detailed description== | ||
| Line 110: | Line 110: | ||
|4 | |4 | ||
|5 | |5 | ||
|12 | |12 | ||
|13 | |13 | ||
| Line 144: | Line 138: | ||
|A4 | |A4 | ||
|A5 | |A5 | ||
|A12 | |A12 | ||
|A13 | |A13 | ||
| Line 178: | Line 166: | ||
|4 | |4 | ||
|5 | |5 | ||
|12 | |12 | ||
|13 | |13 | ||
| Line 241: | Line 223: | ||
<span style="color:red">Please note that PWM channels are tied in pairs and so channel 0 and 1 use the same internal timer peripheral. They will always run at the same frequency and when enabling channel 1 channel 0 duty will be reset to 0% and visa versa.</span> | <span style="color:red">Please note that PWM channels are tied in pairs and so channel 0 and 1 use the same internal timer peripheral. They will always run at the same frequency and when enabling channel 1 channel 0 duty will be reset to 0% and visa versa.</span> | ||
{| class="wikitable" | {| class="wikitable" | ||
| Line 277: | Line 260: | ||
|A15 | |A15 | ||
|A14 | |A14 | ||
| | |A13 | ||
| | |A12 | ||
| | |A14 | ||
| | |A23 | ||
| | |A19 | ||
| | |A18 | ||
|A26 | |A26 | ||
|A25 | |A25 | ||
| Line 306: | Line 289: | ||
|15 | |15 | ||
|14 | |14 | ||
| | |13 | ||
| | |12 | ||
| | |14 | ||
| | |23 | ||
| | |19 | ||
| | |18 | ||
|26 | |26 | ||
|25 | |25 | ||
| Line 335: | Line 318: | ||
PortB = GPIO pins 32 - 39 : B0 = GPIO 32 | PortB = GPIO pins 32 - 39 : B0 = GPIO 32 | ||
==Macro reference== | ==Macro reference== | ||
===ADCSample10=== | ===ADCSample10=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSample10''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 12-bit value range 0-4095 | | colspan="2" | Reads the voltage present on an Analog pin as an 12-bit value range 0-4095 | ||
| Line 364: | Line 341: | ||
===ADCSample8=== | ===ADCSample8=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSample8''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | | colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | ||
| Line 383: | Line 360: | ||
===ADCSampleArray10=== | ===ADCSampleArray10=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSampleArray10''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet | | colspan="2" | Reads the voltage present on an Analog pin as an 10-bit value range 0-1023 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet | ||
| Line 417: | Line 394: | ||
===ADCSampleArray8=== | ===ADCSampleArray8=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSampleArray8''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet | | colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples and returns each sample in a single packet | ||
| Line 451: | Line 428: | ||
===ADCSampleAverage10=== | ===ADCSampleAverage10=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSampleAverage10''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 10-bit value range 0-1023. Performs the selected number of samples with the selected time in microseconds in between samples | | colspan="2" | Reads the voltage present on an Analog pin as an 10-bit value range 0-1023. Performs the selected number of samples with the selected time in microseconds in between samples | ||
| Line 480: | Line 457: | ||
===ADCSampleAverage8=== | ===ADCSampleAverage8=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSampleAverage8''' | ||
|- | |- | ||
| colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples | | colspan="2" | Reads the voltage present on an Analog pin as an 8-bit value range 0-255 Performs the selected number of samples with the selected time in microseconds in between samples | ||
| Line 509: | Line 486: | ||
===ADCSetPrechargeTime=== | ===ADCSetPrechargeTime=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSetPrechargeTime''' | ||
|- | |- | ||
| colspan="2" | Specifies the precharge time for the ADC input readings in microseconds. The longer the time the more immune to noise the reading will be. | | colspan="2" | Specifies the precharge time for the ADC input readings in microseconds. The longer the time the more immune to noise the reading will be. | ||
| Line 528: | Line 505: | ||
===ADCSetReferenceVoltage=== | ===ADCSetReferenceVoltage=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''ADCSetReferenceVoltage''' | ||
|- | |- | ||
| colspan="2" | Specified the reference setting for ADC reads. | | colspan="2" | Specified the reference setting for ADC reads. | ||
| Line 547: | Line 524: | ||
===I2CInitialise=== | ===I2CInitialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CInitialise''' | ||
|- | |- | ||
| colspan="2" | Initialise the I2C module ready for communications | | colspan="2" | Initialise the I2C module ready for communications | ||
| Line 571: | Line 548: | ||
===I2CReceive=== | ===I2CReceive=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CReceive''' | ||
|- | |- | ||
| colspan="2" | Receive a byte using the I2C bus | | colspan="2" | Receive a byte using the I2C bus | ||
| Line 595: | Line 572: | ||
===I2CRestart=== | ===I2CRestart=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CRestart''' | ||
|- | |- | ||
| colspan="2" | Put the I2C Module into Restart mode | | colspan="2" | Put the I2C Module into Restart mode | ||
| Line 614: | Line 591: | ||
===I2CSend=== | ===I2CSend=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CSend''' | ||
|- | |- | ||
| colspan="2" | Transmit a byte using the I2C bus | | colspan="2" | Transmit a byte using the I2C bus | ||
| Line 638: | Line 615: | ||
===I2CStart=== | ===I2CStart=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CStart''' | ||
|- | |- | ||
| colspan="2" | Put the I2C Module into Start mode | | colspan="2" | Put the I2C Module into Start mode | ||
| Line 657: | Line 634: | ||
===I2CStop=== | ===I2CStop=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CStop''' | ||
|- | |- | ||
| colspan="2" | Put the I2C Module into Stop mode | | colspan="2" | Put the I2C Module into Stop mode | ||
| Line 676: | Line 653: | ||
===I2CTransInit=== | ===I2CTransInit=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CTransInit''' | ||
|- | |- | ||
| colspan="2" | Initialises the I2C Transaction mode with the 7-bit device address | | colspan="2" | Initialises the I2C Transaction mode with the 7-bit device address | ||
| Line 705: | Line 682: | ||
===I2CTransReceive=== | ===I2CTransReceive=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CTransReceive''' | ||
|- | |- | ||
| colspan="2" | Receives an I2C Transaction on the selected I2C channel. Returns the number of bytes received. | | colspan="2" | Receives an I2C Transaction on the selected I2C channel. Returns the number of bytes received. | ||
| Line 734: | Line 711: | ||
===I2CTransSend=== | ===I2CTransSend=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''I2CTransSend''' | ||
|- | |- | ||
| colspan="2" | Sends an I2C Transaction on the selected I2C channel. Returns the number of bytes sent. | | colspan="2" | Sends an I2C Transaction on the selected I2C channel. Returns the number of bytes sent. | ||
| Line 763: | Line 740: | ||
===IOGetInputPin=== | ===IOGetInputPin=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''IOGetInputPin''' | ||
|- | |- | ||
| colspan="2" | Sets the selected digital pin to an input and reads the input state. | | colspan="2" | Sets the selected digital pin to an input and reads the input state. | ||
| Line 782: | Line 759: | ||
===IOSetOutputPin=== | ===IOSetOutputPin=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''IOSetOutputPin''' | ||
|- | |- | ||
| colspan="2" | Sets the selected digital pin to an output and assigns the output state. | | colspan="2" | Sets the selected digital pin to an output and assigns the output state. | ||
| Line 806: | Line 783: | ||
===Initialise=== | ===Initialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Initialise''' | ||
|- | |- | ||
| colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. | | colspan="2" | Initialise the comms to the Arduino board ready for commands to be sent. | ||
| Line 820: | Line 797: | ||
===OneWireBusReset=== | ===OneWireBusReset=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireBusReset''' | ||
|- | |- | ||
| colspan="2" | Issue a 'ping' on the bus. If there is at least one sensor on the bus then it will generate a presence pulse. Returns 0 if a presense pulse was detected Returns 1 no device was detected | | colspan="2" | Issue a 'ping' on the bus. If there is at least one sensor on the bus then it will generate a presence pulse. Returns 0 if a presense pulse was detected Returns 1 no device was detected | ||
| Line 839: | Line 816: | ||
===OneWireGetDeviceCount=== | ===OneWireGetDeviceCount=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireGetDeviceCount''' | ||
|- | |- | ||
| colspan="2" | Returns the number of devices found by the last ScanBus operation. | | colspan="2" | Returns the number of devices found by the last ScanBus operation. | ||
| Line 858: | Line 835: | ||
===OneWireGetIDByte=== | ===OneWireGetIDByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireGetIDByte''' | ||
|- | |- | ||
| colspan="2" | Returns a single byte of the 64-Bit lasered ROM code, 255 on error | | colspan="2" | Returns a single byte of the 64-Bit lasered ROM code, 255 on error | ||
| Line 887: | Line 864: | ||
===OneWireInitialise=== | ===OneWireInitialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireInitialise''' | ||
|- | |- | ||
| colspan="2" | Initialise the OneWire module ready for communications | | colspan="2" | Initialise the OneWire module ready for communications | ||
| Line 906: | Line 883: | ||
===OneWireMatchROM=== | ===OneWireMatchROM=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireMatchROM''' | ||
|- | |- | ||
| colspan="2" | Performs a reset followed by the MatchROM code and then the 8-bit ROM code. | | colspan="2" | Performs a reset followed by the MatchROM code and then the 8-bit ROM code. | ||
| Line 935: | Line 912: | ||
===OneWireReceiveByte=== | ===OneWireReceiveByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireReceiveByte''' | ||
|- | |- | ||
| colspan="2" | Receives a byte from the one wire bus a bit at a time | | colspan="2" | Receives a byte from the one wire bus a bit at a time | ||
| Line 954: | Line 931: | ||
===OneWireScanBus=== | ===OneWireScanBus=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireScanBus''' | ||
|- | |- | ||
| colspan="2" | Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. | | colspan="2" | Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. | ||
| Line 973: | Line 950: | ||
===OneWireSkipROM=== | ===OneWireSkipROM=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireSkipROM''' | ||
|- | |- | ||
| colspan="2" | Performs a bus reset and the sends the SkipROM command byte | | colspan="2" | Performs a bus reset and the sends the SkipROM command byte | ||
| Line 992: | Line 969: | ||
===OneWireTransmitByte=== | ===OneWireTransmitByte=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''OneWireTransmitByte''' | ||
|- | |- | ||
| colspan="2" | Transmit a byte to the one wire bus a bit at a time | | colspan="2" | Transmit a byte to the one wire bus a bit at a time | ||
| Line 1,016: | Line 993: | ||
===PWMDisable=== | ===PWMDisable=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''PWMDisable''' | ||
|- | |- | ||
| colspan="2" | Disable a PWM output | | colspan="2" | Disable a PWM output | ||
| Line 1,035: | Line 1,012: | ||
===PWMEnable=== | ===PWMEnable=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''PWMEnable''' | ||
|- | |- | ||
| colspan="2" | Enable a PWM output | | colspan="2" | Enable a PWM output | ||
| Line 1,054: | Line 1,031: | ||
===PWMSetDuty=== | ===PWMSetDuty=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''PWMSetDuty''' | ||
|- | |- | ||
| colspan="2" | Sets the duty for the PWM output | | colspan="2" | Sets the duty for the PWM output | ||
| Line 1,078: | Line 1,055: | ||
===PWMSetFrequency=== | ===PWMSetFrequency=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''PWMSetFrequency''' | ||
|- | |- | ||
| colspan="2" | Sets PWM frequency in Hz | | colspan="2" | Sets PWM frequency in Hz | ||
| Line 1,102: | Line 1,079: | ||
===SPIInitialise=== | ===SPIInitialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SPIInitialise''' | ||
|- | |- | ||
| colspan="2" | Initialsie the SPI module ready for communications | | colspan="2" | Initialsie the SPI module ready for communications | ||
| Line 1,121: | Line 1,098: | ||
===SPIPrescaler=== | ===SPIPrescaler=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SPIPrescaler''' | ||
|- | |- | ||
| colspan="2" | Modify the speed of the SPI bus | | colspan="2" | Modify the speed of the SPI bus | ||
| Line 1,145: | Line 1,122: | ||
===SPITransfer=== | ===SPITransfer=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SPITransfer''' | ||
|- | |- | ||
| colspan="2" | Transfer a byte using the SPI bus | | colspan="2" | Transfer a byte using the SPI bus | ||
| Line 1,169: | Line 1,146: | ||
===SPITransferTrans=== | ===SPITransferTrans=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''SPITransferTrans''' | ||
|- | |- | ||
| colspan="2" | Transfer an array of bytes using the SPI bus | | colspan="2" | Transfer an array of bytes using the SPI bus | ||
| Line 1,203: | Line 1,180: | ||
===UARTBaud=== | ===UARTBaud=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''UARTBaud''' | ||
|- | |- | ||
| colspan="2" | Control the communications rate of the UART module | | colspan="2" | Control the communications rate of the UART module | ||
| Line 1,227: | Line 1,204: | ||
===UARTCheckRX=== | ===UARTCheckRX=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''UARTCheckRX''' | ||
|- | |- | ||
| colspan="2" | Check to see if the UART module has received any data | | colspan="2" | Check to see if the UART module has received any data | ||
| Line 1,246: | Line 1,223: | ||
===UARTInitialise=== | ===UARTInitialise=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''UARTInitialise''' | ||
|- | |- | ||
| colspan="2" | Initialise the UART module ready for communications | | colspan="2" | Initialise the UART module ready for communications | ||
| Line 1,265: | Line 1,242: | ||
===UARTReceive=== | ===UARTReceive=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''UARTReceive''' | ||
|- | |- | ||
| colspan="2" | Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | | colspan="2" | Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | ||
| Line 1,284: | Line 1,261: | ||
===UARTSend=== | ===UARTSend=== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-comp-macro.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''UARTSend''' | ||
|- | |- | ||
| colspan="2" | Send a byte via the UART module | | colspan="2" | Send a byte via the UART module | ||
| Line 1,305: | Line 1,282: | ||
| width="90%" style="border-top: 2px solid #000;" | ''Return'' | | width="90%" style="border-top: 2px solid #000;" | ''Return'' | ||
|} | |} | ||
==Property reference== | ==Property reference== | ||
{| class="wikitable | {| class="mtx-class-macrotable wikitable" | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-macrohead" | [[File:Fc9-prop-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-macrohead" | '''Properties''' | ||
|- | |- | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Connection | ||
|- | |- | ||
|- | |- | ||
| Line 1,341: | Line 1,316: | ||
| colspan="2" | IP Address of the selected network interface. | | colspan="2" | IP Address of the selected network interface. | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | API Peripherals | ||
|- | |- | ||
|- | |- | ||
| Line 1,390: | Line 1,365: | ||
| colspan="2" | | | colspan="2" | | ||
|- | |- | ||
| width="10%" align="center" | | width="10%" align="center" class="mtx-class-propfolder" | [[File:Fc9-conn-icon.png]] | ||
| width="90%" | | width="90%" class="mtx-class-propfolder" | Console | ||
|- | |- | ||
|- | |- | ||
Latest revision as of 14:36, 13 July 2026
| Author | Matrix TSL |
| Version | 2.0 |
| Category | API Slave Devices |
API (ESP32) component
Connects to an ESP32 device running the API Firmware allowing the board to become a slave to the Flowcode Embedded simulation or Flowcode App Developer. Supports: Digital IO / ADC / I2C / SPI / PWM / UART See Flowcode Help Wiki for firmware.
Component Source Code
Please click here to download the component source project: FC_Comp_Source_ESP32_API_Comp.fcfx
Please click here to view the component source code (Beta): FC_Comp_Source_ESP32_API_Comp.fcfx
Detailed description
The App Developer (ESP32) component allows an ESP32 board to be controlled from within the Flowcode simulation runtime.
To allow Flowcode to communicate and control the ESP32 hardware the board must first be pre-programmed with dedicated firmware.
The firmware source project can be downloaded from here.
You will need to set your WIFI SSID and Password near the top of Main to allow the ESP module to connect to your network.
More information about the workings of the firmware project can be found on the FiniteStateMachine page.
The IP Address to the ESP32 hardware is selected via the SCADA_ESP32 component IP Address property.
When building the component into a App Developer project remember to expose the IP Address property to allow the end user to select the address for the hardware.
The console window can display data in two modes which is set via a component property.
- fixed statistics showing IO / ADC inputs / PWM
- scrolling log showing all commands and returns
Examples
Pin Mapping
Here is a table showing how the App Developer Slave digital pins are mapped on the device.
Please note pins 34, 35, 36, 39 are only capable of digital inputs and cannot be used as digital outputs.
| App Developer Slave Digital Pin | 0 | 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | 39 |
| Device Port Pin | A0 | A1 | A2 | A3 | A4 | A5 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | A21 | A22 | A23 | A25 | A26 | A27 | B0 | B1 | B2 | B3 | B4 | B7 |
| GPIO Number | 0 | 1 | 2 | 3 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 | 22 | 23 | 25 | 26 | 27 | 32 | 33 | 34 | 35 | 36 | 39 |
Here is a table showing how the App Developer Slave analogue pins are mapped on the device.
Please note not all analogue input pins are available as peripheral ADC2 is not accesible when WIFI/Bluetooth is active. Only the pins shown are available.
| App Developer Slave Analogue Pin | 0 | 3 | 4 | 5 | 6 | 7 |
| Device Port Pin | B4 | B7 | B0 | B1 | B2 | B3 |
| GPIO Number | 36 | 39 | 32 | 33 | 34 | 35 |
Here is a table showing how the App Developer Slave peripheral pins are mapped on the device.
Please note that PWM channels are tied in pairs and so channel 0 and 1 use the same internal timer peripheral. They will always run at the same frequency and when enabling channel 1 channel 0 duty will be reset to 0% and visa versa.
| App Developer Slave Peripheral Pin | I2C 0 SDA | I2C 0 SCL | I2C 1 SDA | I2C 1 SCL | SPI 0 MOSI | SPI 0 MISO | SPI 0 SCK | SPI 1 MOSI | SPI 1 MISO | SPI 1 SCK | UART 0 RX | UART 0 TX | UART 1 RX | UART 1 TX | PWM 0 | PWM 1 | PWM 2 | PWM 3 | PWM 4 | PWM 5 | PWM 6 | PWM 7 | PWM 8 | PWM 9 | PWM 10 | PWM 11 | OneWire |
| Device Port Pin | A13 | A12 | A15 | A14 | A13 | A12 | A14 | A23 | A19 | A18 | A26 | A25 | B0 | B1 | A0 | A2 | A4 | A5 | A12 | A13 | A14 | A15 | A16 | A17 | A18 | A19 | A21 |
| GPIO Number | 13 | 12 | 15 | 14 | 13 | 12 | 14 | 23 | 19 | 18 | 26 | 25 | 32 | 33 | 0 | 2 | 4 | 5 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 21 |
PortA = GPIO pins 0 - 31 : A0 = GPIO 0
PortB = GPIO pins 32 - 39 : B0 = GPIO 32
Macro reference
ADCSample10
| ADCSample10 | |
| Reads the voltage present on an Analog pin as an 12-bit value range 0-4095 | |
| ADCChannel | |
| Range: 0, 3-7 | |
| Return | |
ADCSample8
| ADCSample8 | |
| Reads the voltage present on an Analog pin as an 8-bit value range 0-255 | |
| ADCChannel | |
| Range: 0, 3-7 | |
| Return | |
ADCSampleArray10
ADCSampleArray8
ADCSampleAverage10
ADCSampleAverage8
ADCSetPrechargeTime
ADCSetReferenceVoltage
| ADCSetReferenceVoltage | |
| Specified the reference setting for ADC reads. | |
| RefType | |
| 0=AREF, 1=VCC, 3=Internal 1.1V | |
| Return | |
I2CInitialise
| I2CInitialise | |
| Initialise the I2C module ready for communications | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Baud | |
| 0=100KHz, 1=400KHz, 2=1MHz | |
| Return | |
I2CReceive
| I2CReceive | |
| Receive a byte using the I2C bus | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Last | |
| Last byte to receive: Range 0-1 | |
| Return | |
I2CRestart
| I2CRestart | |
| Put the I2C Module into Restart mode | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
I2CSend
| I2CSend | |
| Transmit a byte using the I2C bus | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| DataOut | |
| Return | |
I2CStart
| I2CStart | |
| Put the I2C Module into Start mode | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
I2CStop
| I2CStop | |
| Put the I2C Module into Stop mode | |
| Channel | |
| Return | |
I2CTransInit
I2CTransReceive
I2CTransSend
IOGetInputPin
| IOGetInputPin | |
| Sets the selected digital pin to an input and reads the input state. | |
| Pin | |
| Range: 0-29 | |
| Return | |
IOSetOutputPin
| IOSetOutputPin | |
| Sets the selected digital pin to an output and assigns the output state. | |
| Pin | |
| Range: 0-29 | |
| State | |
| Range: 0-1 | |
| Return | |
Initialise
| Initialise | |
| Initialise the comms to the Arduino board ready for commands to be sent. | |
| Return | |
OneWireBusReset
OneWireGetDeviceCount
| OneWireGetDeviceCount | |
| Returns the number of devices found by the last ScanBus operation. | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
OneWireGetIDByte
OneWireInitialise
| OneWireInitialise | |
| Initialise the OneWire module ready for communications | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
OneWireMatchROM
OneWireReceiveByte
| OneWireReceiveByte | |
| Receives a byte from the one wire bus a bit at a time | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
OneWireScanBus
| OneWireScanBus | |
| Scans the one wire bus to detect all connected devices. Returns the number of one wire devices found. | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
OneWireSkipROM
| OneWireSkipROM | |
| Performs a bus reset and the sends the SkipROM command byte | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Return | |
OneWireTransmitByte
| OneWireTransmitByte | |
| Transmit a byte to the one wire bus a bit at a time | |
| Channel | |
| Channel Index: Range 0 - I2C Bus Count - 1 | |
| Data | |
| Return | |
PWMDisable
| PWMDisable | |
| Disable a PWM output | |
| Channel | |
| Range: 0-11 | |
| Return | |
PWMEnable
| PWMEnable | |
| Enable a PWM output | |
| Channel | |
| Range: 0-11 | |
| Return | |
PWMSetDuty
| PWMSetDuty | |
| Sets the duty for the PWM output | |
| Channel | |
| Range: 0-11 | |
| Duty | |
| Return | |
PWMSetFrequency
| PWMSetFrequency | |
| Sets PWM frequency in Hz | |
| Channel | |
| Range: 0 - 11 | |
| Frequency | |
| Frequency (Hz) | |
| Return | |
SPIInitialise
| SPIInitialise | |
| Initialsie the SPI module ready for communications | |
| Channel | |
| Channel Index: Range 0 - SPI Bus Count - 1 | |
| Return | |
SPIPrescaler
| SPIPrescaler | |
| Modify the speed of the SPI bus | |
| Channel | |
| Channel Index: Range 0 - SPI Bus Count - 1 | |
| Prescaler | |
| Range: 0-2 | |
| Return | |
SPITransfer
| SPITransfer | |
| Transfer a byte using the SPI bus | |
| Channel | |
| Channel Index: Range 0 - SPI Bus Count - 1 | |
| DataOut | |
| Return | |
SPITransferTrans
UARTBaud
UARTCheckRX
| UARTCheckRX | |
| Check to see if the UART module has received any data | |
| Channel | |
| Channel Index: Range 0 - UART Bus Count - 1 | |
| Return | |
UARTInitialise
| UARTInitialise | |
| Initialise the UART module ready for communications | |
| Channel | |
| Channel Index: Range 0 - UART Bus Count - 1 | |
| Return | |
UARTReceive
| UARTReceive | |
| Receives a data byte from the UART. Recommend calling the UARTCheckRx function first to ensure data is available. | |
| Channel | |
| Channel Index: Range 0 - UART Bus Count - 1 | |
| Return | |
UARTSend
| UARTSend | |
| Send a byte via the UART module | |
| Channel | |
| Channel Index: Range 0 - UART Bus Count - 1 | |
| Data | |
| Data Byte to send. Range: 0-255 | |
| Return | |