Previous post:CC3200-LAUNCHXL program uploading data to IoT and hibernating

Next Post: CC3200 IoT Backyard Challenge Tomato Greenhouse Summary

 

energi.png

Great news for Internet of Things and Backyard Challenge people!  Texas Instruments CC3200-LAUNCHXL board is now supported by Energia v.13+

http://energia.nu/pin-maps/guide_cc3200launchpad/

http://energia.nu/cc3200guide/

This blog post was featured by Hackaday.com.http://hackaday.com/2014/09/13/energia-on-the-cc3200/http://Yes!!!


After downloading Energia unzipped it and clicked on energia.exe. No installation, so easy!  Selected CC3200 as output board and serial port. I already had device drivers installed from CCStudio. It is no longer necessary to toggle SOP2 jumper every time for programming. Connect jumper wire between  SOP2 and J8 as shown in picture below. If WiFi examples do not work for you you might have an lder board version and  need to use Uniflash and update bootloader. I did not need to update mine.

sop.png

Tried examples:


  • Blink example runs immediately on the red LED.

 

  • AnalogInput did not run as A0 is not specified. How to write input PIN_58 or 58 or ADC1 or analogRead(6)? See next line.

 

  • AnalogInOutSerial displays ADC value on serial and as yellow LED intensity

          const int analogInPin = 6; // this is pin number on P1 header PIN_59

            const int analogOutPin = 9;  //yellow LED


  • Thermometer QuickTMP006 example did not compile. QuickTMP006.ino:17:20: fatal error: tmp006.h: No such file or directory.  TMP006.cpp:(.text.setup+0x10): undefined reference to `tmp006::begin(unsigned short)' TMP006.cpp.o: In function `loop': TMP006.cpp:(.text.loop+0x14): undefined reference to `tmp006::getTempStruct(TMP006_TempStruct*)'

Thermopile sensor TMP006 measures the chip die temperature using on-chip thermometer. Thermopile voltage can be positive or negative and is added to the  die temperature after a polinomial correction.

I copied TMP006 example from MSP430 into the directory energia-0101E0013/hardware/cc3200/libraries/TMP006

inside the file tmp006.cpp changed in all places ADR1_0_ADR0_0 to ADR1_0_ADR0_1


Compiling gave 312:8 error in tmp006.cpp "expected unqualified-id before numeric constant"

Changed S0 to some other name. Probably name S0 is reserved.

Now it compiles, uploads and runs. Noted that green and yellow LEDs change intensity as they are on I2C pins.

Temp in C = 385.80 deg. C

Temp in C = 386.01 deg. C

Temp in C = 386.38 deg. C

Hand in front

Temp in C = 33.83 deg. C

Temp in C = 33.27 deg. C

Temp in C = 33.61 deg. C

Temp in C = 33.02 deg. C

hand removed

Temp in C = 386.40 deg. C

Temp in C = 386.20 deg. C

Values were more or less correct above +31C. Values below +31C were indicated wrong.

Program worked correctly only for temperatures above the chip temperature.

Problem seems to be with negative numbers, when outside temperature is less then chip temperature,

then VObj suddenly becomes a large nr around 65000. And that was not handled properly.

if (*vObj_V >32000){

  *vObj_V=*vObj_V-65535;

  }

After such tweaking TMP006 example is working. I attached zip files.

 

  • BMA222 accelerometer example worked without need to configure anything

        ReadXYZ

          X: -16 Y: 46 Z: 58

          X: -17 Y: 45 Z: 59

          X: -15 Y: 40 Z: 56

 

  • WiFi server example did not connect to AP. This example is for encrypted network, I had open. Works after modifying line to:  "WiFi.begin(ssid);"

 

  • ConnectNoEncription for WiFi works:

Attempting to connect to Network named: OpenWrt ... You're connected to the network  Waiting for an ip address..  IP Address obtained  SSID: OpenWrt  BSSID: F0:0:20:1:79:C4  signal strength (RSSI):0 Encryption Type:0 IP Address: 192.168.1.190  192.168.1.190  MAC address: 78:A5:4:2E:C1:3E  NetMask: 255.255.255.0  Gateway: 192.168.1.1  SSID: OpenWrt  BSSID: F0:0:20:1:79:C4 


  • SimpleWebserverWiFi

Attempting to connect to Network named: OpenWrtYou're connected to the network  Waiting for an ip address  ..  IP Address obtained  SSID: OpenWrt  IP Address: 192.168.1.190  signal strength (RSSI):0 dBm  To see this page in action, open a browser to http://192.168.1.190  Starting webserver on port 80  Webserver started!

webs.png


  • WiFiHivelyClient  Works nicely, but if once the connection to Wi-Fi router is lost (it happens after some hours) it does not reconnect and stops sending data. analogRead(6) measures from PIN_59.

