Giter VIP home page Giter VIP logo

esp-roomba-mqtt's Introduction

esp-roomba-mqtt

TravisCI Build Status

ESP8266 MQTT Roomba controller (Useful for hooking up old Roombas to Home Assistant)

Parts:

  • ESP12E ESP8266 Wifi microcontroller ($3-4) Though any ESP module will probably work
  • Small 3.3V switching step-down regulator ($1-2)
  • 5kOhm & 10kOhm resistor for 5V->3.3V voltage divider (any two resistors above a few kOhm with a 1:2 ratio should work)
  • Some ~10kOhm pullup/pulldown resistors to get the ESP12E in the right modes for programming (probably anything 2k-20kOhm will work fine)
  • 3.3V FTDI cable for initial programming
  • Some wire you can jam into the Roomba's Mini Din connector, or a proper Mini Din connector

Electronics

esp-roomba-mqtt schematic. ESP-12E symbol by J. Dunmire in kicad-ESP8266. is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License. To view a copy of this license visit http://creativecommons.org/licenses/by-sa/4.0/

Connections

  • ESP GPIO15 -> 10kOhm Resistor -> GND
  • ESP GPIO0 -> 10kOhm Resistor -> 3.3V
  • ESP EN -> 10kOhm Resistor -> 3.3V
  • ESP TX -> Roomba RX (Pin3 on Roomba's Mini Din connector)
  • Roomba TX (Pin4 on Roomba) -> 5kOhm -> ESP RX -> 10kOhm -> GND
  • ESP GPIO14 -> Roomba BRC (Pin5 on Roomba)
  • ESP 3.3V -> Voltage regulator 3.3V
  • ESP GND -> Voltage regulator GND
  • Voltage regulator Vin -> Roomba Vpwr (Pin 1 or 2 on Roomba)
  • Voltage regulator GND -> Roomba GND (Pin 6 or 7 on Roomba)

Voltage divider

Note that I used a voltage divider from the Roomba TX pin to the ESP12E RX pin since the Roomba serial is 5V and the ESP is 3.3V. I used a 5kOhm resistor and a 10kOhm resistor but anything above a few kOhm with a 1:2 ratio should be fine.

Compiling the code

Setting some in-code config values

First off you'll need to create a src/secrets.h. This file is .gitignore'd so you don't put your passwords on Github.

cp src/secrets.example.h src/secrets.h

Then edit your src/secrets.h file to reflect your wifi ssid/password and MQTT server password (if you're using the Home Assistant built-in broker, this is just your API password).

You may also need to modify the values in src/config.h (particularly MQTT_SERVER) to match your setup.

Building and uploading

The easiest way to build and upload the code is with the PlatformIO IDE.

The first time you program your board you'll want to do it over USB/Serial. After that, programming can be done over wifi (via ArduinoOTA). To program over USB/Serial, change the upload_port in the platformio.ini file to point to the appropriate device for your board. Probably something like the following will work if you're on a Mac.

upload_port = /dev/tty.cu*

If you're not using an ESP12E board, you'll also want to update the board line with your board. See here for other PlatformIO supported ESP8266 board. For example, for the Wemos D1 Mini:

board = d1_mini

After that, from the PlatformIO Atom IDE, you should be able to go to PlatformIO->Upload in the menu.

Testing

Mosquitto can be super useful for testing this code. For example the following commands can be used publish and subscribe to messages to and from the vacuum respectively.

export MQTT_SERVER=YOURSERVERHOSTHERE
export MQTT_USER=homeassistant
export MQTT_PASSWORD=PROBABLYYOURHOMEASSISTANTPASSWORD
mosquitto_pub -t 'vacuum/command' -h $MQTT_SERVER -p 1883 -u $MQTT_USER -P $MQTT_PASSWORD -V mqttv311 -m "turn_on"
mosquitto_sub -t 'vacuum/#' -v -h $MQTT_SERVER -p 1883 -u $MQTT_USER -P $MQTT_PASSWORD -V mqttv311

Debugging

Included in the firmware is a telnet debugging interface. To connect run telnet roomba.local. With that you can log messages from code with the DLOG macro and also send commands back that the code can act on (see the debugCallback function).

Roomba 650 Sleep on Dock Issue

Newer Roomba 650s (2016 and newer) fall asleep after ~1 minute of being on the dock. Though the iRobot Create 2 docs say that you can keep a Roomba awake by pulsing the BRC pin low, it doesn't seem to work for newer Roomba 650s when they are on the dock. Thinking Cleaner's docs note that this is likely a bug, and they have a workaround to keep the Roomba awake while docked. I haven't figured out the magic sequence to keep Roomba 650s awake on the dock (see this code comment for what I've tried).

esp-roomba-mqtt's People

Contributors

apocrathia avatar johnboiles avatar kg333 avatar kylearector avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

esp-roomba-mqtt's Issues

config of secrets.h file

Hi,
I see there isn't MQTT_USER line in secrets.h file, I don't use default conifg/integrated MQTT in HASSIO, so I ask you if I can add this line:

#define MQTT_USER "usernameMQTT"

Disable default wifi hotspot

Hello! Great project! Finally may be I can get a remote control to my 500 old guy :)

