소스가 맞나요?
페이지 정보
작성자 엘도라도 작성일19-11-15 13:31 조회12,140회 댓글1건본문
nodemcu에 dm452를 연결하여 차량12v의 데이터를 불러오려고 합니다 현재 이소스는 정상적으로 데이터 출력이 되고 있는데 차량이12v 이다보니 제대로된값이 안나오네요 어디를 수정해야 하나요?
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ThingSpeak.h>
#define VOLTAGE_MAX 3.3
#define VOLTAGE_MAXCOUNTS 4095.0
// wifi
const char* ssid = "U+Net5B60";
const char* password = "DD59009446";
WiFiClient client;
// thingSpeak
unsigned long ChannelID = 899961;
const char* WriteAPIKey = "FLTU2NV5PWUU08W3";
void setup() {
Serial.begin(115200);
delay(10);
initWiFi();
ThingSpeak.begin(client);
}
void loop() {
float voltage = analogRead(A0) * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
Serial.print("Voltage : ");
Serial.println(voltage);
ThingSpeak.writeField(ChannelID, 1, voltage, WriteAPIKey);
delay(20000);
}
void initWiFi(){
Serial.println();
Serial.println();
Serial.println("Connectiong to ssid ...");
// attempt to connect to WiFi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println(".");
}
// 접속성공!
Serial.println();
Serial.println("Connected WiFi");
//사용하는 ip출력
Serial.println(WiFi.localIP());
Serial.println();
}
#include <ESP8266WiFi.h>
#include <WiFiClient.h>
#include <ThingSpeak.h>
#define VOLTAGE_MAX 3.3
#define VOLTAGE_MAXCOUNTS 4095.0
// wifi
const char* ssid = "U+Net5B60";
const char* password = "DD59009446";
WiFiClient client;
// thingSpeak
unsigned long ChannelID = 899961;
const char* WriteAPIKey = "FLTU2NV5PWUU08W3";
void setup() {
Serial.begin(115200);
delay(10);
initWiFi();
ThingSpeak.begin(client);
}
void loop() {
float voltage = analogRead(A0) * (VOLTAGE_MAX / VOLTAGE_MAXCOUNTS);
Serial.print("Voltage : ");
Serial.println(voltage);
ThingSpeak.writeField(ChannelID, 1, voltage, WriteAPIKey);
delay(20000);
}
void initWiFi(){
Serial.println();
Serial.println();
Serial.println("Connectiong to ssid ...");
// attempt to connect to WiFi network
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println(".");
}
// 접속성공!
Serial.println();
Serial.println("Connected WiFi");
//사용하는 ip출력
Serial.println(WiFi.localIP());
Serial.println();
}
댓글 : 1
조회수 : 12,140
master님의 댓글
master 작성일
차량12v의 데이터라는 것이 무엇인지
현재 비정상적인 동작이 무엇인지 상세하게 적어보세요