Recently bought gy bme280 and trying to connect it with the Esp8266 Nodemcu V3 Esp 12.
Followed the instructions here for the hookup and then for the code, followed this tutorial.
I built the firmware from https://nodemcu-build.com/ a couple of days ago from master.
The debug logs shows this
Queue empty
Running
Function platform_gpio_mode() is called. pin_mux:1610614844, func:0
Function platform_gpio_mode() is called. pin_mux:1610614848, func:0
i2c setup result --> 100000
mode: b7
humidity oss: 5
config: f0
No ACK on address: 76
No ACK on address: 77
bme280 setup result -->
nil
pm open,type:2 0
My code
srv = net.createServer(net.TCP)
scl = 1
sda = 2
i2cResult = i2c.setup(0, sda, scl, i2c.SLOW) -- call i2c.setup() only once
print("i2c setup result --> " .. i2cResult)
local bmeResult = bme280.setup()
print("bme280 setup result --> ")
print(bmeResult)
The connections between BME280 and ESP8266 I have are
SDO -> G
CSB -> 3V
SDA -> D2
SCL -> D1
VCC -> 3V
GND -> G
Any idea of what is failing or what else can I do to troubleshoot it?
Related
i am a total beginner with LUA / ESP8266 and i am trying to find out where this error comes from:
PANIC: unprotected error in call to Lua API (bad argument #2 to 'set' (index out of range))
This is the Whole Message in serial monitor:
NodeMCU 2.2.0.0 built with Docker provided by frightanic.com
.branch: master
.commit: 11592951b90707cdcb6d751876170bf4da82850d
.SSL: false
.Build type: float
.LFS: disabled
.modules: adc,bit,dht,file,gpio,i2c,mqtt,net,node,ow,spi,tmr,uart,wifi
build created on 2019-12-07 23:52
powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)
> Config done, IP is 192.168.2.168
LED-Server started
PANIC: unprotected error in call to Lua API (bad argument #2 to 'set' (index out of range))
ets Jan 8 2013,rst cause:2, boot mode:(3,6)
load 0x40100000, len 27780, room 16
tail 4
chksum 0xbc
load 0x3ffe8000, len 2188, room 4
tail 8
chksum 0xba
load 0x3ffe888c, len 136, room 0
tail 8
chksum 0xf2
csum 0xf2
å¬ú‰.Éo‰ísÉÚo|Ï.å.õd$`..#íú..æÑ2rí.lúN‡.Éo„..l`.Ñ‚r€lÑ$.å...l`.Ñ‚s≤pɉ$.å....l`.Ñ‚r€l.èæ.å...$l`.{$é.êo.Ñü¬cc.ÑÑ".|l.Bè.c.‰è¬.lc‰ÚnÓ.2NN‚....å#€‚n.ÏéÑ.l..$Ïådè|Ïl.é.lÄ.o¸.Ñæ.#".llÏÑè..c...åû„åc.l.Ñb.{$r.
I Uploaded this code (https://github.com/Christoph-D/esp8266-wakelight) to the ESP8266, and did build the correct NodeMCU firmware with all required modules.
The Serial output is ok for a couple of seconds, then i get this error and it starts to repeat rebooting.
Where would i start looking for the Problem?
Thanks a lot!!!
EDIT: there are only a few places in the lua files where anything about "set" is written:
local function update_buffer(buffer, c)
if not c.r_frac then c.r_frac = 0 end
if not c.g_frac then c.g_frac = 0 end
if not c.b_frac then c.b_frac = 0 end
local r2 = c.r_frac >= 0 and c.r + 1 or c.r - 1
local g2 = c.g_frac >= 0 and c.g + 1 or c.g - 1
local b2 = c.b_frac >= 0 and c.b + 1 or c.b - 1
local r3, g3, b3
local set = buffer.set
for i = 1, NUM_LEDS do
if i > c.r_frac then r3 = c.r else r3 = r2 end
if i > c.g_frac then g3 = c.g else g3 = g2 end
if i > c.b_frac then b3 = c.b else b3 = b2 end
set(buffer, i - 1, g3, r3, b3)
end
end
Is there anything wrong?
Just above the for-loop where set is called, try adding this:
print(buffer:size(), NUM_LEDS)
If everything is OK, it should print the same number twice. If NUM_LEDS is larger, then that's your bug.
I don't really get why it uses the global variable in that place anyway; it'd make much more sense to use buffer:size() instead for exactly this reason.
I am trying to trace some register coalescing too complex NYI in my luajit code. From the IR in can see that the snapshot when the NYI happens is pretty full. My attempt is to trace backwards and to find out what causes the snapshot to be filled up.
To start with I am looking to understand what information is given out by the SNAP line. for example in a SNAP line below:
> local x = 1.2 for i=1,1e3 do x = x * -3 end
---- TRACE 1 start stdin:1
0006 MULVN 0 0 1 ; -3
0007 FORL 1 => 0006
---- TRACE 1 IR
.... SNAP #0 [ ---- ]
0001 rbp int SLOAD #2 CI
0002 xmm7 > num SLOAD #1 T
0003 xmm7 + num MUL 0002 -3
0004 rbp + int ADD 0001 +1
.... SNAP #1 [ ---- 0003 ]
0005 > int LE 0004 +1000
.... SNAP #2 [ ---- 0003 0004 ---- ---- 0004 ]
0006 ------------ LOOP ------------
0007 xmm7 + num MUL 0003 -3
0008 rbp + int ADD 0004 +1
.... SNAP #3 [ ---- 0007 ]
0009 > int LE 0008 +1000
0010 rbp int PHI 0004 0008
0011 xmm7 num PHI 0003 0007
If my understanding is correct, in first snapshot second position is written by IR at 0003. Going by the argument of IR at 0003 I guess 0002 (is this a memory location?) is x.
What I do not understand is that in second snapshot line (after IR 0005) 3rd and 6th position is modified by IR at 0004. How is that?
Now, how can I trace which variables are present in a snapshot position in above IR? For eg: in SNAP #7 [ ---- 0007 ].
Also what does the second argument to SLOAD (flags) signify? [I, CI, CRI, T, PI, PRI, R, RI] etc... I have also seen SLOAD with second argument empty.
This has been extensively answerd at luajit mail list by Peter Cawley in the following thread
https://www.freelists.org/post/luajit/Understanding-SNAP
I've been working on yasm assembly language and I generated a listing file that contains the following. I need help understanding how the memory displacement is computed in the first column. Thanks in advance.
1 %line 1+1 memory.asm
2 [section .data]
3 00000000 04000000 a dd 4
4 00000004 CDCC8C40 b dd 4.4
5 00000008 00000000<rept> c times 10 dd 0
6 00000030 01000200 d dw 1, 2
7 00000034 FB e db 0xfb
8 00000035 68656C6C6F20776F72- f db "hello world", 0
9 00000035 6C6400
Assembler is producing bytes (machine code), starting at some start address (here 0) and laying them next to each other. So first a dd 4 produces 4 bytes of data 04 00 00 00, thus memory at addresses 0, 1, 2 and 3 are filled up. Next free slot is at address 4. There goes b dd 4.4, again 4 bytes long. c times 10 dd 0 is 40 bytes long, so 8+40 = 48 (0x30) => next free slot.
I am trying to automate the exporting of full dissections of a pcap to a .txt file using tshark. I am aware of the file->export packet dissections as option, but I am working to automate that. Right now I have tshark -X lua_script: -r > . The files enclosed in <> are paths. The lone > is the command for printing text. It will export packet summaries but not the full dissection. IS there any way to export the full dissection to the command line. These sample line are what is exported right now,
1 0.000000000 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
2 0.000001180 10.81.130.23 -> 239.1.5.238 ST 1451 Messages: 14
3 0.006327070 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
4 0.006328250 10.81.130.23 -> 239.1.5.238 ST 1451 Messages: 14
5 0.019039770 02:00:00:00:00:67 -> IPv4mcast_01:05:ee 0x8903 1467 Data Center Ethernet (DCE) protocol(Cisco)
This is what I want the exports to look like
No. Time Source Destination Protocol Length Info
2 0.000001180 10.81.130.23 239.1.5.238 ST 1451 Messages: 14
Frame 2: 1451 bytes on wire (11608 bits), 1451 bytes captured (11608 bits)
Ethernet II, Src: Solarfla_0e:e4:a1 (00:0f:53:0e:e4:a1), Dst: IPv4mcast_01:05:ee (01:00:5e:01:05:ee)
Internet Protocol Version 4, Src: 10.81.130.23 (10.81.130.23), Dst: 239.1.5.238 (239.1.5.238)
User Datagram Protocol, Src Port: 43464 (43464), Dst Port: 25238 (25238)
ST Block
Block Header
Sanity: 23559 (Should be 23559)
Header Version (Major: 0 Minor: 1)
Header Size in Bytes: 19
Payload Size in Bytes: 1386
Messages: 14
Environment Id: 0
Feed Id: 1 (Uqdf)
Compression Type: 0
Sender Id: 1
Sequence: 37495844
Message Header
Header Version (Major: 0 Minor: 1)
Header Length in Bytes: 31
Msg Type: 1 (Equity Quote)
Message Version (Major: 0 Minor: 1)
Msg Length in Bytes: 68
Flags: 0
Data Type: 1 (Equity)
Feed Id: 1 (Uqdf)
Feed Line: 1
Feed Seq Num: 7123431
Feed Sub Seq Num: 0
Exchange Time (10:59:59.978517000)
High: 9220
Low: 380047880
Note: this is what the packet dissections look like when using file->export packet dissections
Thank you in advance!
After looking at the problem I have figured it out. It is tshark -X lua_script:filename -r p.pcap -V -T text > file.txt.
The key was the -V, as that prints packet details.
I made an entity in which quartus successfully recognizes RAM, and instantiates a RAM megafunction for it. It would be nice if I could initialize that RAM from a file. I found tutorials for making such file (.mif file). Now that I have created that file, i don't know how to make quartus initialize that module. Any help is appreciated.
Here is my RAM entity:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity RAM is
port (
clk: in std_logic;
we: in std_logic;
data_in: in std_logic_vector (7 downto 0);
read_addr: in integer range 0 to 65535;
write_addr: in integer range 0 to 65535;
data_out: out std_logic_vector (7 downto 0)
);
end entity RAM;
architecture RAM_arch of RAM is
type memory is array (65535 downto 0) of std_logic_vector (7 downto 0);
signal content: memory;
begin
process(clk)
begin
if (RISING_EDGE(clk)) then
if (we = '1') then
content(write_addr) <= data_in;
end if;
data_out <= content(read_addr);
end if;
end process;
end architecture;
Possibly the best way to initialise the memory is to ... put an initialisation clause on the memory variable. There may be Quartus-specific ways to load .MIF files, but this is probably simpler, definitely more portable (to Xilinx for example), and more flexible because you get to define the file format, you don't have to generate .mif files.
Given the following code:
type memory is array (65535 downto 0) of std_logic_vector (7 downto 0);
signal content: memory;
you could simply write
type memory is array (65535 downto 0) of std_logic_vector (7 downto 0);
signal content: memory := init_my_RAM(filename => "ram_contents.txt");
Now it is possible but unlikely that Quartus doesn't support initialisation this way,
so we can test it by writing a simple init_my_ram function ignoring the actual file contents:
function init_my_ram (filename : string) return memory is
variable f : file;
variable m : memory;
begin
file_open(f, filename, read_mode);
for i in memory'range loop
m(i) := X"55";
end loop;
file_close(f);
return m;
end init_my_ram;
Because the function call is an initialiser, and called at elaboration time when the design is synthesised, this is all synthesisable.
If this compiles and Quartus generates a memory full of X"55", you are good to go, to parse whatever file format you want, in the init_my_ram function. (Binary files are harder, and the reader code may not be so portable between tools, but not impossible).
The .MIF approach has one potential advantage though : you can update just the memory contents without requiring another synthesis/place and route cycle.
One simple way to initalize a ram area is as follows:
(quartus 15.1 tested)
(* ram_init_file = "Bm437_IBM_VGA8.mif" *) reg [7:0] Bm437_IBM_VGA8[4096];
Best regards,
Johi.
simplest method of initializing is by writing .mif with any simple editor such as Notepad. The .mif list below is for a ROM decoder as multiplexer. 6-bit address 64-bit data. .mif can contain any data word size 8,16,32,64-bit etc..in both hex or binary. Works all the time. The file must be in same directory as project.
WIDTH=64;
DEPTH=128;
ADDRESS_RADIX=HEX;
DATA_RADIX=HEX;
CONTENT BEGIN
000 : 0000000000000001;-- 0
001 : 0000000000000002;-- 1
002 : 0000000000000004;-- 2
003 : 0000000000000008;-- 3
004 : 0000000000000010;-- 4
005 : 0000000000000020;-- 5
006 : 0000000000000040;-- 6
007 : 0000000000000080;-- 7
008 : 0000000000000100;-- 8
009 : 0000000000000200;-- 9
00A : 0000000000000400;-- 10
00B : 0000000000000800;-- 11
00C : 0000000000001000;-- 12
00D : 0000000000002000;-- 13
00E : 0000000000004000;-- 14
00F : 0000000000008000;-- 15
010 : 0000000000010000;-- 16
011 : 0000000000020000;-- 17
012 : 0000000000040000;-- 18
013 : 0000000000080000;-- 19
014 : 0000000000100000;-- 20
015 : 0000000000200000;-- 21
016 : 0000000000400000;-- 22
017 : 0000000000800000;-- 23
018 : 0000000001000000;-- 24
019 : 0000000002000000;-- 25
01A : 0000000004000000;-- 26
01B : 0000000008000000;-- 27
01C : 0000000010000000;-- 28
01D : 0000000020000000;-- 29
01E : 0000000040000000;-- 30
01F : 0000000080000000;-- 31
020 : 0000000100000000;-- 32
021 : 0000000200000000;-- 33
022 : 0000000400000000;-- 34
023 : 0000000800000000;-- 35
024 : 0000001000000000;-- 36
025 : 0000002000000000;-- 37
026 : 0000004000000000;-- 38
027 : 0000008000000000;-- 39
028 : 0000010000000000;-- 40
029 : 0000020000000000;-- 41
02A : 0000040000000000;-- 42
02B : 0000080000000000;-- 43
02C : 0000100000000000;-- 44
02D : 0000200000000000;-- 45
02E : 0000400000000000;-- 46
02F : 0000800000000000;-- 47
030 : 0001000000000000;-- 48
031 : 0002000000000000;-- 49
032 : 0004000000000000;-- 50
033 : 0008000000000000;-- 51
034 : 0010000000000000;-- 52
035 : 0020000000000000;-- 53
036 : 0040000000000000;-- 54
037 : 0080000000000000;-- 55
038 : 0100000000000000;-- 56
039 : 0200000000000000;-- 57
03A : 0400000000000000;-- 58
03B : 0800000000000000;-- 59
03C : 1000000000000000;-- 60
03D : 2000000000000000;-- 61
03E : 4000000000000000;-- 62
03F : 8000000000000000;-- 63
[40..7F] : 0000000000000000;
END;
As specified in this document this is the proper way to init memory from file:
signal content: memory;
attribute ram_init_file : string;
attribute ram_init_file of content:
signal is "init.mif";
If you generated one of the RAM modules using the wizard but forgot to add a memory initialization file to it you can add one later by doing the following:
Tools > MegaWizard Plug-In Manager > Edit an existing custom megafunction variation > {Select your file} > Next > Mem Init > Yes, use this file for the memory content data > Browse