But I have a question: I successfully compiled and uploaded firmware to esp card. Booted it then and connected to it using telnet. Seems to be ok so far. But what I don't understand - is when card is booted I see AI-THINKER_xxxxx wifi hotspot with no security provided. Can you tell me how to turn off that wifi?

Regards,
Dash

Roomba 560 no control

I have the hardware built and it is working with the "hookup" MQTT code but I wanted to use the mqtt_vacuum code instead.

its an esp07 to start with and voltage regulator and the PNP for the TX line boost.

I can telnet to the esp running the code and see verbose messages. I see it uploading info to MQTT topics with all 0s and when I send a command I see it in the debug telnet session.

it's like the Roomba is not recognizing the codes sent.

Does this code work with the older 500 series?
Do I need to change the code and comment out something? I have read through most of the code

TX and BRC

Device: Roomba 700 using ESP01
I have one problem and one question;

  1. RX works fine I get all the sensor values but nothing happens when sending it any commands.

Question: Can I switch the BRC ping from GPIO15 to GPIO2 since the esp01 doesnt expose 15?

Not Compatible with the newest hass.io integration

Im having a great deal of problems getting this integrated.
The legacy MQTT Vacuum is going to be removed. So im trying to switch to the newest state driven object.

I just cant figure out howto get this script to report the right format.

Deep sleep

Hi,

any updates from preventing the roomba going to deep sleep, so the serial comm doesn't get disabled?
Same problem here :/

howto rename Roomba

if I have different Roomba to control where I can change name of Roomba to control them all together with same MQTT server?

MQTT message size limit

After charging, MQTT stopped working. Reason: https://github.com/knolleary/pubsubclient has documented limit to 128b - this is apparently exceeded when voltage and charge have sufficient digits.

Workaround: Prepend
#define MQTT_MAX_PACKET_SIZE 256
before other includes or withing PubSubClient.h

Compiling using Arduino IDE (passing build_flags)

Doe anyone know how to push build_flags in platformio.ini to Arduino IDE or optional code to be used for Arduino IDE? For now I worked around by removing #IF LOGGING (and #ELSE structure) to have it compiled with debug mode.

Roomba 770 Responds to clean message, but no others.

I've got this "working" on my Roomba 770.

I had to make some changes where ArduinoJSON got version incremented and broke a few things.

The side effect seems to be that the roomba wakes up and cleans randomly and stops responding over mqtt. I suspect its crashing, but the telnet interface never goes down or stops responding.

Debug mode keeps disconnecting

Roomba 780
PLATFORM: Espressif 8266 > WeMos D1 R2 and mini
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
BRC is on GPIO14 (marked as D5 on Wemos)
Compiled with PlatformIO (had to fix ArduinoJSON to v5), WiFi and MQTT connections seemingly work but debug terminal keeps disconnecting (tried telnet, nc and websocket - same behavior). Pings to the ESP continue to return with no interruptions.

I suspect that this may have other symptoms as it responds to incoming MQTT commands but it feels as if it hangs waiting for response from Roomba - first command is executed but consecutive ones are seemingly not processed until it times out.
Another symptom which may confirm lack of response is the status message:

Reporting packet Distance:0mm ChargingState:0 Voltage:0mV Current:0mA Charge:0mAh Capacity:0mAh

D1 Mini restarting every 11 seconds

Once flashed, D1 mini is restarting every 11 seconds.

When connected through telnet to the device, last message shows it is trying to connect to MQTT server before telnet connection is lost

* Please type the command and press enter to execute.(? or h for this help)
***
v
* Debug: Command received: v
* Debug level set to Verbose
(D) Reconnecting MQTT
(D) Attempting MQTT connection...
(D) MQTT connected

This issue occurs both right after flashing a new D1Mini, as well as when it is connected to Roomba.

No MQTT status updates observed with vacuum/#

Below the platformio.ini

