Power

Discussion about the upcoming YellowJacket (WiFi+Arduino mini).

Re: Power

Postby John_Ryan » Tue May 25, 2010 7:35 pm

GregEigsti wrote:My plan for global domination is to connect the YJ to the Mattel Mindflex headset thereby making its "brain activity" data available on the net - probably UDP broadcast.


So you'll be wanting to broadcast occasional packets of 128 bytes?

GregEigsti wrote:The next step will be world domination via thought transmission


Google already beat you to it.

GregEigsti wrote:My son who can make the ball go up and down at will
Greg


And they say "an apple never falls far from the tree"?

:D
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: Power

Postby John_Ryan » Tue May 25, 2010 7:40 pm

seanblink wrote:Please hook it up to Twitter.


Twitter is perfect for short messages :mrgreen:

..
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: Power

Postby GregEigsti » Tue May 25, 2010 9:39 pm

John_Ryan - you are mean spirited ;)

I don't think twit, errrr really fits the bill for a couple of reasons. While the headset is being worn it transmits a ~64 to ~128 byte packet every second. Twit, errrr is not really well suited to accept raw data at that rate (yeah I could just tx an occasional summary but the headset is not very comfy so I doubt I'll be wearing it for long stretches). Also, since the YJ will be receiving data from the headset every second I don't think that there will be enough processing power/speed to read the data and send it to an external service every second. BTW - go check out BrightKite it is far superior to twit, errrrr. Ok, now I am being mean spirited :lol:

mfm219 thanks for the wisdom! I took a look at the headset this evening and it takes 3 AAA batteries meaning there is ~4.5v max available. Doubtful that is enough to run the YJ without some serious trickery (or for very long). I have a BlueSmirf gold bluetooth module and need to look up its operational parameters; it might be a better solution. My goal is to keep this all completely wireless. Another potential fly in the ointment is that the Mindflex headset transmits on 2.4Ghz which could very well interfere with WiFi and/or Bluetooth.

We received the Mindflex late last week and the kids are still enamored with it. I'll have to wait a week or two until they get bored with it before I can start hacking around with it...

Edit - found the following specs on the BlueSMiRF Gold. Its looking pretty good for this application.
  • Low power consumption : 25mA avg
  • Operating Voltage: 3.3V-6V

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Power

Postby John_Ryan » Wed May 26, 2010 1:20 am

GregEigsti wrote:I don't think that there will be enough processing power/speed to read the data and send it to an external service every second.


I would have thought a server might handle it? Post the data from yJ to a php script that saves the data to a mysql table, then display the data using ajax which reads the mysql, and then updates the document element assigned to display the data. There won't be any pulling from the server side on the yJ that way, which should leave the controller free to deliver the data at 1 second (or thereabouts) intervals.

You could also use the same method for "chucking" data at a server, then letting the server handle the processing and posting the data back to the likes of "twit errr". These small controllers need all the help they can get, and thankfully the Wishield makes it easy (as you know) to draw upon the resources of a well endowed linux server - like my date/time example for instance, I don't need to include a big fat date / time / synchronization library anymore, that hard work is performed by a php script running as a cron job on a server which retrieves the date and time from an atomically calibrated clock, and the controller can then opt to take delivery of the data the script posts to it using one simple URL variable.

These are exciting times, I can envisage a whole host of tasks being handled servers instead of these poor little controllers.

..
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: Power

Postby GregEigsti » Wed May 26, 2010 4:48 pm

