代码土壤

#include 
#include 

#define SS_PIN 53
#define RST_PIN 5

byte nuidPICC[4]; 
char buff[20];

int sensorPin = A0;    // 土壤湿度引脚
int sensorValue = 0;  //土壤湿度值
int soilValue = 0;  //土壤湿度值

void setup() {
  Serial.begin(115200);
  Wire.begin();
  SPI.begin();  
}

long now;
void loop() {
if(millis()-now>1000){
  now=millis();
  sensorValue = analogRead(sensorPin);
  soilValue = map(sensorValue,300,610,100,0);
  sprintf(buff,"{\"soil\":%d}",soilValue);        
  Serial.println(buff);
  memset(buff,0,20);
}
}

 

你可能感兴趣的:(python学习笔记)