Previous post:Sample upload to Plotly: success
Next post: Energia is out there for CC3200
CC3200 measuring hot water pipe temperature in bathroom
It was my old dream to measure pipe temperature, but until appearance of CC3200 I was hesitating to install wires all the way from webserver to the bathroom. It is very practical now to tape CC3200 board to a pipe in the bathroom and run it from 2xAA rechargeable cells. No installation wires needed. Same code as used for greenhouse was used with just the Xively feed nr changed to this:
https://xively.com/feeds/242759090
This is in a 12-storey building with central heating. Can see that water temperature drops in the Mo-Fr nights. Temperature is actually too low to be safe from legionellas infection. Safe would be > 55 degrees, but water is flowing, so it it is probably fine.
The housekeeper should keep temperature at 40 deg. C. Need to mention that TMP006 sensor factory uncertainty could be 3 degrees.
First weeks the recorded temperature was too low, but after packing CC3200 with a plastic foam it started to measure +40C.
We pay for water volume we use in m3. It would be great to be able to automate water meter readings with CC3200 camera module.
Experiment continues over 1 month and purpose is to see how long batteries will keep it going.
Similar temperature measurements could be done on centralised heating water pipe in winter.
TMP106 sensor is non-contact but that sacrifices resolution. In the plot below you can clearly see that resolution is in 1 degree steps.
CC3200 is sending data to Internet via a tiny Wi-Fi router TP-LINK WR-703N consuming <1W electricity. I use router as Wi-Fi range extender, USB Webcam and 1-Wire thermometer. Previously I have composed an instructable about this router Smart home automation webserver on OpenWRT router WR703N
Plant watering system using CC3200
As it is late autumn now the greenhouse has been taken down and I experimented on watering a plant in the room on a window isle. Once a bad surprise expected me when I came to the room there was 5 liters of water on floor. Soil humidity only should not be reason for watering. There should be some maximum daily allowed dose. Professional plant watering systems exist, for example Daisy.si, Click and Grow.
CC3200 uploading to IoT. Program OK, uploading ADC values and hibernating
Code is working that periodically uploads sensor data and hibernates. Program sequence:
- Blink orange LED for 0.1s.
- Connect to AP. Red LED blinks while connecting and turns on when connected.
- Read the on-board temperature sensor and 3 ADC voltages.
- Prepare a http message with wrapped-in sensor values.
- Send message to server.
- Hibernate for 5 min. Current consumption 0.6 mA.
If program gets stuck somewhere and watchdog is not fed within 8s then green LED shines for 0.1s and hibernate command is issued.
Hibernation resets everything. Program seems to run reliably. Program code is attached at the end of this blog.
Plots of 4-channels of live data are here: https://xively.com/feeds/39457629
Plot 1 is onboard I2C temperature sensor value.
Plot 2 is battery voltage via resistor divider.
Plot 3 is conductive moisture sensor. It takes residual voltage from ADC input ca 0.6V and shortens it to GND. Soil moisture sensor from Ebay is a small PCB with 2 stripes plugged into soil. I omitted amplifier to minimize current consumption. I use a piece of shielded cable and ADC input has a 1uF capacitor to GND.
Plot 4 is ambient light sensor. It is a 5x5 mm photodiode loaded with 1k . Photovoltac voltage that develops across the photodiode should not reach 0.6 V as there the photodiode response becomes quite nonlinear. There is a 1uF blocking capacitor as well.
There were no more spare ADC inputs for air humidity sensor. Humidity sensor would draw extra current from 2xAA cells and that is not desirable.
1-wire bus temperature sensors would be somewhat problematic to add because one would need a level-converter chip, since 1-wire bus operates with 5V signals. Probably should add an extra temperature sensors on I2C or SPI bus. Connection of external I2C temperatrure sensor TMP103 I describe in Energia blog.
I use rechargeable AA batteries and have connected them in parallel with a 5x7cm solar panel. In direct sunlight it produces 40 mA and in shadow a couple of mA. It seems enough to recharge the batteries. Rechargeable AA cell has lower voltage of 1.2V compared to normal ones.
Supply range for CC3200 is 2.1V to 3.6V and for temperature sensor TMP006 range is 2.2V to 5.5V
IP60 class plastic box is housing electronics. Setup in a greenhouse worked fine for one month.
Soil moisture sensor for CC3200
Measuring resistance with a multimeter showed that it is increasing within a minute and swaping multimeter polarity showed decreased resistance that increased too. So DC probing is not a correct way. Electrolysis/electroetching takes place and oxyde resistance increases with time (capacitor get's charged)
Need to run the current both forward and reverse like in electrolytic capacitor and switch off voltage between measurements.
http://gardenbot.org/howTo/soilMoisture
I use two zink-coated nails. Sensors made of gypsum have a problem that they like to attract water, resistance drops to very low level and saturates and never really gets back. Conductivity of materials and also soil is affected by the soil temperature. This could cause a false "dry" effect. So it is adviceable also to measure soil temperature as well. Note that different soils have a different resistance. Also, sometimes, watered soil will continue to have a high resistance until the soil absorbs the water with a delay of about one hour.
There was a problem with nails measuring moisture. Resistance had a slow tendency to steadily increase during several weeks even if the soil was watered. This is because there is permanently 0.6V DC voltage on the ADC input coming from inside the CC3200 chip. One can imagine nails being like electrodes of a battery. When battery is charged full the charging current decreases. Another view is from chemical viewpoint that ions travel to negative electrode and polarize it so external current decreases. A solution to this problem would be to use an external analog switch chip with MOSFETs disconnecting nails from the circuit while not measuring. Best would be to implement AC capacitive measurement technique described here.
ADC - Analog to Digital Converter on CC3200
ADC can be used to monitor battery voltage and sensors. Chip has CC3200 has 4 ADCs with 12 bit resolution. Voltage range is 0...1.45V. ADC_CH0 on PIN_57 is not working. PIN_58 and PIN_59 header pins are routed to header P1. PIN_60 is routed to header P3. Bits 2:13 can be selected by such line:
ulSample = (ulSample & 0x3ffc)>>2;
With the example provided in SDK the ADC was not working reliably.
Values were erratic and not linked with the input voltages. It seemed that some internal MUX was not enabled, but actually one needed to add a small delay between enabling ADC and sampling.
There is a bug in the ADC example that can be fixed by adding a line in while(forewer) loop uiIndex=0;:
http://e2e.ti.com/support/wireless_connectivity/f/968/t/365450.aspx
http://e2e.ti.com/support/wireless_connectivity/f/968/p/354092/1243186.aspx#1243186
I made a voltage divider using 100k and 1M to be able to measure up to 20V voltages.
A capacitor of 0.1 uF at ADC input was necessary to prevent pickup.
There is a strange thing. Is ADC input (for example PIN_60) is floating can measure voltage on it about 0.5 V.
If pin_60 is tied to GND via 100k then voltage is 0.4 V.
Is there some pull-up on the pin that has to be additionally disabled?
I have changed ADC example to a function that returns just one value read from CC3200 ADC.
----------------------------------------------------------------
float readADC(unsigned long uiAdcInputPin)
{ unsigned int uiChannel;
unsigned long ulSample;
//uiAdcInputPin=PIN_60;
PinTypeADC(uiAdcInputPin, 0xFF);
switch(uiAdcInputPin)
{
case PIN_58: {uiChannel = ADC_CH_1;}break;
case PIN_59: {uiChannel = ADC_CH_2;}break;
case PIN_60: {uiChannel = ADC_CH_3;}break;
default: break;
}
MAP_ADCChannelEnable(ADC_BASE, uiChannel);
MAP_ADCEnable(ADC_BASE);
MAP_UtilsDelay(800000);
if(MAP_ADCFIFOLvlGet(ADC_BASE, uiChannel))
{
ulSample = MAP_ADCFIFORead(ADC_BASE, uiChannel);
ulSample = (ulSample & 0x3ffc)>>2;
}
// UART_PRINT(" %d \n\r", ulSample);
return ulSample;
}
----------------------------------------------------------------
ADC Voltage Calibration
Apply 5V to divider and note the number. Then ground the divider input and note the number again. I got something like this:
voltage=(ADCnumber-196)/940*5;
Check by measuring 3.3V. Repeat callibration for each channel.
CC3200 driving a 12V DC motor
For pumping water I use 12 V DC motor and circuit consisting of 3 transistors. MOSFET BUZ12 (40A, 30V, 0.028 Ohm) can not be driven with 1.8V from CC3200. So it is driven by a bipolar transistor. Another bipolar transistor is used as level inverter.
I2C thermometer TMP006 on CC3200
I wanted to switch off green and orange LEDs for power conservation. It appeared not possible, if I2C is used. In LAUNCHXL LEDs are wired to the same lines as onboard jumpers for I2C SCL and SDA lines. It apears that other CC3200 pins can be used for I2C. I choose pins 4 and 5 and write in the file pinmux.c
MAP_PinTypeI2C(PIN_05, PIN_MODE_5); //I2C SCL
MAP_PinTypeI2C(PIN_04, PIN_MODE_5); I2C SDA
When I am reading the onboard I2C thermometer sometimes thermometer readout freezes. In principle one could try to debug where. So it is necessary to set up a watchdog.
Uniflash utility for permanent storage of programm into flash
For some time I got stuck trying to store programm on LAUNCHXL using Uniflash. Using CCs I could build the project, debug it, but programm would be lost after reset.
When I run Uniflash and select add new file where browse oob.bin file to upload, it is uploaded.
There are some other files that are present for example /sys/macadd.bin But after I reset the board and remove SOP2 jumper the board does not seem to run (no LED is blinking)
Problem was solved a couple of hours later. I tried to add a new file to the project. This was wrong.
Needed to modify bin file name used under sys/mcuimg.bin
In principle, it is logical that one just does not upload a program file somewhere, but to the already defined place.
Now I can flash my program and it executes from flash without a PC. In order to test hibernate and watchdog, the programm has to be written to flash.
CC3200 Watchdog
I implemented a Watchdog timer resetting the board it spends too much to much time trying to connect to AP.
Watchdog was implemented based on example. Watchdog time set to 8s. If program is unable to connect to internet and send data in 8s, then watchdog resets the processor code.
Watchdog is not equivalent to pressing a reset button. It has happened twice after couple hours of normal operation that watchdog restarts program, but it hangs and only pressing Reset button helps. Presumably after watchdog activation the program is not read from flash but executed code from SRAM code which might have be damaged.
Watchdog resets the user program, but not the Internet processor and it is internet processor that locks up. Watchdog needs to be used together with hibernate to reset also network processor. Hibernate command is placed inside watchdog handling routine.
WDT not resetting Wi-Fi MCU: http://e2e.ti.com/support/wireless_connectivity/f/968/t/365205.aspx
"The MCU application must detect a recovery from the WDOG trigger and force the device into complete hibernation with a wake-up associated with an internal RTC timer. This ensures a complete system cleanup".
Testing Deepsleep and Hibernate examples for CC3200
Flashing file sensor_profile.bin and measuring current across the J12:
9 mA WDT_DEEPSLEEP
13 mA GPT_SLEEP
9 mA GPT_DEEPSLEEP
Applying battery voltage to the J12 jumper VBAT_CC that supplies CC3200 chip and serial flash chip only:
0.2 mA current.
20 uA with soldered 100k pullup CS# (pin 1) and 100K pull-down on the DOUT, CLK (pin 5,6) of the serial flash U15.
2 mA with USB unplugged, but the board is not functioning. Board needs VCC_BRD providing positive reset voltage and VCC_DCDC_3V3
8 mA from 2xAA with red and yellow LEDs shining in bibernate mode
Applying 3V to 2xAA connector:
0.65 mA with unsoldered red and yellow LEDs from 2AA connector (VCC_board) in hibernate mode.
0.65mA is the best current consumption value I get from the 2xAA connector. J12 closed. J13 open. PWR and RESET LEDs unoldered.
Plugging in USB cable to monitor serial communication does not increase the power consumption.
CC3200 Hibernate mode: 0.65 mA consumption from 2xAA batteries
Current consumption measured from 2xAA batteries is 30 mA from when processor is running and 150 mA when WiFi data are sent.
Soldered a 1000uFx16V capacitor in parallel to the 2xAA pins. Without it board was constantly resetting when current was measured with a multimer.
Could I damage the processor by supplying board from a 4V LiPo? It is out of specs of 2xAA cells of 3.3V. Program stopped working when run from LiPo, but after reflashing things are OK again. I am not using LiPo anymore.
Could implement hibernate by copping code from Sensor_profile example. Current drawn from 2xAA battery in hibernate mode is 0.65 mA. J12 is closed. J13 is open.
Resistors in series with PWR and RESET LEDs are unsoldered. I2C is rerouted to other pins to be able to switch off the green and the orange LEDs (see my notes about I2C).
This current could probably be smaller if I2C thermometer and accelerometer chips were unpowered. For me is not clear the function of U8 boost regulator for VCC_3V3. Onboard L4 is not populated. Is U8 necessary because of pre-production chip.
CC3200 wake-up by Interrupt from Hibernate on GPIO 13
As I would like to make an IoT garden lamp I would like to switch on LEDs when someone passes by in the night. For that I would like to use wake-up on GPIO. Nice thing is that wake-up from HIB can happen both on timer and GPIO13 (button SW3) simultaneously.
// Enable the HIB RTC
MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_SLOW_CLK_CTR);
// Enable the HIB GPIO
MAP_PRCMHibernateWakeupSourceEnable(PRCM_HIB_GPIO13);
MAP_PRCMHibernateWakeUpGPIOSelect(PRCM_LPDS_GPIO13, PRCM_HIB_HIGH_LEVEL); // no effect
Hibernate wake-up worked for me only on GPIO13 (that is button SW3).
Wake-up from HIB happens only on LOW level. I tried to programm HIGH level or RISE edge without success.
Similar situation was with Arduino chips where interrupt active level was LOW.
This means that the SW3 button has to be pressed down all the time to keep the board in HIB.
I would like to wake-up from HIB using a PIR motion-detector module having HIGH output when active. So a level inverter is necessary. NPN transistor can be used with 100 k in collector and base resistors of 100k. Actually CC3200 pin levels are up to 1.8V so one should probably add extra 100 k from transistor collector to digital pin. Instead of transistor one could use a CMOS NAND gate.
CC3200-LAUNCHXL connecting to AndroidAP Wi-Fi in the garden
During August-September I had placed the CC3200 board flashed with my IoT code in the garden greenhouse. Wi-Fi was provided by Android phone tethering from GSM (same phone was taking pictures for time lapse). Phone was placed in a water proof enclosure with a window and running from extra LiPo pack charged by a 10 Wp solar panel.
A reliability problem with connecting to AndroidAP was observed after 2 weeks. Problem disappeared after restarting the phone.
Started SimpleLink Device: STA Mode
WLAN ERROR]Device disconnected from the AP AP: , BSSID: 0:0:0:0:0:0 on an ERROR
Device could not connect to AndroidAP
After one month the mobile operator wanted to confirm SMS about extending internet connection. So I had to touch the phone again.
Besides these interactions with phone the internet tethering was working OK.
External Wi-Fi Antenna with CC3200
Wi-Fi connection range with onboard ceramic antenna was a approximately 10m. External antenna can be connected via U.FL connector (for example Farnell MULTICOMP - R-132G7210100CB - CABLE, U.FL - SMA, 100MM, 50OHM). On board need to resolder one jumper.
Texas Instruments forum about CC3200
A lot of reading: more than 100 pages with 10 topics each.
Could find there answers about ADC problems and resetting with watchdog and hibernate.
CCStudio freeware restrictions
Posted by Lenio Cacula on Aug 26 2014 09:47. Answer Verified by Guy Dillen
"When using the CC3200 Launchpad, CCS does not limit the access to the 256kB of memory available, independently of the license.
Restrictions will however apply to a custom board that features the CC3200 or any other device. Those restrictions are either 16kB of code or 90 days from the initial installation of CCS."