<p>Hi folks</p>
<p> </p>
<p>I started to use CC3200 in the ENERGIA environment.</p>
<p>I was using the examples from the Book "Arduino projects to save the world"</p>
<p> </p>
<p>I tested the code on an Arduino UNO board, and is OK.</p>
<p> </p>
<p>But in the CC3200, only one Analog channel is printed correctly, in the getADC() function, I can comment any two // ADC1 = analogRead(A1); statement and the third will print correctly</p>
<p> </p>
<p> </p>
<p>I am new on ENERGIA so any help will be apreciated.</p>
<p> </p>
<p> </p>
<p> </p>
<p>The code follows:</p>
<p> </p>
<div> </div>
<div> </div>
<div>//Listing 2-4. Software-calibrated Version of SpiderTemps.</div>
<div>/*</div>
<div>SpiderTemps 6 sensor plus software calibration</div>
<div>Arduino projects to save the world</div>
<div>This sketch reads all six analog inputs, calculates temperature© and outputs them to the</div>
<div>serial monitor.</div>
<div>*/</div>
<div>//-------------- Modified for Tree LM35 on AN1 AN2 and AN3 ----------------------</div>
<div> </div>
<div>float temp1, temp2, temp3;</div>
<div>int ADC1, ADC2, ADC3;</div>
<div>int LM35offset = 0;</div>
<div> </div>
<div>float calibration1 = 0;</div>
<div>float calibration2 = 0;</div>
<div>float calibration3 = 0;</div>
<div> </div>
<div>void setup() </div>
<div>{</div>
<div>Serial.begin(9600);</div>
<div>}</div>
<div> </div>
<div>void loop() </div>
<div>{</div>
<div> </div>
<div> getADC();</div>
<div> </div>
<div>temp1 = calcTemp(ADC1, LM35offset, calibration1);</div>
<div>temp2 = calcTemp(ADC2, LM35offset, calibration2);</div>
<div>temp3 = calcTemp(ADC3, LM35offset, calibration3);</div>
<div> </div>
<div>Serial.print(temp1, 0);</div>
<div>Serial.print(" ");</div>
<div>Serial.print(temp2, 0);</div>
<div>Serial.print(" ");</div>
<div>Serial.println(temp3, 0);</div>
<div> </div>
<div>delay(500);</div>
<div>}</div>
<div> </div>
<div>void getADC() </div>
<div>{</div>
<div>ADC1 = analogRead(A1);</div>
<div>ADC2 = analogRead(A2);</div>
<div>ADC3 = analogRead(A3);</div>
<div>}</div>
<div> </div>
<div>float calcTemp (int val, int offset, float cal) </div>
<div>{</div>
<div>return (((val * 0.3418) - offset) / 10) + cal; // 1.4V / 4096 12Bit ADC</div>
<div>}</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
View the full article on Stellarisiti. 43oh pulls Stellarisiti Energia posts, so that members do not miss out questions. Please bear with this arrangement for now. Thanks!
<p> </p>
<p>I started to use CC3200 in the ENERGIA environment.</p>
<p>I was using the examples from the Book "Arduino projects to save the world"</p>
<p> </p>
<p>I tested the code on an Arduino UNO board, and is OK.</p>
<p> </p>
<p>But in the CC3200, only one Analog channel is printed correctly, in the getADC() function, I can comment any two // ADC1 = analogRead(A1); statement and the third will print correctly</p>
<p> </p>
<p> </p>
<p>I am new on ENERGIA so any help will be apreciated.</p>
<p> </p>
<p> </p>
<p> </p>
<p>The code follows:</p>
<p> </p>
<div> </div>
<div> </div>
<div>//Listing 2-4. Software-calibrated Version of SpiderTemps.</div>
<div>/*</div>
<div>SpiderTemps 6 sensor plus software calibration</div>
<div>Arduino projects to save the world</div>
<div>This sketch reads all six analog inputs, calculates temperature© and outputs them to the</div>
<div>serial monitor.</div>
<div>*/</div>
<div>//-------------- Modified for Tree LM35 on AN1 AN2 and AN3 ----------------------</div>
<div> </div>
<div>float temp1, temp2, temp3;</div>
<div>int ADC1, ADC2, ADC3;</div>
<div>int LM35offset = 0;</div>
<div> </div>
<div>float calibration1 = 0;</div>
<div>float calibration2 = 0;</div>
<div>float calibration3 = 0;</div>
<div> </div>
<div>void setup() </div>
<div>{</div>
<div>Serial.begin(9600);</div>
<div>}</div>
<div> </div>
<div>void loop() </div>
<div>{</div>
<div> </div>
<div> getADC();</div>
<div> </div>
<div>temp1 = calcTemp(ADC1, LM35offset, calibration1);</div>
<div>temp2 = calcTemp(ADC2, LM35offset, calibration2);</div>
<div>temp3 = calcTemp(ADC3, LM35offset, calibration3);</div>
<div> </div>
<div>Serial.print(temp1, 0);</div>
<div>Serial.print(" ");</div>
<div>Serial.print(temp2, 0);</div>
<div>Serial.print(" ");</div>
<div>Serial.println(temp3, 0);</div>
<div> </div>
<div>delay(500);</div>
<div>}</div>
<div> </div>
<div>void getADC() </div>
<div>{</div>
<div>ADC1 = analogRead(A1);</div>
<div>ADC2 = analogRead(A2);</div>
<div>ADC3 = analogRead(A3);</div>
<div>}</div>
<div> </div>
<div>float calcTemp (int val, int offset, float cal) </div>
<div>{</div>
<div>return (((val * 0.3418) - offset) / 10) + cal; // 1.4V / 4096 12Bit ADC</div>
<div>}</div>
<div> </div>
<div> </div>
<div> </div>
<div> </div>
View the full article on Stellarisiti. 43oh pulls Stellarisiti Energia posts, so that members do not miss out questions. Please bear with this arrangement for now. Thanks!