Posted: 11:43am 02 Jun 2023 |
Copy link to clipboard |
Print this post |
|
Hello,
as I wrote in an earlier posting, WEB MQTT is eating 512 bytes of ram after each use. In the following program the "General" RAM is constantly increasing within the main loop when WEB MQTT commands are used. If I comment out the WEB MQTT part (from ON ERROR until WEB MQTT CLOSE) then the program runs stable and does not increase general ram as shown by the "memory" statement.
The program is measuring a brightness sensor.
' Helligkeitsmessung Option explicit
SetPin gp28,ain
Dim minbrightness As float = 4.0 Dim maxbrightness As float = 0.0 Dim hell As Integer
Function bright() Static h As float = 0.0 Static n As integer = 0 n = Min(5, n+1) h = h + (Pin(gp28)-h)/n If h > maxbrightness Then maxbrightness = h If h < minbrightness Then minbrightness = h bright = h End Function
Function scale(brightness) Local range As float = 0.0
range = maxbrightness - minbrightness If range <> 0 Then scale = 100 - Int((brightness - minbrightness) / (range / 100)) Else scale = 100 EndIf End Function
Do hell = scale(bright()) Print "Helligkeit: ";hell;" %" On ERROR SKIP 3 WEB MQTT CONNECT "192.168.178.54",1883,"anon","anon" WEB MQTT PUBLISH "brightness",Str$(hell) WEB MQTT CLOSE Print Print Memory Print Print Pause 200 Loop
the OPTIONS are:
WebMite MMBasic Version 5.07.07 OPTION SYSTEM I2C GP0,GP1 OPTION LIBRARY_FLASH_SIZE 14000 OPTION COLOURCODE ON OPTION DISPLAY 50, 100 OPTION WIFI FritzBox, ********************* OPTION TELNET CONSOLE ON OPTION SDCARD GP5, GP2, GP3, GP4
-andreas Edited 2023-06-02 21:46 by andreas |