in your prexisting ardino project add this to it
Serial.print("cmd_1("); Serial.print(somevalue); Serial.println(")"); --to be captured by esp8266
and you connect the esp8266 to the tx of the the ardino ( or any serial device) and esp8266 captures and then rebroadcast to your IoT or webpage or data base
------
uart.setup(0,9600,8,0,1)
function cmd_1(value)
i= value
end
----------
works fine if producing a webpage or json.. but i was having some compatibility issues with json so I wanted to send as mqtt. and this is where it gets weird
if i run my scripts by "send to ESP" for MQTT it works fine if they are installed to flash they cause panics due to nill data--
so here my test out put running from "Send to ESP"( as flashed data would cause a panic and loop esp8266 if it loops just unplug your wifi router so it can not obtain an ip ( would not uses a static or as AP for testing - because even if you loop it and you reflash it it still looped afterward with MQTT module installed another strange bug) then restart esp8266 and format it and try again
-------
uart.setup(0,9600,8,0,1)
function cmd_1(value)
print(value)
i= value
print(i)
payload_1=value
print(payload_1)
if pcall(payload_1) then
m:publish("/invert",payload_1,0,0, function(conn) print("sent") end) )
else
print(" error - nill value )
end
m:publish("/invert",payload_1,0,0 , function(conn) print("sent") end)) --- works with "send to ESP" but when not when loaded at boot - creates a panic )
end
-----------
here the output on the com window :
> cmd_1(146.00)
146 ( prints value)
146 ( prints i )
146 ( prints payload )
error - nil value ( pcall sees it as nil value does not matter if I use "value "," i " or "payload " as the input for pcall )
sent ( sent to mqtt broker - but only when ran from "send to ESP" - if run by an application through init if creates panic code due to nil value - but yet if a delete the mqtt section and display only a webpage or manipulate in in anyway. it does not create a panic condition- but yet any manipulation of data I ei multiply payload by ten then divide by ten it will print the result but will still be recognized as nil data by pcall and will cause panic in MQTT no where else just MQTT that i found )
it a very weird problem...
would anyone have a suggestion of what might be going wrong --