Power Opcode: 133 Data Bytes: 0
This command powers down Roomba. The OI can be in Passive, Safe, or Full mode to accept this
command.
• Serial sequence: [133]
• Available in modes: Passive, Safe, or Full
• Changes mode to: Passive
#include "connect.h"
#include "init.h"
#include <Arduino.h>
byte start[1] = {128};
byte baud[2] = {129, 11};
void connect(){
Serial.begin(115200);
Serial3.begin(115200);
//Connect to Roomba's serial
Serial3.write(start, sizeof(start));
delay(200);
Serial3.write(baud, sizeof(baud));
delay(200);
Serial3.write(fullMode, sizeof(fullMode));
delay(200);
}
#include "sleep_handler.h"
#include "init.h"
#include "button_handler.h"
#include <Arduino.h>
unsigned long last_active_time = 0;
//Serial commands
byte power_down[1] = {133};
//Run to keep roomba active and prevent from sleeping
void roomba_active(){
last_active_time = millis() + 300000;
}
//Check activity time, and power off roomba if inactive for more than 5 minutes
void check_activity_time(){
if(!last_active_time){
roomba_active();
}
if(last_active_time <= millis()){
sleep();
}
}
//Power off roomba
void sleep(){
if(roomba_mode != 0){
Serial3.write(power_down, sizeof(power_down));
roomba_mode = 0;
power_down_roomba = true;
clean_button_pressed_time = 0;
}
}
#include "wake_handler.h"
#include "init.h"
#include "led_handler.h"
#include "sound_handler.h"
void wake(){
roomba_mode = 1;
//Set the mode to safe mode
Serial3.write(fullMode, sizeof(fullMode));
//Turn on the power LED
ledData[1] = 0;
Serial3.write(ledData, sizeof(ledData));
//Play beep
play_beep();
}
Then it's reading sensor group 3 (142,3) every 10 seconds
Users browsing this forum: KeldBroe, someoneclever and 321 guests