Skip to content
This repository was archived by the owner on Mar 17, 2025. It is now read-only.

Pro-mini + ESP8266 connection to Firebase #297

Closed
jfrankert opened this issue Nov 13, 2017 · 16 comments
Closed

Pro-mini + ESP8266 connection to Firebase #297

jfrankert opened this issue Nov 13, 2017 · 16 comments

Comments

@jfrankert
Copy link

Good morning all!

It looks like a similar question was asked a few months back, but has not been closed as complete, so I decided to post one here.

I am trying to connect to Firebase using a Pro-mini connected to a ESP8266. I have successfully connected a ESP8266 directly to my Firebase DB and sent info. Now I want to use the Pro-mini as the main board and send the data this way.

Has anyone done this yet? Sample code? Much appreciated!

@jfrankert
Copy link
Author

It looks like it errors on missing <string.h>. Any ideas?

Trying to run this via ESP thru Pro-mini.

@proppy
Copy link
Contributor

proppy commented Nov 14, 2017

https://github.com/firebase/firebase-arduino/tree/master/contrib/examples/FirebaseSerialHost_ESP8266 contains the sketch to deploy to the ESP

Make sure the TX,RX line of the ESP to the RX,TX line of the Arduino board.

You can then make Firebase API call from the Arduino sketch using the Serial protocol defined by @ed7coyne https://raw.githubusercontent.com/firebase/firebase-arduino/7144703dc6269bee4e60b60fa612f41aeeb5a75f/contrib/src/modem/serial_protocol.md

###Examples
	>> NETWORK home-guest
	<< +CONNECTED
	>> NETWORK home-private MySecretPassword
	<< +CONNECTED
	>> NETWORK home-guest
	<< -UNABLE_TO_CONNECT

###Examples
	>> BEGIN_DB https://samplechat.firebaseio-demo.com
	<< +OK
	>> BEGIN_DB https://samplechat.firebaseio-demo.com nnz...sdf
	<< +OK

###Examples
	>>GET /user/aturing/first
	<<+Alan
	>>GET /user/aturing
	<<$39
	<<{ "first" : "Alan", "last" : "Turing" }

@jfrankert
Copy link
Author

@proppy - When I try to compile the sketch before uploading it to the ESP8266 I get the following error:

....fatal error: SerialTransceiver.h: No such file or directory
#include <SerialTransceiver.h>
^
compilation terminated.

exit status 1
Error compiling for board Generic ESP8266 Module.

The .h files are located in the repository. Not sure why this is not compiling.

@proppy
Copy link
Contributor

proppy commented Nov 15, 2017

This might have broken when we moved the file to contrib, as the modem code is not something we're actively developing anymore.

Can you try to copy the file from https://github.com/firebase/firebase-arduino/tree/master/contrib/src in your sketch directory.

@jfrankert
Copy link
Author

I have copied all SerialTranceiver.h contents and replaced in the current directory. The same error exists.

@jfrankert
Copy link
Author

I also tried the commit prior to contrib. That does not work as well.

@jfrankert
Copy link
Author

jfrankert commented Nov 15, 2017

The following commits (e1co3 /922cf / 67c88 on contrib branch) on example: FirebaseSerialHost_ESP8266 produced the following error:

Arduino: 1.8.5 (Mac OS X), Board: "Generic ESP8266 Module, 80 MHz, 40MHz, DIO, 115200, 512K (64K SPIFFS), ck, Disabled, None"

/Users/Documents/Arduino/libraries/firebase-arduino-67c880d543d47612eca34c5a62a18555a3cabf74/src/thing/FireThing.cpp:15:3: error: 'D1' was not declared in this scope
D1, // digital in
^
/Users/Documents/Arduino/libraries/firebase-arduino-67c880d543d47612eca34c5a62a18555a3cabf74/src/thing/FireThing.cpp:18:3: error: 'D1' was not declared in this scope
D1, // analog out
^
/Users/Documents/Arduino/libraries/firebase-arduino-67c880d543d47612eca34c5a62a18555a3cabf74/src/thing/FireThing.cpp:19:3: error: 'D0' was not declared in this scope
D0, // config mode button
^
exit status 1
Error compiling for board Generic ESP8266 Module.
#######