Attempting to connect to Network named: OpenWrt ..  You're connected to the network  Waiting for an ip addressIP Address obtained  SSID: OpenWrt  IP Address: 192.168.1.190  signal strength (RSSI):0dBm  connecting...  HTTP/1.1 200 OK  Date: Sat, 13 Sep 2014 12:18:06 GMT  Content-Type: text/plain; charset=utf-8  Content-Length: 0  Connection: close  X-Request-Id: ebabd5c32aa8091805293a803012d80cd172fbdd  Cache-Control: max-age=0  Vary: Accept-Encoding  disconnecting

xiv.png 

After getting TMP006 to work it was easy to combine it with Xively client example.  Live feed with temperature data is here https://xively.com/feeds/363176112

Zip file with code is attached to this post.

 

  • ScanNetworks  finds wifi networks around without connecting. It can do it very fast compared to Windows.

SimpleLink SDK 0.5 MAC: 78:A5:4:2E:C1:3E Scanning available networks... ** Scan Networks **  number of available networks:3

0) Bumbieris    Signal: -88 dBm Encryption: WPA

1) Chernichka  Signal: -86 dBm Encryption: WPA 

2) OpenWrt      Signal: -38 dBm Encryption: None

 

  • SendAnEmail  Should send an email from a google mail user to any address. 
    Needs registration at Temboo account, Temboo API key, google allowing 3-rd party requests,  ... too complicated - did not wish to spend an hour to figure it out.

 

  • Interrupts

Interrupt handling for Energia is described here. http://energia.nu/AttachInterrupt.html

attachInterrupt() exists like for Arduino.

I copied the code from that website pasted in Energia and it worked on CC3200 without need for any modifications.

Could control green or red LEDs and use buttons 1 and 2.

 

 

  • I2C temperature sensor TMP103A connected externally

 

For several applications it is desirable to have an external temperature sensor like inside a beehive or earth. It would be practical to use some I2C sensor. I got advice to use TMP103A from Texas Instruments. Different label letters have different addresses so it is possible to use several sensor in parallel.


Sensor has 8 bit resolution meaning that temperature steps are 1 degree. Tiny 4-pin BGA package I soldered using thin wires onto a 4-pin prototyping board under a magnifier glass.

It was tricky but doable. I melted some solder on the tip of the thin wire first and then touched with it the BGA pin. Note the dot on the opposite side before soldering. After soldering I could not see the dot and could find pins blindly by using a multimeter in diode mode. Connection between 5V and GND produces large resistance. Low resistance means that internal protection diodes are open.

 

For reading the I2C bus there is an example  Wire master_reader in Energia CC3200


It is a good idea to look on the oscilloscope at SDC and SDA signals. There should be 3.3 V present. Jumpers on J2 and J3 have to be closed as they are generating pull-up voltage.

With closed jumpers TMP006 sensor and accellerometer should be accessible.

 

TMP103 datasheet mentions that the sensor can be called at I2C address 0 as well. It worked as could be seen on the scope there was a reply.:

  Wire.requestFrom(0, 1);    // request 1 byte from slave device o

TI datasheet states that TMP103A address is 1110000 being 112 in decimal. Reading a byte from this address also returns the actual temperature.

TMP103A.pngTMP103Aa.pngtmp.png

 

Serial.print did not work and showed some strange ASCII character. Had to change the line:

    char c = Wire.read(); // receive a byte as character

    int c = Wire.read(); // receive a byte as character

 

Now the Wire example program printed on serial terminal temperature value in degrees Centigrade.

23  23  24  25  ...

 

 

  • ADC Analog to Digital converter

 

Values are DC biased. Read more: CC3200 Energia ADC weirdness

Serial.println(analogRead(2));  //pin 58 in TI  (P1) //ADC_CH1
Serial.println(analogRead(6)); //pin 59 in TI (P1) //ADC_CH2
Serial.println(analogRead(24)); //pin 60 in TI (P3)//ADC_CH3

 

 

 

 

  • Hibernate

 

Can somebody, please, help with hibernate (and watchdog) example code so important for battery driven applications?


Would be enogh to brute-force load bit values into appropriate registers.

Register names like WDTCTL are not recognized in Energia sketch. Error appears on attempt to write for example WDTCTL=0x00;

It looks like one can read register values using command

    int aaa=HWREG(0x0);

    Serial.println(aaa);

 

 

  • Conclusions


Energia is an excellent solution to bring to life a new IoT gadget quickly based on customizing demo examples without need to learn programming professionally.

Without availability of watchdog and hibernate examples it is suitable for educational/demo purposes, but not for 24/7 b attery driven applications.

Hope this blog about Energia will make it easier for other people to get IoT projects running.

But without being able presently to implement hibernate in Energia I am switching back to programming in CCStudio.