Member #333081

Member Since: June 22, 2012

Country: United States

  • Product SEN-11447 | about 4 months ago

    OK. HERE IS THE ANSWER I WAS LOOKING FOR!!

         /********************************************** 
          This is code for an Arduino to change the
          "delay between wake up and return to sleep"
          parameter on the Wake-On-Shake (WoS).                       
    
          See the user guide for the syntax to change other parameters.
    
          It is assumed that the serial port on the WoS
          is connected to Serial1 on, say an Arduino Mega.
    
          (Connect RX to TX, TX to RX, Vcc to 3.3V and GND to GND.) 
    
          PLEASE NOTE: I'm no expert. This code worked for me. 
          But I can't guarantee it's accuracy.      
        **********************************************/
    
       void setup() {
          // Initialize the serial port that's connected to the Wake-on-shake. 
         //  (Note: I've used Serial1 which is the 2nd serial port on the Arduino Mega 2560
         //   because Serial (the first port) is used to program the Arduino.)
         //     
          Serial1.begin(9600);
    
          // Establish contact (this seems to help..not sure why?)
          while (Serial1.available() <= 0) {            
            delay(300);
          }
    
          // This is command string.
          // 'd' is the specific command to change the
          // "delay between wake up and return to sleep" parameter.
          // "50000" is the delay time in milliseconds.
          // The command string must end in either '\r' and/or '\n'.
          //
          Serial1.write("d50000\r");
        }
    
        void loop() {
    
          // nothing to do here
        }
    
  • Product SEN-11447 | about 4 months ago

    A want to be able to reliably read before attempting to write. I have the wake on shake’s serial connection connected to Serial 1 on an Arduino Mega 2560. I’m writing a read command ‘E’, for reading the EEPROM, on Serial 1 and printing the reply to the serial monitor (serial 0). Here’s the code:

    (edit) The following works to some degree but not completely. You really have to dig into the source code to figure out how to read parameters from the wake on shake.

    It turns out writing (to change) a parameter is much easier. See my reply to this post.)

         #define DELAY_FACTOR 10
    
        void setup() {
          // initialize both serial ports:
          Serial.begin(9600);
          Serial1.begin(9600);
    
          // Establish contact (this seems to help..why?)
          while (Serial1.available() <= 0) {
            Serial.print('A');   // send a capital A
            delay(300);
          }
        }
    
        void loop() {
    
          Serial.println("--------Start:--------");
          readAddress(0);
          readAddress(1);
          readAddress(2);
          readAddress(3);
          readAddress(4);
          readAddress(5);
          readAddress(127);
          Serial.println("--------End-----------");
    
          while(1);  // do the above only once
        }
    
        void readAddress(byte addr) {
            char buf[16];
    
            Serial1.write('E');
             Serial1.write(addr);        
             Serial1.write('\r');
    
             delay(DELAY_FACTOR);
             if(Serial1.available() > 0)
             {
                   // Read up till the newline which signals the end of the data stream
                   //
                 int n = Serial1.readBytesUntil('\n', buf, 16);
    
                 for(int j=0; j<n; j++)         
                       Serial.print(buf[j]);                        
             }
             else
                 Serial.print("empty");
    
             Serial.println("");
             delay(DELAY_FACTOR);
    
        }
    

    Here is what is printed to the serial monitor:

     A--------Start:--------
    ���� 00150
     05000
     :-)
     00173
     :-)
     :-(
     :-(
     --------End-----------
    

    I’m getting closer. I’m seeing the default values for the 1st 2 parameters. But why am I not seeing the others?

    Any help with what I’m missing is appreciated. Thanks!

  • Product SEN-11447 | about 4 months ago

    OK. I had to read it a few times. I think I see where the info is. Thanks for your reply!

  • Product SEN-11447 | about 4 months ago

    Still looking for help with this. I’d think there should be a way of changing the thing’s basic parameters. In fact is says you can in the user guide but doesn’t explain “how”.

    I’d think one could program an arduino to issue the appropriate serial commands to set the wake on shake’s eeprom with the desired parameters.

    Can someone provide a sample sketch?

    Thanks.

  • Product SEN-11447 | about 4 months ago

    Thanks for the response! (Edit)

    I don’t want to do anything fancy. I just want to adjust the “Time after wake-up before returning to sleep mode” parameter.

    From the user guide:

    “EEPROM Memory Space Reference The Wake-on-Shake uses on-board EEPROM memory to store configuration parameters even if power is removed. The EEPROM is exposed through the serial interface; users can alter these values as they see fit.”

    And apparently the address for this param on the EEPROM is 2-3. I should be able to set this address to a number between 0 - 65535.

    But exactly how? What software and hardware do I need? What are the exact serial commands to do this?

    Thanks.

  • Product SEN-11447 | about 4 months ago

    Please see my question above. Can you provide a small example sketch? Thanks!

  • Product SEN-11447 | about 4 months ago

    Can someone explain how to change the parameters of the wake-on-shake, as to change the time before resuming sleep, etc.? I’m trying to reverse engineer the code in the Github Repo but so far have had no luck compiling in the Arduino IDE. I’m not sure how to setup the IDE for programming the wake on shake board, i.e. what board do I choose, etc?

    I see this is partially explained below. But an example Arduino sketch would be great.

    Thanks!

No public wish lists :(