A place users can post their projects. If you have a small project and would like your own dedicated place to post and have others chat about it then this is your spot.

User avatar
By quackmore
#89662 heck yeah!

that was kind of fun

you still have garbage and missing chars on the serial line though ...

latest nodemcu is shipping with SDK 3.0.1 so I think you don't really need to flash esp_init_data_default.bin and blank.bin, those were for fixing issues with the old nodemcu version (with an old SDK)
from nodemc docs
Code: Select allThe SDK version 3.x firmware builds detect if the RF calibration sector has been erased or corrupted, and will automatically initialise it with the correct content before restarting the processor. This works for all SDK supported flash sizes.

now that you know what to do, give it a try
User avatar
By maxniz
#89665 "latest nodemcu is shipping with SDK 3.0.1 so I think you don't really need to flash esp_init_data_default.bin and blank.bin, those were for fixing issues with the old nodemcu version (with an old SDK)
from nodemc docs"

you are right... i have tried without and blink is ok..
i have loaded the scripts and i have some errors...

they are for the client what you can find in the attach... and the file is :
please tell me where i wrong ..
-- application.lua
button_pressed = false
last_communicated_button_status = false

cmd_led_on = "http://192.168.10.1/led/turn/on"

periodic_task = function()
-- custom application ...
-- YOUR CODE HERE

tmr.alarm(0, duration, 1, function ()
if status == gpio.LOW then
status = button_pressed = true
else
status = button_status = false

-- example begin

if connected_to_AP and (button_pressed ~= last_commnicated_button_status) then
if button_pressed then
button_pressed = false
print("sending command for turning led off")
cmd = "http://192.168.10.1/led/turn/off"
else
button_pressed = true
print("sending command for turning led on")
cmd = "http://192.168.10.1/led/turn/on"
end
http.post(cmd, nil, nil, function(code, data)
if (code < 0) then
print("HTTP error, cannot communicate with AP")
last_communicated_button_status = not(button_pressed)
else
print(code, data)
last_communicated_button_status = button_pressed
end
end)
end
-- example end

print("connected to AP " .. tostring(connected_to_AP))
tmr.create():alarm(10000, tmr.ALARM_SINGLE, periodic_task)
end

print("now running the application")
print("connected to AP " .. tostring(connected_to_AP))
tmr.create():alarm(10000, tmr.ALARM_SINGLE, periodic_task)

i have also some errors for AP ... i don't touch anything !! i'm not able to...
You do not have the required permissions to view the files attached to this post.
User avatar
By quackmore
#89666 two things first:
1) when you are using serial port for both providing input and getting output don't lock yourself out. That means: don't put code you did not test into loops or function that are called periodically (such as periodic_task below) and, while testing, always insert delays (huge delays, tens of seconds) so that if something goes wrong you can catch it and react

2) you are running the latest nodemcu, you have to read the latest doc
https://nodemcu.readthedocs.io/en/release/modules/tmr/
https://nodemcu.readthedocs.io/en/release/modules/gpio/#gpioread
and copy the examples code

in your code
Code: Select alltmr.alarm(0, duration, 1, function ()
if status == gpio.LOW then
status = button_pressed = true
else
status = button_status = false


the syntax you are using for the timer is probably wrong or old
moreover you don't need to set a timer there cause you are already in a function that is executed every 10s (large value cause you are testing...), see
Code: Select alltmr.create():alarm(10000, tmr.ALARM_SINGLE, periodic_task)


you are using a bad syntax reading the input, checkout the doc
you are using a bad syntax when you write "status = button_pressed = true"
check out lua docs https://www.lua.org/manual/5.1/


delete all the lua files
create a init.lua file that do just this:

read an input value to a variable
print the variable value

run the init.lua and check if it's working with different inputs value

go back to the application.lua and just

read the input
set button_pressed to true/false accordingly to what you read
delete the lines below in my code that set button_pressed (Into the example I was switching the value every 10 secs)