フィルターのクリア

Sometimes updates temp others humidity

4 ビュー (過去 30 日間)
Gobllyn Gremllyn
Gobllyn Gremllyn 2024 年 3 月 30 日
コメント済み: Gobllyn Gremllyn 2024 年 3 月 30 日
Hi guys.
This is the part of the code that I use to send the DHT11 data , temp and hum to the thinspeak server, but sometimes just updates the temperature and if I reset just updates de humidity, what can be the issue? Can i send booth arguments in just one expression?
void loop()
{
// Leia os dados do sensor DHT
float temperature = dht.readTemperature();
float humidity = dht.readHumidity();
// Convert temperature and humidity to strings
String tempStr = String(temperature, 2);
String humidityStr = String(humidity, 2);
// Write temperature to ThingSpeak
ThingSpeak.writeField(THINGSPEAK_CHANNEL_ID, 1, tempStr.toFloat(), THINGSPEAK_API_KEY);
// Write humidity to ThingSpeak
ThingSpeak.writeField(THINGSPEAK_CHANNEL_ID, 2, humidityStr.toFloat(), THINGSPEAK_API_KEY);

回答 (1 件)

Christopher Stapels
Christopher Stapels 2024 年 3 月 30 日
編集済み: Christopher Stapels 2024 年 3 月 30 日
Yes you can send in one command. See the library examples on write multiple fields. Your code is violating the 15 second rule between updates. You send the second update with no wait. If you send both fields in one update, all will be well. Just make sure to wait another 15 seconds for the next update. (For a free user)
  1 件のコメント
Gobllyn Gremllyn
Gobllyn Gremllyn 2024 年 3 月 30 日
Thank you for you help, will read it tonight, and try to implement it.
Already added the 15 second delay and looks like it's works.

サインインしてコメントする。

コミュニティ

その他の回答  ThingSpeak コミュニティ

カテゴリ

Help Center および File ExchangeGoogle についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by