Martin's corner on the web

[OBSOLETE] Funky v2

Revision for “[OBSOLETE] Funky v2” created on December 23, 2018 @ 21:13:41

[OBSOLETE] Funky v2
<h1 style="text-align: center;"><span style="color: #ff0000;">[This project is obsoleted and not supported]</span></h1> &nbsp; The "Funky v2" is a miniature <a href="" target="_blank" rel="noopener">open source/hardware</a> cut-down clone of the <a href="" target="_blank" rel="noopener">Arduino Leonardo</a>  with <a href="" target="_blank" rel="noopener">RFM12B </a>radio module. It is intended as low power, battery operated remote sensing node with USB interface. Due to the miniature size, only few carefully selected pins are available at the side header, none the less that is more than sufficient to interface several sensors at a time. <a href=""><img class="alignnone size-large wp-image-2673" src="" alt="IMG_27281.jpg" /></a> <a href=""><img class="alignnone size-full wp-image-2656" src="" alt="IMG_2727" width="1024" height="768" /></a><a href=""><img class="alignnone size-full wp-image-2654" src="" alt="IMG_2729" width="1024" height="768" /></a> Having gained experience with my <a href="" target="_blank" rel="noopener">Funky v1</a> project, I decided to create a new version. The Funky v1 project is a success, yet the areas I wanted to optimize are: <ul> <li><span style="line-height: 15px;">The <a href="" target="_blank" rel="noopener">Attiny84 MCU </a>that was used in the Funky v1 has limited RAM and sketch memory</span></li> <li>The Attiny84 requires an <a href="" target="_blank" rel="noopener">ISP programmer</a> for sketch uploading</li> <li>The Attiny84 required a <a title="Setting up Arduino IDE for working with Attinys" href="" target="_blank" rel="noopener">modified Arduino core</a></li> <li>Many of the available Arduino libraries are not compatible with Attiny84</li> </ul> So the Funky v2 was created, see my posts <a title="Atmega32U4 based micro node with RFM12B" href="" target="_blank" rel="noopener">here </a>, <a title="Update on the Atmega32u4 based new Funky" href="" target="_blank" rel="noopener">here</a> and <a title="Funky v2 (well almost)" href="" target="_blank" rel="noopener">here</a> <ul> <li><span style="line-height: 15px;">Board size is 20×21.2mm (0.78″x0.83″) in size (same as Funky v1)</span></li> <li>The MCU used in an <a href="" target="_blank" rel="noopener">Atmega32U4</a>, the same MCU that <a href="" target="_blank" rel="noopener">Arduino Leonardo</a> uses. This makes the Funky v2 a minuature Arduino Leonardo compatible board with <a href="" target="_blank" rel="noopener">RFM12b </a>transciever module</li> <li>The Funky v2 has the Caterina bootloader, so programming is done with Arduino IDE via micro USB cable</li> <li>Uses external 8Mhz crystal (can switch to internal RC clock in software as described <a title="Power saving techniques on the Atmega32u4" href="" target="_blank" rel="noopener">here</a>)</li> <li>Operates on 3.3V</li> <li>Weights only 3 grams</li> </ul> Funky v2 is available for sale in limited quantities in the <a href="" target="_blank" rel="noopener">shop</a>. Eagle design files and example sketches are available on<a href="" target="_blank" rel="noopener"> my github repository</a>. Some of my projects involving Funky v2: <ul> <li><a href="" target="_blank" rel="noopener">Wearable wireless body temperature logger/monitor</a> with DS18B20</li> <li><a href="" target="_blank" rel="noopener">OLED status display</a></li> <li><a href="" target="_blank" rel="noopener">Flood alarm</a></li> <li><a href="" target="_blank" rel="noopener">RGB LED project</a></li> <li><a href="" target="_blank" rel="noopener">Temperature sensor node</a></li> <li><a href="" target="_blank" rel="noopener">Weight logger</a></li> <li><a href="" target="_blank" rel="noopener">Frequency generator</a></li> <li><a href="" target="_blank" rel="noopener">Using in energy harvesting project</a></li> <li><a href="" target="_blank" rel="noopener">Soil moisture wireless node</a></li> <li><a href="" target="_blank" rel="noopener">April fool prank</a></li> <li><a href="" target="_blank" rel="noopener">Software I2C with Funky v2</a></li> <li><a href="" target="_blank" rel="noopener">TCP/IP over RFM12b serial connection</a></li> <li><a href="" target="_blank" rel="noopener">Frequency counter</a></li> <li><a href="" target="_blank" rel="noopener">RFM12b gateway to emoncms</a></li> <li><a href="" target="_blank" rel="noopener">Controlling RF power sockets</a></li> <li><a href="">IR receiver</a></li> <li><a href="">DHT22 </a></li> <li><a href="" target="_blank" rel="noopener">Pulse counting</a></li> </ul> Complete list of examples: <a href=""></a> Funky v2 revision 2 schematic/board layout: <img class="alignnone size-large wp-image-2727" src="" alt="Funky_v2_r2_sch" width="584" height="399" /> <a href=""><img class="alignnone size-full wp-image-2726" src="" alt="Funky_v2_r2_brd" width="892" height="1024" /></a> Note the added MOSFET to control the RFM12B's power state; This requires explicitly powering up RFM12B transciever before initialization: <pre>pinMode(A5,OUTPUT); // RFM12B power control pin9 digitalWrite(A5,LOW); //Make sure the RFM12B is on (LOW is on) delay(20); // Allow for RFM12B to start ....RFM12B initalization code here.......</pre> <h3><strong>Setting up Arduino IDE for the board</strong></h3> Funky v2 r2 will have the <a href="" target="_blank" rel="noopener">Caterina bootloader</a> and will identify itself as an <a href="" target="_blank" rel="noopener">Arduino LilyPad USB</a>. The purpose of this is to have <a href="" target="_blank" rel="noopener">Arduino IDE</a> support for the Funky v2 without the need of any additional setup.  Both Arduno LilyPad USB and Funky v2 operate on 3.3V @ 8Mhz, so it is important to select that board type and not the Arduino Leonardo that runs on 16Mhz. Simply plug in the Funky v2 and when asked for drivers (Windows), navigate to the Arduino/drivers folder. Older Funky v2 revisions need to use the <a href="" target="_blank" rel="noopener">Arduino Fiov3</a> drivers. The ZIP file includes instructions on using them. <h3><strong>Powering the board</strong></h3> <span style="color: #993300;"><strong>Note</strong><b>: </b>The micro-USB connector is soldered <i>on</i> the board — not <i>through</i> it. Be gentle when plugging and unplugging your USB cable.</span> The board can be powered from the micro USB plug and will regulate that input to 3.3V using the the <a href="" target="_blank" rel="noopener">Torex XC6206</a> LDO regulator included on the board (Funky v2 used <a href="" target="_blank" rel="noopener">MCP1700 </a>LDO prior to Aug 14th 2013, see my post <a href="" target="_blank" rel="noopener">here</a>) . The VUSB line is exposed as a pin on the side header, meaning that you can power the board from there too, just do not exceed the 6V limit that the ATMega32U4 VUSB has. The XC6206 dropout voltage according to the datasheets is 250mV meaning the minimum supply voltage when powering via the VUSB should be 3.3V+0.25=3.55V, so LiPo batteries can be also used  as well. The board carries an option for the <a href="">LTC3525ESC6</a> (3 or 3.3V versions) boost regulator and supporting elements to be included, this is useful when you wish to power the board from a 0.8 - 5.5V source and get that regulated to 3.3V. I use that option to power the Funky v2 from a single AAA battery. The board can also be powered from a single CR2032 battery, but unlike the Funky v1 the battery holder now can only be soldered at the side where the RFM12B module lays as the micro USB connector stands on the way on the reverse side. See example of this setup <a title="Funky v2 low power example" href="">here</a>. Running on battery is one one of the advantages of the Funky v2 project, however it needs taking special care to reduce power usage and therefore prolong battery life. Using this <a href="" target="_blank" rel="noopener">example sketch</a>  I managed to bring the power consumption down to 0.02mA @ 3V in sleep mode. <span style="color: #993300;">NOTE: Please remove any battery attached when plugging into USB.</span> The default fuse settings I use are the same as Arduino LilyPad USB: <a href=""><img class="alignnone size-full wp-image-2728" src="" alt="Funky_v2_fuses" width="770" height="322" /></a> <pre>avrdude -v -v -patmega32u4 -cusbtiny -e -Ulock:w:0x3F:m -Uefuse:w:0xce:m -Uhfuse:w:0xd8:m -Ulfuse:w:0xff:m avrdude -v -v -patmega32u4 -cusbtiny -Uflash:w:Caterina-lilypadusb.hex:i -Ulock:w:0x2F:m</pre> You could disable the BOD fuse to save extra 0.02mA in sleep mode. The bootloader also slightly differs from the  "stock"<a href="" target="_blank" rel="noopener"> Caterina bootloader</a> because it passes control to the sketch immediately on board power-up and will only go in bootloader mode for 8 seconds on external reset (or if no sketch is present). This is done so that no time is lost between board power-up and the sketch powering down the unused peripherals. Source code of the bootloader <a href="" target="_blank" rel="noopener">here</a>. <h3><strong>Funky v2 header pins</strong></h3> The side header of the Funky v2 started as intended Jeelabs's <a href="" target="_blank" rel="noopener">JeePort</a>, but that changed slightly as I advanced with the design. The reason for that is that JeePorts are Atmega328 specific and there is no information on which pins <a href="" target="_blank" rel="noopener">JCW </a>will use in a future Atmega32u4 (if ever) based JeeNode. I still kept the overall idea of having a VCC-DIO-GND-3.3V-AIO-IRQ concept. Having said that, the <a href="" target="_blank" rel="noopener">Ports library</a> will probably work with minor modifications. <a href=""><img class="alignnone size-large wp-image-1588" src="" alt="Funkyv2_pins" width="584" height="424" /></a> <ol> <li><strong>Pin 1</strong> connects to VUSB and provides +5V if the USB cable is plugged in. It can also be used to power the board from a 3.5-6V source, given the USB cable is disconnected. Typical application of this pin would be to provide 5V for sensors attached to the header</li> <li><strong>Pin 2</strong> connects to Digital 13, a special pin with timer output to <a href="" target="_blank" rel="noopener">drive IR LEDs</a> for example.</li> <li><strong>Pin 3</strong> connects to GND</li> <li><strong>Pin 4</strong> connects to VCC (3.3V if powered via the USB or the voltage that your battery is providing if powered by a battery)</li> <li><strong>Pin 5</strong> can be used both as Digital 8 or Analog 8 in Arduino IDE, it is a pin that supports pin-change interrupts: Needed for RX of SoftwareSerial (TX can be digital any pin)</li> <li><strong>Pin 6</strong> is Connects to Digital 2 pin, also can be used for IRQs</li> </ol> The on-board LED is connected to Digital 1 <h3><strong>Detecting USB connection</strong></h3> This is useful when determining weather we are running on battery power or USB power and take measures to reduce power consumption if we are running on battery. See my full post <a title="Detecting USB connection on the Funky v2" href="">here</a>. <pre class="brush: cpp">void setup(){ USBCON = USBCON | B00010000; pinMode(1,OUTPUT); // The on-board LED delay(550); // Wait at least 550ms,may even require more on slow hosts (necessary) if (UDINT &amp; B00000001){ // USB Disconnected code here digitalWrite(1,HIGH); } else { // USB is connected code here digitalWrite(1,LOW); } } void loop(){ }</pre> &nbsp; <h3><strong>Power saving techniques</strong></h3> When running on battery, we aim to cut power consumption down as much as possible. The following code will bring Funky v2 to about 0.03mA sleep current when running with BOD fuse disabled and at 4Mhz. Also see a <a href="" target="_blank" rel="noopener">complete example on GitHub</a>. <pre class="brush: cpp"> ADCSRA =0; power_adc_disable(); power_usart0_disable(); //power_spi_disable(); //do that a bit later, after we power RFM12b down power_twi_disable(); power_timer0_disable(); // Will also kill timekeeping, so be careful if your code relies on millis(); comment out if these are needed. power_timer1_disable(); power_timer3_disable(); PRR1 |= (uint8_t)(1 &lt;&lt; 4); //PRTIM4 power_usart1_disable(); // Switch to RC Clock UDINT &amp;= ~(1 &lt;&lt; SUSPI); // UDINT.SUSPI = 0; Usb_ack_suspend USBCON |= ( 1 &lt;&lt;FRZCLK); // USBCON.FRZCLK = 1; Usb_freeze_clock PLLCSR &amp;= ~(1 &lt;&lt; PLLE); // PLLCSR.PLLE = 0; Disable_pll CLKSEL0 |= (1 &lt;&lt; RCE); // CLKSEL0.RCE = 1; Enable_RC_clock() while ( (CLKSTA &amp; (1 &lt;&lt; RCON)) == 0){} // while (CLKSTA.RCON != 1); while (!RC_clock_ready()) CLKSEL0 &amp;= ~(1 &lt;&lt; CLKS); // CLKSEL0.CLKS = 0; Select_RC_clock() CLKSEL0 &amp;= ~(1 &lt;&lt; EXTE); // CLKSEL0.EXTE = 0; Disable_external_clock // Datasheet says that to power off the USB interface we have to: // Detach USB interface // Disable USB interface // Disable PLL // Disable USB pad regulator // Disable the USB interface USBCON &amp;= ~(1 &lt;&lt; USBE); // Disable the VBUS transition enable bit USBCON &amp;= ~(1 &lt;&lt; VBUSTE); // Disable the VUSB pad USBCON &amp;= ~(1 &lt;&lt; OTGPADE); // Freeze the USB clock USBCON &amp;= ~(1 &lt;&lt; FRZCLK); // Disable USB pad regulator UHWCON &amp;= ~(1 &lt;&lt; UVREGE); // Clear the IVBUS Transition Interrupt flag USBINT &amp;= ~(1 &lt;&lt; VBUSTI); // Physically detact USB (by disconnecting internal pull-ups on D+ and D-) UDCON |= (1 &lt;&lt; DETACH); power_usb_disable(); // Keep it here, after the USB power down rf12_initialize(storage.myNodeID,storage.freq,; // Initialize RFM12 // Adjust low battery voltage to 2.2V rf12_control(0xC000); rf12_sleep(0); // Put the RFM12 to sleep power_spi_disable();</pre> &nbsp; <a href=""><img class="alignnone size-large wp-image-2487" src="" alt="IMG_2374.jpg" /></a> Licensed under a <a href="" rel="license">Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License</a>. <a href="" rel="license"><img src="" alt="Creative Commons License" /></a>

OldNewDate CreatedAuthorActions
December 23, 2018 @ 21:13:41 Martin
December 23, 2018 @ 21:09:46 Martin
August 26, 2013 @ 19:01:14 Martin
August 26, 2013 @ 19:00:43 [Autosave] Martin
August 24, 2013 @ 14:38:07 Martin
August 12, 2013 @ 15:02:09 Martin
August 7, 2013 @ 10:45:07 Martin
August 7, 2013 @ 10:43:45 Martin
August 7, 2013 @ 10:42:36 Martin
August 4, 2013 @ 14:45:48 Martin
August 3, 2013 @ 19:17:20 Martin
July 19, 2013 @ 19:16:21 Martin
July 3, 2013 @ 12:32:35 Martin
July 2, 2013 @ 10:45:57 Martin
June 17, 2013 @ 15:30:42 Martin
June 16, 2013 @ 20:54:45 Martin
June 16, 2013 @ 19:36:45 Martin
June 12, 2013 @ 15:37:31 Martin
June 11, 2013 @ 17:30:24 Martin
June 10, 2013 @ 17:40:24 Martin
May 9, 2013 @ 22:35:17 Martin
May 6, 2013 @ 17:55:05 Martin
May 6, 2013 @ 17:50:58 Martin
May 6, 2013 @ 17:43:19 Martin
April 18, 2013 @ 20:57:07 Martin
April 1, 2013 @ 21:18:17 Martin
April 1, 2013 @ 21:15:30 Martin
March 26, 2013 @ 11:31:04 Martin
March 26, 2013 @ 11:24:34 Martin
March 26, 2013 @ 11:22:49 Martin
March 18, 2013 @ 15:20:54 Martin
March 17, 2013 @ 19:33:13 Martin
March 17, 2013 @ 19:32:20 Martin
March 15, 2013 @ 13:58:02 Martin
March 15, 2013 @ 13:55:21 Martin
March 13, 2013 @ 12:05:31 Martin
March 12, 2013 @ 22:22:48 Martin
March 1, 2013 @ 14:17:54 Martin
March 1, 2013 @ 13:44:46 Martin
March 1, 2013 @ 13:41:58 Martin
February 21, 2013 @ 09:17:07 Martin
February 21, 2013 @ 09:16:30 Martin
February 20, 2013 @ 12:22:20 Martin
February 19, 2013 @ 14:33:48 Martin
February 19, 2013 @ 14:22:07 Martin
February 19, 2013 @ 14:00:38 Martin
February 19, 2013 @ 14:00:10 Martin
February 19, 2013 @ 11:48:51 Martin
February 19, 2013 @ 11:46:49 Martin
February 19, 2013 @ 11:38:41 Martin
February 19, 2013 @ 11:34:19 Martin
February 19, 2013 @ 11:32:07 Martin
February 19, 2013 @ 11:24:33 Martin
February 19, 2013 @ 09:30:42 Martin
February 19, 2013 @ 09:30:41 Martin
February 19, 2013 @ 09:30:07 Martin
February 19, 2013 @ 09:23:05 Martin

6 thoughts on “[OBSOLETE] Funky v2

  1. Thorsten

    Martin, this is pretty sweet! The only thing that concerns me is that you only provide 3 I/O pins with so much horsepower. How much do these boards end up costing you? It seems to me that it would be totally worthwhile to add another 8-pin strip on the other side. That would only add a couple of millimeters and allow you to add 6 more I/O (assuming VCC+GND pins). I.e. a perhaps 4mm extra space and you get 9 I/Os…

    1. Martin Post author

      I intended this for interfacing with a single sensor, i.e. temperature, humidity, light level, PIR, pulse counter or sending IR/RF codes etc. It is just about the size of a button cell battery and can be powered by one, so having more pins would put more strain to the limited battery power anyway.
      Anyway, I will probably create a bigger “cousin” to the Funky v2 with more pins available some day 🙂

  2. Bill Smith

    What you’ve done here is really cool. I see that you have the RFM2Pi board. Do you know if anyone has interfaced with a Beaglebone Black? Is the RFM12 standard enough that a Funky v2 can talk to a JeeNode or other RFM12 implementation? Thx.


    1. Martin Post author

      I don’t think that it is ported yet, but that should be pretty easy to do, as it uses standard serial @ 3.3V. Yes, the Funky v2 talks happily to all RFM12b based nodes.

  3. Pingback: Non-contact AC detection | Martin's corner on the web

  4. Pingback: RFM12B End of Life | Martin's corner on the web