Im pretty fresh to app inventor, can you elaborate on how to do that with clock?
Did you pull in a Clock component from the Sensors Drawer in the Designer yet?
yes but i dont quite understand what to do with it or how
Smth like that? ( i want to use button to manually refresh values aswell sometimes)
Did you pull in a Clock1 Timer event block in the Blocks Editor?
Yes but what do i need to put in it? To make it work like a refresher/puller of data from firebase>?
You put in it the same Get blocks you had in that button Click event you showed us.
There is a tool tip that pops up when you hover your cursor over each block.
It helps to read those.
Is this it? Should be working now?
Yes, that's it.
If the Timer is enabled, it should be shooting off requests to Firebase every second, following the Clock1 attributes.
and
But it still doesnt work when i download it on android
It's still the same screen im getting in the beggining with both labels having "text for the label"
And i have like this in firebase
Am I doing something wrong with this app? Cuz im really hopeless ngl.
No matter what i do the changes wont show in my android phone at all ;/
You are supposed to read all the blocks in the FireBase Blocks Pallette to see what they do.
Especially the golden event blocks.
That should give you a hint of what you need.
okay nvm, my esp 12 e wrote things in wrong directory. They just weren't in bucket but were buckets themselves. After correctly arranging them i succeded in properly getting read from firebase!
Thanks for patience! <3
Could you post your new code from both sides, for the next person who needs this?
Here a tutorial
Here, the wiever with firebase
The block code:
The ESP 8266 code:
#include <ESP8266WiFi.h>
#include <FirebaseArduino.h>
#include <DHT.h>
#define frb_link "axxxxxxxxxxxxxxxeio.com"
#define frb_haslo "8JGxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxOJGq3"
#define wifi_ssid "SM-xxxxxx"
#define wifi_haslo "mnxxxxxx"
#define DHTPIN D2 // Cyfrowy pin podlaczony do sensoru
#define DHTTYPE DHT11 // definiowanie sensoru temperatury
#define Indupin D3 //
DHT dht(DHTPIN, DHTTYPE);
String msg1 = " Wykryto metal";
String msg2 = " Nie wykrywa";
void setup()
{
pinMode(Indupin, INPUT); // definiuje typ pinu 2
Serial.begin(9600);
dht.begin(); //odczytuje dane z sensora
WiFi.begin(wifi_ssid, wifi_haslo); // Logowanie do wifi
Serial.print(wifi_ssid);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("Polaczono z siecia");
Serial.print("Adres IP: ");
Serial.println(WiFi.localIP()); //wyświetla lokalne ip
Firebase.begin(frb_link, frb_haslo); // łączenie do bazy danych
}
void loop()
{
float t = dht.readTemperature(); // Odczyt temperatury w celsjuszach
int sensorValue = digitalRead(Indupin);
if(sensorValue==LOW)
{
Serial.println(msg1); // komunikat w konsoli
Firebase.setString("Indukcja", msg1); // Zmiana wpisu w bazie danych
delay(500);
}
else
{
Serial.println(msg2); // komunikat w konsoli
Firebase.setString("project-787465550920/Indukcja", msg2); // Zmiana wpisu w bazie danych
}
Serial.print("% Temperatura: ");
Serial.print(t);
Serial.println("°C ");
Firebase.setFloat ("project-787465550920/Temperatura",t); // wypchniecie do bazy danych wartosci temperatury
delay(2500);
}
There you go, all the changes ive made so far.
If you use Firebase realtime, the Timer is not necessary since the change is detected automatically with the "DataChanged" block. Have you consulted my tutorial?
Yes I did, but I added that, because of firebase not responding and after fixing the issue I just left it there. It doesn't cause any problem and is just kinda failnsafe protocol for me.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.