Left for archival purposes.

User avatar
By BilirShop
#47522 First, Hello everybody.
I'm new among you. And English is not very good.
I'm trying to subtract 10 from the wifi to a limit of 4 for 1 week.
I have tried to do this by using Doctor.
LINK:https://hub.doc[attachment=3]Screenshot_1.png[/attachment]ker.com/r/marcelstoer/nodemcu-build/
1-Clone the NodeMCU firmware repository
<code>
git clone https://github.com/nodemcu/nodemcu-firmware.git
</code>
2-Run this image with Docker
[code]<code>[/code]
docker run --rm -it -v //c/Users/Babu/nodemcu-firmware:/opt/nodemcu-firmware marcelstoer/nodemcu-build
[code]</code>[/code]
3-Nodemcu-Flasher "C:\Users\Babu\nodemcu-firmware-3\bin" "nodemcu_float_master_20160516-0905" nodemcu dev kit flash.

ESPLORER ERROR
[code]
> ÆQ)� ®ôˆL‹Èı@HJÊ Hà


NodeMCU 1.4.0 build 20151006 powered by Lua 5.1.4 on SDK 1.4.0

lua: aserver.lua:31: attempt to index global 'spi' (a nil value)
stack traceback:
aserver.lua:31: in function 'initspi'
aserver.lua:6: in function 'ayar'
aserver.lua:105: in main chunk
[C]: in function 'dofile'
init.lua:2: in main chunk
[C]: ?
>
Communication with MCU...
Got answer! AutoDetect firmware...

NodeMCU firmware detected.
=node.heap()
28536
>
[/code]

init.lua
[code]
dofile("wifi.lua");
dofile("aserver.lua");
[/code]

wifi.lua
[code]
function wifista(id,ps)
wifi.setmode(wifi.STATION)
wifi.setphymode(wifi.PHYMODE_B)
wifi.sta.config(id, ps , 1 )
return wifi.sta.getip();
end

function wifiap(id,ps)
wifi.setmode(wifi.SOFTAP)
wifi.setphymode(wifi.PHYMODE_B)
local cf={}
cf.ssid=id
cf.pwd=ps
wifi.ap.config(cf)
end
[/code]

aserver.lua
[code]

function ayar()
deger();
print(wifiap("LUA","12345678"));
initUDP();
initspi();
pin(0);
end

function deger()

end --deger

function initUDP()

u=net.createServer(net.UDP)
u:on("receive", reed)
u:listen(8001)

cu=net.createConnection(net.UDP)
cu:connect(8001,"192.168.4.255")
ca=net.createConnection(net.UDP)
ca:connect(5000,"192.168.4.255")

end -- initUDP

function initspi()
latch_pin = 8
gpio.mode(latch_pin, gpio.OUTPUT)
gpio.write(latch_pin, gpio.LOW)
result = spi.setup(1, spi.MASTER, spi.CPOL_HIGH, spi.CPHA_LOW, spi.DATABITS_8, 0)
end -- initspi



function reed(u,c)
cv=string.sub(c, 1, 3)
cs=string.sub(c,4)
cs=tonumber(cs);

-- A Verileri --
if(cv=="APV")then
if(cs ~= nil)then
pin(cs);
cu:send(cv.."G"..cs);
end
elseif(cv=="AAV")then
cu:send(cv.."G"..adcread());
-- B Verileri --
elseif(cv=="BAV" or cv=="BPV")then
ca:send(c);
-- C Verileri --
elseif(cv=="CAV" or cv=="CPV")then
ca:send(c);
-- D Verileri --
elseif(cv=="DAV" or cv=="DPV")then
ca:send(c);
-- E Verileri --
elseif(cv=="EAV" or cv=="EPV")then
ca:send(c);
else
cu:send(c);
end
end

function adcread()
aa=0;
a=0;
for i=0,250,1 do
end
for i=0,100,1 do
aa=aa+adc.read(0);
end[attachment=3]Screenshot_1.png[/attachment]
a=(aa/21670);
a=a+(aa/500000)
return a;
end


function pin(pinv)
spi.send(1, pinv);
gpio.write(latch_pin, gpio.HIGH)
gpio.write(latch_pin, gpio.LOW)
end

ayar();
[/code]
Attachments
Screenshot_4.png
Screenshot_3.png
Screenshot_2.png
Screenshot_1.png