The following commit has compiled: 9ae40

I will test and report back.

@jfrankert
Copy link
Author

I have successfully uploaded the FirebaseSerialHost file to the ESP8266. After the initial upload the board successfully got through the setup() w/ SSID and PASSWORD entered via the sketch.

I will connect the Arduino board to the ESP and try to send general protocol commands via the Arduino serial monitor and report back.

@jfrankert
Copy link
Author

I can not get the ESP to respond to any general protocol items. I tried directly to the ESP with serial monitor and I have also tried through the Arduino Pro-mini.

Can you provide some more info on how to get this working? The details on the connections are not that clear.

Also, does anyone have any other ideas?

@proppy
Copy link
Contributor

proppy commented Nov 17, 2017

@jfrankert what happens when you try to talk to the ESP thru the serial port after deploying https://github.com/firebase/firebase-arduino/tree/master/contrib/examples/FirebaseSerialHost_ESP8266 ?

By default the serial channel is on pin 4 and 5, see https://github.com/firebase/firebase-arduino/blob/master/contrib/examples/FirebaseSerialHost_ESP8266/FirebaseSerialHost_ESP8266.ino#L35

I think we discussed with @ed7coyne in the past that it might be better to set it on the default channel for better discovery.

Can you try to replace data_serial with Serial in the sketch and see what happens?

@jfrankert
Copy link
Author

@proppy When I connect the ESP to an FTDI and upload, the serial monitor will show wifi connected. If I try to run commands through the serial monitor, I get no response. No errors / +OK ...etc.

Just to explain a bit better, on the Arduino Pro-Mini I run a sketch like attached: http://www.martyncurrey.com/arduino-to-esp8266-serial-commincation/

I changed the serial channel pins to 2 and 3 based on how I have successfully used the Pro-mini in the past. So on the FirebaseSerialHost sketch this is updated.

Yes, I will pull out SoftwareSerial and just use Serial today. I will report back.

@Nerus92
Copy link

Nerus92 commented Nov 27, 2017

Hi @proppy, I am working on the same issue and I am making some progress. My 'strategy' is to take the modem code you previously did, and adapt it to the new FirebaseArduino.h functions rather than the lower level Firebase.h ones which have evolved in an incompatible way apparently.

Using the adapted modem I am able to connect to Firebase and set an integer value --> Good!

Now I am trying to replace the previous error handling. I was thinking about using Firebase.available() to replace else if (!fbase_) on line 28 of DatabaseProtocol.cpp, but it seems that I cannot get a proper response from that. While I am able to push and get values to my Firebase, a call to Firebase.available() will return False. Am I understanding this function right?

@proppy
Copy link
Contributor

proppy commented Jan 31, 2018

@Nerus92 glad to hear you got something working.

I think the if (!fbase_) only test if BEGIN_DB has been called (and therefore if the object has been initialized. @ed7coyne might be able to comment further.

@proppy
Copy link
Contributor

proppy commented Jun 15, 2018

FYI, filed #340 to turn the modem codebase into a simpler sample, which would go in the same direction point ed by @Nerus92 in #297 (comment).

@sebasbose
Copy link

Is this solution still working?? I think this might solve the problem I am currently experiencing. I am working with an Arduino Mega2560 as the main board and ESP8266 (ESP-01) as the WiFi Module, they communicate using Serial Communication. The library I used to manage the WiFi is "ESPWiFi.h" but I haven't been able to Read/Write data from (to) Firebase because the existing libraries seem to not be compatible with the ATMega2560's architecture... any ideas??

@jfrankert
Copy link
Author

jfrankert commented Mar 7, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants