WTA : nodeMCU DHT11/22 send to EasyIoT server

8 years 11 months ago #1536 by ArneiO
Replied by ArneiO on topic "404 Not Found" error

Dennis wrote: which easyIoT server version are you running? In another thread i just read that part of the http api is only included since 0.8x release, maybe thats the problem?
regards

When I press the 'i' in the upper right corner it says V0.8.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1537 by ArneiO
Replied by ArneiO on topic "404 Not Found" error

Dennis wrote: ... you can use the chrome add-in Postman for example, to send post request

I sent this using Postman add-in: POST /Api/EasyIoT/Control/Module/Esp8266/N9S0/ControlLevel/22.0/
Result: "Could not get any response"
I think the error is on the server side. I have tried several times to set up new nodes. In the server console window on the RPi the API message shows up with lines looking like this:
<date/time> INFO EasyIoWwebinterface EasyIoControl Module Virtual <the API message that is sent>
When I send a line from browser URL-line as suggested, such a line comes up on the EasyIoT server console.
But nothing more happens.
If I do the same thing with a non-existing node identifier, like this - the same thing happens (I do not have a node N22S0:
http://192.168.0.123/Api/EasyIoT/Control/Module/Esp8266/N22S0/ControlLevel/22.0/

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1538 by lesjaw
Replied by lesjaw on topic "404 Not Found" error

ArneiO wrote:

Dennis wrote: ... you can use the chrome add-in Postman for example, to send post request

I sent this using Postman add-in: POST /Api/EasyIoT/Control/Module/Esp8266/N9S0/ControlLevel/22.0/
Result: "Could not get any response"
I think the error is on the server side. I have tried several times to set up new nodes. In the server console window on the RPi the API message shows up with lines looking like this:
<date/time> INFO EasyIoWwebinterface EasyIoControl Module Virtual <the API message that is sent>
When I send a line from browser URL-line as suggested, such a line comes up on the EasyIoT server console.
But nothing more happens.
If I do the same thing with a non-existing node identifier, like this - the same thing happens (I do not have a node N22S0:
http://192.168.0.123/Api/EasyIoT/Control/Module/Esp8266/N22S0/ControlLevel/22.0/


ArneiO.. sorry cant much help..

i think you already on the right course to fix.. it just a matter of path problem.. and maybe there is a problem in EasyIot Server side..

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1576 by EasyIoT
You do not need POST. It will also work with GET, so you can test with WEB browser. Just enter url in WEB browser and you should see response message.

Please Log in or Create an account to join the conversation.

8 years 11 months ago #1581 by ArneiO
So far all attempts using browser URL has just given blank screens, both in Firefox and Chrome.

Please Log in or Create an account to join the conversation.

8 years 6 months ago #2324 by NightOne
For those still following this thread NodeMCU now natively supposes DHT11 and DHT22.... to get the temp and humidity you simply use the following code:

status,temp,humi,temp_decimial,humi_decimial = dht.read11(pin) you can also just use dht.read() as it will automativally discover what type of DHT you are using:

The following code is for a ESP01 sensor with single DHT11 to upload to EasyIOT

init.lua

print(wifi.sta.getip())
wifi.setmode(wifi.STATION)
wifi.sta.config("SSID","your wifi password goes here")
tmr.alarm(1, 600000, 1, function() print(wifi.sta.getip()) dofile('BedRoom_Temp.lua') end )

BedRoom_Temp.lua

easyiot_username = "admin"
easyiot_password = "test"
easyiot_server = "192.168.1.15"

-- character table string
local b='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
function enc(data)
return ((data:gsub('.', function(x)
local r,b='',x:byte()
for i=8,1,-1 do r=r..(b%2^i-b%2^(i-1)>0 and '1' or '0') end
return r;
end)..'0000'):gsub('%d%d%d?%d?%d?%d?', function(x)
if (#x < 6) then return '' end
local c=0
for i=1,6 do c=c+(x:sub(i,i)=='1' and 2^(6-i) or 0) end
return b:sub(c+1,c+1)
end)..({ '', '==', '=' })[#data%3+1])
end

function SendTemp()

conn = nil
conn=net.createConnection(net.TCP, 0)

-- send status to sensor node

conn:on("receive", function(conn, payload)
success = true
print(payload)
end)

-- when connected, request page (send parameters to a script)
conn:on("connection", function(conn, payload)
print('\nConnected')
conn:send("POST /Api/EasyIoT/Control/Module/Virtual/N8S0/ControlLevel/"..temp.." HTTP/1.1\r\n"
.."Host: "..easyiot_server.."\r\n"
.."Content-Length: 0\r\n"
.."Connection: keep-alive\r\n"
.."Authorization: Basic "..credentals.."\r\n"
.."Accept: */*\r\n"
.."User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n"
.."\r\n")
end)
-- when disconnected, let it be known
conn:on("disconnection", function(conn, payload) print('\nSend status') end)

conn:connect(80,easyiot_server)
end

function SendHumi()

conn = nil
conn=net.createConnection(net.TCP, 0)

-- send status to sensor node

conn:on("receive", function(conn, payload)
success = true
print(payload)
end)

-- when connected, request page (send parameters to a script)
conn:on("connection", function(conn, payload)
print('\nConnected')
conn:send("POST /Api/EasyIoT/Control/Module/Virtual/N3S0/ControlLevel/"..humi.." HTTP/1.1\r\n"
.."Host: "..easyiot_server.."\r\n"
.."Content-Length: 0\r\n"
.."Connection: keep-alive\r\n"
.."Authorization: Basic "..credentals.."\r\n"
.."Accept: */*\r\n"
.."User-Agent: Mozilla/4.0 (compatible; esp8266 Lua; Windows NT 5.1)\r\n"
.."\r\n")
end)
-- when disconnected, let it be known
conn:on("disconnection", function(conn, payload) print('\nSend status') end)

conn:connect(80,easyiot_server)
end


pin = 4

status,temp,humi,temp_decimial,humi_decimial = dht.read11(pin)
if( status == dht.OK ) then
print("DHT Temperature:"..temp..";".."Humidity:"..humi)
credentals = enc(easyiot_username..":"..easyiot_password)
SendTemp(temp)
tmr.delay(1000000)
SendHumi(humi)


elseif( status == dht.ERROR_CHECKSUM ) then
print( "DHT Checksum error." );
elseif( status == dht.ERROR_TIMEOUT ) then
print( "DHT Time out." );

end

Please Log in or Create an account to join the conversation.

Time to create page: 0.267 seconds

Forum latest

  • No posts to display.