ESP8266 + ds18b20 + thingspeak+ nodemcu

Dotazy na technické problémy, vlastní řešení technických problémů

Moderátor: Moderátoři

Odpovědět
Zpráva
Autor
Uživatelský avatar
markoni
Příspěvky: 2312
Registrován: 30 říj 2006, 00:00
Bydliště: Poblíž Zlína
Kontaktovat uživatele:

ESP8266 + ds18b20 + thingspeak+ nodemcu

#1 Příspěvek od markoni »

Zdravím
Když to posílám do modulu tak mě to vyhazuje chyby ta chyba začíná řádek bez tohoto symbolu >>
stdin:12: cannot use '...' outside a vararg function near '...' je těch chyb tam víc potřeboval bych aby jste se mi na to podívali díky
odkaz na projekt je http://vaasa.hacklab.fi/2015/01/12/esp8 ... k-nodemcu/ odkud čerpám

Kód: Vybrat vše

-------------------------------------------------------------------------------
>> -- DS18B20 one wire module for NODEMCU
>> -- NODEMCU TEAM
>> -- LICENCE: http://opensource.org/licenses/MIT
>> -- Vowstar <vowstar@nodemcu.com>
>> -- 2015/02/14 sza2 <sza2trash@gmail.com> Fix for negative values
>> --------------------------------------------------------------------------------
>>
>> -- Set module name as parameter of require
>> local modname = ...
stdin:12: cannot use '...' outside a vararg function near '...'
> local M = {}_G[modname] = M
stdin:1: table index is nil
> ---------------------------------------------------------------------------------- Local used variables
> --------------------------------------------------------------------------------
> -- DS18B20 dq pin
> local pin = nil
> -- DS18B20 default pin
> local defaultPin = 9
> --------------------------------------------------------------------------------
> -- Local used modules
> --------------------------------------------------------------------------------
> -- Table module
> local table = table
> -- String module
> local string = string
> -- One wire module
> local ow = ow
> -- Timer module
> local tmr = tmr
> -- Limited to local environment
> setfenv(1,M)
stdin:1: bad argument #2 to 'setfenv' (table expected, got nil)
> ---------------------------------------------------------------------------------- Implementation
> --------------------------------------------------------------------------------
> C = 0
> F = 1
> K = 2
> function setup(dq)
>> pin = dq
>> if(pin == nil) then
>> pin = defaultPin
>> end
>> ow.setup(pin)
>> end
>
> function addrs()
>> setup(pin)
>> tbl = {}
>> ow.reset_search(pin)
>> repeat
>> addr = ow.search(pin)
>> if(addr ~= nil) then
>> table.insert(tbl, addr)
>> end
>> tmr.wdclr()
>> until (addr == nil)
>> ow.reset_search(pin)
>> return tbl
>> end
>
> function readNumber(addr, unit)
>> result = nil
>> setup(pin)
>> flag = false
>> if(addr == nil) then
>> ow.reset_search(pin)
>> count = 0
>> repeat
>> count = count + 1
>> addr = ow.search(pin)
>> tmr.wdclr()
>> until((addr ~= nil) or (count > 100))
>> ow.reset_search(pin)
>> end
>> if(addr == nil) then
>> return result
>> end
>> crc = ow.crc8(string.sub(addr,1,7))
>> if (crc == addr:byte(8)) then
>> if ((addr:byte(1) == 0x10) or (addr:byte(1) == 0x28)) then
>> -- print("Device is a DS18S20 family device.")
>> ow.reset(pin)
>> ow.select(pin, addr)
>> ow.write(pin, 0x44, 1)
>> -- tmr.delay(1000000)
>> present = ow.reset(pin)
>> ow.select(pin, addr)
>> ow.write(pin,0xBE,1)
>> -- print("P="..present)
>> data = nil
>> data = string.char(ow.read(pin))
not enough memory
> for i = 1, 8 do
>> data = data .. string.char(ow.read(pin))
>> end
stdin:2: bad argument #1 to 'read' (number expected, got nil)
> -- print(data:byte(1,9))crc = ow.crc8(string.sub(data,1,8))
stdin:1: bad argument #1 to 'sub' (string expected, got nil)
> -- print("CRC="..crc)if (crc == data:byte(9)) then
>> t = (data:byte(1) + data:byte(2) * 256)
>> if (t > 32767) then
>> t = t - 65536
>> end
>> if(unit == nil or unit == C) then
>> t = t * 625
>> elseif(unit == F) then
>> t = t * 1125 + 320000
>> elseif(unit == K) then
>> t = t * 625 + 2731500
>> else
>> return nil
>> end
>> t = t / 10000
>> -- print("Temperature="..t1.."."..t2.." Centigrade")
>> -- result = t1.."."..t2
>> return t
>> end
stdin:1: attempt to index global 'data' (a nil value)
> tmr.wdclr()else
stdin:1: '<eof>' expected near 'else'
> -- print("Device family is not recognized.")end
stdin:1: '<eof>' expected near 'end'
> else
stdin:1: '<eof>' expected near 'else'-- print("CRC is not valid!")end
stdin:1: '<eof>' expected near 'end'
> return result
nilend
stdin:1: '<eof>' expected near 'end'
>
> function read(addr, unit)
>> t = readNumber(addr, unit)
>> if (t == nil) then
>> return nil
>> else
>> return t
>> end
>> end
>
> -- Return module table
> return M
nil
>
Čím víc dál se snažím se učit tím poznávám že nic nevím .Poslední 2 roky mám kvadruparézu
Odpovědět

Zpět na „Poradna“