In fact I do employ this model at the house - my sensing apps (heat/humidity/power use/cat's blood pressure/etc.) all throw data to a Win32 server which logs said data into MySQL and then forwards it on to the appropriate places (e.g. Pachube).

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Power

Postby John_Ryan » Thu May 27, 2010 9:08 pm

GregEigsti wrote:In fact I do employ this model at the house - my sensing apps (heat/humidity/power use/cat's blood pressure/etc.) all throw data to a Win32 server which logs said data into MySQL and then forwards it on to the appropriate places (e.g. Pachube).

Greg


So, do you have you board accessible to the outside world or are you only using it locally?
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: Power

Postby GregEigsti » Thu May 27, 2010 9:58 pm

So, do you have you board accessible to the outside world or are you only using it locally?

Here are a couple that are accessible to the outside world:
Home Power Meter
SHT15 Temperature/Humidity - this feed has five inputs; the two from the SHT15 are clearly marked. The other three are from a temperature/pressure unit that is connected directly to the server via the serial port (temperature probe is outside). Bought that years ago before I started playing with embedded stuff.

The Whole House Power Meter project is documented here (personal site) and here (Completed Wi-Fi forum).

The SHT15 Temperature/Humidity project is documented here (personal site) and here (Completed Wi-Fi forum). This is the project that is in the problematic WiFi coverage spot and has recently been replaced with the WiShield 2.0 with external antenna (which has been working flawlessly). Its out in my shop which has an oil/radiator/heater that is always on (and appears to be set too warm - must have been working out there, turned it up, and neglected to turn it back down). :lol:

Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Power

Postby John_Ryan » Fri May 28, 2010 7:02 pm

Awesome. The reason I asked is because I sneaked some time and managed to get the WiPiler (WiCli) running. To use it, requires an outside accessible IP address for the target controller.

Below is a snap shot of a session using a few token commands. The CLI executes the connect string and the last command entered, so the first command must always be the connect string. The "LAST" command gets executed when the ENTER key is pressed, but you can navigate around the command area using the arrow keys and/or mouse.

Connect: 000.000.000.000, the controllers IP address - php evaluates the address, decides if its valid, then pings it.
RAM, returns the number of bytes currently free in RAM
FREE, shows available memory using malloc/free
USED, shows memory used using malloc/free
KILL, resets the controller
ELAPSED, shows minutes elapsed since power up
LED1 ON, turns a LED on
LED1 OFF, turns a LED off

The commands and responses happen in real time, and the Response window updates automatically as soon as a reply from the controller is received. Using the "Save" button, saves the session commands and responses in an xml file.

1ss1.jpg
1ss1.jpg (69.79 KiB) Viewed 42 times


This is the Sketch, and its for WiServer mode.

Code: Select all
/*
* for WiPiler / WiCli
*/
#include <WiServer.h>

/******************************************
*              Wireless SetUp             *
******************************************/
unsigned char local_ip[] = {10,1,1,3};
unsigned char gateway_ip[] = {10,1,1,1};
unsigned char subnet_mask[] = {255,0,0,0};
const prog_char ssid[] PROGMEM = {"SSID"};
unsigned char security_type = 2;
const prog_char security_passphrase[] PROGMEM = {"password"};
prog_uchar wep_keys[] PROGMEM = {};
unsigned char wireless_mode = 1;
unsigned char ssid_len;
unsigned char security_passphrase_len;

/******************************************
*                Variables                *
******************************************/
unsigned long theMinutes; // Minutes elapsed since start up
extern int  __bss_end; // used by freemem
extern int  *__brkval; // used by freemem
char nuMbuf[10]; // holds result of itoa
int cType=2048; // RAM value for a 328 controller
#define cmds_count 7 // number of commands in list below
char *cmds[]={ "/", "/?LED1_ON", "/?LED1_OFF", "/?KILL", "/?ELAPSED", "/?FREE", "/?USED", "/?RAM" };
int cmd_selected=99; // an invalid command value

/******************************************
*         Funtion Definitions             *
******************************************/

// FUNCTION: Send reply
void reply (char* respond){
    WiServer.print(respond); // send response
    WiServer.print("\r\n");
}

// FUNCTION: Calculate Available memory using malloc
int availableMemory() {
    int aM_size = 2048;
    byte *aM_buf;
    while ((aM_buf = (byte *) malloc(--aM_size)) == NULL);
    free(aM_buf);
    return aM_size;
}

// FUNCTION: return the number of bytes currently free in RAM     
int freemem(){
    int free_memory;
    if((int)__brkval == 0)
        free_memory = ((int)&free_memory) - ((int)&__bss_end);
    else
        free_memory = ((int)&free_memory) - ((int)__brkval);
    return free_memory;
}
 
// Function that generates responses for recognized URL commands
boolean sendMyPage(char* URL) {
 
  cmd_selected=99; // 99 is an invalid command
  // We examine the URL command against the cmds array
  for( int comp_cmds=0; comp_cmds <=  cmds_count; comp_cmds++) {
    if (strcmp(URL, cmds[comp_cmds]) == 0) {
    cmd_selected=comp_cmds; // the value of a command match
    } 
  }

  switch (cmd_selected) {
    case 0: { // Check if the requested URL matches "/" - the default home page
      reply ("<html><title>Server ready</title><p>Ready ></p></html>"); // send response
      break;
    }
    case 1: { // COMMAND: "/LED1 ON" turn led on
      reply ("LED 1 is ON"); // send response
      break;
     }
    case 2: { //LED1 OFF" turn led off
      reply ("LED 1 is OFF"); // send response
      break;
    }
    case 3: { // COMMAND: "/KILL" reset
      reply ("Resetting"); // send response
      WiServer.init(sendMyPage); // do a reset
      break;
    }
    case 4: { // COMMAND: "/ELAPSED" microsceonds since power up
      reply (itoa(millis()/1000/60, nuMbuf, 10)); // send response
      break;
    } 
    case 5: { // COMMAND: "/FREE" report available memory
      reply (itoa(availableMemory(), nuMbuf,10)); // send response
      break;
    }
    case 6: { // COMMAND: "/USED" report memory used
      reply (itoa(cType-availableMemory(), nuMbuf,10)); // send response
      break;
    }   
    case 7: { // COMMAND: "/RAM" report available RAM
      reply (itoa(freemem(), nuMbuf,10)); // send response
      break;
    }
    default: {
      // The default output is page name is unknown. This seems to fix controllers locking-up when bots visit looking for content
      reply("ok"); // something was typed but we don't know what, so reply with an ok acknowledgement
      return true; // URL was recognized
    }
  }
return true;
}

/******************************************
*                  SETUP                  *
******************************************/
void setup() {
  WiServer.init(sendMyPage); // Initialize WiServer
  WiServer.enableVerboseMode(false); // Turn off event printing
}

/******************************************
*                   LOOP                  *
******************************************/
void loop(){
  // Run the WiServer
  WiServer.server_task();
}

/******************************************
*                    END                  *
******************************************/


If you want to try the application, you can go to ( http://www.cssgurus.com/pm/ ) and register a new account, that takes 2 seconds and you can start playing immediately.

If you do and you come across any bugs, let me know. I expect there'll be a few ajax issues with different browsers so as long as you've got Firefox then it should be sweet = )

..

EDIT Sketch updated, RAM command added
EDIT Introduced a command array and switch/case command translator to save a few bytes, 53 to be exact 30/05/10
Last edited by John_Ryan on Sat May 29, 2010 9:27 pm, edited 3 times in total.
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

Re: Power

Postby GregEigsti » Fri May 28, 2010 8:30 pm

Nice stuff! Can you explain what the IP address parameter to "CONNECT:" should point to? I pointed it at an intarweb site and it downloaded the site data (e.g. curl like) but my subsequent LED1 ON / LED1 OFF / KILL commands yielded "Invalid IP address." So I am guessing that my incorrect use of the IP address param to CONNECT is to blame?

Thanks for sharing!
Greg
Check out the wiki!
uIP Stack Docs
Compatible Access Point List
WiShield user contrib branch - DNS, DHCP, AP Scanning, bug fixes, etc.
SlackLab.org - My geek projects blog.
User avatar
GregEigsti
 
Posts: 1067
Joined: Sun Aug 02, 2009 5:23 pm
Location: Sammamish WA USA (near Seattle)
  • Website

Re: Power

Postby John_Ryan » Fri May 28, 2010 9:07 pm

Thanks, and yes your IP address needs to be used, so that can be IPv4 or IPv5 eg. Connect: 123.004.119.002 etc etc

If that's going to cause problems then I can modify the script to accept DNS forwarded address, which is how I had it originally - but I didn't think many people used dns forwarding so I decided an IP address format would have a more generic appeal.

Let me know how you get on = )

..
John_Ryan
 
Posts: 155
Joined: Thu Jun 04, 2009 11:24 pm

PreviousNext

Return to YellowJacket

Who is online

Users browsing this forum: No registered users and 1 guest