FirebaseArduino is a library to simplify connecting to the Firebase database fromarduino clients.

It is a full abstraction of Firebase’s REST API exposed through C++ calls in a wiringfriendly way. All Json parsing is handled by the library and you may deal in pure C/Arduinotypes.

Class Documentation

classFirebaseArduino

Main class for Arduino clients to interact with Firebase.

This implementation is designed to follow Arduino best practices and favor simplicity over all else. For more complicated usecases and more control see the Firebase class in Firebase.h.

Public Functions

voidbegin(const String &host,const String &auth = "")

Must be called first.

This initialize the client with the given firebase host and credentials.

Parameters
  • host: Your firebase db host, usually X.firebaseio.com.
  • auth: Optional credentials for the db, a secret or token.

StringpushInt(const String &path, intvalue)

Appends the integer value to the node at path.

Equivalent to the REST API’s POST. You should checksuccess() after calling.

Return
The unique key of the new child node.
Parameters
  • path: The path of the parent node.
  • value: Integer value that you wish to append to the node.

StringpushFloat(const String &path, floatvalue)

Appends the float value to the node at path.

Equivalent to the REST API’s POST. You should checksuccess() after calling.

Return
The unique key of the new child node.
Parameters
  • path: The path of the parent node.
  • value: Float value that you wish to append to the node.

StringpushBool(const String &path, boolvalue)

Appends the bool value to the node at path.

Equivalent to the REST API’s POST. You should checksuccess() after calling.

Return
The unique key of the new child node.
Parameters
  • path: The path of the parent node.
  • value: Bool value that you wish to append to the node.

StringpushString(const String &path,const String &value)

Appends the String value to the node at path.

Equivalent to the REST API’s POST. You should checksuccess() after calling.

Return
The unique key of the new child node.
Parameters
  • path: The path of the parent node.
  • value: String value that you wish to append to the node.

Stringpush(const String &path,const JsonVariant &value)

Appends the JSON data to the node at path.

Equivalent to the REST API’s POST. You should checksuccess() after calling.

Return
The unique key of the new child node.
Parameters
  • path: The path of the parent node.
  • value: JSON data that you wish to append to the node.

voidsetInt(const String &path, intvalue)

Writes the integer value to the node located at path equivalent to the REST API’s PUT.

You should checksuccess() after calling.

Parameters
  • path: The path inside of your db to the node you wish to update.
  • value: Integer value that you wish to write.

voidsetFloat(const String &path, floatvalue)

Writes the float value to the node located at path equivalent to the REST API’s PUT.

You should checksuccess() after calling.

Parameters
  • path: The path inside of your db to the node you wish to update.
  • value: Float value that you wish to write.

voidsetBool(const String &path, boolvalue)

Writes the bool value to the node located at path equivalent to the REST API’s PUT.

You should checksuccess() after calling.

Parameters
  • path: The path inside of your db to the node you wish to update.
  • value: Bool value that you wish to write.

voidsetString(const String &path,const String &value)

Writes the String value to the node located at path equivalent to the REST API’s PUT.

You should checksuccess() after calling.

Parameters
  • path: The path inside of your db to the node you wish to update.
  • value: String value that you wish to write.

voidset(const String &path,const JsonVariant &value)

Writes the JSON data to the node located at path.

Equivalent to the REST API’s PUT. You should checksuccess() after calling.

Parameters
  • path: The path inside of your db to the node you wish to update.
  • value: JSON data that you wish to write.

intgetInt(const String &path)

Gets the integer value located at path.

You should checksuccess() after calling.

Return
The integer value located at that path. Will only be populated ifsuccess() is true.
Parameters
  • path: The path to the node you wish to retrieve.

floatgetFloat(const String &path)

Gets the float value located at path.

You should checksuccess() after calling.

Return
The float value located at that path. Will only be populated ifsuccess() is true.
Parameters
  • path: The path to the node you wish to retrieve.

StringgetString(const String &path)

Gets the string value located at path.

You should checksuccess() after calling.

Return
The string value located at that path. Will only be populated ifsuccess() is true.
Parameters
  • path: The path to the node you wish to retrieve.

boolgetBool(const String &path)

Gets the boolean value located at path.

You should checksuccess() after calling.

Return
The boolean value located at that path. Will only be populated ifsuccess() is true.
Parameters
  • path: The path to the node you wish to retrieve.

FirebaseObjectget(const String &path)

Gets the json object value located at path.

You should checksuccess() after calling.

Return
aFirebaseObject value located at that path. Will only be populated ifsuccess() is true.
Parameters
  • path: The path to the node you wish to retrieve.

voidremove(const String &path)

Remove the node, and possibly entire tree, located at path.

You should checksuccess() after calling.

Parameters
  • path: The path to the node you wish to remove, including all of its children.

voidstream(const String &path)

Starts streaming any changes made to the node located at path, including any of its children.

You should checksuccess() after calling. This changes the state of this object. Once this is called you may start monitoringavailable() and callingreadEvent() to get new events.

Parameters
  • path: The path inside of your db to the node you wish to monitor.

boolavailable()

Checks if there are new events available.

This is only meaningful oncestream() has been called.

Return
If a new event is ready.

FirebaseObjectreadEvent()

Reads the next event in a stream.

This is only meaningful oncestream() has been called.

Return
FirebaseObject will have [“type”] that describes the event type, [“path”] that describes the effected path and [“data”] that was updated.

boolsuccess()

Return
Whether the last command was successful.

boolfailed()

Return
Whether the last command failed.

const String &error()

Return
Error message from last command iffailed() is true.

classFirebaseObject

Represents value stored in firebase, may be a singular value (leaf node) or a tree structure.

Public Functions

FirebaseObject(const char *data)

Construct from json.

Parameters
  • data: JSON formatted string.

boolgetBool(const String &path = "")const

Return the value as a boolean.

Return
result as a bool.
Parameters
  • optional: path in the JSON object.

intgetInt(const String &path = "")const

Return the value as an int.

Return
result as an integer.
Parameters
  • optional: path in the JSON object.

floatgetFloat(const String &path = "")const

Return the value as a float.

Return
result as a float.
Parameters
  • optional: path in the JSON object.

StringgetString(const String &path = "")const

Return the value as a String.

Return
result as a String.
Parameters
  • optional: path in the JSON object.

JsonVariantgetJsonVariant(const String &path = "")const

Return the value as a JsonVariant.

Return
result as a JsonVariant.
Parameters
  • optional: path in the JSON object.

boolsuccess()const

Return
Whether there was an error decoding or accessing the JSON object.

boolfailed()const

Return
Whether there was an error decoding or accessing the JSON object.

const String &error()const

Return
Error message iffailed() is true.