Help with berry read temperature from AM2301

178 views
Skip to first unread message

Yi Dr

unread,
Nov 12, 2023, 6:47:32 PM11/12/23
to TasmotaUsers
I am using Tasmota 13.0.0.1 and trying to write a Berry script to control a relay depending on the temperature reading from AM2301.

The AM2301 is working correctly and the temperature and humidity is showing good on the webGUI. But I didn't manage to get the temperature reading in the berry script. I have tried:
1.
def check_heat()
  var arc = tasmota.arch()
  var sens = tasmota.read_sensors()
  log("value is", arc, sens)
end
tasmota.add_cron("* * */10 * * *", check_heat, "every_10m")

It can print value is in the console log, but nothing following.

2.
def check_heat(value) log("The value:", value) end tasmota.add_rule("tele-AM2301#Temperature", check_heat)



In this way, it doesn't print at all. No matter what value I changed for TelePeriod.


Any idea, please? Thank you very much

Philip Knowles

unread,
Nov 13, 2023, 12:28:55 AM11/13/23
to Yi Dr, TasmotaUsers
It does say in the Berry pages that you must use Tele# not Tele-


From: sonof...@googlegroups.com <sonof...@googlegroups.com> on behalf of Yi Dr <wac...@gmail.com>
Sent: Sunday, November 12, 2023 11:47:31 PM
To: TasmotaUsers <sonof...@googlegroups.com>
Subject: Help with berry read temperature from AM2301
 
--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/80fc49d7-76e5-4a53-bd09-8c2e8c4ee583n%40googlegroups.com.

Andrew Russell

unread,
Nov 13, 2023, 3:25:40 AM11/13/23
to Yi Dr, TasmotaUsers
1) Seems that log() takes a single argument, so you need to concatenate the variables that you want see.
2) I noticed that tasmota 12.0 seems to need tasmota.log(), 12.5 accepts log().


# This worked for me in the 12.5 REPL console.
def check_heat()
  var arc = tasmota.arch()
  var sens = tasmota.read_sensors()
  log("value is " .. arc .. " " .. sens)
end
check_heat()



--

Yi Dr

unread,
Nov 13, 2023, 6:23:05 AM11/13/23
to TasmotaUsers
Thanks a lot for your kindly input. I will try it.
Reply all
Reply to author
Forward
0 new messages