iT邦幫忙

1

請問我的arduino的serial monitor 為顯示出亂碼

請問一下,我是一枚arduino的萌新,因為要交學校的功課,左找右找的,在github 上找到了一個用來運行MLX90640(熱象探測)的arduino程式,並連接了那個機體,運行了起來。可是,我卻發現我的serial monitor出的是亂碼,我已經check了我的程式是Serial.begin(9600),也開了9600的bund,請問應當如何解決?謝謝。
https://ithelp.ithome.com.tw/upload/images/20210210/20134300AMPBJKnSro.pnghttps://ithelp.ithome.com.tw/upload/images/20210210/201343009FtCv9esbo.png
https://ithelp.ithome.com.tw/upload/images/20210210/20134300oHEpcrbAVm.png
`#include <Wire.h>

#include "MLX90640_API.h"
#include "MLX90640_I2C_Driver.h"

const byte MLX90640_address = 0x33; //Default 7-bit unshifted address of the MLX90640

#define TA_SHIFT 8 //Default shift for MLX90640 in open air

static float mlx90640To[768];
paramsMLX90640 mlx90640;

void setup()
{
Wire.begin();
Wire.setClock(400000); //Increase I2C clock speed to 400kHz

Serial.begin(9600);
while (!Serial); //Wait for user to open terminal
Serial.println("MLX90640 IR Array Example");

if (isConnected() == false)
{
Serial.println("MLX90640 not detected at default I2C addres. Please check wiring. Freezing.");
while (1);
}
Serial.println("MLX90640 online!");

//Get device parameters - We only have to do this once
int status;
uint16_t eeMLX90640[832];
status = MLX90640_DumpEE(MLX90640_address, eeMLX90640);
if (status != 0)
Serial.println("Failed to load system parameters");

status = MLX90640_ExtractParameters(eeMLX90640, &mlx90640);
if (status != 0)
Serial.println("Parameter extraction failed");

//Once params are extracted, we can release eeMLX90640 array
}

void loop()
{
for (byte x = 0 ; x < 2 ; x++) //Read both subpages
{
uint16_t mlx90640Frame[834];
int status = MLX90640_GetFrameData(MLX90640_address, mlx90640Frame);
if (status < 0)
{
Serial.print("GetFrame Error: ");
Serial.println(status);
}

float vdd = MLX90640_GetVdd(mlx90640Frame, &mlx90640);
float Ta = MLX90640_GetTa(mlx90640Frame, &mlx90640);

float tr = Ta - TA_SHIFT; //Reflected temperature based on the sensor ambient temperature
float emissivity = 0.95;

MLX90640_CalculateTo(mlx90640Frame, &mlx90640, emissivity, tr, mlx90640To);

}

for (int x = 0 ; x < 10 ; x++)
{
Serial.print("Pixel ");
Serial.print(x);
Serial.print(": ");
Serial.print(mlx90640To[x], 2);
Serial.print("C");
Serial.println();
}

delay(1000);
}

//Returns true if the MLX90640 is detected on the I2C bus
boolean isConnected()
{
Wire.beginTransmission((uint8_t)MLX90640_address);
if (Wire.endTransmission() != 0)
return (false); //Sensor did not ACK
return (true);
}
`

allship iT邦新手 5 級 ‧ 2021-02-10 21:50:07 檢舉
p.s. 不知為何在copy and paste程式碼時,會多了一張相片在中間...
\OWO|||
檢查一下你的序列埠口的速率,檢查碼,停止位元的設定是否相同
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

2 個回答

0
s312194
iT邦見習生 ‧ 2021-02-10 23:17:29

試試看把右下角 new line 改成 nc & lr 看看

不行的話檢查板子吧

這個程式碼是for i2c使用的

allship iT邦新手 5 級 ‧ 2021-02-11 19:22:04 檢舉

試了,還是不行...或許要再看看其他方法吧!謝謝你

0
sibulun
iT邦新手 5 級 ‧ 2021-02-11 10:49:36

把 mlx90640To[x] 放到下面代碼轉成文字看看~

final String data=new String(mlx90640To[x], "US-ASCII");
allship iT邦新手 5 級 ‧ 2021-02-11 19:21:15 檢舉

請問一下,到底是要把
final String data=new String(mlx90640To[x], "US-ASCII");
造句放在那?

我要發表回答

立即登入回答