I tried your guideline on a TH02 temperature/humidity high accuracy sensor from Seeedstudio, using
this code. The sketch runs in the Arduino IDE, and I tried to translate it into Embrio. It compiled (after a few tries, ;-) ) without errors, yet nothing appears on the outputs.
What am I doing wrong?
The generated node is below:
<Nodes>
<Node>
<UniqueID>7eecc49d-7ed1-4ae3-add0-f48df17957cd</UniqueID>
<AssemblyType>Embrio.NodeEngine.AgentController.Nodes.AgentControllerCustomArduinoNode</AssemblyType>
<NodeType>Custom Arduino Node</NodeType>
<UserDefinedName></UserDefinedName>
<Description>A node that lets you write any Arduino code to interact with the Arduino hardware. Can be both an input and output.</Description>
<NodeColor>201,204,227,255</NodeColor>
<X>0</X>
<Y>0</Y>
<Width>834</Width>
<IncludeCode>#include <arduino.h>
#include <TH02.h>
#include <I2C.h></IncludeCode>
<DeclerationCode>// Instantiate TH02 sensor
TH02 sensor;
uint8_t devID;
int16_t temp, rh, rh_comp;</DeclerationCode>
<SetupCode>I2c.begin();
I2c.pullup(true); // Enable I2C Internal pullup
I2c.setSpeed(1); // Set I2C to 400Khz
// TH02 ID is 4 MSB
devID = sensor.getId() >> 4;</SetupCode>
<ImageName>arduino.png</ImageName>
<InfoURL></InfoURL>
<CodeDefinitions>
<CodeDefinition>
<UpdateCondition>EveryUpdate</UpdateCondition>
<Code>// Get temperature calculated
sensor.startTempConv();
sensor.waitEndConversion();
temp = sensor.getConversionValue();
Output_Temperature = sensor.getLastRawTemp()/100.0 ;
// Convert humidity
sensor.startRHConv();
sensor.waitEndConversion();
rh = sensor.getConversionValue();
Output_Raw_Humidity = sensor.getLastRawRH()/100.0 ;
Output_Compensated_Humidity = sensor.getConpensatedRH(0)/100.0 ;</Code>
<UniqueID>15dc4bee-78ba-47ce-9c50-6742589a1376</UniqueID>
</CodeDefinition>
</CodeDefinitions>
<Inputs></Inputs>
<Outputs>
<Output>
<UniqueID>47956206-4569-4151-bafe-eddbc6bc597d</UniqueID>
<DefinitionID>00000000-0000-0000-0000-000000000000</DefinitionID>
<DefaultName>Activation</DefaultName>
<CustomName>Temperature</CustomName>
<IsDisplayed>True</IsDisplayed>
<IsNative>False</IsNative>
<TypeName>Numeric</TypeName>
<IsOutsideConnection>False</IsOutsideConnection>
<IOType>Embrio.NodeEngine.NodeIO.NumericNodeOutput</IOType>
<ShowGraph>True</ShowGraph>
<LinkedIOID>00000000-0000-0000-0000-000000000000</LinkedIOID>
<IsUserAdded>True</IsUserAdded>
<MinValue>0</MinValue>
<MaxValue>1</MaxValue>
<UseNegativeRange>False</UseNegativeRange>
<CanUseNegativeRange>True</CanUseNegativeRange>
</Output>
<Output>
<UniqueID>01ffcd6a-2426-41eb-90fe-fee04e14a4ec</UniqueID>
<DefinitionID>00000000-0000-0000-0000-000000000000</DefinitionID>
<DefaultName>Activation 1</DefaultName>
<CustomName>Raw_Humidity</CustomName>
<IsDisplayed>True</IsDisplayed>
<IsNative>False</IsNative>
<TypeName>Numeric</TypeName>
<IsOutsideConnection>False</IsOutsideConnection>
<IOType>Embrio.NodeEngine.NodeIO.NumericNodeOutput</IOType>
<ShowGraph>True</ShowGraph>
<LinkedIOID>00000000-0000-0000-0000-000000000000</LinkedIOID>
<IsUserAdded>True</IsUserAdded>
<MinValue>0</MinValue>
<MaxValue>1</MaxValue>
<UseNegativeRange>False</UseNegativeRange>
<CanUseNegativeRange>True</CanUseNegativeRange>
</Output>
<Output>
<UniqueID>0904f836-7d7e-4ad8-945c-d561632be26c</UniqueID>
<DefinitionID>00000000-0000-0000-0000-000000000000</DefinitionID>
<DefaultName>Activation 2</DefaultName>
<CustomName>Compensated_Humidity</CustomName>
<IsDisplayed>True</IsDisplayed>
<IsNative>False</IsNative>
<TypeName>Numeric</TypeName>
<IsOutsideConnection>False</IsOutsideConnection>
<IOType>Embrio.NodeEngine.NodeIO.NumericNodeOutput</IOType>
<ShowGraph>True</ShowGraph>
<LinkedIOID>00000000-0000-0000-0000-000000000000</LinkedIOID>
<IsUserAdded>True</IsUserAdded>
<MinValue>0</MinValue>
<MaxValue>1</MaxValue>
<UseNegativeRange>False</UseNegativeRange>
<CanUseNegativeRange>True</CanUseNegativeRange>
</Output>
</Outputs>
</Node>
</Nodes>