[env:d1_mini]
platform = espressif8266
board = d1_mini
framework = arduino
lib_deps = 
	RemoteDebug
	PubSubClient
	ArduinoJson@~5.13.4,!=6
upload_port = COM3
build_flags = -DLOGGING=1 -DMQTT_MAX_PACKET_SIZE=512

and config.h

#include "secrets.h"

#define HOSTNAME "roomba555" // e.g. roomba.local
#define BRC_PIN 14
#define ROOMBA_650_SLEEP_FIX 1

#define ADC_VOLTAGE_DIVIDER 44.551316985
//#define ENABLE_ADC_SLEEP

#define MQTT_SERVER "192.168.1.1"
#define MQTT_USER "********"
#define MQTT_COMMAND_TOPIC "vacuum/command"
#define MQTT_STATE_TOPIC "vacuum/state"

Failed to read sensor values from Roomba

Platform: Roomba 780
board: d1_mini
Used PlatformIO to build the code.
Start/stop/return_to_home seems to work just fine but unfortunately no telemetry. Connecting back to telnet debug port getting repeating:
(d) Failed to read sensor values from Roomba

Happy to provide any necessary information

Roomba wakes up and restarts every 10 seconds

When connecting the Nodemcu the roomba enters a loop that wakes it up (sound included) and after about 10 seconds it restarts and returns to do the same. I can have debug connection by telnet. But when sending a command I receive the disconnect message. When trying to press the buttons of the roomba, he receives the commands but executes them with these 10-second pauses. By executing a pin to the ip of the nodemcu, I check that the board restarts at that time. Test with 2 other plates and the result is the same. Even if the feed for usb and without any additional connection is reset every 10 seconds.

Not Working after Upload to D1 Mini

I have uploaded the code on a D1 Mini board and it doesn't appear to work.

If i monitor the serial out i can see
--- Miniterm on /dev/cu.usbserial-1410 9600,8,N,1 --- --- Quit: Ctrl+C | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H --- ,E����dGI�0lK��␄i�␞H␡����Ȍ!C����V)��3���T!��4�B�P�j���������������������������������\��������������������������������������޿��������������n���ʿ�������\��������������q��R8���d:w����␌!��␎��f闍␙���v��!�K��b��\�l�������������������������������\��T����������������ş�����������l�������ղ�����������ڱ����������������������������?3�b(��;G������E�����)��7��!!�:�TD�j�����������d���������������������\�������������������������������������ڌ�������Ų��������?��������������������l�����u��V(�)�D
�������E���␙�ť�7�1!��*�␚����U�����������������������܍�������������������ʲ���g��������������������ݸ������������F�܌�������������������l�����u���)�D`

I also don't get any messages published to the MQTT Topic.

Strange Thing taking from Roomba

Hello

I have the following issue: from time to time my Roomba is saying something in docking position, "lei aler" maybe???
I don't have any clue what is he saying.
I changed the software on my ESP 01 and tried a simple sketch and when the Roomba is Docked and I send again the seak dock command to it it's saving the same thing."lei aler"
Why is the command to seek Dock is sent from time to time if the Roomba is in docking position?
Can I disable this? And How?

Problems installing on ESP01

Hi.

Ive tried uploading it to an Wemos D1 mini..

And connected it. But i get nothing in MQTT. Not even the hello message.. First time using Platform IO.

Tried uploading to an ESP01 instead.. This does not work either.

What is the correct schematic for using the wemos D1 mini. The Schematics seems to show some of the internal resistors also

Wiring Scmatics for ESP 01

Hello,

Would it be possible to post a wiring Scmatics & Config changes required for use with an ESP 01?

I seen another video online from The Hookup where Rob uses a PNP transistor and a buck converter. I’m wondering why you use all the resistors?

Apologies, my electronic knowledge is not great!

Roomba 521

I would know if it work also with roomba 521

Warning: control reaches end of non-void function

Getting the following warning on build:

src\main.cpp: In function 'bool parseRoombaStateFromStreamPacket(uint8_t*, int, RoombaState*)':
src\main.cpp:309:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^

Quick fix of adding a "return false" statement to the end of the function caused boot-loops, so this will need a more in-depth look.

Using it with domoticz ?

Hello, does someone use it with Domoticz ? I don't have home assistant, only domoticz. Could you tell me what command send to start the roomba ? When it's connected on my wifi, there is no web interface. Is it normal ?

build problem

Hi,
using suggested Visual studio Code, I obtain this error during build task:

src/main.cpp:1:10: fatal error:
'Arduino.h' file not found
#include <Arduino.h>

I need to download libraries from other repository?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.