SPI read

Hi I am writing code to read data from another chip. When I run the following code, this is what I see on the server: (instance: 0x0x2000fe30). The last four digits change every second. The other chip is sending 01h, 02h, 03h, 04h.

`//pin configurations
//Pin 1: reset
//Pin 8: output enable
//Pin 2: MISO
//Pin 7: MOSI

// Configure Hardware
// Pin 8 is the output enable line and should also be high unless driven low
hardware.pin8.configure(DIGITAL_OUT_OD_PULLUP);

// Configure the operating parameters of the SPI bus
hardware.spi257.configure(MSB_FIRST | CLOCK_IDLE_LOW, 3800);//3.8MHz data rate

// Function to receive data
function receive() {
hardware.pin8.write(0);
local data = hardware.spi257.readblob(4); //read 4 bytes of data from pin 2
server.show(data);
hardware.pin8.write(1);
imp.wakeup(1, receive); //read data every 1 second
}

// Configure the imp and register with the server
imp.configure(“AET2”, [], []);

receive();`

Yeah, you’re server.show’ing a blob. It doesn’t know how to render this.

If you want to show the 4 bytes in hex, use:

server.show(format("%02x %02x %02x %02x", data[0], data[1], data[2], data[3]));

it worked. thanks